From ce7b4a4b2b8b20d32b272cc8d5e81cc687326a62 Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Thu, 3 Apr 2025 17:55:21 +0300 Subject: [PATCH] single product visiblity? version --- .../oont-themev2/assets/js/product-slider.js | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/themes/oont-themev2/assets/js/product-slider.js b/themes/oont-themev2/assets/js/product-slider.js index 8b48d0231..73e8c64c9 100644 --- a/themes/oont-themev2/assets/js/product-slider.js +++ b/themes/oont-themev2/assets/js/product-slider.js @@ -1,28 +1,28 @@ -//jQuery(document).ready(function ($) { -// $('.product-image-slider').each(function () { -// let slider = $(this); -// let items = slider.find('.slider-item'); -// let currentIndex = 0; -// -// function showSlide(index) { -// items.removeClass('active'); -// $(items[index]).addClass('active'); -// } -// -// slider.siblings('.slider-prev').click(function () { -// currentIndex = (currentIndex > 0) ? currentIndex - 1 : items.length - 1; -// showSlide(currentIndex); -// }); -// -// slider.siblings('.slider-next').click(function () { -// currentIndex = (currentIndex < items.length - 1) ? currentIndex + 1 : 0; -// showSlide(currentIndex); -// }); -// -// // Initialize -// showSlide(currentIndex); -// }); -//}); +jQuery(document).ready(function($) { + $('.product-image-slider').each(function() { + let slider = $(this); + let items = slider.find('.slider-item'); + let currentIndex = 0; + + function showSlide(index) { + items.removeClass('active'); + $(items[index]).addClass('active'); + } + + slider.siblings('.slider-prev').click(function() { + currentIndex = (currentIndex > 0) ? currentIndex - 1 : items.length - 1; + showSlide(currentIndex); + }); + + slider.siblings('.slider-next').click(function() { + currentIndex = (currentIndex < items.length - 1) ? currentIndex + 1 : 0; + showSlide(currentIndex); + }); + + // Initialize + showSlide(currentIndex); + }); +}); // // //