// DOM elements const $mainImg = $('#mainImage'); const $zoomContainer = $('#zoomContainer'); const $thumbTrack = $('#thumbTrack'); const $thumbWrapper = $('#thumbWrapper'); const prevBtn = $('#prevThumbBtn'); const nextBtn = $('#nextThumbBtn');
body background: linear-gradient(145deg, #f5f7fc 0%, #eef2f6 100%); font-family: 'Inter', sans-serif; min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 2rem;
.thumb-item.active-thumb border-color: #2c5f8a; box-shadow: 0 8px 20px rgba(44,95,138,0.25); transform: scale(1.02); product thumbnail slider with zoom effect jquery codepen
/* slider track */ .thumbnail-track-wrapper overflow-x: auto; scroll-behavior: smooth; scrollbar-width: thin; border-radius: 1.5rem; padding-bottom: 0.5rem;
/* main product card container */ .product-showcase max-width: 1280px; width: 100%; background: rgba(255,255,255,0.75); backdrop-filter: blur(2px); border-radius: 2.5rem; box-shadow: 0 25px 45px -12px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.05); padding: 2rem 2rem 2rem 2rem; transition: all 0.2s ease; // DOM elements const $mainImg = $('#mainImage'); const
<div class="product-showcase"> <div class="product-grid"> <!-- Zoomable main area --> <div class="zoom-container" id="zoomContainer"> <img class="main-image" id="mainImage" src="https://picsum.photos/id/20/800/600" alt="Product main view"> <div class="zoom-badge"> <i class="fas fa-search-plus"></i> Hover to zoom </div> </div>
// Update active thumbnail UI function updateActiveThumbnail() $('.thumb-item').removeClass('active-thumb'); $('.thumb-item').eq(currentIndex).addClass('active-thumb'); // optional: scroll thumbnail into view horizontally const $activeThumb = $('.thumb-item').eq(currentIndex); if ($activeThumb.length) const $zoomContainer = $('#zoomContainer')
.nav-btn:hover background: #1e2f4b; color: white; transform: scale(0.96);
// Set main image and reset zoom function setActiveImage(index) if (index === currentIndex) return; currentIndex = index; const newLargeSrc = galleryItems[currentIndex].large; // Reset zoom before changing image (avoid weird transforms) resetZoomWithGSAP(); // Fade transition effect gsap.to($mainImg[0], duration: 0.15, opacity: 0, onComplete: () => $mainImg.attr('src', newLargeSrc); $mainImg.attr('alt', galleryItems[currentIndex].alt); gsap.to($mainImg[0], duration: 0.2, opacity: 1 ); ); updateActiveThumbnail(); // also reset any ongoing zoom flag currentZoomScale = 1; $mainImg.css('transform', 'scale(1)');