this is my code import React, { useState, useEffect } from "react"; import { motion }…
- User
this is my code
import React, { useState, useEffect } from "react"; import { motion } from "framer-motion"; import "./styles/custom_cursor.css";
export default function CustomCursor() { const [position, setPosition] = useState<{ x: number; y: number }>({ x: 0, y: 0, });
useEffect(() => { const handleMouseMove = (e: MouseEvent) => { setPosition({ x: e.clientX, y: e.clientY }); };
code// Add event listener for mouse movement window.addEventListener("mousemove", handleMouseMove); // Cleanup event listener on component unmount return () => { window.removeEventListener("mousemove", handleMouseMove); };}, []);
return ( <> {
body { cursor: none; }} <motion.div className="fixed top-0 left-0 w-4 h-4 bg-black rounded-full pointer-events-none z-50" animate={{ x: position.x - 8, y: position.y - 8, }} transition={{ type: "spring", stiffness: 500, damping: 30, }} /> </> ); }it is pretty lagging behind the actual cursor, and i want the cursor to be available to see under any background. now it is really invisiable on dark background
- Assistant