function customizeSetInterval(callback, interval) {
let timer = null;
let startTime = Date.now();
let loop = () => {
let endTime = Date.now();
if (endTime - startTime >= interval) {
startTime = endTime = Date.now();
callback(timer);
}
timer = window.requestAnimationFrame(loop);
}
loop();
return timer;
}
customizeSetInterval((timer) => {
console.log(1);
// cancelAnimationFrame(timer);
}, 1000)
福利来袭-----下一遍分享