Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kristoferjoseph
Last active March 31, 2018 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristoferjoseph/c952f461b415299d6a52f07f9a34b18e to your computer and use it in GitHub Desktop.
Save kristoferjoseph/c952f461b415299d6a52f07f9a34b18e to your computer and use it in GitHub Desktop.
Debounce with immediate execution option removed
function debounce (fn, wait) {
var timeout
return function () {
var context = this
var args = Array.prototype.slice.call(arguments)
var later = function () {
timeout = null
fn.apply(context, args)
}
clearTimeout(timeout)
timeout = setTimeout(later, wait)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment