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

194
Views
Issue with GSAP and Intersection Observer

I'm using GSAP and IntersectionObserver to animate some texts on scroll. I want to trigger the animation only just once when the element is in the viewport.

The issue is, each time the element appears in the viewport white scrolling the animation is triggered.

const observerElement = document.querySelectorAll(".reveal-text");

const options = {
 root: null,
 rootMargin: '0px',
 threshold: 0.2
}

let callback = (entries) => {
   entries.forEach(entry => {
   if(entry.isIntersecting) {

     let revealLines = observerElement.forEach((element) => {
          const lines = element.querySelectorAll(".words");

          gsap.set(element, { autoAlpha: 1 });
          gsap.from(lines, 1, {
            yPercent: 100,
            ease: Power3.out,
            stagger: 0.25,
            delay: 0.2
          });

        });
     }
   });
}

let observer = new IntersectionObserver(callback, options);

observerElement.forEach(box => { observer.observe(box) });

Thank you.

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!