cursor-position
Advanced tools
Comparing version
{ | ||
"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 | ||
[](http://www.npmjs.com/package/cursor-position) | ||
[](http://www.npmjs.com/package/cursor-position) | ||
[](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) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17952
9.67%10
-23.08%113
117.31%0
-100%66
13.79%5
-16.67%