| 88 | let autoPlayInterval = null; |
| 89 | |
| 90 | function updateCarousel() { |
| 91 | const translateX = -currentSlide * 100; |
| 92 | carouselTrack.style.transform = `translate3d(${translateX}%, 0, 0)`; |
| 93 | |
| 94 | carouselDots.forEach((dot, index) => { |
| 95 | if (index === currentSlide) { |
| 96 | dot.classList.add("active"); |
| 97 | } else { |
| 98 | dot.classList.remove("active"); |
| 99 | } |
| 100 | }); |
| 101 | |
| 102 | // Update text content below carousel |
| 103 | const activeSlide = carouselTrack.querySelector(`[data-slide-index="${currentSlide}"]`); |
| 104 | const titleEl = document.getElementById("carouselTitle"); |
| 105 | const descriptionEl = document.getElementById("carouselDescription"); |
| 106 | |
| 107 | if (activeSlide && titleEl && descriptionEl) { |
| 108 | const title = activeSlide.getAttribute("data-title"); |
| 109 | const description = activeSlide.getAttribute("data-description"); |
| 110 | |
| 111 | if (title) { |
| 112 | titleEl.style.opacity = "0"; |
| 113 | setTimeout(() => { |
| 114 | titleEl.textContent = title; |
| 115 | titleEl.style.opacity = "1"; |
| 116 | }, 150); |
| 117 | } |
| 118 | |
| 119 | if (description) { |
| 120 | descriptionEl.style.opacity = "0"; |
| 121 | setTimeout(() => { |
| 122 | descriptionEl.textContent = description; |
| 123 | descriptionEl.style.opacity = "1"; |
| 124 | }, 150); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | function nextSlide() { |
| 130 | currentSlide = (currentSlide + 1) % totalSlides; |