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

101
Views
Intersection observer not adding the classes to all the entries

I used intersection observer to fade in some divs when they are visible by adding a class, for some reason it only adds it to the first one, on desktop all the these divs are in viewport so if the first one is visible so are the others, however when I scroll out of that section that has the divs and then I scroll back into it it adds the class to the next div and so on, my question is why doesnt it add the class to all the divs at the same time since they are visible right away.

const items = document.querySelectorAll(".item");
const newoptions = {
  root: null,
  threshold: 0.3,
};

const fadeWork = function (entries, observer) {
  const [entry] = entries;
  if (!entry.isIntersecting) return;
  entry.target.classList.add("items-active");
};

const newObserver = new IntersectionObserver(fadeWork, newoptions);

items.forEach((curr) => newObserver.observe(curr));
   <div class="items">
            <div class="item">
              <a target="_blank" href="https://sixteenclothingsite.netlify.app/"
                ><img src="assets/images/clothing-site.png" alt=""
              /></a>
            </div>
            <div class="item">
              <a target="_blank" href="https://drinosi.github.io/"
                ><img src="assets/images/portfolio-site.png" alt=""
              /></a>
            </div>
            <div class="item">
              <a target="_blank" href="https://drinos.helpjuice.com/"
                ><img src="assets/images/help-center.png" alt=""
              /></a>
            </div>
            <div class="item">
              <a target="_blank" href="https://wfskills.com/"
                ><img src="assets/images/contractor-site.png" alt=""
              /></a>
            </div>
            <div class="item">
              <a target="_blank" href=""
                ><img src="assets/images/bankist.png" alt=""
              /></a>
            </div>
          </div>

.item {
  transition: 1s;
  transform: translateY(10%);
  opacity: 0;
}

.items-active {
  transform: translate(0);
  opacity: 1;
}
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!