react-native-gesture-handler 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +5 -1
- package/RNGestureHandler.podspec +27 -3
- package/android/build.gradle +81 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +5 -1
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +14 -12
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +2 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ScaleGestureDetector.java +558 -0
- package/android/src/fabric/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +29 -0
- package/android/src/fabric/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +12 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +29 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +29 -10
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +111 -47
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +9 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +17 -2
- package/android/src/main/jni/Android.mk +53 -0
- package/android/src/main/jni/OnLoad.cpp +9 -0
- package/android/src/main/jni/RNGestureHandlerComponentsRegistry.cpp +71 -0
- package/android/src/main/jni/RNGestureHandlerComponentsRegistry.h +34 -0
- package/android/src/main/jni/cpp-adapter.cpp +41 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +47 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +22 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +25 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +16 -0
- package/android/src/paper/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +13 -0
- package/ios/Handlers/RNFlingHandler.m +2 -0
- package/ios/Handlers/RNPanHandler.m +2 -0
- package/ios/Handlers/RNPinchHandler.m +2 -0
- package/ios/Handlers/RNRotationHandler.m +2 -0
- package/ios/RNGestureHandler.h +3 -8
- package/ios/RNGestureHandler.m +2 -10
- package/ios/RNGestureHandlerActionType.h +8 -0
- package/ios/RNGestureHandlerButtonComponentView.h +17 -0
- package/ios/RNGestureHandlerButtonComponentView.mm +48 -0
- package/ios/RNGestureHandlerButtonManager.h +5 -0
- package/ios/RNGestureHandlerButtonManager.m +30 -0
- package/ios/RNGestureHandlerManager.h +2 -4
- package/ios/{RNGestureHandlerManager.m → RNGestureHandlerManager.mm} +92 -20
- package/ios/{RNGestureHandlerModule.m → RNGestureHandlerModule.mm} +91 -36
- package/ios/RNGestureHandlerRegistry.h +1 -2
- package/ios/RNGestureHandlerRegistry.m +2 -11
- package/ios/RNGestureHandlerRootViewComponentView.mm +21 -0
- package/lib/commonjs/ActionType.js +15 -0
- package/lib/commonjs/ActionType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +6 -6
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +2 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +4 -2
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +2 -2
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +5 -2
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +22 -20
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +21 -0
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +21 -0
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.js +24 -0
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
- package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js +4 -2
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +8 -4
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/LongPressGestureHandler.js +4 -2
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +4 -2
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +4 -2
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PinchGestureHandler.js +4 -2
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/RotationGestureHandler.js +4 -2
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/TapGestureHandler.js +4 -2
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +61 -9
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +6 -2
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +84 -32
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +25 -8
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +16 -1
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +7 -4
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +4 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/handlers/handlersRegistry.js +42 -6
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +10 -0
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils.js +375 -0
- package/lib/commonjs/jestUtils.js.map +1 -0
- package/lib/commonjs/utils.js +38 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/ActionType.js +7 -0
- package/lib/module/ActionType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +5 -6
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +2 -3
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -2
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +1 -1
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +2 -2
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +4 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/Swipeable.js +22 -20
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +9 -0
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +9 -0
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.js +17 -0
- package/lib/module/getShadowNodeFromRef.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.web.js +8 -0
- package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
- package/lib/module/handlers/FlingGestureHandler.js +2 -1
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js +5 -3
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js +2 -1
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +2 -1
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +2 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PinchGestureHandler.js +2 -1
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/handlers/RotationGestureHandler.js +2 -1
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/handlers/TapGestureHandler.js +2 -1
- package/lib/module/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +60 -10
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/createNativeWrapper.js +6 -2
- package/lib/module/handlers/createNativeWrapper.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +79 -32
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +25 -7
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +16 -1
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +6 -4
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js +2 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/handlers/handlersRegistry.js +34 -6
- package/lib/module/handlers/handlersRegistry.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +6 -0
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils.js +350 -0
- package/lib/module/jestUtils.js.map +1 -0
- package/lib/module/utils.js +28 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +7 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +5 -2
- package/lib/typescript/GestureHandlerRootView.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +3 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerButton.d.ts +2 -2
- package/lib/typescript/components/Swipeable.d.ts +12 -4
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -1
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +2 -4
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +4 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -2
- package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -2
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -2
- package/lib/typescript/handlers/handlersRegistry.d.ts +11 -3
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/jestUtils.d.ts +28 -0
- package/lib/typescript/utils.d.ts +6 -0
- package/lib/typescript/web/constants.d.ts +0 -1
- package/package.json +39 -16
- package/src/ActionType.ts +9 -0
- package/src/GestureHandlerRootView.android.tsx +14 -14
- package/src/GestureHandlerRootView.tsx +4 -4
- package/src/RNGestureHandlerModule.ts +11 -6
- package/src/RNGestureHandlerModule.web.ts +2 -1
- package/src/components/DrawerLayout.tsx +8 -2
- package/src/components/GestureHandlerButton.tsx +7 -4
- package/src/components/Swipeable.tsx +28 -22
- package/src/fabric/RNGestureHandlerButtonNativeComponent.js +27 -0
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +19 -0
- package/src/getShadowNodeFromRef.ts +19 -0
- package/src/getShadowNodeFromRef.web.ts +7 -0
- package/src/handlers/FlingGestureHandler.ts +3 -1
- package/src/handlers/ForceTouchGestureHandler.ts +8 -2
- package/src/handlers/LongPressGestureHandler.ts +3 -1
- package/src/handlers/NativeViewGestureHandler.ts +3 -1
- package/src/handlers/PanGestureHandler.ts +3 -1
- package/src/handlers/PinchGestureHandler.ts +3 -1
- package/src/handlers/RotationGestureHandler.ts +3 -1
- package/src/handlers/TapGestureHandler.ts +3 -1
- package/src/handlers/createHandler.ts +69 -7
- package/src/handlers/createNativeWrapper.tsx +7 -1
- package/src/handlers/gestureHandlerCommon.ts +2 -5
- package/src/handlers/gestures/GestureDetector.tsx +110 -37
- package/src/handlers/gestures/eventReceiver.ts +23 -19
- package/src/handlers/gestures/forceTouchGesture.ts +1 -1
- package/src/handlers/gestures/gesture.ts +21 -1
- package/src/handlers/gestures/gestureStateManager.ts +9 -12
- package/src/handlers/gestures/panGesture.ts +1 -1
- package/src/handlers/gestures/pinchGesture.ts +1 -1
- package/src/handlers/gestures/reanimatedWrapper.ts +4 -1
- package/src/handlers/handlersRegistry.ts +44 -6
- package/src/index.ts +4 -0
- package/src/init.ts +6 -0
- package/src/jestUtils.ts +506 -0
- package/src/utils.ts +38 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +0 -18
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +0 -17
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
@@ -9,10 +9,7 @@ export interface GestureEventPayload {
|
|
9
9
|
numberOfPointers: number;
|
10
10
|
state: ValueOf<typeof State>;
|
11
11
|
}
|
12
|
-
export interface HandlerStateChangeEventPayload {
|
13
|
-
handlerTag: number;
|
14
|
-
numberOfPointers: number;
|
15
|
-
state: ValueOf<typeof State>;
|
12
|
+
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
16
13
|
oldState: ValueOf<typeof State>;
|
17
14
|
}
|
18
15
|
export declare type HitSlop = number | Partial<Record<'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal', number>> | Record<'width' | 'left', number> | Record<'width' | 'right', number> | Record<'height' | 'top', number> | Record<'height' | 'bottom', number>;
|
@@ -48,6 +45,7 @@ export declare type BaseGestureHandlerProps<ExtraEventPayloadT extends Record<st
|
|
48
45
|
id?: string;
|
49
46
|
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
50
47
|
simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
|
48
|
+
testID?: string;
|
51
49
|
onBegan?: (event: HandlerStateChangeEvent) => void;
|
52
50
|
onFailed?: (event: HandlerStateChangeEvent) => void;
|
53
51
|
onCancelled?: (event: HandlerStateChangeEvent) => void;
|
@@ -2,12 +2,15 @@ import React from 'react';
|
|
2
2
|
import { GestureType, HandlerCallbacks } from './gesture';
|
3
3
|
import { SharedValue } from './reanimatedWrapper';
|
4
4
|
import { ComposedGesture } from './gestureComposition';
|
5
|
+
declare global {
|
6
|
+
function isFormsStackingContext(node: unknown): boolean | null;
|
7
|
+
}
|
5
8
|
export declare type GestureConfigReference = {
|
6
9
|
config: GestureType[];
|
7
10
|
animatedEventHandler: unknown;
|
8
11
|
animatedHandlers: SharedValue<HandlerCallbacks<Record<string, unknown>>[] | null> | null;
|
9
12
|
firstExecution: boolean;
|
10
|
-
|
13
|
+
useReanimatedHook: boolean;
|
11
14
|
};
|
12
15
|
interface GestureDetectorProps {
|
13
16
|
gesture?: ComposedGesture | GestureType;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
2
|
import { ForceTouchGestureConfig, ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';
|
3
3
|
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
4
|
-
declare type ForceTouchGestureChangeEventPayload = {
|
4
|
+
export declare type ForceTouchGestureChangeEventPayload = {
|
5
5
|
forceChange: number;
|
6
6
|
};
|
7
7
|
export declare class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGestureHandlerEventPayload, ForceTouchGestureChangeEventPayload> {
|
@@ -13,4 +13,3 @@ export declare class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGe
|
|
13
13
|
onChange(callback: (event: GestureUpdateEvent<GestureUpdateEvent<ForceTouchGestureHandlerEventPayload & ForceTouchGestureChangeEventPayload>>) => void): this;
|
14
14
|
}
|
15
15
|
export declare type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;
|
16
|
-
export {};
|
@@ -16,6 +16,8 @@ export interface BaseGestureConfig extends CommonGestureConfig, Record<string, u
|
|
16
16
|
simultaneousWith?: GestureRef[];
|
17
17
|
needsPointerData?: boolean;
|
18
18
|
manualActivation?: boolean;
|
19
|
+
runOnJS?: boolean;
|
20
|
+
testId?: string;
|
19
21
|
}
|
20
22
|
declare type TouchEventHandlerType = (event: GestureTouchEvent, stateManager: GestureStateManagerType) => void;
|
21
23
|
export declare type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {
|
@@ -83,11 +85,14 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
|
|
83
85
|
enabled(enabled: boolean): this;
|
84
86
|
shouldCancelWhenOutside(value: boolean): this;
|
85
87
|
hitSlop(hitSlop: HitSlop): this;
|
88
|
+
runOnJS(runOnJS: boolean): this;
|
86
89
|
simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]): this;
|
87
90
|
requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]): this;
|
91
|
+
withTestId(id: string): this;
|
88
92
|
initialize(): void;
|
89
93
|
toGestureArray(): GestureType[];
|
90
94
|
prepare(): void;
|
95
|
+
get shouldUseReanimated(): boolean;
|
91
96
|
}
|
92
97
|
export declare abstract class ContinousBaseGesture<EventPayloadT extends Record<string, unknown>, EventChangePayloadT extends Record<string, unknown>> extends BaseGesture<EventPayloadT> {
|
93
98
|
onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void): this;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
2
|
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
3
3
|
import { PanGestureConfig, PanGestureHandlerEventPayload } from '../PanGestureHandler';
|
4
|
-
declare type PanGestureChangeEventPayload = {
|
4
|
+
export declare type PanGestureChangeEventPayload = {
|
5
5
|
changeX: number;
|
6
6
|
changeY: number;
|
7
7
|
};
|
@@ -23,4 +23,3 @@ export declare class PanGesture extends ContinousBaseGesture<PanGestureHandlerEv
|
|
23
23
|
onChange(callback: (event: GestureUpdateEvent<PanGestureHandlerEventPayload & PanGestureChangeEventPayload>) => void): this;
|
24
24
|
}
|
25
25
|
export declare type PanGestureType = InstanceType<typeof PanGesture>;
|
26
|
-
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ContinousBaseGesture } from './gesture';
|
2
2
|
import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';
|
3
3
|
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
4
|
-
declare type PinchGestureChangeEventPayload = {
|
4
|
+
export declare type PinchGestureChangeEventPayload = {
|
5
5
|
scaleChange: number;
|
6
6
|
};
|
7
7
|
export declare class PinchGesture extends ContinousBaseGesture<PinchGestureHandlerEventPayload, PinchGestureChangeEventPayload> {
|
@@ -9,4 +9,3 @@ export declare class PinchGesture extends ContinousBaseGesture<PinchGestureHandl
|
|
9
9
|
onChange(callback: (event: GestureUpdateEvent<PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload>) => void): this;
|
10
10
|
}
|
11
11
|
export declare type PinchGestureType = InstanceType<typeof PinchGesture>;
|
12
|
-
export {};
|
@@ -1,6 +1,14 @@
|
|
1
1
|
import { GestureType } from './gestures/gesture';
|
2
|
+
import { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';
|
2
3
|
export declare const handlerIDToTag: Record<string, number>;
|
3
4
|
export declare function getNextHandlerTag(): number;
|
4
|
-
export declare function registerHandler(handlerTag: number, handler: GestureType): void;
|
5
|
-
export declare function
|
6
|
-
export declare function
|
5
|
+
export declare function registerHandler(handlerTag: number, handler: GestureType, testID?: string): void;
|
6
|
+
export declare function registerOldGestureHandler(handlerTag: number, handler: GestureHandlerCallbacks): void;
|
7
|
+
export declare function unregisterHandler(handlerTag: number, testID?: string): void;
|
8
|
+
export declare function findHandler(handlerTag: number): GestureType | undefined;
|
9
|
+
export declare function findOldGestureHandler(handlerTag: number): GestureHandlerCallbacks | undefined;
|
10
|
+
export declare function findHandlerByTestID(testID: string): import("./gestures/gesture").BaseGesture<Record<string, unknown>> | import("./gestures/gesture").BaseGesture<Record<string, never>> | import("./gestures/gesture").BaseGesture<import("./TapGestureHandler").TapGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PanGestureHandler").PanGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./LongPressGestureHandler").LongPressGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./RotationGestureHandler").RotationGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PinchGestureHandler").PinchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./ForceTouchGestureHandler").ForceTouchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./NativeViewGestureHandler").NativeViewGestureHandlerPayload> | null;
|
11
|
+
export interface GestureHandlerCallbacks {
|
12
|
+
onGestureEvent: (event: GestureEvent<any>) => void;
|
13
|
+
onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;
|
14
|
+
}
|
@@ -1,14 +1,18 @@
|
|
1
1
|
export { Directions } from './Directions';
|
2
2
|
export { State } from './State';
|
3
|
+
export { getByGestureTestId, fireGestureHandler } from './jestUtils';
|
3
4
|
export { default as gestureHandlerRootHOC } from './gestureHandlerRootHOC';
|
4
5
|
export { default as GestureHandlerRootView } from './GestureHandlerRootView';
|
5
6
|
export type { GestureEvent, HandlerStateChangeEvent, GestureEventPayload, HandlerStateChangeEventPayload, GestureTouchEvent, TouchData, GestureUpdateEvent, GestureStateChangeEvent, } from './handlers/gestureHandlerCommon';
|
6
7
|
export type { GestureType } from './handlers/gestures/gesture';
|
7
8
|
export type { TapGestureHandlerEventPayload, TapGestureHandlerProps, } from './handlers/TapGestureHandler';
|
8
9
|
export type { ForceTouchGestureHandlerEventPayload, ForceTouchGestureHandlerProps, } from './handlers/ForceTouchGestureHandler';
|
10
|
+
export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture';
|
9
11
|
export type { LongPressGestureHandlerEventPayload, LongPressGestureHandlerProps, } from './handlers/LongPressGestureHandler';
|
10
12
|
export type { PanGestureHandlerEventPayload, PanGestureHandlerProps, } from './handlers/PanGestureHandler';
|
13
|
+
export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture';
|
11
14
|
export type { PinchGestureHandlerEventPayload, PinchGestureHandlerProps, } from './handlers/PinchGestureHandler';
|
15
|
+
export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture';
|
12
16
|
export type { RotationGestureHandlerEventPayload, RotationGestureHandlerProps, } from './handlers/RotationGestureHandler';
|
13
17
|
export type { FlingGestureHandlerEventPayload, FlingGestureHandlerProps, } from './handlers/FlingGestureHandler';
|
14
18
|
export { TapGestureHandler } from './handlers/TapGestureHandler';
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
2
|
+
import { FlingGestureHandler } from './handlers/FlingGestureHandler';
|
3
|
+
import { ForceTouchGestureHandler, ForceTouchGestureHandlerEventPayload } from './handlers/ForceTouchGestureHandler';
|
4
|
+
import { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent } from './handlers/gestureHandlerCommon';
|
5
|
+
import { FlingGesture } from './handlers/gestures/flingGesture';
|
6
|
+
import { ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
7
|
+
import { BaseGesture, GestureType } from './handlers/gestures/gesture';
|
8
|
+
import { LongPressGesture } from './handlers/gestures/longPressGesture';
|
9
|
+
import { NativeGesture } from './handlers/gestures/nativeGesture';
|
10
|
+
import { PanGesture } from './handlers/gestures/panGesture';
|
11
|
+
import { PinchGesture } from './handlers/gestures/pinchGesture';
|
12
|
+
import { RotationGesture } from './handlers/gestures/rotationGesture';
|
13
|
+
import { TapGesture } from './handlers/gestures/tapGesture';
|
14
|
+
import { LongPressGestureHandler, LongPressGestureHandlerEventPayload } from './handlers/LongPressGestureHandler';
|
15
|
+
import { NativeViewGestureHandler, NativeViewGestureHandlerPayload } from './handlers/NativeViewGestureHandler';
|
16
|
+
import { PanGestureHandler, PanGestureHandlerEventPayload } from './handlers/PanGestureHandler';
|
17
|
+
import { PinchGestureHandler, PinchGestureHandlerEventPayload } from './handlers/PinchGestureHandler';
|
18
|
+
import { RotationGestureHandler, RotationGestureHandlerEventPayload } from './handlers/RotationGestureHandler';
|
19
|
+
import { TapGestureHandler, TapGestureHandlerEventPayload } from './handlers/TapGestureHandler';
|
20
|
+
declare type GestureHandlerTestEvent<TEventPayload extends Record<string, unknown> = Record<string, unknown>> = (GestureEvent<TEventPayload> | HandlerStateChangeEvent<TEventPayload>)['nativeEvent'];
|
21
|
+
declare type AllGestures = TapGesture | PanGesture | LongPressGesture | RotationGesture | PinchGesture | FlingGesture | ForceTouchGesture | NativeGesture;
|
22
|
+
declare type AllHandlers = TapGestureHandler | PanGestureHandler | LongPressGestureHandler | RotationGestureHandler | PinchGestureHandler | FlingGestureHandler | ForceTouchGestureHandler | NativeViewGestureHandler;
|
23
|
+
declare type ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, any>;
|
24
|
+
declare type ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<infer TPayload> ? TPayload : never;
|
25
|
+
declare type ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload> ? TGesturePayload : T extends ClassComponentConstructor<infer THandlerProps> ? ExtractPayloadFromProps<THandlerProps> : Record<string, unknown>;
|
26
|
+
export declare function fireGestureHandler<THandler extends AllGestures | AllHandlers>(componentOrGesture: ReactTestInstance | GestureType, eventList?: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[]): void;
|
27
|
+
export declare function getByGestureTestId(testID: string): BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload>;
|
28
|
+
export {};
|
@@ -1 +1,7 @@
|
|
1
1
|
export declare function toArray<T>(object: T | T[]): T[];
|
2
|
+
export declare type withPrevAndCurrentMapFn<T, Transformed> = (previous: Transformed | null, current: T) => Transformed;
|
3
|
+
export declare function withPrevAndCurrent<T, Transformed>(array: T[], mapFn: withPrevAndCurrentMapFn<T, Transformed>): Transformed[];
|
4
|
+
export declare function hasProperty(object: object, key: string): boolean;
|
5
|
+
export declare function isJestEnv(): boolean;
|
6
|
+
export declare function tagMessage(msg: string): string;
|
7
|
+
export declare function isFabric(): boolean;
|
package/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0",
|
4
4
|
"description": "Experimental implementation of a new declarative API for gesture handling in react-native",
|
5
5
|
"scripts": {
|
6
6
|
"prepare": "bob build",
|
7
7
|
"test": "jest",
|
8
|
-
"build": "yarn tsc",
|
8
|
+
"build": "yarn tsc -p tsconfig.build.json",
|
9
9
|
"precommit": "lint-staged",
|
10
10
|
"release": "npm login && release-it",
|
11
11
|
"ts-check": "yarn tsc --noEmit",
|
@@ -25,6 +25,9 @@
|
|
25
25
|
"android/gradle.properties",
|
26
26
|
"android/src/main/AndroidManifest.xml",
|
27
27
|
"android/src/main/java/",
|
28
|
+
"android/src/main/jni/",
|
29
|
+
"android/src/fabric/java",
|
30
|
+
"android/src/paper/java",
|
28
31
|
"android/lib/build.gradle",
|
29
32
|
"android/lib/src/main/java/",
|
30
33
|
"android/common/src/main/java/",
|
@@ -57,7 +60,7 @@
|
|
57
60
|
"prop-types": "^15.7.2"
|
58
61
|
},
|
59
62
|
"jest": {
|
60
|
-
"preset": "
|
63
|
+
"preset": "react-native",
|
61
64
|
"modulePathIgnorePatterns": [
|
62
65
|
"<rootDir>/lib/"
|
63
66
|
]
|
@@ -68,36 +71,41 @@
|
|
68
71
|
"@babel/preset-env": "^7.12.11",
|
69
72
|
"@babel/preset-typescript": "^7.12.7",
|
70
73
|
"@babel/runtime": "^7.12.5",
|
74
|
+
"@testing-library/jest-native": "^4.0.4",
|
75
|
+
"@testing-library/react-native": "^9.0.0",
|
71
76
|
"@types/hammerjs": "^2.0.38",
|
72
77
|
"@types/hoist-non-react-statics": "^3.3.1",
|
73
|
-
"@types/jest": "^
|
78
|
+
"@types/jest": "^27.0.3",
|
74
79
|
"@types/react": "^17.0.0",
|
75
80
|
"@types/react-native": "^0.64.2",
|
76
81
|
"@types/react-test-renderer": "^17.0.0",
|
77
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
78
|
-
"@typescript-eslint/parser": "^4.
|
82
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
83
|
+
"@typescript-eslint/parser": "^4.33.0",
|
79
84
|
"babel-jest": "^26.6.3",
|
80
85
|
"eslint": "^7.15.0",
|
81
86
|
"eslint-config-satya164": "^3.1.8",
|
82
87
|
"eslint-import-resolver-babel-module": "^5.2.0",
|
83
88
|
"eslint-plugin-import": "^2.22.1",
|
89
|
+
"eslint-plugin-jest": "^26.0.0",
|
84
90
|
"expo": "^35.0.1",
|
85
|
-
"flow-bin": "^0.98.0",
|
86
91
|
"husky": "^0.14.3",
|
87
|
-
"jest": "^
|
88
|
-
"
|
89
|
-
"lint-staged": "^10.2.11",
|
92
|
+
"jest": "^26.6.3",
|
93
|
+
"lint-staged": "^12.3.2",
|
90
94
|
"metro-react-native-babel-preset": "^0.64.0",
|
91
95
|
"prettier": "^2.2.1",
|
92
96
|
"react": "^16.8.6",
|
93
97
|
"react-dom": "^16.12.0",
|
94
98
|
"react-native": "^0.64.0",
|
95
99
|
"react-native-builder-bob": "^0.17.1",
|
96
|
-
"react-native-reanimated": "^2.
|
100
|
+
"react-native-reanimated": "^2.3.1",
|
97
101
|
"react-native-web": "^0.11.7",
|
98
|
-
"react-test-renderer": "
|
102
|
+
"react-test-renderer": "17.0.2",
|
99
103
|
"release-it": "^13.6.5",
|
100
|
-
"typescript": "^4.
|
104
|
+
"typescript": "^4.5.5"
|
105
|
+
},
|
106
|
+
"peerDependencies": {
|
107
|
+
"react": "*",
|
108
|
+
"react-native": "*"
|
101
109
|
},
|
102
110
|
"lint-staged": {
|
103
111
|
"*.{ts,tsx}": [
|
@@ -117,11 +125,26 @@
|
|
117
125
|
"targets": [
|
118
126
|
"commonjs",
|
119
127
|
"module",
|
120
|
-
|
128
|
+
[
|
129
|
+
"typescript",
|
130
|
+
{
|
131
|
+
"project": "tsconfig.build.json"
|
132
|
+
}
|
133
|
+
]
|
121
134
|
]
|
122
135
|
},
|
123
136
|
"eslintIgnore": [
|
124
137
|
"node_modules/",
|
125
|
-
"lib/"
|
126
|
-
|
138
|
+
"lib/",
|
139
|
+
"src/fabric/*NativeComponent.js"
|
140
|
+
],
|
141
|
+
"codegenConfig": {
|
142
|
+
"libraries": [
|
143
|
+
{
|
144
|
+
"name": "rngesturehandler",
|
145
|
+
"type": "components",
|
146
|
+
"jsSrcsDir": "./src/fabric"
|
147
|
+
}
|
148
|
+
]
|
149
|
+
}
|
127
150
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export const ActionType = {
|
2
|
+
REANIMATED_WORKLET: 1,
|
3
|
+
NATIVE_ANIMATED_EVENT: 2,
|
4
|
+
JS_FUNCTION_OLD_API: 3,
|
5
|
+
JS_FUNCTION_NEW_API: 4,
|
6
|
+
} as const;
|
7
|
+
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
9
|
+
export type ActionType = typeof ActionType[keyof typeof ActionType];
|
@@ -1,18 +1,18 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
1
2
|
import * as React from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
3
|
+
import { PropsWithChildren } from 'react';
|
4
|
+
import { requireNativeComponent, ViewProps } from 'react-native';
|
5
|
+
import { isFabric } from './utils';
|
4
6
|
|
5
|
-
const
|
6
|
-
'
|
7
|
-
);
|
7
|
+
const GestureHandlerRootViewNativeComponent = isFabric()
|
8
|
+
? require('./fabric/RNGestureHandlerRootViewNativeComponent').default
|
9
|
+
: requireNativeComponent('RNGestureHandlerRootView');
|
8
10
|
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
</GestureHandlerRootViewNative>
|
17
|
-
);
|
11
|
+
export interface GestureHandlerRootViewProps
|
12
|
+
extends PropsWithChildren<ViewProps> {}
|
13
|
+
|
14
|
+
export default function GestureHandlerRootView(
|
15
|
+
props: GestureHandlerRootViewProps
|
16
|
+
) {
|
17
|
+
return <GestureHandlerRootViewNativeComponent {...props} />;
|
18
18
|
}
|
@@ -5,8 +5,8 @@ import { View, ViewProps } from 'react-native';
|
|
5
5
|
export interface GestureHandlerRootViewProps
|
6
6
|
extends PropsWithChildren<ViewProps> {}
|
7
7
|
|
8
|
-
export default function GestureHandlerRootView(
|
9
|
-
|
10
|
-
|
11
|
-
return <View {...
|
8
|
+
export default function GestureHandlerRootView(
|
9
|
+
props: GestureHandlerRootViewProps
|
10
|
+
) {
|
11
|
+
return <View {...props} />;
|
12
12
|
}
|
@@ -1,14 +1,18 @@
|
|
1
1
|
import { NativeModules } from 'react-native';
|
2
|
+
import { ActionType } from './ActionType';
|
3
|
+
import { tagMessage } from './utils';
|
2
4
|
const { RNGestureHandlerModule } = NativeModules;
|
3
5
|
|
4
6
|
if (RNGestureHandlerModule == null) {
|
5
7
|
console.error(
|
6
|
-
|
8
|
+
tagMessage(
|
9
|
+
`react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`
|
12
|
+
.split('\n')
|
13
|
+
.map((line) => line.trim())
|
14
|
+
.join('\n')
|
15
|
+
)
|
12
16
|
);
|
13
17
|
}
|
14
18
|
|
@@ -23,13 +27,14 @@ export type RNGestureHandlerModuleProps = {
|
|
23
27
|
attachGestureHandler: (
|
24
28
|
handlerTag: number,
|
25
29
|
newView: number,
|
26
|
-
|
30
|
+
actionType: ActionType
|
27
31
|
) => void;
|
28
32
|
updateGestureHandler: (
|
29
33
|
handlerTag: number,
|
30
34
|
newConfig: Readonly<Record<string, unknown>>
|
31
35
|
) => void;
|
32
36
|
dropGestureHandler: (handlerTag: number) => void;
|
37
|
+
install: () => void;
|
33
38
|
};
|
34
39
|
|
35
40
|
export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ActionType } from './ActionType';
|
1
2
|
import { Direction } from './web/constants';
|
2
3
|
import FlingGestureHandler from './web/FlingGestureHandler';
|
3
4
|
import LongPressGestureHandler from './web/LongPressGestureHandler';
|
@@ -44,7 +45,7 @@ export default {
|
|
44
45
|
attachGestureHandler(
|
45
46
|
handlerTag: number,
|
46
47
|
newView: number,
|
47
|
-
|
48
|
+
_actionType: ActionType,
|
48
49
|
propsRef: React.RefObject<unknown>
|
49
50
|
) {
|
50
51
|
NodeManager.getHandler(handlerTag).setView(newView, propsRef);
|
@@ -490,7 +490,8 @@ export default class DrawerLayout extends Component<
|
|
490
490
|
// TODO: decide if it should be null or undefined is the proper value
|
491
491
|
undefined,
|
492
492
|
this.props.drawerWidth!,
|
493
|
-
options.velocity ? options.velocity : 0
|
493
|
+
options.velocity ? options.velocity : 0,
|
494
|
+
options.speed
|
494
495
|
);
|
495
496
|
|
496
497
|
// We need to force the update, otherwise the overlay is not rerendered and
|
@@ -500,7 +501,12 @@ export default class DrawerLayout extends Component<
|
|
500
501
|
|
501
502
|
closeDrawer = (options: DrawerMovementOption = {}) => {
|
502
503
|
// TODO: decide if it should be null or undefined is the proper value
|
503
|
-
this.animateDrawer(
|
504
|
+
this.animateDrawer(
|
505
|
+
undefined,
|
506
|
+
0,
|
507
|
+
options.velocity ? options.velocity : 0,
|
508
|
+
options.speed
|
509
|
+
);
|
504
510
|
|
505
511
|
// We need to force the update, otherwise the overlay is not rerendered and
|
506
512
|
// it would be still clickable
|
@@ -1,7 +1,10 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
1
2
|
import { HostComponent, requireNativeComponent } from 'react-native';
|
2
3
|
import { RawButtonProps } from './GestureButtons';
|
3
|
-
|
4
|
-
'RNGestureHandlerButton'
|
5
|
-
);
|
4
|
+
import { isFabric } from '../utils';
|
6
5
|
|
7
|
-
|
6
|
+
const RNGestureHandlerButtonNativeComponent = isFabric()
|
7
|
+
? require('../fabric/RNGestureHandlerButtonNativeComponent').default
|
8
|
+
: requireNativeComponent('RNGestureHandlerButton');
|
9
|
+
|
10
|
+
export default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;
|
@@ -90,11 +90,15 @@ export interface SwipeableProps
|
|
90
90
|
overshootFriction?: number;
|
91
91
|
|
92
92
|
/**
|
93
|
+
* @deprecated Use `direction` argument of onSwipeableOpen()
|
94
|
+
*
|
93
95
|
* Called when left action panel gets open.
|
94
96
|
*/
|
95
97
|
onSwipeableLeftOpen?: () => void;
|
96
98
|
|
97
99
|
/**
|
100
|
+
* @deprecated Use `direction` argument of onSwipeableOpen()
|
101
|
+
*
|
98
102
|
* Called when right action panel gets open.
|
99
103
|
*/
|
100
104
|
onSwipeableRightOpen?: () => void;
|
@@ -102,19 +106,23 @@ export interface SwipeableProps
|
|
102
106
|
/**
|
103
107
|
* Called when action panel gets open (either right or left).
|
104
108
|
*/
|
105
|
-
onSwipeableOpen?: () => void;
|
109
|
+
onSwipeableOpen?: (direction: 'left' | 'right') => void;
|
106
110
|
|
107
111
|
/**
|
108
112
|
* Called when action panel is closed.
|
109
113
|
*/
|
110
|
-
onSwipeableClose?: () => void;
|
114
|
+
onSwipeableClose?: (direction: 'left' | 'right') => void;
|
111
115
|
|
112
116
|
/**
|
117
|
+
* @deprecated Use `direction` argument of onSwipeableWillOpen()
|
118
|
+
*
|
113
119
|
* Called when left action panel starts animating on open.
|
114
120
|
*/
|
115
121
|
onSwipeableLeftWillOpen?: () => void;
|
116
122
|
|
117
123
|
/**
|
124
|
+
* @deprecated Use `direction` argument of onSwipeableWillOpen()
|
125
|
+
*
|
118
126
|
* Called when right action panel starts animating on open.
|
119
127
|
*/
|
120
128
|
onSwipeableRightWillOpen?: () => void;
|
@@ -122,12 +130,12 @@ export interface SwipeableProps
|
|
122
130
|
/**
|
123
131
|
* Called when action panel starts animating on open (either right or left).
|
124
132
|
*/
|
125
|
-
onSwipeableWillOpen?: () => void;
|
133
|
+
onSwipeableWillOpen?: (direction: 'left' | 'right') => void;
|
126
134
|
|
127
135
|
/**
|
128
136
|
* Called when action panel starts animating on close.
|
129
137
|
*/
|
130
|
-
onSwipeableWillClose?: () => void;
|
138
|
+
onSwipeableWillClose?: (direction: 'left' | 'right') => void;
|
131
139
|
|
132
140
|
/**
|
133
141
|
*
|
@@ -369,29 +377,27 @@ export default class Swipeable extends Component<
|
|
369
377
|
...this.props.animationOptions,
|
370
378
|
}).start(({ finished }) => {
|
371
379
|
if (finished) {
|
372
|
-
if (toValue > 0
|
373
|
-
this.props.onSwipeableLeftOpen();
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
if (toValue === 0) {
|
379
|
-
this.props.onSwipeableClose?.();
|
380
|
+
if (toValue > 0) {
|
381
|
+
this.props.onSwipeableLeftOpen?.();
|
382
|
+
this.props.onSwipeableOpen?.('left');
|
383
|
+
} else if (toValue < 0) {
|
384
|
+
this.props.onSwipeableRightOpen?.();
|
385
|
+
this.props.onSwipeableOpen?.('right');
|
380
386
|
} else {
|
381
|
-
|
387
|
+
const closingDirection = fromValue > 0 ? 'left' : 'right';
|
388
|
+
this.props.onSwipeableClose?.(closingDirection);
|
382
389
|
}
|
383
390
|
}
|
384
391
|
});
|
385
|
-
if (toValue > 0
|
386
|
-
this.props.onSwipeableLeftWillOpen();
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
if (toValue === 0) {
|
392
|
-
this.props.onSwipeableWillClose?.();
|
392
|
+
if (toValue > 0) {
|
393
|
+
this.props.onSwipeableLeftWillOpen?.();
|
394
|
+
this.props.onSwipeableWillOpen?.('left');
|
395
|
+
} else if (toValue < 0) {
|
396
|
+
this.props.onSwipeableRightWillOpen?.();
|
397
|
+
this.props.onSwipeableWillOpen?.('right');
|
393
398
|
} else {
|
394
|
-
|
399
|
+
const closingDirection = fromValue > 0 ? 'left' : 'right';
|
400
|
+
this.props.onSwipeableWillClose?.(closingDirection);
|
395
401
|
}
|
396
402
|
};
|
397
403
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/**
|
2
|
+
* @flow strict-local
|
3
|
+
* @format
|
4
|
+
*/
|
5
|
+
/* eslint-disable */
|
6
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
7
|
+
import type { HostComponent } from 'react-native';
|
8
|
+
import type { ColorValue } from 'react-native/Libraries/StyleSheet';
|
9
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
10
|
+
import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
11
|
+
|
12
|
+
type NativeProps = $ReadOnly<{|
|
13
|
+
...ViewProps, // This is required.
|
14
|
+
exclusive: boolean,
|
15
|
+
foreground: boolean,
|
16
|
+
borderless: boolean,
|
17
|
+
enabled: boolean,
|
18
|
+
rippleColor: ColorValue,
|
19
|
+
rippleRadius: Int32,
|
20
|
+
|}>;
|
21
|
+
|
22
|
+
type ComponentType = HostComponent<NativeProps>;
|
23
|
+
|
24
|
+
export default (codegenNativeComponent<NativeProps>(
|
25
|
+
'RNGestureHandlerButton',
|
26
|
+
{}
|
27
|
+
): ComponentType);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* @flow strict-local
|
3
|
+
* @format
|
4
|
+
*/
|
5
|
+
/* eslint-disable */
|
6
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
7
|
+
import type { HostComponent } from 'react-native';
|
8
|
+
import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
|
9
|
+
|
10
|
+
type NativeProps = $ReadOnly<{|
|
11
|
+
...ViewProps, // This is required.
|
12
|
+
|}>;
|
13
|
+
|
14
|
+
type ComponentType = HostComponent<NativeProps>;
|
15
|
+
|
16
|
+
export default (codegenNativeComponent<NativeProps>(
|
17
|
+
'RNGestureHandlerRootView',
|
18
|
+
{}
|
19
|
+
): ComponentType);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// Used by GestureDetector (unsupported on web at the moment) to check whether the
|
2
|
+
// attached view may get flattened on Fabric. This implementation causes errors
|
3
|
+
// on web due to the static resolution of `require` statements by webpack breaking
|
4
|
+
// the conditional importing. Solved by making .web file.
|
5
|
+
let findHostInstance_DEPRECATED = (_ref: any) => null;
|
6
|
+
|
7
|
+
try {
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
9
|
+
findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')
|
10
|
+
.findHostInstance_DEPRECATED;
|
11
|
+
} catch (e) {
|
12
|
+
// do nothing
|
13
|
+
}
|
14
|
+
|
15
|
+
export function getShadowNodeFromRef(ref: any) {
|
16
|
+
// @ts-ignore Fabric
|
17
|
+
return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode
|
18
|
+
.node;
|
19
|
+
}
|