We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
防抖和节流都是我们解决高频触发事件的两种常用解决方案,与节流不同,防抖是将若干次事件调用合成为一次,并在给定时间过去之后,或者连续事件完全触发完成之后,调用一次。
防抖函数:
function debounce(fn, delay) { var timer = null; delay = delay || 1000; return function() { var context = this; var args = arguments; clearTimeout(timer); timer = setTimeout(function() { fn.apply(context, args); }, delay); } }
应用举例:
inputElm.addEventListener('input', debounce(function() { console.log(Date.now()) }));
The text was updated successfully, but these errors were encountered:
No branches or pull requests
防抖和节流都是我们解决高频触发事件的两种常用解决方案,与节流不同,防抖是将若干次事件调用合成为一次,并在给定时间过去之后,或者连续事件完全触发完成之后,调用一次。
防抖函数:
应用举例:
The text was updated successfully, but these errors were encountered: