【发布时间】:2011-11-01 08:52:44
【问题描述】:
问题不断演变
- 这个随机浮动脚本只允许进行步进移动 就像先到左边然后到顶部一样,但在完美的情况下它会在两者之间
- 不够流畅
我也尝试过使用缓动插件
代码在这里:
function ran(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function moveIt()
{
$(".circle").each(function() {
x = ran(-3, 3);
y = ran(-3, 3);
pos = $(this).position();
nowX = pos.left + x;
nowY = pos.top + y;
$(this).animate({"left": nowX}, {queue:false, duration:400, easing: 'linear'});
$(this).animate({"top": nowY}, {queue:false, duration:400, easing: 'linear'});
});
}
setInterval(moveIt, 400);
【问题讨论】:
-
所以我们知道您的问题,现在您的问题是什么?
-
如何摆脱之字形运动.....它很小......但很明显
-
Smoother Jquery Animation 的可能重复项
标签: jquery jquery-animate setinterval smooth motion