【问题标题】:infinite scroll does not work when width of a page is less then 981px当页面宽度小于 981 像素时,无限滚动不起作用
【发布时间】:2018-01-13 21:33:02
【问题描述】:

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

我坚持认为这仅与身高有关,但看起来我错了。

代码:

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

    console.log("infinite scroll works");


}

});

对于宽度小于 981px 的设备有没有办法解决这个问题?

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

【问题讨论】:

    标签: javascript jquery infinite-scroll


    【解决方案1】:

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

    代码:

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

    });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-09
      相关资源
      最近更新 更多