start-drag
v1.0.1
Published
Listens and composes mouse or touch events to dragging callbacks
Downloads
55
Maintainers
Readme
start-drag
This package is a small utility that listens and composes mouse or touch events to dragging callbacks.
Install
npm i start-drag
Usage
import { strtr } from 'start-drag';
element.addEventListener('mousedown', (event) => {
const destroy = startDrag(
event,
document.body,
(event: MouseEvent, x: number, y: number, relX: number, relY: number) => {
console.log(x, y, relX, relY);
},
(event: MouseEvent) => {
console.log('end');
},
);
// call destroy to stop listening
destroy();
});
License
MIT License