Last active
September 29, 2016 22:43
-
-
Save james2doyle/2c0ddd5c0aba56131f8179c1894ce72d to your computer and use it in GitHub Desktop.
Window resize event listener with an added delay. This stops the resize event from firing constantly while resizing. Basically a debounce for scrolling
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 someNamedFunction() { | |
// fires 200 ms after the last scroll event | |
} | |
function handleResize() { | |
clearTimeout(this.delayer); | |
this.delayer = setTimeout(someNamedFunction, 200); | |
} | |
window.addEventListener('resize', handleResize); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment