import React, { useEffect, useRef } from 'react'; import { gsap } from 'gsap'; import { ScrollTrigger } from 'gsap/ScrollTrigger'; gsap.registerPlugin(ScrollTrigger); const horizontalImages = [ { src: '/product_images/kitchenware.png', title: 'Coffee Cups', description: 'Wheel-thrown cups for your morning ritual — no two alike' }, { src: '/product_images/lass_das_so_202603231510.png', title: 'Bowls', description: 'Handcrafted stoneware bowls for the table and the kitchen' }, { src: '/product_images/Produkt_foto_studio_202603231654 (1).png', title: 'Tableware', description: 'Small-batch dinnerware made to be used every day' }, { src: '/product_images/Produkt_foto_studio_202603231744.png', title: 'Kitchenware', description: 'Functional ceramics built for the rhythms of daily life' }, { src: '/product_images/Produkt_foto_studio_202603231654 (2).png', title: 'Decoration', description: 'Sculptural pieces inspired by the textures of the Gulf Coast' }, ]; const HorizontalScrollSection: React.FC = () => { const containerRef = useRef(null); const scrollRef = useRef(null); useEffect(() => { const container = containerRef.current; const scrollContainer = scrollRef.current; if (!container || !scrollContainer) return; const cards = Array.from(scrollContainer.children) as HTMLDivElement[]; const lastCard = cards[cards.length - 1]; if (!lastCard) return; const lastCardRightEdge = lastCard.offsetLeft + lastCard.offsetWidth; const mobileEndInset = window.innerWidth < 768 ? 24 : 64; const maxScroll = Math.max(lastCardRightEdge - window.innerWidth + mobileEndInset, 0); const tween = gsap.to(scrollContainer, { x: -maxScroll, ease: 'none', scrollTrigger: { trigger: container, start: 'top top', end: () => `+=${maxScroll * 0.5}`, scrub: 1, pin: true, anticipatePin: 1, }, }); return () => { tween.scrollTrigger?.kill(); tween.kill(); }; }, []); return (
{horizontalImages.map((image, index) => (
{image.title}

{image.title}

{image.description}

{String(index + 1).padStart(2, '0')}
))}
arrow_back Scroll to explore arrow_forward
); }; export default HorizontalScrollSection;