Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
JavaScript: Infinite scroll near bottom in div (70% near bottom)

I want to implement an infinite scroll inside a div whereby data is fetched when a user scrolls past 70% of the content.

Here is my current code:

element.onscroll = () => {
  let dom = document.getElementById('scrollable');

  let scrollY = dom.scrollHeight - dom.scrollTop;
  let height = dom.offsetHeight;
  let offset = height - scrollY;

  if (offset == 0 || offset == 1) {
   getMoreData()
  }
};

Is there a way I can check whether the scroll is over 70%? Without executing getMoreData() multiple time?

I need to make sure that getMoreData function runs only once when scrolling down.

Implementations in Vue are also welcome.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda