From 05f1bf9e85d9cad5b590a944a10e17953e53baee Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Thu, 3 Apr 2025 08:33:41 +0300 Subject: [PATCH] product slider dots & complete the look resize --- themes/oont-themev2/assets/css/alaskardev.css | 5 +- .../assets/css/product-slider.css | 30 +++++++ .../oont-themev2/assets/js/product-slider.js | 82 +++++++++++++++++-- themes/oont-themev2/functions.php | 2 +- themes/oont-themev2/style.css | 2 +- 5 files changed, 112 insertions(+), 9 deletions(-) diff --git a/themes/oont-themev2/assets/css/alaskardev.css b/themes/oont-themev2/assets/css/alaskardev.css index d093d19d2..99463896a 100644 --- a/themes/oont-themev2/assets/css/alaskardev.css +++ b/themes/oont-themev2/assets/css/alaskardev.css @@ -89,7 +89,7 @@ p.price { display: flex; width: 100%; height: auto; /* Allow the image to scale proportionally */ - max-height: 450px; /* Set a max height for the image (adjust as needed) */ + max-height: 1024px; /* Set a max height for the image (adjust as needed) */ max-width: none; object-fit: cover; /* Crop edges if the image is too tall/wide */ @@ -156,9 +156,10 @@ a.ast-loop-product__link h2 { .woocommerce ul.products li.product { flex: 0 0 50%; /* Each item takes up 50% of the row */ max-width: 50%; /* Each item takes up 50% of the row */ - height: 300px; /* Fixed height for mobile */ + height: 272px; /* Fixed height for mobile */ margin-bottom: 15px; /* Add spacing between rows (optional) */ } + .woocommerce ul.products, .woocommerce-page ul.products { column-gap: 20px !important; margin-bottom: 0px !important; diff --git a/themes/oont-themev2/assets/css/product-slider.css b/themes/oont-themev2/assets/css/product-slider.css index a66deab32..2bfdc300f 100644 --- a/themes/oont-themev2/assets/css/product-slider.css +++ b/themes/oont-themev2/assets/css/product-slider.css @@ -79,3 +79,33 @@ border: none !important; outline: none !important; } + +/* Dots */ +.slider-dots { + text-align: center; + margin-top: 10px; +} + +.slider-dot { + display: inline-block; + width: 10px; + height: 10px; + margin: 0 5px; + background-color: #ccc; + border-radius: 50%; + cursor: pointer; + transition: background-color 0.3s; +} + +.slider-dot.active { + background-color: #333; +} + +/* Hide arrows on mobile */ +@media (max-width: 768px) { + .slider-prev, + .slider-next { + display: none !important; + } +} + diff --git a/themes/oont-themev2/assets/js/product-slider.js b/themes/oont-themev2/assets/js/product-slider.js index f606d4089..c0456a0b3 100644 --- a/themes/oont-themev2/assets/js/product-slider.js +++ b/themes/oont-themev2/assets/js/product-slider.js @@ -1,25 +1,97 @@ -jQuery(document).ready(function ($) { - $('.product-image-slider').each(function () { +//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; + // Add dots container + let dotsContainer = $('
'); + slider.after(dotsContainer); + + items.each(function(i) { + let dot = $(''); + if (i === 0) dot.addClass('active'); + dot.on('click', function() { + currentIndex = i; + showSlide(currentIndex); + }); + dotsContainer.append(dot); + }); + + function updateDots(index) { + dotsContainer.find('.slider-dot').removeClass('active') + .eq(index).addClass('active'); + } + function showSlide(index) { items.removeClass('active'); $(items[index]).addClass('active'); + updateDots(index); } - slider.siblings('.slider-prev').click(function () { + slider.siblings('.slider-prev').click(function() { currentIndex = (currentIndex > 0) ? currentIndex - 1 : items.length - 1; showSlide(currentIndex); }); - slider.siblings('.slider-next').click(function () { + slider.siblings('.slider-next').click(function() { currentIndex = (currentIndex < items.length - 1) ? currentIndex + 1 : 0; showSlide(currentIndex); }); - // Initialize + // Swipe support for mobile + 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; + handleSwipe(); + }); + + function handleSwipe() { + let deltaX = touchEndX - touchStartX; + if (Math.abs(deltaX) > 50) { + if (deltaX < 0) { + currentIndex = (currentIndex + 1) % items.length; + } else { + currentIndex = (currentIndex - 1 + items.length) % items.length; + } + showSlide(currentIndex); + } + } + + // Init showSlide(currentIndex); }); }); + diff --git a/themes/oont-themev2/functions.php b/themes/oont-themev2/functions.php index c1fcb6cda..38013ad41 100644 --- a/themes/oont-themev2/functions.php +++ b/themes/oont-themev2/functions.php @@ -11,7 +11,7 @@ /** * Define Constants */ -define( 'CHILD_THEME_OONT_THEME_VERSION', '1.3.5' ); +define( 'CHILD_THEME_OONT_THEME_VERSION', '1.3.6' ); define( 'SOFTOBA_RETURN_POST_TYPE', 'return_request' ); define( 'SOFTOBA_EXCHANGE_POST_TYPE', 'exchange_request' ); define('SOFTOBA_THEME_DIR', get_stylesheet_directory()); diff --git a/themes/oont-themev2/style.css b/themes/oont-themev2/style.css index d5f16198f..ee5692766 100644 --- a/themes/oont-themev2/style.css +++ b/themes/oont-themev2/style.css @@ -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.3.5 +Version: 1.3.6 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: oont-theme