Last active
January 3, 2018 16:08
-
-
Save corysimmons/4f86d56aa46517437147 to your computer and use it in GitHub Desktop.
John Resig - Learning from Twitter Tiny JS Throttle
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
let didResize = false | |
window.addEventListener(`resize`, () => { | |
didResize = true | |
}) | |
setInterval(() => { | |
if (didResize) { | |
// Do stuff | |
didResize = false | |
} | |
}, 250) |
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
let didScroll = false | |
window.addEventListener(`scroll`, () => { | |
didScroll = true | |
}) | |
setInterval(() => { | |
if (didScroll) { | |
// Do stuff | |
didResize = false | |
} | |
}, 250) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment