Skip to content

Instantly share code, notes, and snippets.

@dmarchuk
Last active July 20, 2018 13:43
Show Gist options
  • Save dmarchuk/c1540f79333452807e5d9175d3b97ac9 to your computer and use it in GitHub Desktop.
Save dmarchuk/c1540f79333452807e5d9175d3b97ac9 to your computer and use it in GitHub Desktop.
Delay function after last action (keydown)
function throttle(f, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = window.setTimeout(function () {
f.apply(context, args);
},
delay || 3000);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment