Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
Simple Intersection Observer API going in infinite rendering loop

I have this simple observer which add and removes classes based on entry.isIntersecting. Everything works fine except when view port is resized to particular size (this size is related to threshold) observer goes to infinite loop switching entry.isIntersecting. I am aware why is this happening and that this is probably a easy fix, but i just can't find it.

    const stickyNavReveal = function(entries){
      const [entry] = entries


      if(!entry.isIntersecting){
        //add class for sticky navigation
        nav.classList.add('sticky');
        toTop.classList.remove('hidden');
      } 
      else{
        nav.classList.remove('sticky');
        toTop.classList.add('hidden');
      }
    }

    const headerObserver = new IntersectionObserver(stickyNavReveal, {
      root:null,
      rootMargin:'40px',
      threshold:[0.4]
    })
    headerObserver.observe(header)
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda