Function useMouseClientPosition

  • Custom React hook that retrieves the current mouse position in the client area.

    This hook tracks the mouse position by listening for mousemove events. It initializes the position to the center of the window and updates the position whenever the mouse moves.

    Example

    const MyComponent = () => {
    const position = useMouseClientPosition();

    return (
    <div>
    <p>Mouse Position: {`x: ${position.x}, y: ${position.y}`}</p>
    </div>
    );
    };

    Returns IMouseClientPositionVector2