function fd(delay, callback) {
let timer = null;
return function () {
clearTimeout(timer)
timer = setTimeout(() => {
callback();
}, delay);
}
}
function jl(delay, callback) {
let time = Date.now();
return function () {
if (Date.now() - time > delay) {
callback();
time = Date.now();
}
}
}
// window.onscroll = fd(1000, () => {
// console.log('滚动')
// })
window.onscroll = jl(1000, () => {
console.log('滚动')
})
网友评论