1 pixel ScrollTop off in Firefox

As with the description here , in certain situations $(window).scrollTop() disabled alone in Firefox.

I use this to determine if the vertical scrollbar has reached:

 if ($(window).scrollTop() == $(document).height() - $(window).height()) { // bottom reached } 

It works. But I just accidentally discovered that it only works in most cases. Here is a magazine from the case when it goes wrong. scrollTop says that I scrolled 611 pixels, difference says that I can scroll 612 pixels.

 scrollTop: 611 doc height: 933 win height: 321 difference: 612 

Is there something wrong with the code? Or is this a problem with Firefox? In the latter case, I think I can change it to check if 5 or fewer pixels remain. But if the code is wrong, I would like to fix it.

+4
source share
1 answer

use below code that it works.

  if ($(window).scrollTop() >= ($(document).height() - $(window).height()-1)) 
+1
source

Source: https://habr.com/ru/post/1403942/


All Articles