开发者

How to re-run animation after animation finishes (jQuery)?

What I am trying to do is to animate an image acr开发者_Go百科oss the page, continuously, while being draggable at the same time. Currently, it moves across, is draggable, and goes back to the initial position after the initial animation is done.

However, I don't know how to get it to run again so that it's a continuous loop of animation. I was thinking to put the function animateCloud() inside animateCloud() but not sure where to attach it. Below is the jsFiddle demo:

http://jsfiddle.net/iamacatperson/SfFgt/2/

I would also appreciate if there's a better method of doing this. I am just starting to learn jQuery and I only know a couple of syntax.


I don't know why are you using .stop() but I guess this should work-

function animateCloud() {
    $(cloud).animate({
        left: '300px'
    }, 25000, function() {
        $(this).css({ left: '0' });
         animateCloud();
    });

}

I hope this is what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜