Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!