Skip to content

Instantly share code, notes, and snippets.

@chrise86
Forked from datacarl/gist:7029558
Last active August 29, 2015 14:04
Show Gist options
  • Save chrise86/e368072f11b1a087b56c to your computer and use it in GitHub Desktop.
Save chrise86/e368072f11b1a087b56c to your computer and use it in GitHub Desktop.
var scheduled = false,
_throttleDelay = 200;
function ScrollHandler(e) {
//throttle event:
if (!scheduled) {
scheduled = true;
setTimeout(function () {
console.log('scroll');
//do work
if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
alert("near bottom!");
}
// Allow method to run again when user scrolls next time.
scheduled = false;
}, _throttleDelay);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment