首页 > 代码库 > javascript 运动缓冲效果

javascript 运动缓冲效果

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title></title></head><style>#box{    width:100px;    height:100px;    background:orange;    position: absolute;    left:0;}</style><body>    <div id="box"></div>    </body></html><script>var oBox = document.getElementById(box);var num = 0 , speed;oBox.onclick = function(){    setInterval(function(){        speed = Math.ceil( 0.1*(1000-num) );        num = num + speed;        oBox.style.left = num+px;    },10);}</script>

 

javascript 运动缓冲效果