Created
May 24, 2016 11:40
-
-
Save avil13/9e99b40ed156236fbd77e434eb948acf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Для вызова функции не чаще чем в указанный интервал времени | |
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