Skip to content

Instantly share code, notes, and snippets.

@avil13
Created May 24, 2016 11:40
Show Gist options
  • Save avil13/9e99b40ed156236fbd77e434eb948acf to your computer and use it in GitHub Desktop.
Save avil13/9e99b40ed156236fbd77e434eb948acf to your computer and use it in GitHub Desktop.
// Для вызова функции не чаще чем в указанный интервал времени
var my_debounce = function(func, wait) {
var timeout;
return function() {
var context = this,
args = arguments,
later = function() {
timeout = null;
func.apply(context, args);
};
if (!timeout) {
timeout = setTimeout(later, wait);
}
return timeout;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment