调用新页面后滚动检测不起作用Javascript
The scroll detection doesn't work after calling a new page Javascript
我正在使用 phonegap 开发应用程序,除滚动检测外一切正常!它工作正常,直到我使用 jQueryMobile 数据转换移动到另一个页面,之后它根本不起作用,尽管其他一切都工作正常!
这是我用于滚动检测的代码
// to check if I reached the bottom of the slide
if($(window).scrollTop() + $(window).height() == $(document).height()) {
// my code goes here
}
// to check if I'm at the top of the slide
if(document.body.scrollTop == 0 ) {
// my code goes here
}
尝试将您的 ==
符号更改为:
// to check if I reached the bottom of the slide
if($(window).scrollTop() + $(window).height() >= $(document).height()) {
// my code goes here
}
// to check if I'm at the top of the slide
if(document.body.scrollTop <= 0 ) {
// my code goes here
}
有时,经过一些计算后,它们的值可能较低或较高,从而导致错误,因此在需要时使用 <=
和 >=
是明智的。
不确定是否有帮助。
我找到了一个解决方案,我所做的就是按照这个方法来检测滚动,它工作得很好!
https://jqmtricks.wordpress.com/2014/07/15/infinite-scrolling/
特别感谢 jQMtricks 管理员 Omar 提供了这种检测
的好方法
我正在使用 phonegap 开发应用程序,除滚动检测外一切正常!它工作正常,直到我使用 jQueryMobile 数据转换移动到另一个页面,之后它根本不起作用,尽管其他一切都工作正常!
这是我用于滚动检测的代码
// to check if I reached the bottom of the slide
if($(window).scrollTop() + $(window).height() == $(document).height()) {
// my code goes here
}
// to check if I'm at the top of the slide
if(document.body.scrollTop == 0 ) {
// my code goes here
}
尝试将您的 ==
符号更改为:
// to check if I reached the bottom of the slide
if($(window).scrollTop() + $(window).height() >= $(document).height()) {
// my code goes here
}
// to check if I'm at the top of the slide
if(document.body.scrollTop <= 0 ) {
// my code goes here
}
有时,经过一些计算后,它们的值可能较低或较高,从而导致错误,因此在需要时使用 <=
和 >=
是明智的。
不确定是否有帮助。
我找到了一个解决方案,我所做的就是按照这个方法来检测滚动,它工作得很好!
https://jqmtricks.wordpress.com/2014/07/15/infinite-scrolling/
特别感谢 jQMtricks 管理员 Omar 提供了这种检测
的好方法