Created
September 8, 2020 17:00
-
-
Save mattzeunert/568ca537e18b15401ccae88cb07ba002 to your computer and use it in GitHub Desktop.
This file contains 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 (callback, limit) { | |
var wait = false; | |
return function () { | |
if (!wait) { | |
callback.apply(null, arguments); | |
wait = true; | |
setTimeout(function () { | |
wait = false; | |
}, limit); | |
} | |
} | |
} | |
window.addEventListener('resize', throttle(function(e){console.log(e)}, 100)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment