Open bbjerling opened 2 months ago
I managed to fix this by using a state and the onAnimationStart on my motion.span. Not the most beautiful solution though. Any thoughts on making this better?
const [animationStarted, setAnimationStarted] = useState(false)
function onAnimationStart() {
console.log("Animation started")
setAnimationStarted(true)
}
const WordWrapper: React.FC<WordWrapperProp> = ({ children, wordIndex }) => {
return (
<motion.span
onAnimationStart={onAnimationStart}
>
{children}
</motion.span>
);
};
const MemoizedWordWrapper = React.memo(WordWrapper);
<SplitText
WordWrapper={MemoizedWordWrapper}
style={{ opacity: animationStarted ? 1 : 0 }}
>
{text}
</SplitText>
The text/children is showed before the wrappers are initiated - causing text to be shown before an in-animation starts.