Created
May 10, 2012 14:56
-
-
Save knorthfield/2653687 to your computer and use it in GitHub Desktop.
jQuery detect if scrolled to bottom or near it
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
$(window).scroll(function(){ | |
toScroll = $(document).height() - $(window).height() - 250; | |
if ( $(this).scrollTop() > toScroll ) { | |
// Do something | |
} | |
}); |
Indeed a good idea to trigger even few pixels before reaching the page bottom, helpful while implementing pagination, better user experience.
You can try the following code,
$("#dashboard-scroll").scroll(function(){ var ele = document.getElementById('dashboard-scroll'); if(ele.scrollHeight - ele.scrollTop === ele.clientHeight){ console.log('at the bottom of the scroll'); } });
Working as expected.Thank u so much
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can try the following code,