Last active
October 21, 2020 17:57
-
-
Save JMayfield/37f03df918336b11985f0bbf5acfd4e7 to your computer and use it in GitHub Desktop.
A gentle way to hook up to the jQuery scroll event while maintaining a reasonable frame-per-second scroll rate.
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
var scrolled = false; | |
$(window).scroll(scrollEvents); | |
function scrollEvents() { | |
scrolled = true; | |
} | |
setInterval(function() { | |
if(didScroll) { | |
// Execute scroll events, animations, etc. here | |
didScroll = false; | |
} | |
}, 200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment