From 598040832e8c7069cb89ff2a60511df3f75d1b06 Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Thu, 3 Apr 2025 17:52:05 +0300 Subject: [PATCH] single product visiblity? version --- .../oont-themev2/assets/js/product-slider.js | 145 +++++++++--------- 1 file changed, 76 insertions(+), 69 deletions(-) diff --git a/themes/oont-themev2/assets/js/product-slider.js b/themes/oont-themev2/assets/js/product-slider.js index 16c07a784..8b48d0231 100644 --- a/themes/oont-themev2/assets/js/product-slider.js +++ b/themes/oont-themev2/assets/js/product-slider.js @@ -24,76 +24,83 @@ // }); //}); // -jQuery(document).ready(function($) { - if (window.location.pathname.startsWith('/product/')) return; +// +// +// - $('.product-slider-container').each(function() { - const container = $(this); - const slider = container.find('.product-image-slider'); - const items = slider.find('.slider-item'); - let currentIndex = 0; - // Hide all except first - items.css({ position: 'absolute', opacity: 0, transition: 'opacity 0.3s ease' }); - items.eq(currentIndex).css({ opacity: 1, position: 'relative' }); - // Create and insert dots - if (items.length <= 1) return; - - const dotsContainer = $('
'); - - items.each(function(i) { - const dot = $(''); - if (i === 0) dot.addClass('active'); - dot.on('click', function() { - currentIndex = i; - updateSlide(); - }); - dotsContainer.append(dot); - }); - - container.append(dotsContainer); - - // Slide update function - function updateSlide() { - items.css({ opacity: 0, position: 'absolute' }); - items.eq(currentIndex).css({ opacity: 1, position: 'relative' }); - dotsContainer.find('.slider-dot').removeClass('active') - .eq(currentIndex).addClass('active'); - } - - // Touch swipe - let touchStartX = 0; - let touchEndX = 0; - - slider.on('touchstart', function(e) { - touchStartX = e.originalEvent.touches[0].clientX; - }); - - slider.on('touchend', function(e) { - touchEndX = e.originalEvent.changedTouches[0].clientX; - const delta = touchEndX - touchStartX; - - if (Math.abs(delta) > 50) { - if (delta < 0) { - currentIndex = (currentIndex + 1) % items.length; - } else { - currentIndex = (currentIndex - 1 + items.length) % items.length; - } - updateSlide(); - } - }); - - // Optional: support prev/next buttons too - container.find('.slider-prev').on('click', function() { - currentIndex = (currentIndex - 1 + items.length) % items.length; - updateSlide(); - }); - - container.find('.slider-next').on('click', function() { - currentIndex = (currentIndex + 1) % items.length; - updateSlide(); - }); - }); -}); +// +//jQuery(document).ready(function($) { +// if (window.location.pathname.startsWith('/product/')) return; +// +// $('.product-slider-container').each(function() { +// const container = $(this); +// const slider = container.find('.product-image-slider'); +// const items = slider.find('.slider-item'); +// let currentIndex = 0; +// +// // Hide all except first +// items.css({ position: 'absolute', opacity: 0, transition: 'opacity 0.3s ease' }); +// items.eq(currentIndex).css({ opacity: 1, position: 'relative' }); +// +// // Create and insert dots +// if (items.length <= 1) return; +// +// const dotsContainer = $('
'); +// +// items.each(function(i) { +// const dot = $(''); +// if (i === 0) dot.addClass('active'); +// dot.on('click', function() { +// currentIndex = i; +// updateSlide(); +// }); +// dotsContainer.append(dot); +// }); +// +// container.append(dotsContainer); +// +// // Slide update function +// function updateSlide() { +// items.css({ opacity: 0, position: 'absolute' }); +// items.eq(currentIndex).css({ opacity: 1, position: 'relative' }); +// dotsContainer.find('.slider-dot').removeClass('active') +// .eq(currentIndex).addClass('active'); +// } +// +// // Touch swipe +// let touchStartX = 0; +// let touchEndX = 0; +// +// slider.on('touchstart', function(e) { +// touchStartX = e.originalEvent.touches[0].clientX; +// }); +// +// slider.on('touchend', function(e) { +// touchEndX = e.originalEvent.changedTouches[0].clientX; +// const delta = touchEndX - touchStartX; +// +// if (Math.abs(delta) > 50) { +// if (delta < 0) { +// currentIndex = (currentIndex + 1) % items.length; +// } else { +// currentIndex = (currentIndex - 1 + items.length) % items.length; +// } +// updateSlide(); +// } +// }); +// +// // Optional: support prev/next buttons too +// container.find('.slider-prev').on('click', function() { +// currentIndex = (currentIndex - 1 + items.length) % items.length; +// updateSlide(); +// }); +// +// container.find('.slider-next').on('click', function() { +// currentIndex = (currentIndex + 1) % items.length; +// updateSlide(); +// }); +// }); +//});