瀏覽代碼

not arrow if not enought images

ouidade 1 周之前
父節點
當前提交
6e2d63c38c
共有 2 個文件被更改,包括 10 次插入2 次删除
  1. 0 0
      web/themes/custom/eql/dist/assets/bundle.js
  2. 10 2
      web/themes/custom/eql/scripts/main.js

File diff suppressed because it is too large
+ 0 - 0
web/themes/custom/eql/dist/assets/bundle.js


+ 10 - 2
web/themes/custom/eql/scripts/main.js

@@ -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 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
   thumbPrev.addEventListener('click', () => {
     if (thumbsContainer.scrollTop <= 0) {

Some files were not shown because too many files changed in this diff