product slider dots & complete the look resize

This commit is contained in:
nomadics9 2025-04-03 08:53:12 +03:00
parent 05f1bf9e85
commit 09b9079508
4 changed files with 139 additions and 62 deletions

View file

@ -1,36 +1,122 @@
/*.product-slider-container {*/
/* position: relative;*/
/*}*/
/**/
/*.product-image-slider {*/
/* position: relative;*/
/* display: flex;*/
/* overflow: hidden;*/
/* max-width: 600px;*/
/* margin: auto;*/
/**/
/*}*/
/**/
/*.slider-item {*/
/* position: absolute;*/
/* opacity: 0;*/
/* transition: opacity 0.5s ease-in-out;*/
/* width: 100%;*/
/* height: auto !important; /* Ensure images fit the aspect ratio */*/
/*}*/
/**/
/*.slider-item.active {*/
/* opacity: 1;*/
/* position: relative;*/
/*}*/
/**/
/*.slider-item img {*/
/* width: 100%;*/
/* height: auto !important; /* Stretch to fill the container while maintaining aspect ratio */*/
/* object-fit: contain; /* Maintain image aspect ratio within the container */*/
/* display: block;*/
/*}*/
/**/
/*.slider-prev, .slider-next {*/
/* position: absolute;*/
/* top: 10%;*/
/* transform: translateY(-10%);*/
/* background: none;*/
/* color: #424242;*/
/* border: none;*/
/* background-color: transparent !important;*/
/* cursor: pointer;*/
/* font-size: 16px;*/
/* padding: 0;*/
/* z-index: 10;*/
/* font-weight: 600;*/
/* transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;*/
/*}*/
/*.slider-prev i.fa-solid.fa-chevron-right,*/
/*.slider-next i.fa-solid.fa-chevron-left{*/
/* opacity: 0 !important; /* Initially hidden */*/
/* padding: 10px !important;*/
/*}*/
/**/
/*.product-slider-container:hover .slider-prev i.fa-solid.fa-chevron-right,*/
/*.product-slider-container:hover .slider-prev i.fa-solid.fa-chevron-left{*/
/* opacity: 1; /* Show arrows on hover */*/
/*}*/
/**/
/*.slider-prev {*/
/* left: 10px;*/
/*}*/
/**/
/*.slider-next {*/
/* right: 10px;*/
/*}*/
/**/
/*@media (max-width: 768px) {*/
/* .slider-prev,*/
/* .slider-next {*/
/* opacity: 1; /* Always visible on mobile */*/
/* }*/
/*}*/
/**/
/*.slider-prev:hover, .slider-next:hover, .slider-next:focus, .slider-prev:focus {*/
/* color: #000000;*/
/* background-color: #cc336600;*/
/* text-decoration: none;*/
/* border: none !important;*/
/* outline: none !important;*/
/*}*/
.product-slider-container {
position: relative;
}
/* Image slider layout */
.product-image-slider {
position: relative;
display: flex;
position: relative;
display: block;
overflow: hidden;
max-width: 600px;
margin: auto;
}
/* Slider item base */
.slider-item {
position: absolute;
opacity: 0;
transition: opacity 0.5s ease-in-out;
width: 100%;
height: auto !important; /* Ensure images fit the aspect ratio */
height: auto !important;
}
/* Active image styling */
.slider-item.active {
opacity: 1;
position: relative;
}
/* Image fit */
.slider-item img {
width: 100%;
height: auto !important; /* Stretch to fill the container while maintaining aspect ratio */
object-fit: contain; /* Maintain image aspect ratio within the container */
height: auto !important;
object-fit: contain;
display: block;
}
/* Prev/Next Buttons (Desktop only) */
.slider-prev, .slider-next {
position: absolute;
top: 10%;
@ -38,7 +124,6 @@
background: none;
color: #424242;
border: none;
background-color: transparent !important;
cursor: pointer;
font-size: 16px;
padding: 0;
@ -46,15 +131,16 @@
font-weight: 600;
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.slider-prev i.fa-solid.fa-chevron-right,
.slider-next i.fa-solid.fa-chevron-left{
opacity: 0 !important; /* Initially hidden */
padding: 10px !important;
.slider-next i.fa-solid.fa-chevron-left {
opacity: 0 !important;
padding: 10px !important;
}
.product-slider-container:hover .slider-prev i.fa-solid.fa-chevron-right,
.product-slider-container:hover .slider-prev i.fa-solid.fa-chevron-left{
opacity: 1; /* Show arrows on hover */
.product-slider-container:hover .slider-prev i.fa-solid.fa-chevron-left {
opacity: 1;
}
.slider-prev {
@ -65,14 +151,9 @@
right: 10px;
}
@media (max-width: 768px) {
.slider-prev,
.slider-next {
opacity: 1; /* Always visible on mobile */
}
}
.slider-prev:hover, .slider-next:hover, .slider-next:focus, .slider-prev:focus {
/* Buttons hover */
.slider-prev:hover, .slider-next:hover,
.slider-next:focus, .slider-prev:focus {
color: #000000;
background-color: #cc336600;
text-decoration: none;
@ -80,7 +161,7 @@
outline: none !important;
}
/* Dots */
/* Dots below slider */
.slider-dots {
text-align: center;
margin-top: 10px;
@ -90,7 +171,7 @@
display: inline-block;
width: 10px;
height: 10px;
margin: 0 5px;
margin: 0 4px;
background-color: #ccc;
border-radius: 50%;
cursor: pointer;
@ -98,7 +179,7 @@
}
.slider-dot.active {
background-color: #333;
background-color: #000;
}
/* Hide arrows on mobile */

View file

@ -25,47 +25,38 @@
//});
//
jQuery(document).ready(function($) {
$('.product-image-slider').each(function() {
let slider = $(this);
let items = slider.find('.slider-item');
$('.product-slider-container').each(function() {
const container = $(this);
const slider = container.find('.product-image-slider');
const items = slider.find('.slider-item');
let currentIndex = 0;
// Add dots container
let dotsContainer = $('<div class="slider-dots"></div>');
slider.after(dotsContainer);
// 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
const dotsContainer = $('<div class="slider-dots"></div>');
items.each(function(i) {
let dot = $('<span class="slider-dot"></span>');
const dot = $('<span class="slider-dot"></span>');
if (i === 0) dot.addClass('active');
dot.on('click', function() {
currentIndex = i;
showSlide(currentIndex);
updateSlide();
});
dotsContainer.append(dot);
});
container.append(dotsContainer);
function updateDots(index) {
// 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(index).addClass('active');
.eq(currentIndex).addClass('active');
}
function showSlide(index) {
items.removeClass('active');
$(items[index]).addClass('active');
updateDots(index);
}
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);
});
// Swipe support for mobile
// Touch swipe
let touchStartX = 0;
let touchEndX = 0;
@ -75,23 +66,28 @@ jQuery(document).ready(function($) {
slider.on('touchend', function(e) {
touchEndX = e.originalEvent.changedTouches[0].clientX;
handleSwipe();
});
const delta = touchEndX - touchStartX;
function handleSwipe() {
let deltaX = touchEndX - touchStartX;
if (Math.abs(deltaX) > 50) {
if (deltaX < 0) {
if (Math.abs(delta) > 50) {
if (delta < 0) {
currentIndex = (currentIndex + 1) % items.length;
} else {
currentIndex = (currentIndex - 1 + items.length) % items.length;
}
showSlide(currentIndex);
updateSlide();
}
}
});
// Init
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();
});
});
});

View file

@ -11,7 +11,7 @@
/**
* Define Constants
*/
define( 'CHILD_THEME_OONT_THEME_VERSION', '1.3.6' );
define( 'CHILD_THEME_OONT_THEME_VERSION', '1.3.7' );
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.3.6
Version: 1.3.7
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: oont-theme