Skip to content

Instantly share code, notes, and snippets.

@eliorivero
Created June 10, 2014 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliorivero/b1e7267f51feb0365bb3 to your computer and use it in GitHub Desktop.
Save eliorivero/b1e7267f51feb0365bb3 to your computer and use it in GitHub Desktop.
(function($){
// Set a flag.
var didScroll = false;
// On scroll event, set the flag to true.
$(window).on('scroll', function() {
didScroll = true;
});
/* At a certain interval, in this case 50 milliseconds,
* check the flag and execute code if it a scroll took place.
*/
setInterval(function() {
if ( didScroll ) {
didScroll = false;
/* Code to execute on scroll goes here.
* If you have code in several places that must be triggered on scroll
* it's better to have all the code called by functions here.
*/
}
}, 50);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment