Infinite Scroll on Mobile browsers

最后都变了- 提交于 2020-01-13 19:10:29

问题


I am trying to implement infinite scroll on my website and it works well on browsers on any computer, but it has issues on mobile browsers. So far, on chrome, if I don't zoom in or out it works ok but once I zoom either way it stops working. On safari it doesn't work at all. This is the code that I am using:

$(window).on('scroll', function (e) {
    console.log(" window.scrollTop = " + $(window).scrollTop() + " document.height=" + $(document).height() + " window.height =" + $(window).height());
    if ($(window).scrollTop() == $(document).height() - $(window).height()) {
        load();
    }
});

If anyone has any suggestions please let me know.


回答1:


Instead of using

$(window).height()

try using

window.innerHeight



来源:https://stackoverflow.com/questions/20619264/infinite-scroll-on-mobile-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!