Spaces:
Running
Running
| // Intersection Observer for animations | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const animateElements = document.querySelectorAll('.animate-on-scroll'); | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fade-in'); | |
| observer.unobserve(entry.target); | |
| } | |
| }); | |
| }, { | |
| threshold: 0.1 | |
| }); | |
| animateElements.forEach(el => observer.observe(el)); | |
| // Feather icons replacement | |
| feather.replace(); | |
| }); | |
| // Smooth scroll for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Current year for footer | |
| document.getElementById('current-year').textContent = new Date().getFullYear(); | |
| // Add active class to current nav link | |
| document.querySelectorAll('custom-navbar').forEach(nav => { | |
| const shadowRoot = nav.shadowRoot; | |
| const links = shadowRoot.querySelectorAll('.nav-link'); | |
| links.forEach(link => { | |
| link.addEventListener('click', function() { | |
| links.forEach(l => l.classList.remove('active')); | |
| this.classList.add('active'); | |
| }); | |
| }); | |
| }); | |