0

How do I remove the class if the page has been scrolled to the bottom with Vanilla JavaScript? The issue is that Android Chrome 87 sometimes does not remove the class with the following code:

const doc = document.body;
const offset = window.innerHeight + window.scrollY;
const height = doc.offsetHeight;

if (offset >= height) {
  document.documentElement.classList.remove('hideOnScroll');
  return;
}

Is there more of an adequate solution, that would always work and be cross-browser?

Shared User
  • 105
  • 9
  • The solution should be vanilla js, please no jQuery, or any other libraries. I have found some notes, that `pageYOffset` should be cross-browser – Shared User Dec 30 '20 at 13:04
  • Does this answer your question? [Detect when Scroll reaches the BOTTOM of the page \[ without jQuery \]](https://stackoverflow.com/questions/10059888/detect-when-scroll-reaches-the-bottom-of-the-page-without-jquery) – Anvay Jan 02 '21 at 02:52

0 Answers0