我試圖通過兩個幻燈片的部分上的信件動畫實施。目前我正在使用jQuery代碼,但恐怕這遠非理想選擇。
這裏是我的代碼示例:codepen通過信件動畫延遲加載
$.fn.animation = function() {
//get the welcome msg element
var $message = $(this);
//get a list of letters from the welcome text
var $getList = $(this).text().split("");
//clear the welcome text msg
$(this).text("");
//loop through the letters in the list array
$.each($getList, function(idx, element) {
//create a span for the letter and set opacity to 0
var newElement = $("<span/>").text(element).css({
opacity: 0
});
//append it to the welcome message
newElement.appendTo($message);
//set the delay on the animation for this element
newElement.delay(idx * 90);
//animate the opacity back to full 1
newElement.animate({
opacity: 1
}, 1100);
});
};
$('.introduction').animation();
$('.secondary').animation();
第一個問題是,我不能這樣做,所以第一個操作完成後纔會帶班第二句「次要」運行。我試過使用.delay和setTimeout,但這沒有幫助。
另外我不確定如何在第二張幻燈片上加載時啓動動畫。
我知道那裏有插件,但我想用香草JavaScript或jQuery,css3來做。
會很高興任何幫助。
是的,這裏是一個例子,我希望它看起來如何 - http://bootstrapart.net/influence/v1.5.3/
是否有可能,所以每當幻燈片更改時動畫開始?
謝謝。
我belieave'promise'將是您正確的答案。檢查此:https://api.jquery.com/promise/ – Andurit