Created
July 21, 2015 13:09
-
-
Save SergeyNarozhny/2f51d22a262444cf2775 to your computer and use it in GitHub Desktop.
Throttle native js realization
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
function throttle(method, context) | |
{ | |
clearTimeout(method.tId); | |
method.tId = setTimeout(function(){ | |
method.call(context); | |
}, 100); | |
} | |
//usage example | |
window.onresize = function() | |
{ | |
throttle(resizeDiv); //throttle function resizeDiv(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment