Created
April 30, 2015 06:15
-
-
Save itsvicsoto/a5b7a8639041de8690c4 to your computer and use it in GitHub Desktop.
jquery
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
$(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