版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/adley_app/article/details/88654864
var start = null;
var element = document.getElementById('SomeElementYouWantToAnimate');
element.style.position = 'absolute';
var progress=0;
function step(timestamp) {
if (!start) start = timestamp;
progress += 50;
element.style.left = Math.floor(progress) + 'px';
if (progress < 1000) {
window.requestAnimationFrame(step);
}
}
window.requestAnimationFrame(step);