当前位置:网站首页>setInterval、setTimeout和requestAnimationFrame
setInterval、setTimeout和requestAnimationFrame
2022-06-28 11:09:00 【InfoQ】
setTimeoutsetTimeoutEventLoopsetTimeout// 延时1s之后,打印hello,world
setTimeout(() => {
console.log('hello,world');
}, 1000)
setIntervalsetTimeoutsetIntervalsetIntervalsetInterval(() => {
console.log('hello,world');
}, 1000)
setTimeout- 根据不同屏幕的刷新频率,自动调整执行回调函数的时机。
- 当窗口处于未激活状态时,
requestAnimationFrame会停止执行,而setTimeout不会
- 自带函数节流功能
var progress = 0;
var timer = null;
function render() {
progress += 1;
if (progress <= 100) {
console.log(progress);
timer = window.requestAnimationFrame(render);
} else {
cancelAnimationFrame(timer);
}
}
//第一帧渲染
window.requestAnimationFrame(render);边栏推荐
- Basic 02: variable, remember the mobile number of the object
- Summary of spatial temporal time series prediction modeling methods
- JS基础1-JS引入与运算符
- Yann Lecun's new paper: the road to building automatic agents
- Download and install mysql5.7 for windows 10
- JS基础2
- flink1.15,支持mysql视图吗?我这边在table-name处配置视图名保存,找不到表。想
- Blackmail virus of industrial control security
- 将浏览器中的文件 url转换为File流
- JS foundation 4
猜你喜欢

Debug debugging in katalon

Making and using of static library
![[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)](/img/e8/21d8d81a3d7b544687d6adc06ad4b1.png)
[practice] 1364- implement a perfect waterfall flow component on the mobile terminal (with source code)

JS基础8

Threads and thread pools

AGCO AI frontier promotion (6.28)

Remote connection of raspberry pie in VNC viewer mode without display

Scientific research - web of science retrieval skills

Katalon framework tests web (XX) custom keywords and upload pop-up operations

移动命令
随机推荐
实体转JSON时,值为null的字段的丢失问题
Which broker is safer and more convenient to open an account for Oriental Fortune mobile stock?
Lihongyi, machine learning 7 Conclusion
东方财富手机股票开户哪个券商更安全更方便?
Basic 02: variable, remember the mobile number of the object
Installing MySQL database (CentOS) in Linux source code
静态库的制作和使用
windows 10下载安装mysql5.7
JS foundation 1-js introduction and operator
Making and using of static library
SQL必需掌握的100个重要知识点:检索数据
Excel导入导出便捷工具类
Remote connection of raspberry pie in VNC viewer mode without display
知道 Redis RDB 这些细节,可以少踩很多坑
【剑指Offer】49. 丑数
Redis6 1: what problems can be solved by the introduction of NoSQL and redis?
什么是DAPP系统发展与解析理解
String & heap & method area
When an entity is converted to JSON, the field with null value is lost
拼接String集合中的字符串_基于Stream