如何重新运行动画完成(jQuery的)后的动画? [英] How to re-run animation after animation finishes (jQuery)?

查看:220
本文介绍了如何重新运行动画完成(jQuery的)后的动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所试图做的是整个页面动画图像,持续,而被同时拖动。目前,它移过,可拖动,初始动画完成后返回到初始位置。

What I am trying to do is to animate an image across 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.

不过,我不知道怎么弄,以便它的动画连续循环它再次运行。我正想着把功能animateCloud()内animateCloud(),但不知道在哪里进行安装。以下是演示的jsfiddle:

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/

我也要AP preciate,如果有这样做的更好的方法。我刚开始学习jQuery和我只知道一对夫妇的语法。

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.

推荐答案

我不知道你为什么使用 .stop(),但我想这应该work-

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.

这篇关于如何重新运行动画完成(jQuery的)后的动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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