jQueryアニメーションプロパティを実行中に一時停止しようとしています。アニメーションの途中でポーズポイントを持つJQueryアニメーション
以下のコードは、アニメーションの途中でアニメーションをランダムに一時停止してから再生します。
これは、marginLeftをアニメーション化し、半分または1秒間ランダムに一時停止し、その後、アニメーションがvar $ playで終了したところでピックアップを実行するような簡単な手順で行います。
私は全体的なアニメーションの速度を遅くし、ランダムな時間に停止点を追加し、元のアニメーションシーケンスを取得しようとしています。
ご協力いただければ幸いです。
<script>
$(document).ready(function() {
var $block = $('.1');
var numRand1 = Math.floor(Math.random()*4000)
var numRand2 = Math.floor(Math.random()*3000)
var numRand3 = Math.floor(Math.random()*9000)
var $play = $block.animate({"marginLeft": "420px"}, numRand1);
setInterval(function() {
$block.stop();
$block.delay(1500);
$block.animate({"marginLeft": "420px"}, numRand2);
}, 2000);
setInterval(function() {
$block.stop();
$block.delay(2500);
$block.animate({"marginLeft": "420px"}, numRand3);
}, 4000);
});
</script>
<style>
.block{
width:50px;
height:50px;
background:#ff0000;
margin-bottom:20px;
}
</style>
<div class="block 1"></div>
編集した答えは、私が試したものを基本的だった、それは私のために実現しなかった –