Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created May 19, 2016 19:20
Show Gist options
  • Save rlemon/21ffaccd3332bbfb18e6a30683771970 to your computer and use it in GitHub Desktop.
Save rlemon/21ffaccd3332bbfb18e6a30683771970 to your computer and use it in GitHub Desktop.
debounce js
function debounce(fn, time) {
let deltaTime = Date.now();
return function(event) {
if (Date.now() - deltaTime >= time) {
fn.call(this, event);
deltaTime = Date.now();
}
}.bind(this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment