Created
June 10, 2014 12:44
-
-
Save eliorivero/b1e7267f51feb0365bb3 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($){ | |
// 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