//防抖
const debounce = (fn, delay) => {
let timer;
return function () {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
fn();
}, delay);
};
};
//resize事件监听窗口变化
const handleWindowResize = (callback) => {
const cancalDebounce = debounce(callback, 500);
window.addEventListener("resize", cancalDebounce);
};
resize事件监听窗口变化
最新推荐文章于 2024-07-14 11:54:09 发布