Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function debounce(callback, wait) {
- var timeout;
- return function() {
- var context = this;
- var args = arguments;
- var later = function() {
- timeout = null;
- }
- var callNow = !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) callback.apply(context, args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement