【发布时间】:2011-11-01 14:24:58
【问题描述】:
我有一个小动画可以让元素上下摆动。每个元素的摆动速度和数量略有不同。 我正在使用 Jquery Timers (http://plugins.jquery.com/project/timers) everyTime 函数来无限循环动画。
我已经成功地让元素上下摆动,但我无法让它们停止使用 stopTime() 函数。
这是我目前所拥有的:
function randomFromTo(from, to){
return Math.floor(Math.random() * (to - from + 1) + from);
}
function bobbing(command){
if(command=='start'){
$("#scroller .feature-headline").each(function (i) {
$(this).everyTime(1, 'bobbing', function (){
var bobAmount = randomFromTo(5, 10);
var bobSpeed = randomFromTo(1200, 2000);
$(this).animate ({marginTop: bobAmount}, bobSpeed, 'linear').animate ({marginTop: 0}, bobSpeed, 'linear');
});
});
} else {
$("#scroller .feature-headline").each(function (i) {
$(this).stopTime('bobbing');
});
}
}
我哪里错了?
【问题讨论】:
标签: jquery timer jquery-animate