简体   繁体   English

滚动到底部不适用于手机中的 chrome 浏览器

[英]scroll to bottom not working on chrome browser in phone

I am trying to load more data as user gets to the bottom of the screen and i am using this condition.当用户到达屏幕底部时,我正在尝试加载更多数据并且我正在使用这种情况。

if ((window.innerHeight + window.scrollY) === document.body.offsetHeight)

However this code is not working on chrome browser in chrome but works on web.What could be the reason behind.I know this is browser specific issue but how can we make it work on browser of all phones?但是,此代码不适用于 chrome 中的 chrome 浏览器,但适用于 web。背后的原因可能是什么。我知道这是浏览器特有的问题,但我们如何才能让它在所有手机的浏览器上运行?

This "if" statement is working on my chrome on phone.这个“if”语句正在我的手机上的 chrome 上工作。 You can check that your page in mobile version does not have any margins at the top or bottom, in the body element for example.您可以检查您的移动版页面在顶部或底部没有任何边距,例如在 body 元素中。 If have, you need to remove that margins to it works.如果有,您需要删除该边距才能正常工作。

Alternativelly you can try this statement:或者,您可以尝试以下语句:

if((window.innerHeight + window.pageYOffset) >= document.body.scrollHeight)

If not works, you can add a little offset, like this:如果不起作用,您可以添加一点偏移量,如下所示:

if((window.innerHeight + window.pageYOffset) >= document.body.scrollHeight - 2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM