drag-event-service
Advanced tools
Comparing version 1.1.10 to 2.0.0
{ | ||
"name": "drag-event-service", | ||
"version": "1.1.10", | ||
"version": "2.0.0", | ||
"description": "", | ||
"main": "dist/drag-event-service.cjs.js", | ||
"module": "dist/drag-event-service.esm.js", | ||
"types": "types/index.d.ts", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts", | ||
"jsdelivr": "dist/index.iife.js", | ||
"unpkg": "dist/index.iife.js", | ||
"files": [ | ||
"dist", | ||
"types" | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "rollup -c scripts/build.js & node scripts/build.js --report", | ||
"watch-lib": "rollup -c scripts/build.js --watch" | ||
"build": "rogo", | ||
"watch": "rogo -w" | ||
}, | ||
"author": "phphe <phphe@outlook.com> (https://github.com/phphe)", | ||
"unpkg": "dist/drag-event-service.js", | ||
"bugs": { | ||
@@ -26,9 +27,10 @@ "url": "https://github.com/phphe/drag-event-service/issues" | ||
"devDependencies": { | ||
"@rollup-use/core": "^0" | ||
"rogo": "^3.1.4", | ||
"typescript": "^4" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.7.7", | ||
"helper-js": "^2.0.0" | ||
"helper-js": "^3.0.0", | ||
"@babel/runtime": "^7.7.7" | ||
}, | ||
"license": "MIT" | ||
} | ||
} |
# drag-event-service | ||
Listen both mouse and touch event. With Typescript definition files. Support Typescript. | ||
同时监听鼠标和触摸事件. 支持Typescript. | ||
同时监听鼠标和触摸事件. 支持 Typescript. | ||
```js | ||
// mapping | ||
const events = { | ||
start: ['mousedown', 'touchstart'], | ||
move: ['mousemove', 'touchmove'], | ||
end: ['mouseup', 'touchend'], | ||
} | ||
start: ["mousedown", "touchstart"], | ||
move: ["mousemove", "touchmove"], | ||
end: ["mouseup", "touchend"], | ||
}; | ||
``` | ||
## install | ||
```sh | ||
npm install drag-event-service --save | ||
``` | ||
## usage & api | ||
```js | ||
import DragEventService from 'drag-event-service' | ||
DragEventService.on(el, name, handler, {args, mouseArgs, touchArgs}) | ||
DragEventService.off(el, name, handler, {args, mouseArgs, touchArgs}) | ||
import DragEventService from "drag-event-service"; | ||
DragEventService.on(el, name, handler, { args, mouseArgs, touchArgs }); | ||
DragEventService.off(el, name, handler, { args, mouseArgs, touchArgs }); | ||
``` | ||
* args, mouseArgs and touchArgs should be Array | ||
* The args will pass to addEventListener. | ||
* mouseArgs will pass to mouse event. | ||
* touchArgs will pass to touch event. | ||
* handler(event, currentPosition). The second argument of handler is current position({x, y, pageX, pageY, clientX, clientY, screenX, screenY}). x and y is pageX and pageY. | ||
- args, mouseArgs and touchArgs should be Array | ||
- The args will pass to addEventListener. | ||
- mouseArgs will pass to mouse event. | ||
- touchArgs will pass to touch event. | ||
- handler(event, currentPosition). The second argument of handler is current position({x, y, pageX, pageY, clientX, clientY, screenX, screenY}). x and y is pageX and pageY. | ||
## example | ||
```js | ||
@@ -40,32 +48,1 @@ // 1 | ||
``` | ||
## Track mouse or touch position globally | ||
全局跟踪鼠标或触摸位置 | ||
### Usage | ||
```js | ||
import {trackMouseOrTouchPosition} from 'drag-event-service' | ||
const {info, start, stop} = trackMouseOrTouchPosition(options) | ||
start() // call start to start tracking. | ||
``` | ||
### Types | ||
```ts | ||
// options | ||
export interface Options_trackMouseOrTouchPosition{ | ||
onMove: () => void | ||
onStart: () => void | ||
onEnd: () => void | ||
} | ||
// info | ||
export interface TrackedInfo{ | ||
position: EventPosition | ||
event: MouseOrTouchEvent | ||
eventType: EventType | ||
isTouch: boolean | ||
started: boolean | ||
startEvent?: MouseOrTouchEvent | ||
endEvent?: MouseOrTouchEvent | ||
} | ||
// | ||
start: () => void | ||
stop: () => void | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108438
9
2
405
48
1
+ Addedhelper-js@3.1.5(transitive)
- Removedhelper-js@2.0.7(transitive)
- Removedtslib@2.7.0(transitive)
Updatedhelper-js@^3.0.0