We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
与setTimeout和setInterval不同,requestAnimationFrame不需要设置时间间隔,最大的优势是由系统决定回调函数的执行时间。具体一点讲,如果屏幕刷新率是60Hz,那么回调函数就每16.7ms被执行一次。
var progress = 0; //回调函数 function render() { console.log(progress) progress += 1; //修改图像的位置 if (progress < 100) { //在动画没有结束前,递归渲染 window.requestAnimationFrame(render); } } //第一帧渲染 window.requestAnimationFrame(render);
除此之外,requestAnimationFrame还有以下两个优势:
canvas基础、动画样例
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一、requestAnimationFrame
与setTimeout和setInterval不同,requestAnimationFrame不需要设置时间间隔,最大的优势是由系统决定回调函数的执行时间。具体一点讲,如果屏幕刷新率是60Hz,那么回调函数就每16.7ms被执行一次。
除此之外,requestAnimationFrame还有以下两个优势:
二、Canvas
canvas基础、动画样例
三、WebGL
The text was updated successfully, but these errors were encountered: