@codewell/get-canvas-mouse-position

1.0.0 • Public • Published

@codewell/get-canvas-mouse-position

Get the position of a mouse on a canvas triggered by an event.

Installation

npm install @codewell/get-canvas-mouse-position

Basic usage

import getCanvasMousePosition from '@codewell/get-canvas-mouse-position':


const handleClick = (event) => {
  const mousePosition = getCanvasMousePosition(event);
  const {x, y} = mousePosition; // The coordinate that was clicked on the canvas
}

return (
  <canvas onClick={handleClick} />
)

Readme

Keywords

none

Package Sidebar

Install

npm i @codewell/get-canvas-mouse-position

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.67 kB

Total Files

4

Last publish

Collaborators

  • fippli