"use client"; import Image from "next/image"; import { useEffect, useRef } from "react"; import { gsap } from "gsap"; import { SplitText } from "gsap/SplitText"; gsap.registerPlugin(SplitText); interface HeroClientProps { item: { heroImage: string; title: string; description: string; }; } export default function HeroClient({ item }: HeroClientProps) { const containerRef = useRef(null); const headingRef = useRef(null); const subHeadingRef = useRef(null); useEffect(() => { const ctx = gsap.context(() => { if (!headingRef.current) return; const headingSplit = new SplitText(headingRef.current, { type: "words" }); gsap.fromTo( headingSplit.words, { yPercent: 120, opacity: 0 }, { yPercent: 0, opacity: 1, duration: 1.2, ease: "expo.out", stagger: 0.09, delay: 0.3, } ); if (subHeadingRef.current) { const subSplit = new SplitText(subHeadingRef.current, { type: "words", }); gsap.fromTo( subSplit.words, { yPercent: 100, opacity: 0 }, { yPercent: 0, opacity: 1, duration: 1, ease: "expo.out", stagger: 0.04, delay: 0.6, } ); } }, containerRef); return () => ctx.revert(); }, []); return (
{item.title}

{item.title}

{item.description}

overlay
); }