Skip to content

Instantly share code, notes, and snippets.

@wilwang
Created September 9, 2014 14:24
Show Gist options
  • Save wilwang/c971de7a5221dcd77219 to your computer and use it in GitHub Desktop.
Save wilwang/c971de7a5221dcd77219 to your computer and use it in GitHub Desktop.
JS - Performant alternative to binding on heavy firing events
/*
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