import { useEffect, useRef } from 'react'; import { motion, useInView, useAnimation } from 'framer-motion'; /* Splits text into individual chars, animates each on mount/scroll */ export default function SplitText({ text = '', className = '', delay = 0, stagger = 0.04, from = { opacity: 0, y: 30 }, to = { opacity: 1, y: 0 }, }) { const ref = useRef(null); const inView = useInView(ref, { once: true, margin: '-50px' }); const controls = useAnimation(); useEffect(() => { if (inView) controls.start('visible'); }, [inView, controls]); const chars = text.split(''); return ( {chars.map((ch, i) => ( ))} ); }