当前位置:网站首页>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);边栏推荐
猜你喜欢

Thesis reading (59):keyword based diverse image retrieval with variable multiple instance graph

太阳能无线LED显示屏的特点

Redis6 1: what problems can be solved by the introduction of NoSQL and redis?

智联招聘基于 Nebula Graph 的推荐实践分享

JS基础1-JS引入与运算符

Making and using of dynamic library (shared library)

MySQL(一)

人人都可以参与开源!龙蜥社区最不容错过的开发者活动来了

Oracle 日期格式化异常:无效数字

科研丨Web of Science检索技巧
随机推荐
买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
东方财富手机股票开户哪个券商更安全更方便?
时间戳和date转换「建议收藏」
Wealth management for programmers
Splicing strings in the string collection_ Stream based
2022 开源软件安全状况报告:超41%的企业对开源安全没有足够的信心
JS基础6
MySQL (II)
关于Pytorch中双向LSTM的输出表示问题
科研丨Web of Science检索技巧
个人买场内基金选择什么证券公司开户好,更安全
Makefile简介
行业分析| 快对讲,楼宇对讲
远程登录sshd服务
Décompression par compression
分析list中有无重复数据且重复了几次
Yann LeCun新论文:构建自动智能体之路
Compareto() and equals() methods of BigDecimal class
Thesis reading (59):keyword based diverse image retrieval with variable multiple instance graph
100 important knowledge points that SQL must master: retrieving data