-
{{ t.links }}
-
+
+
+
×
+
-
-
+
-
-
+ function scrollToSlide(index) {
+ if (!slides.length) return;
+ if (index < 0) index = slides.length - 1;
+ if (index >= slides.length) index = 0;
+
+ const slideWidth = slides[0].getBoundingClientRect().width;
+ track.scrollTo({
+ left: slideWidth * index,
+ behavior: 'smooth'
+ });
+
+ updateActiveState(index);
+ currentIndex = index;
+ }
+
+ function updateActiveState(activeIndex) {
+ dots.forEach((dot, idx) => {
+ dot.classList.toggle('active', idx === activeIndex);
+ });
+ }
+
+ function attachEventListeners() {
+ prevBtn.addEventListener('click', () => scrollToSlide(currentIndex - 1));
+ nextBtn.addEventListener('click', () => scrollToSlide(currentIndex + 1));
+
+ dots.forEach(dot => {
+ dot.addEventListener('click', (e) => {
+ const index = parseInt(e.target.dataset.index);
+ scrollToSlide(index);
+ });
+ });
+
+ let scrollTimeout;
+ track.addEventListener('scroll', () => {
+ clearTimeout(scrollTimeout);
+ scrollTimeout = setTimeout(() => {
+ const slideWidth = slides[0].getBoundingClientRect().width;
+ const newIndex = Math.round(track.scrollLeft / slideWidth);
+ if (newIndex !== currentIndex) {
+ currentIndex = newIndex;
+ updateActiveState(currentIndex);
+ }
+ }, 50);
+ });
+
+ // Lightbox click handler
+ slides.forEach(slide => {
+ const img = slide.querySelector('img');
+ if (img) {
+ img.addEventListener('click', () => {
+ lightboxImg.src = img.src;
+ lightbox.classList.add('active');
+ });
+ }
+ });
+ }
+
+ lightboxClose.addEventListener('click', () => lightbox.classList.remove('active'));
+ lightbox.addEventListener('click', (e) => {
+ if (e.target === lightbox) lightbox.classList.remove('active');
+ });
+
+ // Run gallery initialization
+ initGallery();
+
+