"use client" import { useEffect, useRef, useState } from "react" export function CursorWarp() { const cursorRef = useRef(null) const trailRef = useRef(null) const [mousePos, setMousePos] = useState({ x: 0, y: 0 }) const [isMoving, setIsMoving] = useState(false) useEffect(() => { let timeout: NodeJS.Timeout const handleMouseMove = (e: MouseEvent) => { setMousePos({ x: e.clientX, y: e.clientY }) setIsMoving(true) const elements = document.querySelectorAll(".warp-element") elements.forEach((el) => { const rect = el.getBoundingClientRect() const centerX = rect.left + rect.width / 2 const centerY = rect.top + rect.height / 2 const dx = e.clientX - centerX const dy = e.clientY - centerY const distance = Math.sqrt(dx * dx + dy * dy) // Black hole effect with stronger pull and rotation if (distance < 300) { const strength = Math.pow((300 - distance) / 300, 2) // Quadratic falloff for stronger pull // Pull toward cursor (negative direction) const pullX = -(dx / distance) * strength * 40 const pullY = -(dy / distance) * strength * 40 // Calculate angle for rotation around cursor const angle = Math.atan2(dy, dx) const rotationStrength = strength * 15 // Degrees of twist // Perpendicular vector for tangential twist const twistX = -Math.sin(angle) * strength * 15 const twistY = Math.cos(angle) * strength * 15 // Combine pull + twist + rotation const totalX = pullX + twistX const totalY = pullY + twistY // Scale down as it gets pulled in (singularity effect) const scale = 1 - strength * 0.3 ;(el as HTMLElement).style.transform = `translate(${totalX}px, ${totalY}px) scale(${scale}) rotate(${rotationStrength}deg)` ;(el as HTMLElement).style.filter = `blur(${strength * 2}px) brightness(${1 - strength * 0.3})` } else { ;(el as HTMLElement).style.transform = "" ;(el as HTMLElement).style.filter = "" } }) clearTimeout(timeout) timeout = setTimeout(() => setIsMoving(false), 100) } window.addEventListener("mousemove", handleMouseMove) return () => { window.removeEventListener("mousemove", handleMouseMove) clearTimeout(timeout) } }, []) return ( <> {/* Custom cursor - black hole singularity */}
{/* Accretion disk effect */}
{/* Orbiting matter being pulled in */}
{/* Gravitational wave ripples on movement */} {isMoving && ( <>
)}
) }