visionnova-redesign / script.js
AmixDigital's picture
Redesign ce site en le rendant plus moderne, minimaliste et épuré et en mettant des animation complexe et professionnel.
64cab0c verified
// Intersection Observer for animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animationPlayState = 'running';
}
});
}, observerOptions);
// Observe all animated elements
document.addEventListener('DOMContentLoaded', () => {
const animatedElements = document.querySelectorAll('[class*="animate-"]');
animatedElements.forEach(el => {
observer.observe(el);
});
// Count up animation for stats
const countElements = document.querySelectorAll('[data-count]');
countElements.forEach(element => {
const target = parseInt(element.getAttribute('data-count'));
const duration = 2000;
const step = target / (duration / 16);
let current = 0;
const timer = setInterval(() => {
current += step;
if (current >= target) {
element.textContent = target;
clearInterval(timer);
} else {
element.textContent = Math.floor(current);
}
}, 16);
});
// Parallax effect for hero section
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll('.parallax');
parallaxElements.forEach(element => {
const speed = element.dataset.speed || 0.5;
element.style.transform = `translateY(${scrolled * speed}px)`;
});
});
// Smooth scrolling 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',
block: 'start'
});
}
});
});
// Mobile menu toggle
function toggleMobileMenu() {
const mobileMenu = document.getElementById('mobile-menu');
mobileMenu.classList.toggle('hidden');
mobileMenu.classList.toggle('flex');
}
// Add loading animation
window.addEventListener('load', () => {
document.body.classList.add('loaded');
});
// Cursor follower effect
document.addEventListener('mousemove', (e) => {
const cursorFollower = document.querySelector('.cursor-follower');
if (cursorFollower) {
cursorFollower.style.left = e.clientX + 'px';
cursorFollower.style.top = e.clientY + 'px';
});