Created
September 13, 2013 06:51
-
-
Save kerotaa/6547416 to your computer and use it in GitHub Desktop.
easy throttle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function throttle(fn, interval) { | |
var timer = null; | |
return function() { | |
var self = this, args = arguments; | |
if (!timer) { | |
timer = setTimeout(function() { | |
timer = null; | |
fn.apply(self, args); | |
}, interval); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment