Commit ·
ecb04d4
1
Parent(s): 0d87e65
Disable IntersectionObserver on mobile to fix scroll lag - show all animations immediately
Browse files- static/js/script.js +11 -5
static/js/script.js
CHANGED
|
@@ -79,11 +79,19 @@ function createMobileMenuButton() {
|
|
| 79 |
});
|
| 80 |
}
|
| 81 |
|
| 82 |
-
// Fonction pour détecter les éléments visibles et les animer - VERSION
|
| 83 |
function initScrollAnimations() {
|
| 84 |
const animatedElements = document.querySelectorAll('.animate-on-scroll, .animate-from-left, .animate-from-right, .animate-zoom');
|
| 85 |
|
| 86 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
const observerOptions = {
|
| 88 |
threshold: 0.1,
|
| 89 |
rootMargin: '0px 0px -50px 0px'
|
|
@@ -92,15 +100,12 @@ function initScrollAnimations() {
|
|
| 92 |
const observer = new IntersectionObserver((entries) => {
|
| 93 |
entries.forEach(entry => {
|
| 94 |
if (entry.isIntersecting) {
|
| 95 |
-
// Ajouter la classe animated
|
| 96 |
entry.target.classList.add('animated');
|
| 97 |
-
// NE PLUS OBSERVER cet élément après animation (FIX CRITIQUE!)
|
| 98 |
observer.unobserve(entry.target);
|
| 99 |
}
|
| 100 |
});
|
| 101 |
}, observerOptions);
|
| 102 |
|
| 103 |
-
// Observer tous les éléments
|
| 104 |
animatedElements.forEach(element => {
|
| 105 |
observer.observe(element);
|
| 106 |
});
|
|
@@ -151,3 +156,4 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
| 151 |
});
|
| 152 |
}
|
| 153 |
});
|
|
|
|
|
|
| 79 |
});
|
| 80 |
}
|
| 81 |
|
| 82 |
+
// Fonction pour détecter les éléments visibles et les animer - VERSION MOBILE OPTIMISÉE
|
| 83 |
function initScrollAnimations() {
|
| 84 |
const animatedElements = document.querySelectorAll('.animate-on-scroll, .animate-from-left, .animate-from-right, .animate-zoom');
|
| 85 |
|
| 86 |
+
// Sur mobile : activer tous les éléments immédiatement SANS observer
|
| 87 |
+
if (window.innerWidth <= 768) {
|
| 88 |
+
animatedElements.forEach(element => {
|
| 89 |
+
element.classList.add('animated');
|
| 90 |
+
});
|
| 91 |
+
return; // Arrêter ici pour mobile
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
// Sur desktop : utiliser l'observer normalement
|
| 95 |
const observerOptions = {
|
| 96 |
threshold: 0.1,
|
| 97 |
rootMargin: '0px 0px -50px 0px'
|
|
|
|
| 100 |
const observer = new IntersectionObserver((entries) => {
|
| 101 |
entries.forEach(entry => {
|
| 102 |
if (entry.isIntersecting) {
|
|
|
|
| 103 |
entry.target.classList.add('animated');
|
|
|
|
| 104 |
observer.unobserve(entry.target);
|
| 105 |
}
|
| 106 |
});
|
| 107 |
}, observerOptions);
|
| 108 |
|
|
|
|
| 109 |
animatedElements.forEach(element => {
|
| 110 |
observer.observe(element);
|
| 111 |
});
|
|
|
|
| 156 |
});
|
| 157 |
}
|
| 158 |
});
|
| 159 |
+
|