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

274
Views
Cómo eliminar IntersectionObserver correcto

Tengo una animación en la ventana de entrada en medio del bloque hecho con IntersectionObserver. Y no sé cómo eliminar correctamente la observación después de la primera animación.

Mi código:

 ((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 answers
Answer question

0

¿Es ayuda?

El método unobserve() de IntersectionObserver indica a IntersectionObserver que deje de observar el elemento de destino especificado.

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

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

0

Puede desconectar el observador después de que ocurra la primera intersección.

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