File size: 2,187 Bytes
f620bfe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | // CountUp animation for stats
function animateCountUp() {
const countElements = document.querySelectorAll('.countup');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const target = +entry.target.getAttribute('data-target');
const duration = 2000;
const start = 0;
const increment = target / (duration / 16);
let current = start;
const countUp = () => {
current += increment;
if (current < target) {
entry.target.textContent = Math.floor(current);
requestAnimationFrame(countUp);
} else {
entry.target.textContent = target + '+';
entry.target.classList.add('countup-animate');
}
};
countUp();
observer.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
countElements.forEach(el => observer.observe(el));
}
// Initialize animations when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
animateCountUp();
// Add hover effects to all elements with data-feather
const featherIcons = document.querySelectorAll('[data-feather]');
featherIcons.forEach(icon => {
icon.parentElement.addEventListener('mouseenter', () => {
icon.classList.add('animate-pulse');
});
icon.parentElement.addEventListener('mouseleave', () => {
icon.classList.remove('animate-pulse');
});
});
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
}); |