I've run into a bug/problem when i am trying to use infinity scroll in mobile browsers. I've made a project using vanilla js, and when the scrollbar goes to bottom it calls a function that fetching nextPage from an API( TMDB). Every time scrollbar touches bottom, it returns the next 20 items from the next page. So, in Desktop is all fine, but in mobile browsers, i am going to bottom and nothing happened. I think there is a problem with mobile browser topbar, but how i can fix it? Here is my code:
window.addEventListener("scroll", () => {
const { scrollTop, scrollHeight, clientHeight } = document.documentElement;
if (scrollTop + clientHeight >= scrollHeight) {
showLoading();
}
});
I would be appreciate if anyone can give me a hint about it. Thank you!