working animations

This commit is contained in:
2026-03-13 22:18:44 +01:00
parent d71bb5d26e
commit 4293eef824
8 changed files with 44 additions and 45 deletions

View File

@@ -7,19 +7,16 @@ const AnimatedPageTitle = (
) => {
const el = useRef<HTMLHeadingElement>(null)
const gsapContext = useGsapContext();
useGSAP(() => {
useEffect(() => {
console.log("add animated title with:",position)
const tl = gsap.timeline();
tl.addLabel("title")
const split = new SplitText(el.current, { type: "chars" })
tl.from(el.current, { opacity: 0 })
tl.from(split.chars, {
gsapContext?.addAnimation(gsap.to(el.current, { opacity: 100 }),position)
gsapContext?.addAnimation(gsap.from(split.chars, {
stagger: 0.05, rotate: -90, opacity: 0, x: -10
}, '>')
gsapContext?.addAnimation(tl,position)
}),'>')
})
return (
<h1 className="text-4xl opacity-100 font-bold text-balance w-full" ref={el}> {text} </h1>
<h1 className="text-4xl opacity-0 font-bold text-balance w-full" ref={el}> {text} </h1>
)
}