single product visiblity? version

This commit is contained in:
nomadics9 2025-04-03 18:01:12 +03:00
parent dd41ebbda7
commit afd7c4b4d5
3 changed files with 96 additions and 96 deletions

View file

@ -1,106 +1,106 @@
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($) {
// 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');
// $('.product-image-slider').each(function() {
// let slider = $(this);
// let 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 = $('<div class="slider-dots"></div>');
//
// items.each(function(i) {
// const dot = $('<span class="slider-dot"></span>');
// 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');
// function showSlide(index) {
// items.removeClass('active');
// $(items[index]).addClass('active');
// }
//
// // Touch swipe
// let touchStartX = 0;
// let touchEndX = 0;
//
// slider.on('touchstart', function(e) {
// touchStartX = e.originalEvent.touches[0].clientX;
// slider.siblings('.slider-prev').click(function() {
// currentIndex = (currentIndex > 0) ? currentIndex - 1 : items.length - 1;
// showSlide(currentIndex);
// });
//
// 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();
// }
// slider.siblings('.slider-next').click(function() {
// currentIndex = (currentIndex < items.length - 1) ? currentIndex + 1 : 0;
// showSlide(currentIndex);
// });
//
// // 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();
// });
// // Initialize
// showSlide(currentIndex);
// });
//});
//
//
//
//
//
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 = $('<div class="slider-dots"></div>');
items.each(function(i) {
const dot = $('<span class="slider-dot"></span>');
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();
});
});
});

View file

@ -11,7 +11,7 @@
/**
* Define Constants
*/
define( 'CHILD_THEME_OONT_THEME_VERSION', '1.5.9' );
define( 'CHILD_THEME_OONT_THEME_VERSION', '1.6.0' );
define( 'SOFTOBA_RETURN_POST_TYPE', 'return_request' );
define( 'SOFTOBA_EXCHANGE_POST_TYPE', 'exchange_request' );
define('SOFTOBA_THEME_DIR', get_stylesheet_directory());

View file

@ -3,7 +3,7 @@ Theme Name: OONT THEME V last
Author: Brainstorm Force
Author URI: http://wpastra.com/about/
Description: Astra is the fastest, fully customizable & beautiful theme suitable for blogs, personal portfolios and business websites. It is very lightweight (less than 50KB on frontend) and offers unparalleled speed. Built with SEO in mind, Astra comes with schema.org code integrated so search engines will love your site. Astra offers plenty of sidebar options and widget areas giving you a full control for customizations. Furthermore, we have included special features and templates so feel free to choose any of your favorite page builder plugin to create pages flexibly. Some of the other features: # WooCommerce Ready # Responsive # Compatible with major plugins # Translation Ready # Extendible with premium addons # Regularly updated # Designed, Developed, Maintained & Supported by Brainstorm Force. Looking for a perfect base theme? Look no further. Astra is fast, fully customizable and beautiful theme!
Version: 1.5.9
Version: 1.6.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: oont-theme