import React, { useEffect, useRef } from 'react'; import { gsap } from 'gsap'; import { ScrollTrigger } from 'gsap/ScrollTrigger'; gsap.registerPlugin(ScrollTrigger); const horizontalImages = [ { src: '/pottery-vase.png', title: 'Handcrafted Vases', description: 'Each vase tells a story of patience and craft' }, { src: '/pottery-bowls.png', title: 'Artisan Bowls', description: 'Organic forms inspired by nature' }, { src: '/pottery-plates.png', title: 'Dinner Collection', description: 'Elevate your everyday dining experience' }, { src: '/pottery-studio.png', title: 'Our Studio', description: 'Where creativity meets tradition' }, { src: '/ceramic-cups.png', title: 'Ceramic Cups', description: 'Handmade with love and intention' }, ]; 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 scrollWidth = scrollContainer.scrollWidth - window.innerWidth; const tween = gsap.to(scrollContainer, { x: -scrollWidth, ease: 'none', scrollTrigger: { trigger: container, start: 'top top', end: () => `+=${scrollWidth * 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;