aliyun-light-clock
0.1.5 • Public • Published
- 一个使用 requestAnimationFrame 实现setTimeout、setInterval的定时器
- 支持设置定时器循环次数
import {
setTimeout,
setInterval,
clearTimeout,
clearInterval,
clock,
clearClock,
} from '@ali/light-clock';
// Date.now() - creatTime > 60, 执行函数
// 使用 requestAnimationFrame判断
setTimeout(() => {
console.log(Date.now());
}, 60);
// Date.now() - triggerTime > 60, 执行函数
// 使用 requestAnimationFrame判断
setInterval(() => {
console.log(Date.now());
}, 60);
// Date.now() - triggerTime > 60, 执行函数,总共执行10次
// 使用 requestAnimationFrame判断
clock(() => {
console.log(Date.now());
}, 60, 10);
/aliyun-light-clock/
//
Package Sidebar
Install
Weekly Downloads