| // Count animation | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Animate counting numbers | |
| const counters = document.querySelectorAll('.animate-count'); | |
| const speed = 200; | |
| counters.forEach(counter => { | |
| const target = +counter.getAttribute('data-target'); | |
| const count = +counter.innerText; | |
| const increment = target / speed; | |
| if (count < target) { | |
| counter.innerText = Math.ceil(count + increment); | |
| setTimeout(updateCount, 1); | |
| } else { | |
| counter.innerText = target; | |
| } | |
| function updateCount() { | |
| const count = +counter.innerText; | |
| if (count < target) { | |
| counter.innerText = Math.ceil(count + increment); | |
| setTimeout(updateCount, 1); | |
| } else { | |
| counter.innerText = target; | |
| } | |
| } | |
| }); | |
| // Smooth scrolling for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function (e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| }); |