Skip to content
New issue

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

JS:setTimeout setInterval requestAnimationFrame #58

Open
HCLacids opened this issue Mar 16, 2022 · 1 comment
Open

JS:setTimeout setInterval requestAnimationFrame #58

HCLacids opened this issue Mar 16, 2022 · 1 comment
Labels

Comments

@HCLacids
Copy link
Owner

HCLacids commented Mar 16, 2022

参考链接
setTimeout和setInterval都会返回一个计时器的ID
setTimeout是延迟执行,只执行一次。setInterval是在一定时间内执行一次,直到清除定时器。

@HCLacids HCLacids changed the title set JS:setTimeout setInterval requestAnimationFrame Mar 16, 2022
@HCLacids
Copy link
Owner Author

参考链接
requestAnimationFrame最大的优势是由系统来决定回调函数的执行时机。具体一点讲,如果屏幕刷新率是60Hz,那么回调函数就每16.7ms被执行一次,如果刷新率是75Hz,那么这个时间间隔就变成了1000/75=13.3ms,换句话说就是,requestAnimationFrame的步伐跟着系统的刷新步伐走。

@HCLacids HCLacids added the JS label Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant