简体   繁体   中英

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/

The .animate() function provides a callback function to be executed when the animation completes. 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). (Rotating and swimming to the top.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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