CoolFace
Apppublic

ebillin2/purple-dunk-dynasty

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
script.js51 linesDownload Raw Back to root
1document.addEventListener('DOMContentLoaded', function() {2    // Smooth scroll for anchor links3    document.querySelectorAll('a[href^="#"]').forEach(anchor => {4        anchor.addEventListener('click', function (e) {5            e.preventDefault();6            document.querySelector(this.getAttribute('href')).scrollIntoView({7                behavior: 'smooth'8            });9        });10    });11 12    // Parallax effect for hero section13    const heroSection = document.querySelector('section:first-of-type');14    if (heroSection) {15        window.addEventListener('scroll', function() {16            const scrollPosition = window.pageYOffset;17            heroSection.style.backgroundPositionY = scrollPosition * 0.3 + 'px';18        });19    }20 21    // Count-up animation for stats22    const stats = document.querySelectorAll('.stats-count');23    if (stats.length > 0) {24        const observer = new IntersectionObserver((entries) => {25            entries.forEach(entry => {26                if (entry.isIntersecting) {27                    const target = entry.target;28                    const countTo = parseInt(target.getAttribute('data-count'));29                    const duration = 2000; // Duration in ms30                    const step = countTo / (duration / 16); // 16ms per frame31                    let current = 0;32                    33                    const timer = setInterval(() => {34                        current += step;35                        if (current >= countTo) {36                            clearInterval(timer);37                            current = countTo;38                        }39                        target.textContent = Math.floor(current);40                    }, 16);41                    42                    observer.unobserve(target);43                }44            });45        }, { threshold: 0.5 });46 47        stats.forEach(stat => {48            observer.observe(stat);49        });50    }51});