简体   繁体   English

动画结束时执行动画

[英]Executing animation When an Animation Ends

i created a swimming fish and i want in the end of the animation the fish will rotate and swim to top 我创建了一条游泳鱼,我希望动画结束时鱼会旋转并游泳到顶部

function anim() {
    $(".fish_wrap").animate({
        "left": "-90px" }, 5000);    
}
anim();

here is the fiddle link: 这是小提琴链接:

http://jsfiddle.net/TxC5y/3/ http://jsfiddle.net/TxC5y/3/

The .animate() function provides a callback function to be executed when the animation completes. .animate()函数提供了动画完成时要执行的回调函数。 Something like this: 像这样:

$(".fish_wrap").animate({
    "left": "-90px" }, 5000,
    function () {
        // perform your next task here
});

That inline function being passed to .animate() will be called when the animation completes, so that's where you'd put your next step(s). 动画完成时,将调用传递给.animate()内联函数,因此您可以在其中进行下一步。 (Rotating and swimming to the top.) (旋转并游泳到顶部。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM