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

198
Views
Can't check if the code is in the viewport

this is a code to detect if the section which I'm scrolling right now is in the viewport or not. This code actually works only if I get onto any section and refresh the page, it doesn't work continuously when I scroll through the page.

var secArr = document.querySelectorAll('section');


secArr.forEach(onscroll = function (element) {
    var bounding = element.getBoundingClientRect();

    if (bounding.top <= 350.00 && bounding.top >= -270.00) {
        if (!element.classList.contains("your-active-class")) {
            element.setAttribute("class", "your-active-class");
        }
    } 
    else {
        element.removeAttribute("class");
    }
});
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!