README
var progress = 0;
//回调函数
function render() {
progress += 1; //修改图像的位置
console.log(progress)
// 限制条件:在动画没有结束前,递归渲染
if (progress < 100) {
window.requestAnimationFrame(render);
}
}
// 第一帧渲染
window.requestAnimationFrame(render);
链接
帧数,刷新率,requestAnimationFrame 将requestAnimationFrame与React Hooks一起使用