我有以下 jquery 文本飞入动画。在我进一步解释之前,这是我的代码:
<script type="text/javascript">
$(document).ready(function(){
$('.flying1 .flying-text').css({opacity:0});
$('.flying1 .active-text').animate({opacity:1, marginLeft: "0px"}, 1200); //animate first text
var int = setInterval(changeText, 3500); // call changeText function every 5 seconds
function changeText(){
var $activeText = $(".flying1 .active-text"); //get current text
var $nextText = $activeText.next(); //get next text
if ($activeText.is('.end')) {
$activeText.stop().delay(5000);
$('.flying1').html('<div class="flying-text active-text">Text4<div>
<div class="flying-text">Text5</div>
<div class="flying-text end2">Text6</div>');
$('.flying1 .flying-text').css({opacity:0});
$('.flying1 .active-text').animate({opacity:1, marginLeft: "0px"}, 1200); //animate first text
};
if ($activeText.is('.end2')) {
$activeText.stop().delay(5000);
$('.flying1').html('<div class="flying-text active-text">Text1<div>
<div class="flying-text">Text2</div>
<div class="flying-text end">Text3</div>');
$('.flying1 .flying-text').css({opacity:0});
$('.flying1 .active-text').animate({opacity:1, marginLeft: "0px"}, 1200); //animate first text
};
$nextText.css({opacity: 0}).addClass('active-text').animate({opacity:1, marginLeft: "0px"}, 1200, function(){
$activeText.removeClass('active-text');
});
}
});
</script>
HTML
<div class="flying-text active-text">Text1<div>
<div class="flying-text">Text2</div>
<div class="flying-text end">Text3</div>
现在你可以看到,Text1-3 首先动画/飞入,然后当到达 Text3 时,它们在动画中被 Text4-6 替换,当再次到达 Text6 时,它再次循环回到 Text1-3 ......现在基本上我想要做的是在动画到达文本末尾时暂停/延迟更长的时间,即在 Text3(class="flying-text end") 和 Text6(class="flying-text end2"。所以我希望 Text3 和 Text6 的动画时间比所有其他人都长。我该怎么做?我使用的代码:
$activeText.stop().delay(5000);
不工作...
谢谢你