diff --git a/utils/debounce.js b/utils/debounce.js index 7feffaa..baf1c57 100644 --- a/utils/debounce.js +++ b/utils/debounce.js @@ -1,10 +1,15 @@ -function debounce(fn, delay=800){ - let timer = null; - return function(){ - clearTimeout(timer); - timer = setTimeout(()=> { - fn.apply(this, arguments); - }, delay) - } +function debounce(fn,wait=1500){ + var flag = true; + var timer = null; + return function(){ + if(flag) { + fn.apply(this,arguments); + flag = false; + timer = setTimeout(() => { + flag = true + },wait) + } + } } + export default debounce \ No newline at end of file