This commit is contained in:
Your Name committed 2026-07-12 03:17:30 -04:00
1 parent 9aea635e64
commit c2fc97844f
2 files changed
+8

No files matched your search

@@ -11,18 +11,22 @@ interface ProductImageGalleryProps {
export default function ProductImageGallery({ images, fallback, alt = 'Product Image', badgeText }: ProductImageGalleryProps) {
const [currentIndex, setCurrentIndex] = useState(0)
const scrollRef = useRef<HTMLDivElement>(null)
const isScrollingRef = useRef(false)
const handleThumbnailClick = (idx: number) => {
setCurrentIndex(idx)
if (scrollRef.current) {
const child = scrollRef.current.children[idx] as HTMLElement
if (child) {
isScrollingRef.current = true
scrollRef.current.scrollTo({ left: child.offsetLeft, behavior: 'smooth' })
setTimeout(() => { isScrollingRef.current = false }, 600)
}
}
}
const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
if (isScrollingRef.current) return
const container = e.currentTarget
const scrollLeft = container.scrollLeft
const width = container.clientWidth