Skip to content

Instantly share code, notes, and snippets.

@itsvicsoto
Created April 30, 2015 06:15
Show Gist options
  • Save itsvicsoto/a5b7a8639041de8690c4 to your computer and use it in GitHub Desktop.
Save itsvicsoto/a5b7a8639041de8690c4 to your computer and use it in GitHub Desktop.
jquery
$(document).on('scroll', function(e) {
var $documentHeight = $(this).height();
var $currentScrollOffset = $(this).scrollTop() + $(window).height(); // Scroll Top + the current window height
var distanceToBottom = $documentHeight - $currentScrollOffset;
var offsetEventTrigger = 100;
console.log('$documentHeight', $documentHeight);
console.log('$currentScrollOffset', $currentScrollOffset);
console.log('Distance to bottom of document : ', distanceToBottom);
if(distanceToBottom < offsetEventTrigger) {
// do your logic here
console.log('Trigger your event call api endpoint');
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment