Skip to content

Instantly share code, notes, and snippets.

@avil13
Created May 24, 2016 11:40
Show Gist options
  • Select an option

  • Save avil13/9e99b40ed156236fbd77e434eb948acf to your computer and use it in GitHub Desktop.

Select an option

Save avil13/9e99b40ed156236fbd77e434eb948acf to your computer and use it in GitHub Desktop.

Revisions

  1. avil13 created this gist May 24, 2016.
    16 changes: 16 additions & 0 deletions my_debounce
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // Для вызова функции не чаще чем в указанный интервал времени
    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;
    };
    };