当页面宽度小于 981px 时,无限滚动不起作用

infinite scroll does not work when width of a page is less then 981px

当页面宽度大于 980px 时,无限滚动可以正常工作,但当它小于 981px 时,它就停止工作。

我很难说这只与身高有关,但看起来我错了。

代码:

$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {

    console.log("infinite scroll works");


}

});

对于宽度小于 981 像素的设备,是否有解决此问题的方法?

这里是完整项目的参考:https://github.com/strix25/1-million-books-generator-and-infinite-scroll

我找到了解决这个问题的方法。

代码:

$(window).scroll(function () {
 if ($(this).scrollTop() + 1 >= $('body').height() - $(window).height()) {
  console.log("infinite scroll works"); 
 }

});