1document.addEventListener('DOMContentLoaded', function() { 2 // Function to handle the intersection event 3 const observer = new IntersectionObserver((entries, observer) => { 4 entries.forEach(entry => { 5 if (entry.isIntersecting) { 6 // The element is in the viewport, add a class to start the animation 7 entry.target.classList.add('animate__animated'); 8 requestAnimationFrame(() => { 9 entry.target.style.opacity = 1; 10 entry.target.style.visibility = 'visible'; 11 const animationClasses = entry.target.dataset.animation.split(' '); 12 entry.target.classList.add(...animationClasses); 13 }); 14 // Stop observing the element after it has animated 15 observer.unobserve(entry.target); 16 } 17 }); 18 }, { 19 root: null, // Use the viewport as the root 20 threshold: 0.1 // Trigger the callback when the target is 10% visible 21 }); 22 23 // Start observing elements with the 'animate' class 24 const targets = document.querySelectorAll('.animate'); 25 targets.forEach(target => { 26 observer.observe(target); 27 }); 28 29 });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.