import { useState } from "react";

export interface CursorPosition {
  x: number;
  y: number;
}

export const useCursor = () => {
  const [position, setPosition] = useState<CursorPosition | null>(null);

  const updateCursor = (event: React.MouseEvent) => {
    const rect = event.currentTarget.getBoundingClientRect();
    const relativeX = event.clientX - rect.left;
    const relativeY = event.clientY - rect.top;
    setPosition({ x: relativeX, y: relativeY });
  };

  return { position, setPosition, updateCursor };
};

export default useCursor;
