IntersectionObserver
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
IntersectionObserver të njofton kur një element hyn ose del nga ekrani gjatë scroll-it. Përdoret për lazy loading të fotove, infinite scroll dhe animacione që nisin kur e sheh elementin.
EnglishEN
IntersectionObserver tells you when an element enters or leaves the screen while scrolling. It's used for lazy-loading images, infinite scroll and animations that start when you see the element.
Si ta mendosh
Si sensori i dritës në korridor: ndizet sapo hyn dikush në fushëpamje.
Lexoje në anglisht
Like a motion sensor light in a hallway: it turns on as soon as someone comes into view.
Shembull kodijavascript
const vezhguesi = new IntersectionObserver((hyrjet) => {
for (const h of hyrjet) if (h.isIntersecting) h.target.classList.add("shfaqur");
});
document.querySelectorAll(".karta").forEach((k) => vezhguesi.observe(k));