25 lines
791 B
JavaScript
25 lines
791 B
JavaScript
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);
|
|
});
|
|
});
|