当前位置:网站首页>Setinterval, setTimeout and requestanimationframe
Setinterval, setTimeout and requestanimationframe
2022-06-28 11:21:00 【InfoQ】
setTimeoutsetTimeoutEventLoopsetTimeout// Time delay 1s after , Print hello,world
setTimeout(() => {
console.log('hello,world');
}, 1000)
setIntervalsetTimeoutsetIntervalsetIntervalsetInterval(() => {
console.log('hello,world');
}, 1000)
setTimeout- According to the refresh rate of different screens , Automatically adjust the timing of executing the callback function .
- When the window is inactive ,
requestAnimationFrameWill stop executing , andsetTimeoutCan't
- It has function throttling function
var progress = 0;
var timer = null;
function render() {
progress += 1;
if (progress <= 100) {
console.log(progress);
timer = window.requestAnimationFrame(render);
} else {
cancelAnimationFrame(timer);
}
}
// First frame rendering
window.requestAnimationFrame(render);边栏推荐
- 工控安全之勒索病毒篇
- 使用ssm项目对Mysql8进行访问的时候,出现连接失败和一些错误的解决办法
- 使用 Calendar 计算时间
- Using loops for, while, and if in katalon else、break、continue
- 阿里三面:LEFT JOIN关联表中用ON还是WHERE跟条件有什么区别
- Information hidden in the trend chart of Hong Kong London gold market
- 李宏毅《机器学习》丨7. Conclusion(总结)
- 买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
- Convert the file URL in the browser to a file stream
- BigDecimal 类的 compareTo() 和 equals()方法
猜你喜欢

Yann LeCun新论文:构建自动智能体之路

一套十万级TPS的IM综合消息系统的架构实践与思考

DlhSoft Kanban Library for WPF

ThreadLocal的简单理解

Redis6 一:Nosql引入、Redis可以解决什么问题?

JS foundation 1-js introduction and operator

How does ETF position affect spot gold price?

一套十万级TPS的IM综合消息系统的架构实践与思考

Blue Bridge Cup Maze (dfs+ backtracking)

Katalon framework tests web (XX) custom keywords and upload pop-up operations
随机推荐
Get current system date
Oracle 日期格式化异常:无效数字
Excel导入导出便捷工具类
Metersphere implements UI automation elements that are not clickable (partially occluded)
Solve the problem of reading package listsdonebuilding dependency treereading state informationdone
方法重写(Override)
董宇辉,新东方以及凤凰卫视
Wireshark数据抓包分析之FTP协议
How does ETF position affect spot gold price?
JS foundation 2
JS foundation 6
合约量化交易系统开发 | 合约量化APP开发(现成案例)
[semidrive source code analysis] [x9 chip startup process] 32 - play module analysis - RTOS side
JS基础5
String & heap & method area
Making and using of dynamic library (shared library)
Create ECS using API shortcut
Download and install mysql5.7 for windows 10
爱可可AI前沿推介(6.28)
JS基础3