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 - npm Package Compare versions

Comparing version

to
1.0.0

lib/index.d.ts

32

package.json
{
"name": "cursor-position",
"title": "cursor-position",
"version": "0.0.3",
"version": "1.0.0",
"description": "Simple module for getting the current mouse position in element or window.",
"main": "lib/index.min.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"scripts": {
"build": "babel ./src/index.js -o ./lib/index.min.js"
"build": "tsc",
"test": "mocha -r ts-node/register src/test.ts"
},

@@ -40,16 +45,13 @@ "keywords": [

"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51",
"@babel/preset-flow": "^7.0.0-beta.51",
"@babel/preset-stage-3": "^7.0.0-beta.51",
"babel-eslint": "^8.2.3",
"babel-minify": "^0.5.0-alpha.e9f96ffe",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-flowtype": "^2.49.3",
"eslint-plugin-flowtype-errors": "^3.6.0",
"eslint-plugin-import": "^2.12.0",
"flow-bin": "^0.74.0"
"@types/chai": "^4.1.7",
"@types/jsdom": "^12.2.1",
"@types/mocha": "^5.2.5",
"chai": "^4.2.0",
"jsdom": "^13.1.0",
"jsdom-global": "^3.0.2",
"mocha": "^5.2.0",
"mocha.parallel": "^0.15.6",
"ts-node": "^7.0.1",
"typescript": "^3.2.2"
}
}
# cursor-position
[![Download Count](https://img.shields.io/npm/dm/cursor-position.svg?style=flat-square)](http://www.npmjs.com/package/cursor-position)
[![Download Count](https://img.shields.io/npm/dt/cursor-position.svg?style=flat-square)](http://www.npmjs.com/package/cursor-position)
[![Demo image](https://s3.eu-central-1.amazonaws.com/serhiy/Github_repo/cursor-position/cursor-position.png)](https://exelban.github.io/cursor-position)
Simple module for getting the current mouse position in element or window.
Simple module for getting click/touch position in element or window.

@@ -20,10 +21,8 @@

## Usage
Script has only one function: ```GetCursorPosition(options)```.
Library has only one function: ```GetCursorPosition(options)```
```js
import GetCursorPosition from 'cursor-position'
document.setEventListener('mousemove', (e) => {
const {x, y} = GetCursorPosition({
event: e
})
document.setEventListener('mousemove', () => {
const {x, y} = GetCursorPosition()
console.log(x, y)

@@ -36,10 +35,12 @@ })

{
event MouseEvent
element Node
event?: MouseEvent | TouchEvent
absolute?: boolean
scroll?: boolean
}
```
**Name** | **Type** | **Description** | **Usage**
--- | --- | --- | ---
**event** | **MouseEvent** | **Mouse event with contains cursor position** | **If event not provided scritp will take event object from window.**
**element** | **Node** | **HTML node element** | **Normally 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.**
**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

@@ -49,4 +50,4 @@ ### Response

{
x number,
y number,
x number
y number
}

@@ -56,6 +57,13 @@ ```

## 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;
- first release
## License
[Apache License 2.0](https://github.com/exelban/cursor-position/blob/master/LICENSE)