UNPKG

react-native-gesture-handler

Version:

Declarative API exposing native platform touch and gesture system to React Native

26 lines (21 loc) 633 B
import Hammer from '@egjs/hammerjs'; import { DEG_RAD } from './constants'; import { HammerInputExt } from './GestureHandler'; import IndiscreteGestureHandler from './IndiscreteGestureHandler'; class RotationGestureHandler extends IndiscreteGestureHandler { get name() { return 'rotate'; } get NativeGestureClass() { return Hammer.Rotate; } transformNativeEvent({ rotation, velocity, center }: HammerInputExt) { return { rotation: (rotation - (this.initialRotation ?? 0)) * DEG_RAD, anchorX: center.x, anchorY: center.y, velocity, }; } } export default RotationGestureHandler;