-1

I have a div with position fixed and top:96.9%. I need to handle this div when the page reaches its end (i.e when the page cannot be scrolled down further). How could I detect if the page scroll has reached its end? I did this:

if( ($(window).scrollTop() + $(window).height()) == $(document).height()) {
   // No more scroll!
}

Is there a better way to detect this?

1 Answers1

0

var pixelsBelow = $(window).scrollHeight - $(window).clientHeight - $(window).scrollTop; if (pixelsBelow > 10) ...

10 is a slop factor; you'll generally want to trigger the "at bottom" event even if there are still a few pixels unseen.

Oh My Goodness
  • 216
  • 2
  • 9