Come funziona

document.addEventListener("DOMContentLoaded", function() { const targetModules = document.querySelectorAll('[data-moduloid="6"], [data-moduloid="242"], [data-moduloid="702"]'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { const img = entry.target.querySelector('img'); const textContainer = entry.target.querySelector('.tag-large'); if (entry.isIntersecting) { if (img) { img.classList.remove('slide-out-left'); img.classList.add('slide-in-left'); } if (textContainer) { textContainer.classList.remove('slide-out-right'); textContainer.classList.add('slide-in-right'); } } else { if (img) { img.classList.remove('slide-in-left'); img.classList.add('slide-out-left'); } if (textContainer) { textContainer.classList.remove('slide-in-right'); textContainer.classList.add('slide-out-right'); } } }); }, { threshold: 0.1 }); targetModules.forEach(module => { observer.observe(module); }); });