UNPKG

2.43 kBTypeScriptView Raw
1import type { DependencyList, NativeEventWrapper, ReanimatedEvent } from './commonTypes';
2declare const EVENT_TYPE: {
3 readonly UNDETERMINED: 0;
4 readonly FAILED: 1;
5 readonly BEGAN: 2;
6 readonly CANCELLED: 3;
7 readonly ACTIVE: 4;
8 readonly END: 5;
9};
10type StateType = (typeof EVENT_TYPE)[keyof typeof EVENT_TYPE];
11type DefaultEvent = {
12 nativeEvent: {
13 readonly handlerTag: number;
14 readonly numberOfPointers: number;
15 readonly state: (typeof EVENT_TYPE)[keyof typeof EVENT_TYPE];
16 readonly x: number;
17 readonly y: number;
18 readonly absoluteX: number;
19 readonly absoluteY: number;
20 readonly translationX: number;
21 readonly translationY: number;
22 readonly velocityX: number;
23 readonly velocityY: number;
24 };
25};
26interface PropsUsedInUseAnimatedGestureHandler {
27 handlerTag?: number;
28 numberOfPointers?: number;
29 state?: StateType;
30 oldState?: StateType;
31}
32export type GestureHandlerEvent<Event extends object> = ReanimatedEvent<Event> | Event;
33type GestureHandler<Event extends NativeEventWrapper<PropsUsedInUseAnimatedGestureHandler>, Context extends Record<string, unknown>> = (eventPayload: ReanimatedEvent<Event>, context: Context, isCanceledOrFailed?: boolean) => void;
34export interface GestureHandlers<Event extends NativeEventWrapper<PropsUsedInUseAnimatedGestureHandler>, Context extends Record<string, unknown>> {
35 [key: string]: GestureHandler<Event, Context> | undefined;
36 onStart?: GestureHandler<Event, Context>;
37 onActive?: GestureHandler<Event, Context>;
38 onEnd?: GestureHandler<Event, Context>;
39 onFail?: GestureHandler<Event, Context>;
40 onCancel?: GestureHandler<Event, Context>;
41 onFinish?: GestureHandler<Event, Context>;
42}
43/**
44 * @deprecated UseAnimatedGestureHandler is an old API which is no longer
45 * supported.
46 *
47 * Please check
48 * https://docs.swmansion.com/react-native-gesture-handler/docs/guides/upgrading-to-2/
49 * for information about how to migrate to `react-native-gesture-handler` v2
50 */
51export declare function useAnimatedGestureHandler<Event extends NativeEventWrapper<PropsUsedInUseAnimatedGestureHandler> = DefaultEvent, Context extends Record<string, unknown> = Record<string, unknown>>(handlers: GestureHandlers<Event, Context>, dependencies?: DependencyList): (e: Event) => void;
52export {};
53//# sourceMappingURL=useAnimatedGestureHandler.d.ts.map
\No newline at end of file