Created
September 19, 2014 02:16
-
-
Save lyuehh/4a5cc185bca1a6306522 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 debouncer(func, timeout) { | |
var timeoutID; | |
timeout = timeout || 300; | |
return function () { | |
var scope = this , args = arguments; | |
clearTimeout( timeoutID ); | |
timeoutID = setTimeout( function () { | |
func.apply( scope , Array.prototype.slice.call( args ) ); | |
}, timeout); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment