我正在尝试使用gsapin为元素设置动画react.js。
我的代码仅在响应热重载时才有效,并且在控制台中我收到 gsap 的警告说GSAP target not found
const FeaturedText = () => {
const tl = gsap.timeline({ repeat: 0 });
useEffect(() => {
animation(tl);
}, []);
return <S.FeaturedText className="tl">Hi! Some Text</S.FeaturedText>;
};
const animation = (tl) => {
tl.from(".tl", {
opacity: 0,
duration: 1,
x: 100,
ease: "elastic",
delay: 2,
});
};