移动浏览器上的无限滚动 [英] Infinite Scroll on Mobile browsers
本文介绍了移动浏览器上的无限滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的网站上实现无限滚动,它适用于任何计算机上的浏览器,但它在移动浏览器上存在问题。到目前为止,在chrome上,如果我不放大或缩小它可以正常工作但是一旦我缩放它会停止工作。在野生动物园,它根本不起作用。这是我正在使用的代码:
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.
推荐答案
而不是使用
$(window).height()
$(window).height()
尝试使用
window.innerHeight
window.innerHeight
这篇关于移动浏览器上的无限滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文