用jquery连续运动动画 [英] continuous movement animation with jquery
问题描述
我会喜欢在上面的网站重新创建卡车时刻,它是在mootools完成的。我将如何对此进行编码,是否有一个jQuery插件可以执行此操作?
I would like to recreate the truck moments in the above site , It is done in mootools. How would I code this, is there a jQuery plugin to do this?
因此,从屏幕的开头到结尾为对象设置动画,然后重新开始。我将如何做这个jQuery
So animate an object from beginning to end of screen and then it starts over again. How would I do this jQuery
任何帮助都将受到赞赏
推荐答案
这是一个JSFiddle示例 http://www.jsfiddle.net/XpAjZ/
Here's a JSFiddle sample http://www.jsfiddle.net/XpAjZ/
有关jQuery animate的更多信息: http://api.jquery.com/animate/
More on jQuery animate: http://api.jquery.com/animate/
演示显示在屏幕上以不同的速度等动画的2个框。(见小提琴)
Demonstration shows 2 boxes animated across the screen at different speeds etc. (See fiddle)
相关的jQuery代码:
Relevant jQuery Code:
var animateMe = function(targetElement, speed){
$(targetElement).css({left:'-200px'});
$(targetElement).animate(
{
'left': $(document).width() + 200
},
{
duration: speed,
complete: function(){
animateMe(this, speed);
}
}
);
};
animateMe($('#object1'), 5000);
animateMe($('#object2'), 3000);
这篇关于用jquery连续运动动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!