封装函数防抖

function antiShake(func, delay){
var timer = null;
return function(…argus){
clearTimeout(timer);
if(timer == null){
func.apply(this, argus);
timer = “调用一次”;
}else{
timer = setTimeout(() => {
func.apply(this, argus);
}, delay);
}
}
}

你可能感兴趣的:(笔记)