我试图通过两个幻灯片的部分上的信件动画实施。目前我正在使用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