Created
November 28, 2017 14:51
-
-
Save iamchristough/528345fd5672539d8d1a2b383691310b to your computer and use it in GitHub Desktop.
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 actThenThrottleEvents(listener, delay) { | |
var timeout; | |
return function(e) { | |
if (!timeout) { // no timer running | |
listener(e); // run the function | |
timeout = setTimeout( function() { timeout = null }, | |
delay); // start a timer that turns itself off when it's done | |
} | |
//else, do nothing (we're in a throttling stage) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment