import type { GestureUpdateEvent } from '../gestureHandlerCommon'; import type { RotationGestureHandlerEventPayload } from '../GestureHandlerEventPayload'; import { ContinousBaseGesture } from './gesture'; type RotationGestureChangeEventPayload = { rotationChange: number; }; function changeEventCalculator( current: GestureUpdateEvent, previous?: GestureUpdateEvent ) { 'worklet'; let changePayload: RotationGestureChangeEventPayload; if (previous === undefined) { changePayload = { rotationChange: current.rotation, }; } else { changePayload = { rotationChange: current.rotation - previous.rotation, }; } return { ...current, ...changePayload }; } /** * @deprecated `RotationGesture` is deprecated and will be removed in the future. Please use `useRotationGesture` instead. */ export class RotationGesture extends ContinousBaseGesture< RotationGestureHandlerEventPayload, RotationGestureChangeEventPayload > { constructor() { super(); this.handlerName = 'RotationGestureHandler'; } override onChange( callback: ( event: GestureUpdateEvent< RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload > ) => void ) { // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record this.handlers.changeEventCalculator = changeEventCalculator; return super.onChange(callback); } } /** * @deprecated `RotationGestureType` is deprecated and will be removed in the future. Please use `RotationGesture` instead. */ export type RotationGestureType = InstanceType;