Test Profile
at main 24 lines 545 B view raw
1document.addEventListener("DOMContentLoaded", () => { 2 const fades = document.querySelectorAll(".fade"); 3 4 const options = { 5 root: null, 6 rootMargin: "0px", 7 threshold: 0.2, 8 }; 9 10 const callback = (entries, observer) => { 11 entries.forEach((entry) => { 12 if (entry.isIntersecting) { 13 entry.target.classList.add("visible"); 14 observer.unobserve(entry.target); 15 } 16 }); 17 }; 18 19 const observer = new IntersectionObserver(callback, options); 20 21 fades.forEach((fade) => { 22 observer.observe(fade); 23 }); 24});