I have the following jquery text animation animation. Here is my code before I explain further:
<script type="text/javascript">
$(document).ready(function(){
$('.flying1 .flying-text').css({opacity:0});
$('.flying1 .active-text').animate({opacity:1, marginLeft: "0px"}, 1200);
var int = setInterval(changeText, 3500);
function changeText(){
var $activeText = $(".flying1 .active-text");
var $nextText = $activeText.next();
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);
};
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);
};
$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>
Now, as you can see, Text1-3 animates / flies first, and then, when Text3 is reached, they are replaced by Text4-6 in the animation, when Text6 is received again, it returns to Text1-3 again ... But basically something what I want to do is pause / hold the animation longer when it reaches the end of the text, that is, in Text3 (class = "end of flying text") and Text6 (class = text end2 ", so I want Text3 and Text6 to animate longer than everyone else.How do I do this? The code I used is:
$activeText.stop().delay(5000);
does not work...
thank
source
share