Track the mouse position within a specific DOM element using useMousePosition.
The useMousePosition
hook allows you to track the mouse position within a specific DOM element. This is useful for creating interactive components that need to respond to the user’s mouse movements, such as custom tooltips, draggable elements, or dynamic visual effects.
Name | Type | Description |
---|---|---|
ref | React.RefObject | A ref to the DOM element within which the mouse position should be tracked. |
Name | Type | Description |
---|---|---|
x | number | The current x-coordinate of the mouse position within the specified element. |
y | number | The current y-coordinate of the mouse position within the specified element. |
Track the mouse position within a specific DOM element using useMousePosition.
The useMousePosition
hook allows you to track the mouse position within a specific DOM element. This is useful for creating interactive components that need to respond to the user’s mouse movements, such as custom tooltips, draggable elements, or dynamic visual effects.
Name | Type | Description |
---|---|---|
ref | React.RefObject | A ref to the DOM element within which the mouse position should be tracked. |
Name | Type | Description |
---|---|---|
x | number | The current x-coordinate of the mouse position within the specified element. |
y | number | The current y-coordinate of the mouse position within the specified element. |