CoolFace
Apppublic

mfttraining/fitfusion-transformations-by-michael

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
script.js30 linesDownload Raw Back to root
1// Intersection Observer for animations2const observer = new IntersectionObserver((entries) => {3    entries.forEach(entry => {4        if (entry.isIntersecting) {5            entry.target.classList.add('fade-in');6        }7    });8}, { threshold: 0.1 });9 10// Observe all sections11document.querySelectorAll('section').forEach(section => {12    observer.observe(section);13});14 15// Smooth scroll for anchor links16document.querySelectorAll('a[href^="#"]').forEach(anchor => {17    anchor.addEventListener('click', function (e) {18        e.preventDefault();19        20        const targetId = this.getAttribute('href');21        if (targetId === '#') return;22        23        const targetElement = document.querySelector(targetId);24        if (targetElement) {25            targetElement.scrollIntoView({26                behavior: 'smooth'27            });28        }29    });30});