Created
September 9, 2014 14:24
-
-
Save wilwang/c971de7a5221dcd77219 to your computer and use it in GitHub Desktop.
JS - Performant alternative to binding on heavy firing events
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
/* | |
Found on http://ejohn.org/blog/learning-from-twitter/ | |
- neat way for performant JS when needing to bind on window scroll | |
*/ | |
var outerPane = $details.find(".details-pane-outer"), | |
didScroll = false; | |
$(window).scroll(function() { | |
didScroll = true; | |
}); | |
setInterval(function() { | |
if ( didScroll ) { | |
didScroll = false; | |
// Check your page position and then | |
// Load in more results | |
} | |
}, 250); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment