UNPKG

633 BPlain TextView Raw
1import Hammer from '@egjs/hammerjs';
2
3import { DEG_RAD } from './constants';
4import { HammerInputExt } from './GestureHandler';
5import IndiscreteGestureHandler from './IndiscreteGestureHandler';
6
7class RotationGestureHandler extends IndiscreteGestureHandler {
8 get name() {
9 return 'rotate';
10 }
11
12 get NativeGestureClass() {
13 return Hammer.Rotate;
14 }
15
16 transformNativeEvent({ rotation, velocity, center }: HammerInputExt) {
17 return {
18 rotation: (rotation - (this.initialRotation ?? 0)) * DEG_RAD,
19 anchorX: center.x,
20 anchorY: center.y,
21 velocity,
22 };
23 }
24}
25export default RotationGestureHandler;