You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cursor-position

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cursor-position

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

0.0.1
Source
npmnpm
Version published
Weekly downloads
1.1K
-39.92%
Maintainers
1
Weekly downloads
 
Created
Source

cursor-position

Download Count

Demo image

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

Install

yarn add cursor-position

Or with npm:

npm install cursor-position --save

Usage

Script has only one function: GetCursorPosition(options).

import GetCursorPosition from 'cursor-position'

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

Options

{
  event MouseEvent
  element Node
}
NameTypeDescriptionUsage
eventMouseEventMouse event with contains cursor positionIf event not provided scritp will take event object from window.
elementNodeHTML node elementNormally script will return absolute position of mouse in window. But if You want to get mouse position in specific element, just push this component to this option.

Response

{
  x number,
  y number,
}

What's new

v0.0.1

- first release;

License

Apache License 2.0

Keywords

cursor

FAQs

Package last updated on 15 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts