"use client"; import { useEffect, useRef } from "react"; export default function Cursor() { const dotRef = useRef(null); useEffect(() => { // Skip on touchscreens — pointer:fine === false there if (!window.matchMedia("(pointer: fine)").matches) return; const el = dotRef.current; if (!el) return; const move = (e: MouseEvent) => { // Two translates: first moves to cursor coords, second re-centers the dot el.style.transform = `translate(${e.clientX}px, ${e.clientY}px) translate(-50%, -50%)`; }; window.addEventListener("mousemove", move); return () => window.removeEventListener("mousemove", move); }, []); return (
); }