Guest User

Untitled

a guest
Jan 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function throttle(fn, delay) {
  2. var canInvoke = true;
  3. var invokeDelay = function () {
  4. canInvoke = true;
  5. };
  6.  
  7. return function () {
  8. if (canInvoke) {
  9. fn.apply(this, arguments);
  10. canInvoke = false;
  11. setTimeout(invokeDelay, delay);
  12. }
  13. };
  14. }
Add Comment
Please, Sign In to add comment