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

155
Vistas
IntersectionObserver changes the height of observered element

I'm trying to create a lazy loading article list. I've set an Intersecton Observer that checks when the viewport reaches the end of the observed element (the article container) and makes a new api call.

The thing is when I load the new articles in the observed element the height changes but the observation gets triggered only on the initial height.

Should I use a ResizeObserver on top of the IntersectonObserver?

const sections = document.querySelectorAll('.articles_container');

function observeArticlesContainer() {

  const changeNav = (entries, observer) => {

    entries.forEach((entry) => {
      // verify the element is intersecting
      if (entry.isIntersecting) {
        console.log(entry.target)
        // $(results_wrapper).hide()
        // $(loading_animation).fadeIn(200);
        fetchData();
      }
    });
  }
  // init the observer
  const options = {
    root: null,
    rootMargin: '0px 0px -100% 0px',
    threshold: 0
  }

  const observer = new IntersectionObserver(changeNav, options);

  // target the elements to be observed


  sections.forEach(section => {
    observer.observe(section);
  });

} 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

ok, I've just set the container below as the target.

const sections = document.querySelectorAll('footer');

also set rootMargin back to 0px

about 4 years ago · Juan Pablo Isaza Denunciar
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