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

271
Visualizações
How to remove IntersectionObserver correct

I have animation on enter window on middle of block made with IntersectionObserver. And I dont know how correct remove observing after first animation.

My code:

((window, document) => {
   window.onload = () => {
      const missionBlock = document.getElementById('mission_block');
      const missionText = document.getElementById('mission_text');
      const missionImg = document.getElementById('mission_img');

      let observer = new IntersectionObserver(
         (entries) => {
            // Take the first entry
            const entry = entries[0];

            if (entry.isIntersecting) {
               missionImg.style.transform = "translateX(-70%)"
              missionImg.style.transition = "transform 1s ease-in-out"

               missionText.style.opacity = "0.5"
               missionText.style.transform = "translateX(235%)"
               missionText.style.transition = "opacity 1s ease-in-out"
               missionText.style.transition = "transform 1s ease-in-out"

            }
         },
         { threshold: 0.5 }
      );

      observer.observe(missionBlock);

   }
})(window, document, undefined)
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Is it hepls?

The IntersectionObserver method unobserve() instructs the IntersectionObserver to stop observing the specified target element.

https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/unobserve

//...
if (entry.isIntersecting) {
    observer.unobserve(missionBlock);
//...
about 4 years ago · Juan Pablo Isaza Relatório

0

You can disconnect the observer after the first intersection happens

if (entry.isIntersecting) {
  observer.disconnect()
  missionImg.style.transform = "translateX(-70%)"
  ...
}
about 4 years ago · Juan Pablo Isaza Relatório
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