not arrow if not enought images
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -202,7 +202,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
clearInterval(interval); // Tous les éléments sont là, on lance le carrousel
|
clearInterval(interval); // Tous les éléments sont là, on lance le carrousel
|
||||||
initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContainer });
|
initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContainer });
|
||||||
}
|
}
|
||||||
}, 100); // vérifie toutes les 100ms
|
}, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
function initCarousel({ mainImage, prevArrow, nextArrow, caption, thumbsContainer }) {
|
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'));
|
thumbnails.forEach(img => img.classList.remove('active'));
|
||||||
if (thumbnails[index]) {
|
if (thumbnails[index]) {
|
||||||
thumbnails[index].classList.add('active');
|
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 thumbPrev = document.getElementById('thumbPrev');
|
||||||
const thumbNext = document.getElementById('thumbNext');
|
const thumbNext = document.getElementById('thumbNext');
|
||||||
|
|
||||||
|
// ✅ Masquer les flèches de thumbnails si pas assez d’images 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
|
// Boucle haut/bas avec scroll
|
||||||
thumbPrev.addEventListener('click', () => {
|
thumbPrev.addEventListener('click', () => {
|
||||||
if (thumbsContainer.scrollTop <= 0) {
|
if (thumbsContainer.scrollTop <= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user