"use client"; import { useRef, useEffect, useState } from "react"; import { motion, useAnimation } from "motion/react"; export const TextHoverEffect = ({ text, duration = 6, // loop duration }: { text: string; duration?: number; }) => { const svgRef = useRef(null); const controls = useAnimation(); const [hovered, setHovered] = useState(false); // ✅ Animate mask looping automatically useEffect(() => { const loop = async () => { while (true) { await controls.start({ cx: ["20%", "80%", "50%"], cy: ["20%", "80%", "50%"], transition: { duration, ease: "easeInOut", repeat: 0, }, }); } }; loop(); }, [controls, duration]); return ( setHovered(true)} onMouseLeave={() => setHovered(false)} className="select-none" > {/* ✅ Softer cyan gradient */} {hovered ? ( <> ) : ( <> )} {/* ✅ Mask with autoplay motion */} {/* ✅ Glow */} {/* ✅ Background faint stroke */} {text} {/* ✅ Line drawing animation always plays too */} {text} {/* ✅ Final filled glowing cyan text (mask reveals it) */} {text} ); };