JSPM

cursor-position

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1884
  • Score
    100M100P100Q106187F
  • License Apache-2.0

Simple module for getting the current mouse position in element or window.

Package Exports

  • cursor-position

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cursor-position) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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
}
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

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