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
/** * 节流:连续触发了大量的动作,就规定,在某一段时间内,动作执行一次。比如1s内,只执行一次,其他触发动作的时候忽略。技能冷却 */ function throttle (fn, delay) { let sign = true; return function () { // 闭包,保存变量的值,防止每次执行次函数,值都被重置 if (sign) { sign = false; setTimeout (() => { fn(); sign = true; }, delay); } else { return false; } } } window.onscroll = throttle(foo, 1000);
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: