jQuery的重启动画停止后 [英] jquery restart animation after it stops

查看:188
本文介绍了jQuery的重启动画停止后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

可能重复:结果
   jQuery的不断循环动画


我要当DIV定时器达到940px这个动画重新启动。
到目前为止,我有这样的:

  $('定时器。')动画({'宽度':940},{队列:假的,持续的时间:5000,缓和:线性});
如果($('计时器')。宽度()== 940){
    $('定时器')宽()== 0。
    $('定时器')动画({'宽度':940},{队列:假的,持续的时间:5000,缓和:线性});
}


解决方案

重新启动动画循环:

  $(定时器)。绑定(animation.loop功能(){
    $(本).animate({宽度:940},5000,函数(){
        $(本).animate({宽度:0},5000,函数(){
            $(本).trigger(animation.loop);
        });
    });
})触发(animation.loop);

做动画,硬复位,重新制作动画:

  $(定时器)。绑定(animation.loop功能(){
    $(本).animate({宽度:940,缓和:线性},5000,函数(){
        $(本)的.css(宽度,0).trigger(animation.loop);
    });
})触发(animation.loop);

Possible Duplicate:
Jquery Continuously Loop Animation

I want this animation to restart when the div timer reaches 940px. So far I have this:

$('.timer').animate({'width':940}, {queue:false, duration:5000, easing: 'linear'});
if ($('.timer').width() == 940){
    $('.timer').width() == 0;
    $('.timer').animate({'width':940}, {queue:false, duration:5000, easing: 'linear'});
}

解决方案

Restarting animated loop:

$(".timer").bind("animation.loop", function(){
    $(this).animate({width: 940}, 5000, function(){
        $(this).animate({width: 0}, 5000, function(){
            $(this).trigger("animation.loop");
        });
    });
}).trigger("animation.loop");

Do the animation, hard reset, animate again:

$(".timer").bind("animation.loop", function(){
    $(this).animate({width: 940, easing: 'linear'}, 5000, function(){
        $(this).css("width", 0).trigger("animation.loop");
    });
}).trigger("animation.loop");

这篇关于jQuery的重启动画停止后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆