[英]How to detect my document has reached the page bottom on mobile devices?
How can I detect my document has reached the page bottom on mobile devices? 如何检测我的文档已到达移动设备的页面底部?
I have this code works perfectly on desktop devices, but not on mobile devices, such as android phones, 我的这段代码可以在台式机设备上完美运行,但不能在移动设备(例如android手机)上运行,
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
}
});
any idea what else should I include in the code to make it work on mobile? 知道我还应该在代码中包含哪些内容才能使其在移动设备上运行吗?
I am using it for infinite scroll. 我正在使用它进行无限滚动。 I have a "load more" link on nearly bottom of page.
我在页面底部几乎有一个“加载更多”链接。
jQuery( window ).scroll( function() {
var loadMoreLink = 'a.infinite-link';
var actualLink = jQuery( loadMoreLink );
if ( actualLink.length ) {
var currentPosition = jQuery( loadMoreLink ).offset();
var pixelsVisible = window.innerHeight - currentPosition.top + jQuery( window ).scrollTop();
if ( pixelsVisible > 100 ) {
// time to do some ajax call.
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.