Skip to content

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

License

Notifications You must be signed in to change notification settings

codewell/get-canvas-mouse-position

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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} />
)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published