import React, { useState, useCallback } from 'react'; interface FoldTextProps { text: string; className?: string; wordClassName?: string; charClassName?: string; stagger?: number; duration?: number; perspective?: number; foldDirection?: 'top' | 'bottom' | 'left' | 'right'; hoverEffect?: boolean; } export const FoldText: React.FC = ({ text, className = '', wordClassName = '', charClassName = '', stagger = 0.035, duration = 0.65, perspective = 1000, foldDirection = 'top', hoverEffect = true, }) => { const [animationCycle, setAnimationCycle] = useState(0); const handleMouseEnter = useCallback(() => { if (hoverEffect) { setAnimationCycle((prev) => prev + 1); } }, [hoverEffect]); // Split text into words while tracking cumulative character index for staggered delay const words = text.split(' '); let globalCharIndex = 0; return ( {words.map((word, wordIdx) => { const wordChars = word.split(''); return ( {wordChars.map((char) => { const charIndex = globalCharIndex++; const delay = charIndex * stagger; return ( {char} ); })} ); })} ); };