document.addEventListener("DOMContentLoaded", () => { const fades = document.querySelectorAll(".fade"); const options = { root: null, rootMargin: "0px", threshold: 0.2, }; const callback = (entries, observer) => { entries.forEach((entry) => { if (entry.isIntersecting) { entry.target.classList.add("visible"); observer.unobserve(entry.target); } }); }; const observer = new IntersectionObserver(callback, options); fades.forEach((fade) => { observer.observe(fade); }); });