1.0.1 • Published 5 years ago

cursor-position v1.0.1

Weekly downloads
185
License
Apache-2.0
Repository
github
Last release
5 years ago

cursor-position

Download Count

Demo image

Simple module for getting click/touch position in element or window.

Install

yarn add cursor-position

Or with npm:

npm install cursor-position --save

Usage

Library has only one function: GetCursorPosition(options)

import GetCursorPosition from 'cursor-position'

document.setEventListener('mousemove', () => {
  const {x, y} = GetCursorPosition()
  console.log(x, y)
})

Options

{
    event?: MouseEvent | TouchEvent
    absolute?: boolean
    scroll?: boolean
}
NameTypeRequiredDefaultDescription
eventMouseEvent TouchEventNowindow.eventClick event
absoluteBooleanNotrueDetermine if position must be calculated from body or from parent element
scrollBooleanNofalseDetermine if position must include scroll value

Response

{
  x number
  y number
}

What's new

v1.0.0 (BREAKING CHANGES)

- rewrited library in typescript
- removed eslint
- removed @flow
- changed options
- added some tests (in progress)

v0.0.3

- first release

License

Apache License 2.0