import { useGSAP } from "@gsap/react"; import { useEffect, useLayoutEffect, useRef,type ReactNode } from "react"; import { useGsapContext } from "~/app/_providers/GsapProvicer"; import { SplitText } from "gsap/SplitText"; import gsap from 'gsap' const AnimatedPageTitle = ( { children, position }: { children: ReactNode, position:gsap.Position } ) => { const el = useRef(null) const gsapContext = useGsapContext(); useLayoutEffect(() => { const split = new SplitText(el.current, { type: "lines,chars", autoSplit:true }) gsapContext?.addAnimation(gsap.to(el.current, { opacity: 100 }),position) gsapContext?.addAnimation(gsap.from(split.chars, { id: 'titlesplit', stagger: 0.05, rotate: -90, opacity: 0, x: -10, onComplete: () => {split.revert()} }),'>') },[]) return (

{children}

) } export default AnimatedPageTitle;