not arrow if not enought images

This commit is contained in:
2025-06-06 19:27:22 +02:00
parent 0371076642
commit 6e2d63c38c
2 changed files with 11 additions and 3 deletions
File diff suppressed because one or more lines are too long
+10 -2
View File
@@ -202,7 +202,7 @@ document.addEventListener('DOMContentLoaded', function () {
clearInterval(interval); // Tous les éléments sont là, on lance le carrousel
initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContainer });
}
}, 100); // vérifie toutes les 100ms
}, 100);
});
function initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContainer }) {
@@ -238,7 +238,7 @@ function initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContaine
thumbnails.forEach(img => img.classList.remove('active'));
if (thumbnails[index]) {
thumbnails[index].classList.add('active');
scrollThumbnailToCenter(index); // 👈 centrage de la miniature active
scrollThumbnailToCenter(index);
}
}
@@ -268,6 +268,14 @@ function initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContaine
const thumbPrev = document.getElementById('thumbPrev');
const thumbNext = document.getElementById('thumbNext');
// ✅ Masquer les flèches de thumbnails si pas assez dimages pour scroller
const thumbHeight = 70; // approx : image + gap
const visibleCount = Math.floor(thumbsContainer.clientHeight / thumbHeight);
if (images.length <= visibleCount) {
if (thumbPrev) thumbPrev.style.display = 'none';
if (thumbNext) thumbNext.style.display = 'none';
}
// Boucle haut/bas avec scroll
thumbPrev.addEventListener('click', () => {
if (thumbsContainer.scrollTop <= 0) {