重复jQuery动画(从左到右)

时间:2012-07-13 10:44:30

标签: jquery repeat

我已经在这里搜索了解决方案,但遗憾的是没有任何方法可以帮助我。

我有一些动画云,从我的页面左侧飞到右侧,但我怎么能重复这个动画?

我的代码:

(JS)

$(window).load(function animation() {   
  $(".big_cloud").delay(5000).animate( { marginLeft: '100%' }, speed, 'linear');
  });

(CSS)

.big_cloud {
background-image: url('images/big_cloud.png');
width: 272px;
height: 174px;
cursor:pointer;
position: absolute;
margin-left: -280px;
z-index: 3;
}

(HTML)

<div class="big_cloud"></div>

例如,在云位于页面中间后,是否可以开始重复?

谢谢!

2 个答案:

答案 0 :(得分:3)

这样的事情能实现你想要的吗

http://jsfiddle.net/uxyFE/

一旦动画完成,我只需将现有云移动到负边距并再次调用该函数。当然这意味着一次只有一个云

答案 1 :(得分:0)

这样的东西?

$(".big_cloud").everyTime((speed * 2), function (){
    $(".big_cloud").animate({ marginLeft:'100%' }, speed, 'linear').animate({ marginLeft:'0%' }, speed, 'linear');
});

来源:http://www.irengba.com/codewell/