Simple module for getting the current mouse position in element or window.
npm install cursor-position


Simple module for getting click/touch position in element or window.
sh
yarn add cursor-position
`
Or with npm:
`sh
npm install cursor-position --save
`Usage
Library has only one function: `GetCursorPosition(options)`
`js
import GetCursorPosition from 'cursor-position'document.setEventListener('mousemove', () => {
const {x, y} = GetCursorPosition()
console.log(x, y)
})
`$3
`
{
event?: MouseEvent | TouchEvent
absolute?: boolean
scroll?: boolean
}
`
Name | Type | Required | Default | Description
--- | --- | --- | --- | ---
event | MouseEvent TouchEvent | No | window.event | Click event
absolute | Boolean | No | true | Determine if position must be calculated from body or from parent element
scroll | Boolean | No | false | Determine if position must include scroll value$3
`
{
x number
y number
}
``