Javascript. Intersection Observer

Introducción a la API Intersection Observer de Javascript

Image for post
Image for post
Photo by JR Korpa on Unsplash

Introducción

Image for post
Image for post

La API Intersection Observer

let observer = new IntersectionObserver(callback, options);
const options = {
root: document.querySelector('#main-container'),
rootMargin: '10px 0px', // like css property
threshold: 1.0
}
let target = document.querySelector('#itemId');
observer.observe(target);

Lazy loading para imágenes

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Conclusiones

¿Quieres recibir más artículos como este?

Entre paseo y paseo con Simba desarrollo en Symfony y React

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store