寫了一個物體緩沖運動的demo,但是不能到達目標值,求解!function move(idname, speed, target) { clearInterval(timer); var box = document.getElementById(idname); timer = setInterval(function(){ var v = (target-box.offsetLeft)/speed; v = v > 0 ? Math.ceil(v):Math.floor(v); if (parseInt(box.style.left) == target) { clearInterval(timer); } else { box.style.left = box.offsetLeft + v + 'px'; } }, 30) }box.onmouseover = function() { move('box', 20, 500); }為什么是left值是633px?
緩沖運動怎樣達到目標值?
精慕HU
2018-12-18 17:18:45