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

192
Visualizações
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
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