"use client"; import { useRef, useEffect, useState } from "react"; import { motion } from "motion/react"; export const TextHoverEffect = ({ text, duration, }: { text: string; duration?: number; automatic?: boolean; }) => { const svgRef = useRef(null); const [cursor, setCursor] = useState({ x: 0, y: 0 }); const [hovered, setHovered] = useState(false); const [maskPosition, setMaskPosition] = useState({ cx: "50%", cy: "50%" }); useEffect(() => { if (svgRef.current && cursor.x !== null && cursor.y !== null) { const svgRect = svgRef.current.getBoundingClientRect(); const cxPercentage = ((cursor.x - svgRect.left) / svgRect.width) * 100; const cyPercentage = ((cursor.y - svgRect.top) / svgRect.height) * 100; setMaskPosition({ cx: `${cxPercentage}%`, cy: `${cyPercentage}%`, }); } }, [cursor]); return ( setHovered(true)} onMouseLeave={() => setHovered(false)} onMouseMove={(e) => setCursor({ x: e.clientX, y: e.clientY })} className="select-none" > {hovered && ( <> )} {text} {text} {text} ); };