問題は周りに進化します
- このランダムフローティングスクリプトでは、最初に左に、次に上にステップ移動することしかできませんが、完全には2つの間になります。
- なめらかではありません
プラグインもイージングしてみました
コードはここにあります:
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);