start-drag
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

start-drag

npm version npm downloads

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

Package Sidebar

Install

npm i start-drag

Weekly Downloads

21

Version

1.0.1

License

MIT

Unpacked Size

7.62 kB

Total Files

7

Last publish

Collaborators

  • arumi-s