moverated
Lightweight unified movement, scaling and rotation.
Usage
import { moverated } from 'moverated';
moverated(document, (move) => {
/*
move = {
// absolute
x: number;
y: number;
s: number; // scale
r: number; // rotate
// relative
dx: number;
dy: number;
ds: number; // scale
dr: number; // rotate
// pointer
mx: number; // absolute x path
my: number; // absolute y path
mt: number; // touch time
}
*/
});
Note: for touch devices, you need to put
touch-action: none;
to element
Live example
Installation
Recommend to use yarn for dependency management:
yarn add moverated
License
moverated is MIT licensed.