CoolFace
Apppublic

codekirk1/polymer-shield-pros

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
script.js39 linesDownload Raw Back to root
1// Smooth scrolling for anchor links2document.querySelectorAll('a[href^="#"]').forEach(anchor => {3    anchor.addEventListener('click', function (e) {4        e.preventDefault();5        6        const targetId = this.getAttribute('href');7        if (targetId === '#') return;8        9        const targetElement = document.querySelector(targetId);10        if (targetElement) {11            targetElement.scrollIntoView({12                behavior: 'smooth',13                block: 'start'14            });15        }16    });17});18 19// Simple scroll animation20const animateOnScroll = () => {21    const elements = document.querySelectorAll('.fade-in, .product-card');22    23    elements.forEach(element => {24        const elementPosition = element.getBoundingClientRect().top;25        const screenPosition = window.innerHeight / 1.2;26        27        if (elementPosition < screenPosition) {28            element.style.opacity = '1';29        }30    });31};32 33// Initialize animations34window.addEventListener('load', () => {35    animateOnScroll();36});37 38// Add scroll event listener39window.addEventListener('scroll', animateOnScroll);