|
|
|
|
|
const counters = document.querySelectorAll('.counter'); |
|
|
const speed = 200; |
|
|
|
|
|
const animateCounter = (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(() => animateCounter(counter), 1); |
|
|
} else { |
|
|
counter.innerText = target; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
const observerOptions = { |
|
|
threshold: 0.5 |
|
|
}; |
|
|
|
|
|
const observer = new IntersectionObserver((entries) => { |
|
|
entries.forEach(entry => { |
|
|
if (entry.isIntersecting) { |
|
|
animateCounter(entry.target); |
|
|
observer.unobserve(entry.target); |
|
|
} |
|
|
}); |
|
|
}, observerOptions); |
|
|
|
|
|
counters.forEach(counter => { |
|
|
observer.observe(counter); |
|
|
}); |
|
|
|
|
|
|
|
|
if (document.getElementById('particles-js')) { |
|
|
particlesJS('particles-js', { |
|
|
particles: { |
|
|
number: { value: 80, density: { enable: true, value_area: 800 } }, |
|
|
color: { value: ['#06b6d4', '#8b5cf6', '#ec4899'] }, |
|
|
shape: { type: 'circle' }, |
|
|
opacity: { value: 0.5, random: true }, |
|
|
size: { value: 3, random: true }, |
|
|
line_linked: { |
|
|
enable: true, |
|
|
distance: 150, |
|
|
color: '#06b6d4', |
|
|
opacity: 0.2, |
|
|
width: 1 |
|
|
}, |
|
|
move: { |
|
|
enable: true, |
|
|
speed: 2, |
|
|
direction: 'none', |
|
|
random: true, |
|
|
straight: false, |
|
|
out_mode: 'out', |
|
|
bounce: false |
|
|
} |
|
|
}, |
|
|
interactivity: { |
|
|
detect_on: 'canvas', |
|
|
events: { |
|
|
onhover: { enable: true, mode: 'grab' }, |
|
|
onclick: { enable: true, mode: 'push' }, |
|
|
resize: true |
|
|
}, |
|
|
modes: { |
|
|
grab: { distance: 200, line_linked: { opacity: 0.5 } }, |
|
|
push: { particles_nb: 4 } |
|
|
} |
|
|
}, |
|
|
retina_detect: true |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
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', |
|
|
block: 'start' |
|
|
}); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
document.querySelectorAll('.group').forEach(card => { |
|
|
card.addEventListener('mouseenter', function() { |
|
|
this.style.transform = 'translateY(-5px)'; |
|
|
}); |
|
|
|
|
|
card.addEventListener('mouseleave', function() { |
|
|
this.style.transform = 'translateY(0)'; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
document.querySelector('input[type="email"]')?.closest('div')?.querySelector('button')?.addEventListener('click', function(e) { |
|
|
e.preventDefault(); |
|
|
const email = document.querySelector('input[type="email"]').value; |
|
|
if (email) { |
|
|
this.innerHTML = '<span class="relative z-10">✓ Check your email!</span>'; |
|
|
this.style.background = 'linear-gradient(to right, #10b981, #059669)'; |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
const mobileMenuToggle = document.querySelector('[data-mobile-menu-toggle]'); |
|
|
const mobileMenu = document.querySelector('[data-mobile-menu]'); |
|
|
|
|
|
if (mobileMenuToggle && mobileMenu) { |
|
|
mobileMenuToggle.addEventListener('click', () => { |
|
|
mobileMenu.classList.toggle('hidden'); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
window.addEventListener('scroll', () => { |
|
|
const scrolled = window.pageYOffset; |
|
|
const parallax = document.querySelector('#particles-js'); |
|
|
if (parallax) { |
|
|
parallax.style.transform = `translateY(${scrolled * 0.5}px)`; |
|
|
} |
|
|
}); |