react-native-gesture-handler 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +8 -3
- package/RNGestureHandler.podspec +27 -3
- package/android/build.gradle +82 -9
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +47 -12
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +50 -14
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +7 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +8 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +6 -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 +119 -55
- 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 +72 -8
- 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 -106
- 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 +72 -9
- 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 -11
- 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 +3 -2
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +3 -2
- 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 +15 -11
- 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 +5 -3
- package/src/handlers/NativeViewGestureHandler.ts +3 -1
- package/src/handlers/PanGestureHandler.ts +5 -3
- 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 +80 -5
- 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 +15 -11
- 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
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
#import <React/RCTUIManagerUtils.h>
|
|
8
8
|
#import <React/RCTUIManagerObserverCoordinator.h>
|
|
9
9
|
|
|
10
|
+
#ifdef RN_FABRIC_ENABLED
|
|
11
|
+
#import <React/RCTBridge.h>
|
|
12
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
13
|
+
#import <React/RCTBridge+Private.h>
|
|
14
|
+
#import <ReactCommon/CallInvoker.h>
|
|
15
|
+
#import <React/RCTUtils.h>
|
|
16
|
+
#import <React/RCTSurfacePresenter.h>
|
|
17
|
+
|
|
18
|
+
#import <react/renderer/uimanager/primitives.h>
|
|
19
|
+
#endif // RN_FABRIC_ENABLED
|
|
20
|
+
|
|
10
21
|
#import "RNGestureHandlerState.h"
|
|
11
22
|
#import "RNGestureHandlerDirection.h"
|
|
12
23
|
#import "RNGestureHandler.h"
|
|
@@ -15,41 +26,20 @@
|
|
|
15
26
|
#import "RNGestureHandlerButton.h"
|
|
16
27
|
#import "RNGestureHandlerStateManager.h"
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
#ifdef RN_FABRIC_ENABLED
|
|
30
|
+
using namespace facebook;
|
|
31
|
+
using namespace react;
|
|
32
|
+
#endif // RN_FABRIC_ENABLED
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
#ifdef RN_FABRIC_ENABLED
|
|
35
|
+
@interface RNGestureHandlerModule () <RCTSurfacePresenterObserver, RNGestureHandlerStateManager>
|
|
21
36
|
|
|
22
|
-
@interface RNGestureHandlerButtonManager : RCTViewManager
|
|
23
37
|
@end
|
|
24
|
-
|
|
25
|
-
@
|
|
26
|
-
|
|
27
|
-
RCT_EXPORT_MODULE(RNGestureHandlerButton)
|
|
28
|
-
|
|
29
|
-
RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
|
|
30
|
-
#if !TARGET_OS_TV
|
|
31
|
-
RCT_CUSTOM_VIEW_PROPERTY(exclusive, BOOL, RNGestureHandlerButton)
|
|
32
|
-
{
|
|
33
|
-
[view setExclusiveTouch: json == nil ? YES : [RCTConvert BOOL: json]];
|
|
34
|
-
}
|
|
35
|
-
#endif
|
|
36
|
-
RCT_CUSTOM_VIEW_PROPERTY(hitSlop, UIEdgeInsets, RNGestureHandlerButton)
|
|
37
|
-
{
|
|
38
|
-
if (json) {
|
|
39
|
-
UIEdgeInsets hitSlopInsets = [RCTConvert UIEdgeInsets:json];
|
|
40
|
-
view.hitTestEdgeInsets = UIEdgeInsetsMake(-hitSlopInsets.top, -hitSlopInsets.left, -hitSlopInsets.bottom, -hitSlopInsets.right);
|
|
41
|
-
} else {
|
|
42
|
-
view.hitTestEdgeInsets = defaultView.hitTestEdgeInsets;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (UIView *)view
|
|
47
|
-
{
|
|
48
|
-
return [RNGestureHandlerButton new];
|
|
49
|
-
}
|
|
38
|
+
#else
|
|
39
|
+
@interface RNGestureHandlerModule () <RCTUIManagerObserver, RNGestureHandlerStateManager>
|
|
50
40
|
|
|
51
41
|
@end
|
|
52
|
-
|
|
42
|
+
#endif // RN_FABRIC_ENABLED
|
|
53
43
|
|
|
54
44
|
typedef void (^GestureHandlerOperation)(RNGestureHandlerManager *manager);
|
|
55
45
|
|
|
@@ -71,7 +61,12 @@ RCT_EXPORT_MODULE()
|
|
|
71
61
|
- (void)invalidate
|
|
72
62
|
{
|
|
73
63
|
_manager = nil;
|
|
64
|
+
|
|
65
|
+
#ifdef RN_FABRIC_ENABLED
|
|
66
|
+
[self.bridge.surfacePresenter removeObserver:self];
|
|
67
|
+
#else
|
|
74
68
|
[self.bridge.uiManager.observerCoordinator removeObserver:self];
|
|
69
|
+
#endif // RN_FABRIC_ENABLED
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
- (dispatch_queue_t)methodQueue
|
|
@@ -85,6 +80,32 @@ RCT_EXPORT_MODULE()
|
|
|
85
80
|
return RCTGetUIManagerQueue();
|
|
86
81
|
}
|
|
87
82
|
|
|
83
|
+
#ifdef RN_FABRIC_ENABLED
|
|
84
|
+
void decorateRuntime(jsi::Runtime &runtime)
|
|
85
|
+
{
|
|
86
|
+
auto isFormsStackingContext = jsi::Function::createFromHostFunction(
|
|
87
|
+
runtime,
|
|
88
|
+
jsi::PropNameID::forAscii(runtime, "isFormsStackingContext"),
|
|
89
|
+
1,
|
|
90
|
+
[](jsi::Runtime &runtime,
|
|
91
|
+
const jsi::Value &thisValue,
|
|
92
|
+
const jsi::Value *arguments,
|
|
93
|
+
size_t count) -> jsi::Value
|
|
94
|
+
{
|
|
95
|
+
if (!arguments[0].isObject())
|
|
96
|
+
{
|
|
97
|
+
return jsi::Value::null();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
auto shadowNode = arguments[0].asObject(runtime).getHostObject<ShadowNodeWrapper>(runtime)->shadowNode;
|
|
101
|
+
bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext);
|
|
102
|
+
|
|
103
|
+
return jsi::Value(isFormsStackingContext);
|
|
104
|
+
});
|
|
105
|
+
runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext));
|
|
106
|
+
}
|
|
107
|
+
#endif // RN_FABRIC_ENABLED
|
|
108
|
+
|
|
88
109
|
- (void)setBridge:(RCTBridge *)bridge
|
|
89
110
|
{
|
|
90
111
|
[super setBridge:bridge];
|
|
@@ -93,9 +114,23 @@ RCT_EXPORT_MODULE()
|
|
|
93
114
|
initWithUIManager:bridge.uiManager
|
|
94
115
|
eventDispatcher:bridge.eventDispatcher];
|
|
95
116
|
_operations = [NSMutableArray new];
|
|
117
|
+
|
|
118
|
+
#ifdef RN_FABRIC_ENABLED
|
|
119
|
+
[bridge.surfacePresenter addObserver:self];
|
|
120
|
+
#else
|
|
96
121
|
[bridge.uiManager.observerCoordinator addObserver:self];
|
|
122
|
+
#endif // RN_FABRIC_ENABLED
|
|
97
123
|
}
|
|
98
124
|
|
|
125
|
+
#ifdef RN_FABRIC_ENABLED
|
|
126
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
|
|
127
|
+
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
|
|
128
|
+
auto runtime = (jsi::Runtime *)cxxBridge.runtime;
|
|
129
|
+
decorateRuntime(*runtime);
|
|
130
|
+
return @true;
|
|
131
|
+
}
|
|
132
|
+
#endif // RN_FABRIC_ENABLED
|
|
133
|
+
|
|
99
134
|
RCT_EXPORT_METHOD(createGestureHandler:(nonnull NSString *)handlerName tag:(nonnull NSNumber *)handlerTag config:(NSDictionary *)config)
|
|
100
135
|
{
|
|
101
136
|
[self addOperationBlock:^(RNGestureHandlerManager *manager) {
|
|
@@ -103,14 +138,10 @@ RCT_EXPORT_METHOD(createGestureHandler:(nonnull NSString *)handlerName tag:(nonn
|
|
|
103
138
|
}];
|
|
104
139
|
}
|
|
105
140
|
|
|
106
|
-
RCT_EXPORT_METHOD(attachGestureHandler:(nonnull NSNumber *)handlerTag toViewWithTag:(nonnull NSNumber *)viewTag
|
|
141
|
+
RCT_EXPORT_METHOD(attachGestureHandler:(nonnull NSNumber *)handlerTag toViewWithTag:(nonnull NSNumber *)viewTag actionType:(nonnull NSNumber *)actionType)
|
|
107
142
|
{
|
|
108
143
|
[self addOperationBlock:^(RNGestureHandlerManager *manager) {
|
|
109
|
-
|
|
110
|
-
[manager attachGestureHandlerForDeviceEvents:handlerTag toViewWithTag:viewTag];
|
|
111
|
-
} else {
|
|
112
|
-
[manager attachGestureHandler:handlerTag toViewWithTag:viewTag];
|
|
113
|
-
}
|
|
144
|
+
[manager attachGestureHandler:handlerTag toViewWithTag:viewTag withActionType:(RNGestureHandlerActionType)[actionType integerValue]];
|
|
114
145
|
}];
|
|
115
146
|
}
|
|
116
147
|
|
|
@@ -180,6 +211,28 @@ RCT_EXPORT_METHOD(handleClearJSResponder)
|
|
|
180
211
|
[_operations addObject:operation];
|
|
181
212
|
}
|
|
182
213
|
|
|
214
|
+
#pragma mark - RCTSurfacePresenterObserver
|
|
215
|
+
|
|
216
|
+
#ifdef RN_FABRIC_ENABLED
|
|
217
|
+
|
|
218
|
+
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag
|
|
219
|
+
{
|
|
220
|
+
RCTAssertMainQueue();
|
|
221
|
+
|
|
222
|
+
if (_operations.count == 0) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
NSArray<GestureHandlerOperation> *operations = _operations;
|
|
227
|
+
_operations = [NSMutableArray new];
|
|
228
|
+
|
|
229
|
+
for (GestureHandlerOperation operation in operations) {
|
|
230
|
+
operation(self->_manager);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#else
|
|
235
|
+
|
|
183
236
|
#pragma mark - RCTUIManagerObserver
|
|
184
237
|
|
|
185
238
|
- (void)uiManagerWillFlushUIBlocks:(RCTUIManager *)uiManager
|
|
@@ -203,6 +256,8 @@ RCT_EXPORT_METHOD(handleClearJSResponder)
|
|
|
203
256
|
}];
|
|
204
257
|
}
|
|
205
258
|
|
|
259
|
+
#endif // RN_FABRIC_ENABLED
|
|
260
|
+
|
|
206
261
|
#pragma mark Events
|
|
207
262
|
|
|
208
263
|
- (NSArray<NSString *> *)supportedEvents
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
- (nullable RNGestureHandler *)handlerWithTag:(nonnull NSNumber *)handlerTag;
|
|
14
14
|
- (void)registerGestureHandler:(nonnull RNGestureHandler *)gestureHandler;
|
|
15
|
-
- (void)attachHandlerWithTag:(nonnull NSNumber *)handlerTag toView:(nonnull UIView *)view;
|
|
16
|
-
- (void)attachHandlerWithTagForDeviceEvents:(nonnull NSNumber *)handlerTag toView:(nonnull UIView *)view;
|
|
15
|
+
- (void)attachHandlerWithTag:(nonnull NSNumber *)handlerTag toView:(nonnull UIView *)view withActionType:(RNGestureHandlerActionType)actionType;
|
|
17
16
|
- (void)dropHandlerWithTag:(nonnull NSNumber *)handlerTag;
|
|
18
17
|
|
|
19
18
|
@end
|
|
@@ -32,21 +32,12 @@
|
|
|
32
32
|
_handlers[gestureHandler.tag] = gestureHandler;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
- (void)attachHandlerWithTag:(NSNumber *)handlerTag toView:(UIView *)view
|
|
35
|
+
- (void)attachHandlerWithTag:(NSNumber *)handlerTag toView:(UIView *)view withActionType:(RNGestureHandlerActionType)actionType
|
|
36
36
|
{
|
|
37
37
|
RNGestureHandler *handler = _handlers[handlerTag];
|
|
38
38
|
RCTAssert(handler != nil, @"Handler for tag %@ does not exists", handlerTag);
|
|
39
39
|
[handler unbindFromView];
|
|
40
|
-
handler.
|
|
41
|
-
[handler bindToView:view];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
- (void)attachHandlerWithTagForDeviceEvents:(NSNumber *)handlerTag toView:(UIView *)view
|
|
45
|
-
{
|
|
46
|
-
RNGestureHandler *handler = _handlers[handlerTag];
|
|
47
|
-
RCTAssert(handler != nil, @"Handler for tag %@ does not exists", handlerTag);
|
|
48
|
-
[handler unbindFromView];
|
|
49
|
-
handler.usesDeviceEvents = YES;
|
|
40
|
+
handler.actionType = actionType;
|
|
50
41
|
[handler bindToView:view];
|
|
51
42
|
}
|
|
52
43
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#ifdef RN_FABRIC_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
4
|
+
|
|
5
|
+
Class<RCTComponentViewProtocol> RNGestureHandlerRootViewCls(void)
|
|
6
|
+
{
|
|
7
|
+
// RNGestureHandlerRootView is Android-only.
|
|
8
|
+
// However, if we set `excludedPlatforms: ['iOS']` in `codegenNativeComponent`,
|
|
9
|
+
// codegen still generates `RNGestureHandlerRootViewShadowNode` (which it shouldn't)
|
|
10
|
+
// and thus the project fails to compile due to missing `RNGestureHandlerRootViewProps`.
|
|
11
|
+
// As a workaround, we could set `interfaceOnly: true` to disable autogenerating ShadowNode
|
|
12
|
+
// but then we would have to implement ComponentDescriptor and ShadowNode ourselves
|
|
13
|
+
// (probably just generate it once and keep the generated files in the repo)
|
|
14
|
+
// as well as make additional configuration so these files are actually compiled for Android.
|
|
15
|
+
// This simple trick allows us to have all the necessary files generated
|
|
16
|
+
// and compiled on Android while avoiding compilation errors on iOS.
|
|
17
|
+
// TODO: remove this file once `excludedPlatforms` option properly disables generating ShadowNode
|
|
18
|
+
return nil;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#endif // RN_FABRIC_ENABLED
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ActionType = void 0;
|
|
7
|
+
const ActionType = {
|
|
8
|
+
REANIMATED_WORKLET: 1,
|
|
9
|
+
NATIVE_ANIMATED_EVENT: 2,
|
|
10
|
+
JS_FUNCTION_OLD_API: 3,
|
|
11
|
+
JS_FUNCTION_NEW_API: 4
|
|
12
|
+
}; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
|
13
|
+
|
|
14
|
+
exports.ActionType = ActionType;
|
|
15
|
+
//# sourceMappingURL=ActionType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ActionType.ts"],"names":["ActionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","JS_FUNCTION_OLD_API","JS_FUNCTION_NEW_API"],"mappings":";;;;;;AAAO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,kBAAkB,EAAE,CADI;AAExBC,EAAAA,qBAAqB,EAAE,CAFC;AAGxBC,EAAAA,mBAAmB,EAAE,CAHG;AAIxBC,EAAAA,mBAAmB,EAAE;AAJG,CAAnB,C,CAOP","sourcesContent":["export const ActionType = {\n REANIMATED_WORKLET: 1,\n NATIVE_ANIMATED_EVENT: 2,\n JS_FUNCTION_OLD_API: 3,\n JS_FUNCTION_NEW_API: 4,\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value\nexport type ActionType = typeof ActionType[keyof typeof ActionType];\n"]}
|
|
@@ -9,16 +9,16 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
|
|
12
14
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
13
15
|
|
|
14
16
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
19
|
+
const GestureHandlerRootViewNativeComponent = (0, _utils.isFabric)() ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerRootView');
|
|
17
20
|
|
|
18
|
-
function GestureHandlerRootView({
|
|
19
|
-
|
|
20
|
-
...rest
|
|
21
|
-
}) {
|
|
22
|
-
return /*#__PURE__*/React.createElement(GestureHandlerRootViewNative, rest, children);
|
|
21
|
+
function GestureHandlerRootView(props) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(GestureHandlerRootViewNativeComponent, props);
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=GestureHandlerRootView.android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["GestureHandlerRootView.android.tsx"],"names":["GestureHandlerRootViewNativeComponent","require","default","GestureHandlerRootView","props"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;;;;;AAJA;AAMA,MAAMA,qCAAqC,GAAG,yBAC1CC,OAAO,CAAC,kDAAD,CAAP,CAA4DC,OADlB,GAE1C,yCAAuB,0BAAvB,CAFJ;;AAOe,SAASC,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,qCAAD,EAA2CA,KAA3C,CAAP;AACD","sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { requireNativeComponent, ViewProps } from 'react-native';\nimport { isFabric } from './utils';\n\nconst GestureHandlerRootViewNativeComponent = isFabric()\n ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default\n : requireNativeComponent('RNGestureHandlerRootView');\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <GestureHandlerRootViewNativeComponent {...props} />;\n}\n"]}
|
|
@@ -13,8 +13,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
|
-
function GestureHandlerRootView({
|
|
17
|
-
|
|
18
|
-
return /*#__PURE__*/React.createElement(_reactNative.View, rest);
|
|
16
|
+
function GestureHandlerRootView(props) {
|
|
17
|
+
return /*#__PURE__*/React.createElement(_reactNative.View, props);
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=GestureHandlerRootView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","
|
|
1
|
+
{"version":3,"sources":["GestureHandlerRootView.tsx"],"names":["GestureHandlerRootView","props"],"mappings":";;;;;;;AAAA;;AAEA;;;;;;AAKe,SAASA,sBAAT,CACbC,KADa,EAEb;AACA,sBAAO,oBAAC,iBAAD,EAAUA,KAAV,CAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { PropsWithChildren } from 'react';\nimport { View, ViewProps } from 'react-native';\n\nexport interface GestureHandlerRootViewProps\n extends PropsWithChildren<ViewProps> {}\n\nexport default function GestureHandlerRootView(\n props: GestureHandlerRootViewProps\n) {\n return <View {...props} />;\n}\n"]}
|
|
@@ -7,14 +7,16 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
|
|
10
12
|
const {
|
|
11
13
|
RNGestureHandlerModule
|
|
12
14
|
} = _reactNative.NativeModules;
|
|
13
15
|
|
|
14
16
|
if (RNGestureHandlerModule == null) {
|
|
15
|
-
console.error(`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 ..).
|
|
17
|
+
console.error((0, _utils.tagMessage)(`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 ..).
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`.split('\n').map(line => line.trim()).join('\n')));
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
var _default = RNGestureHandlerModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join"],"mappings":";;;;;;;AAAA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,
|
|
1
|
+
{"version":3,"sources":["RNGestureHandlerModule.ts"],"names":["RNGestureHandlerModule","NativeModules","console","error","split","map","line","trim","join"],"mappings":";;;;;;;AAAA;;AAEA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAA6BC,0BAAnC;;AAEA,IAAID,sBAAsB,IAAI,IAA9B,EAAoC;AAClCE,EAAAA,OAAO,CAACC,KAAR,CACE,uBACG;AACP;AACA,gIAFM,CAGGC,KAHH,CAGS,IAHT,EAIGC,GAJH,CAIQC,IAAD,IAAUA,IAAI,CAACC,IAAL,EAJjB,EAKGC,IALH,CAKQ,IALR,CADF,CADF;AAUD;;eAuBcR,sB","sourcesContent":["import { NativeModules } from 'react-native';\nimport { ActionType } from './ActionType';\nimport { tagMessage } from './utils';\nconst { RNGestureHandlerModule } = NativeModules;\n\nif (RNGestureHandlerModule == null) {\n console.error(\n tagMessage(\n `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 ..).\n\n For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`\n .split('\\n')\n .map((line) => line.trim())\n .join('\\n')\n )\n );\n}\n\nexport type RNGestureHandlerModuleProps = {\n handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;\n handleClearJSResponder: () => void;\n createGestureHandler: (\n handlerName: string,\n handlerTag: number,\n config: Readonly<Record<string, unknown>>\n ) => void;\n attachGestureHandler: (\n handlerTag: number,\n newView: number,\n actionType: ActionType\n ) => void;\n updateGestureHandler: (\n handlerTag: number,\n newConfig: Readonly<Record<string, unknown>>\n ) => void;\n dropGestureHandler: (handlerTag: number) => void;\n install: () => void;\n};\n\nexport default RNGestureHandlerModule as RNGestureHandlerModuleProps;\n"]}
|
|
@@ -59,7 +59,7 @@ var _default = {
|
|
|
59
59
|
this.updateGestureHandler(handlerTag, config);
|
|
60
60
|
},
|
|
61
61
|
|
|
62
|
-
attachGestureHandler(handlerTag, newView,
|
|
62
|
+
attachGestureHandler(handlerTag, newView, _actionType, propsRef) {
|
|
63
63
|
NodeManager.getHandler(handlerTag).setView(newView, propsRef);
|
|
64
64
|
},
|
|
65
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","
|
|
1
|
+
{"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["Gestures","PanGestureHandler","RotationGestureHandler","PinchGestureHandler","TapGestureHandler","NativeViewGestureHandler","LongPressGestureHandler","FlingGestureHandler","Direction","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","NodeManager","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","getHandler","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,iBAAiB,EAAjBA,0BADsB;AAEtBC,EAAAA,sBAAsB,EAAtBA,+BAFsB;AAGtBC,EAAAA,mBAAmB,EAAnBA,4BAHsB;AAItBC,EAAAA,iBAAiB,EAAjBA,0BAJsB;AAKtBC,EAAAA,wBAAwB,EAAxBA,iCALsB;AAMtBC,EAAAA,uBAAuB,EAAvBA,gCANsB;AAOtBC,EAAAA,mBAAmB,EAAnBA,4BAPsB,CAQtB;;AARsB,CAAjB;;eAWQ;AACbC,EAAAA,SAAS,EAATA,oBADa;;AAEbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAJY;;AAKbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GAPY;;AAQbE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA;AACA,QAAI,EAAEF,WAAW,IAAIhB,QAAjB,CAAJ,EACE,MAAM,IAAImB,KAAJ,CACH,iCAAgCH,WAAY,2BADzC,CAAN;AAGF,UAAMI,YAAY,GAAGpB,QAAQ,CAACgB,WAAD,CAA7B;AACAK,IAAAA,WAAW,CAACN,oBAAZ,CAAiCE,UAAjC,EAA6C,IAAIG,YAAJ,EAA7C;AACA,SAAKE,oBAAL,CAA0BL,UAA1B,EAAsCC,MAAtC;AACD,GArBY;;AAsBbK,EAAAA,oBAAoB,CAClBN,UADkB,EAElBO,OAFkB,EAGlBC,WAHkB,EAIlBC,QAJkB,EAKlB;AACAL,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCW,OAAnC,CAA2CJ,OAA3C,EAAoDE,QAApD;AACD,GA7BY;;AA8BbJ,EAAAA,oBAAoB,CAACL,UAAD,EAAqBY,SAArB,EAAqC;AACvDR,IAAAA,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,EAAmCa,mBAAnC,CAAuDD,SAAvD;AACD,GAhCY;;AAiCbE,EAAAA,qBAAqB,CAACd,UAAD,EAAqB;AACxC,WAAOI,WAAW,CAACM,UAAZ,CAAuBV,UAAvB,CAAP;AACD,GAnCY;;AAoCbe,EAAAA,kBAAkB,CAACf,UAAD,EAAqB;AACrCI,IAAAA,WAAW,CAACW,kBAAZ,CAA+Bf,UAA/B;AACD;;AAtCY,C","sourcesContent":["import { ActionType } from './ActionType';\nimport { Direction } from './web/constants';\nimport FlingGestureHandler from './web/FlingGestureHandler';\nimport LongPressGestureHandler from './web/LongPressGestureHandler';\nimport NativeViewGestureHandler from './web/NativeViewGestureHandler';\nimport * as NodeManager from './web/NodeManager';\nimport PanGestureHandler from './web/PanGestureHandler';\nimport PinchGestureHandler from './web/PinchGestureHandler';\nimport RotationGestureHandler from './web/RotationGestureHandler';\nimport TapGestureHandler from './web/TapGestureHandler';\n\nexport const Gestures = {\n PanGestureHandler,\n RotationGestureHandler,\n PinchGestureHandler,\n TapGestureHandler,\n NativeViewGestureHandler,\n LongPressGestureHandler,\n FlingGestureHandler,\n // ForceTouchGestureHandler,\n};\n\nexport default {\n Direction,\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n //TODO(TS) extends config\n if (!(handlerName in Gestures))\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(handlerTag, new GestureClass());\n this.updateGestureHandler(handlerTag, config);\n },\n attachGestureHandler(\n handlerTag: number,\n newView: number,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n NodeManager.getHandler(handlerTag).setView(newView, propsRef);\n },\n updateGestureHandler(handlerTag: number, newConfig: any) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n },\n getGestureHandlerNode(handlerTag: number) {\n return NodeManager.getHandler(handlerTag);\n },\n dropGestureHandler(handlerTag: number) {\n NodeManager.dropGestureHandler(handlerTag);\n },\n};\n"]}
|
|
@@ -321,7 +321,7 @@ class DrawerLayout extends React.Component {
|
|
|
321
321
|
|
|
322
322
|
_defineProperty(this, "openDrawer", (options = {}) => {
|
|
323
323
|
this.animateDrawer( // TODO: decide if it should be null or undefined is the proper value
|
|
324
|
-
undefined, this.props.drawerWidth, options.velocity ? options.velocity : 0); // We need to force the update, otherwise the overlay is not rerendered and
|
|
324
|
+
undefined, this.props.drawerWidth, options.velocity ? options.velocity : 0, options.speed); // We need to force the update, otherwise the overlay is not rerendered and
|
|
325
325
|
// it would not be clickable
|
|
326
326
|
|
|
327
327
|
this.forceUpdate();
|
|
@@ -329,7 +329,7 @@ class DrawerLayout extends React.Component {
|
|
|
329
329
|
|
|
330
330
|
_defineProperty(this, "closeDrawer", (options = {}) => {
|
|
331
331
|
// TODO: decide if it should be null or undefined is the proper value
|
|
332
|
-
this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0); // We need to force the update, otherwise the overlay is not rerendered and
|
|
332
|
+
this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0, options.speed); // We need to force the update, otherwise the overlay is not rerendered and
|
|
333
333
|
// it would be still clickable
|
|
334
334
|
|
|
335
335
|
this.forceUpdate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DrawerLayout.tsx"],"names":["DRAG_TOSS","IDLE","DRAGGING","SETTLING","DrawerLayout","Component","constructor","props","React","createRef","state","drawerPosition","drawerWidth","drawerType","dragX","dragXValue","touchX","touchXValue","drawerTranslation","containerWidth","Animated","multiply","Value","add","setValue","translationX","startPositionX","dragOffsetFromOnStartPosition","interpolate","inputRange","outputRange","openValue","extrapolate","gestureOptions","useNativeDriver","useNativeAnimations","onDrawerSlide","listener","ev","Math","floor","abs","nativeEvent","position","onGestureEvent","event","x","setState","layout","width","newState","drawerWillShow","onDrawerStateChanged","oldState","State","ACTIVE","handleRelease","emitStateChanged","keyboardDismissMode","Keyboard","dismiss","hideStatusBar","StatusBar","setHidden","statusBarAnimation","drawerShown","drawerLockMode","closeDrawer","velocityX","gestureStartX","dragOffsetBasedOnStart","startOffsetX","projOffsetX","shouldOpen","animateDrawer","showing","accessibilityIsModalView","current","setNativeProps","accessibilityViewIsModal","pointerEventsView","pointerEvents","minSwipeDistance","edgeWidth","fromLeft","gestureOrientation","hitSlop","left","undefined","right","panGestureHandler","activeOffsetX","fromValue","toValue","velocity","speed","nextFramePosition","min","max","willShow","updateShowing","spring","bounciness","start","finished","onDrawerOpen","onDrawerClose","options","forceUpdate","overlayOpacity","dynamicOverlayStyles","opacity","backgroundColor","overlayColor","onTapHandlerStateChange","styles","overlay","drawerBackgroundColor","drawerContainerStyle","contentContainerStyle","drawerSlide","containerSlide","reverseContentDirection","I18nManager","isRTL","dynamicDrawerStyles","containerStyles","containerTranslateX","transform","translateX","drawerTranslateX","closedDrawerOffset","drawerStyles","flexDirection","main","handleContainerLayout","containerOnBack","containerInFront","children","renderOverlay","drawerContainer","renderNavigationView","ref","onGestureRef","updateAnimatedEvent","UNSAFE_componentWillUpdate","render","setPanGestureRef","openingHandlerStateChange","enableTrackpadTwoFingerGesture","renderDrawer","Left","Right","StyleSheet","create","absoluteFillObject","zIndex","flex","overflow"],"mappings":";;;;;;;AAQA;;AAEA;;AACA;;AAkBA;;AAIA;;AAIA;;;;;;;;;;AAEA,MAAMA,SAAS,GAAG,IAAlB;AAEA,MAAMC,IAAiB,GAAG,MAA1B;AACA,MAAMC,QAAqB,GAAG,UAA9B;AACA,MAAMC,QAAqB,GAAG,UAA9B;;AAwHe,MAAMC,YAAN,SAA2BC,eAA3B,CAGb;AAaAC,EAAAA,WAAW,CAACC,MAAD,EAA2B;AACpC,UAAMA,MAAN;;AADoC;;AAAA;;AAAA,mEAmCHC,KAAK,CAACC,SAAN,EAnCG;;AAAA,4DAoCVD,KAAK,CAACC,SAAN,EApCU;;AAAA,4DAqCVD,KAAK,CAACC,SAAN,EArCU;;AAAA,yCAsChB,KAtCgB;;AAAA,iDA6CR,CAC5BF,KAD4B,EAE5BG,KAF4B,KAGzB;AACH;AACA,YAAM;AAAEC,QAAAA,cAAF;AAAkBC,QAAAA,WAAlB;AAA+BC,QAAAA;AAA/B,UAA8CN,KAApD;AACA,YAAM;AACJO,QAAAA,KAAK,EAAEC,UADH;AAEJC,QAAAA,MAAM,EAAEC,WAFJ;AAGJC,QAAAA,iBAHI;AAIJC,QAAAA;AAJI,UAKF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;;AAqcrB,MAAMrC,MAAM,GAAGsC,wBAAWC,MAAX,CAAkB;AAC/Bd,EAAAA,eAAe,EAAE,EACf,GAAGa,wBAAWE,kBADC;AAEfC,IAAAA,MAAM,EAAE,IAFO;AAGfvB,IAAAA,aAAa,EAAE;AAHA,GADc;AAM/BI,EAAAA,gBAAgB,EAAE,EAChB,GAAGgB,wBAAWE,kBADE;AAEhBC,IAAAA,MAAM,EAAE;AAFQ,GANa;AAU/BpB,EAAAA,eAAe,EAAE,EACf,GAAGiB,wBAAWE;AADC,GAVc;AAa/BrB,EAAAA,IAAI,EAAE;AACJuB,IAAAA,IAAI,EAAE,CADF;AAEJD,IAAAA,MAAM,EAAE,CAFJ;AAGJE,IAAAA,QAAQ,EAAE;AAHN,GAbyB;AAkB/B1C,EAAAA,OAAO,EAAE,EACP,GAAGqC,wBAAWE,kBADP;AAEPC,IAAAA,MAAM,EAAE;AAFD;AAlBsB,CAAlB,CAAf","sourcesContent":["// This component is based on RN's DrawerLayoutAndroid API\n//\n// It perhaps deserves to be put in a separate repo, but since it relies on\n// react-native-gesture-handler library which isn't very popular at the moment I\n// decided to keep it here for the time being. It will allow us to move faster\n// and fix issues that may arise in gesture handler library that could be found\n// when using the drawer component\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport invariant from 'invariant';\nimport {\n Animated,\n StyleSheet,\n View,\n Keyboard,\n StatusBar,\n I18nManager,\n StatusBarAnimation,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n NativeSyntheticEvent,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\nconst IDLE: DrawerState = 'Idle';\nconst DRAGGING: DrawerState = 'Dragging';\nconst SETTLING: DrawerState = 'Settling';\n\nexport type DrawerPosition = 'left' | 'right';\n\nexport type DrawerState = 'Idle' | 'Dragging' | 'Settling';\n\nexport type DrawerType = 'front' | 'back' | 'slide';\n\nexport type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';\n\nexport type DrawerKeyboardDismissMode = 'none' | 'on-drag';\n\nexport interface DrawerLayoutProps {\n /**\n * This attribute is present in the standard implementation already and is one\n * of the required params. Gesture handler version of DrawerLayout make it\n * possible for the function passed as `renderNavigationView` to take an\n * Animated value as a parameter that indicates the progress of drawer\n * opening/closing animation (progress value is 0 when closed and 1 when\n * opened). This can be used by the drawer component to animated its children\n * while the drawer is opening or closing.\n */\n renderNavigationView: (\n progressAnimatedValue: Animated.Value\n ) => React.ReactNode;\n\n drawerPosition?: DrawerPosition;\n\n drawerWidth?: number;\n\n drawerBackgroundColor?: string;\n\n drawerLockMode?: DrawerLockMode;\n\n keyboardDismissMode?: DrawerKeyboardDismissMode;\n\n /**\n * Called when the drawer is closed.\n */\n onDrawerClose?: () => void;\n\n /**\n * Called when the drawer is opened.\n */\n onDrawerOpen?: () => void;\n\n /**\n * Called when the status of the drawer changes.\n */\n onDrawerStateChanged?: (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => void;\n useNativeAnimations?: boolean;\n\n drawerType?: DrawerType;\n\n /**\n * Defines how far from the edge of the content view the gesture should\n * activate.\n */\n edgeWidth?: number;\n\n minSwipeDistance?: number;\n\n /**\n * When set to true Drawer component will use\n * {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS\n * status bar whenever the drawer is pulled or when its in an \"open\" state.\n */\n hideStatusBar?: boolean;\n\n /**\n * @default 'slide'\n *\n * Can be used when hideStatusBar is set to true and will select the animation\n * used for hiding/showing the status bar. See\n * {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for\n * more details\n */\n statusBarAnimation?: StatusBarAnimation;\n\n /**\n * @default black\n *\n * Color of a semi-transparent overlay to be displayed on top of the content\n * view when drawer gets open. A solid color should be used as the opacity is\n * added by the Drawer itself and the opacity of the overlay is animated (from\n * 0% to 70%).\n */\n overlayColor?: string;\n\n contentContainerStyle?: StyleProp<ViewStyle>;\n\n drawerContainerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n onDrawerSlide?: (position: number) => void;\n\n onGestureRef?: (ref: PanGestureHandler) => void;\n}\n\nexport type DrawerLayoutState = {\n dragX: Animated.Value;\n touchX: Animated.Value;\n drawerTranslation: Animated.Value;\n containerWidth: number;\n};\n\nexport type DrawerMovementOption = {\n velocity?: number;\n speed?: number;\n};\nexport default class DrawerLayout extends Component<\n DrawerLayoutProps,\n DrawerLayoutState\n> {\n static defaultProps = {\n drawerWidth: 200,\n drawerPosition: 'left',\n useNativeAnimations: true,\n drawerType: 'front',\n edgeWidth: 20,\n minSwipeDistance: 3,\n overlayColor: 'rgba(0, 0, 0, 0.7)',\n drawerLockMode: 'unlocked',\n enableTrackpadTwoFingerGesture: false,\n };\n\n constructor(props: DrawerLayoutProps) {\n super(props);\n\n const dragX = new Animated.Value(0);\n const touchX = new Animated.Value(0);\n const drawerTranslation = new Animated.Value(0);\n\n this.state = {\n dragX,\n touchX,\n drawerTranslation,\n containerWidth: 0,\n };\n\n this.updateAnimatedEvent(props, this.state);\n }\n\n UNSAFE_componentWillUpdate(\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) {\n if (\n this.props.drawerPosition !== props.drawerPosition ||\n this.props.drawerWidth !== props.drawerWidth ||\n this.props.drawerType !== props.drawerType ||\n this.state.containerWidth !== state.containerWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n }\n\n private openValue?: Animated.AnimatedInterpolation;\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private accessibilityIsModalView = React.createRef<View>();\n private pointerEventsView = React.createRef<View>();\n private panGestureHandler = React.createRef<PanGestureHandler | null>();\n private drawerShown = false;\n\n static positions = {\n Left: 'left',\n Right: 'right',\n };\n\n private updateAnimatedEvent = (\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) => {\n // Event definition is based on\n const { drawerPosition, drawerWidth, drawerType } = props;\n const {\n dragX: dragXValue,\n touchX: touchXValue,\n drawerTranslation,\n containerWidth,\n } = state;\n\n let dragX = dragXValue;\n let touchX = touchXValue;\n\n if (drawerPosition !== 'left') {\n // Most of the code is written in a way to handle left-side drawer. In\n // order to handle right-side drawer the only thing we need to do is to\n // reverse events coming from gesture handler in a way they emulate\n // left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is\n // calulcated by subtracing real touchX from the width of the container\n // (such that when touch happens at the right edge the value is simply 0)\n dragX = Animated.multiply(\n new Animated.Value(-1),\n dragXValue\n ) as Animated.Value; // TODO(TS): (for all \"as\" in this file) make sure we can map this\n touchX = Animated.add(\n new Animated.Value(containerWidth),\n Animated.multiply(new Animated.Value(-1), touchXValue)\n ) as Animated.Value; // TODO(TS): make sure we can map this;\n touchXValue.setValue(containerWidth);\n } else {\n touchXValue.setValue(0);\n }\n\n // While closing the drawer when user starts gesture outside of its area (in greyed\n // out part of the window), we want the drawer to follow only once finger reaches the\n // edge of the drawer.\n // E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by\n // dots. The touch gesture starts at '*' and moves left, touch path is indicated by\n // an arrow pointing left\n // 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // +---------------+ +---------------+ +---------------+ +---------------+\n //\n // For the above to work properly we define animated value that will keep\n // start position of the gesture. Then we use that value to calculate how\n // much we need to subtract from the dragX. If the gesture started on the\n // greyed out area we take the distance from the edge of the drawer to the\n // start position. Otherwise we don't subtract at all and the drawer be\n // pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n //\n let translationX = dragX;\n if (drawerType === 'front') {\n const startPositionX = Animated.add(\n touchX,\n Animated.multiply(new Animated.Value(-1), dragX)\n );\n\n const dragOffsetFromOnStartPosition = startPositionX.interpolate({\n inputRange: [drawerWidth! - 1, drawerWidth!, drawerWidth! + 1],\n outputRange: [0, 0, 1],\n });\n translationX = Animated.add(\n dragX,\n dragOffsetFromOnStartPosition\n ) as Animated.Value; // TODO: as above\n }\n\n this.openValue = Animated.add(translationX, drawerTranslation).interpolate({\n inputRange: [0, drawerWidth!],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n\n const gestureOptions: {\n useNativeDriver: boolean;\n // TODO: make sure it is correct\n listener?: (\n ev: NativeSyntheticEvent<PanGestureHandlerEventPayload>\n ) => void;\n } = {\n useNativeDriver: props.useNativeAnimations!,\n };\n\n if (this.props.onDrawerSlide) {\n gestureOptions.listener = (ev) => {\n const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));\n const position = translationX / this.state.containerWidth;\n\n this.props.onDrawerSlide?.(position);\n };\n }\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragXValue, x: touchXValue } }],\n gestureOptions\n );\n };\n\n private handleContainerLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ containerWidth: nativeEvent.layout.width });\n };\n\n private emitStateChanged = (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => {\n this.props.onDrawerStateChanged?.(newState, drawerWillShow);\n };\n\n private openingHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease({ nativeEvent });\n } else if (nativeEvent.state === State.ACTIVE) {\n this.emitStateChanged(DRAGGING, false);\n if (this.props.keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');\n }\n }\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (\n this.drawerShown &&\n nativeEvent.oldState === State.ACTIVE &&\n this.props.drawerLockMode !== 'locked-open'\n ) {\n this.closeDrawer();\n }\n };\n\n private handleRelease = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n const { drawerWidth, drawerPosition, drawerType } = this.props;\n const { containerWidth } = this.state;\n let { translationX: dragX, velocityX, x: touchX } = nativeEvent;\n\n if (drawerPosition !== 'left') {\n // See description in _updateAnimatedEvent about why events are flipped\n // for right-side drawer\n dragX = -dragX;\n touchX = containerWidth - touchX;\n velocityX = -velocityX;\n }\n\n const gestureStartX = touchX - dragX;\n let dragOffsetBasedOnStart = 0;\n\n if (drawerType === 'front') {\n dragOffsetBasedOnStart =\n gestureStartX > drawerWidth! ? gestureStartX - drawerWidth! : 0;\n }\n\n const startOffsetX =\n dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth! : 0);\n const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;\n\n const shouldOpen = projOffsetX > drawerWidth! / 2;\n\n if (shouldOpen) {\n this.animateDrawer(startOffsetX, drawerWidth!, velocityX);\n } else {\n this.animateDrawer(startOffsetX, 0, velocityX);\n }\n };\n\n private updateShowing = (showing: boolean) => {\n this.drawerShown = showing;\n this.accessibilityIsModalView.current?.setNativeProps({\n accessibilityViewIsModal: showing,\n });\n this.pointerEventsView.current?.setNativeProps({\n pointerEvents: showing ? 'auto' : 'none',\n });\n const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;\n const fromLeft = drawerPosition === 'left';\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: showing ? undefined : edgeWidth }\n : { right: 0, width: showing ? undefined : edgeWidth };\n // @ts-ignore internal API, maybe could be fixed in handler types\n this.panGestureHandler.current?.setNativeProps({\n hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance!,\n });\n };\n\n private animateDrawer = (\n fromValue: number | null | undefined,\n toValue: number,\n velocity: number,\n speed?: number\n ) => {\n this.state.dragX.setValue(0);\n this.state.touchX.setValue(\n this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth\n );\n\n if (fromValue != null) {\n let nextFramePosition = fromValue;\n if (this.props.useNativeAnimations) {\n // When using native driver, we predict the next position of the\n // animation because it takes one frame of a roundtrip to pass RELEASE\n // event from native driver to JS before we can start animating. Without\n // it, it is more noticable that the frame is dropped.\n if (fromValue < toValue && velocity > 0) {\n nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);\n } else if (fromValue > toValue && velocity < 0) {\n nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);\n }\n }\n this.state.drawerTranslation.setValue(nextFramePosition);\n }\n\n const willShow = toValue !== 0;\n this.updateShowing(willShow);\n this.emitStateChanged(SETTLING, willShow);\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');\n }\n Animated.spring(this.state.drawerTranslation, {\n velocity,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n speed: speed ?? undefined,\n }).start(({ finished }) => {\n if (finished) {\n this.emitStateChanged(IDLE, willShow);\n if (willShow) {\n this.props.onDrawerOpen?.();\n } else {\n this.props.onDrawerClose?.();\n }\n }\n });\n };\n\n openDrawer = (options: DrawerMovementOption = {}) => {\n this.animateDrawer(\n // TODO: decide if it should be null or undefined is the proper value\n undefined,\n this.props.drawerWidth!,\n options.velocity ? options.velocity : 0\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would not be clickable\n this.forceUpdate();\n };\n\n closeDrawer = (options: DrawerMovementOption = {}) => {\n // TODO: decide if it should be null or undefined is the proper value\n this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0);\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would be still clickable\n this.forceUpdate();\n };\n\n private renderOverlay = () => {\n /* Overlay styles */\n invariant(this.openValue, 'should be set');\n const overlayOpacity = this.openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n const dynamicOverlayStyles = {\n opacity: overlayOpacity,\n backgroundColor: this.props.overlayColor,\n };\n\n return (\n <TapGestureHandler onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={this.drawerShown ? 'auto' : 'none'}\n ref={this.pointerEventsView}\n style={[styles.overlay, dynamicOverlayStyles]}\n />\n </TapGestureHandler>\n );\n };\n\n private renderDrawer = () => {\n const {\n drawerBackgroundColor,\n drawerWidth,\n drawerPosition,\n drawerType,\n drawerContainerStyle,\n contentContainerStyle,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n const drawerSlide = drawerType !== 'back';\n const containerSlide = drawerType !== 'front';\n\n // we rely on row and row-reverse flex directions to position the drawer\n // properly. Apparently for RTL these are flipped which requires us to use\n // the opposite setting for the drawer to appear from left or right\n // according to the drawerPosition prop\n const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;\n\n const dynamicDrawerStyles = {\n backgroundColor: drawerBackgroundColor,\n width: drawerWidth,\n };\n const openValue = this.openValue;\n invariant(openValue, 'should be set');\n\n let containerStyles;\n if (containerSlide) {\n const containerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: fromLeft ? [0, drawerWidth!] : [0, -drawerWidth!],\n extrapolate: 'clamp',\n });\n containerStyles = {\n transform: [{ translateX: containerTranslateX }],\n };\n }\n\n let drawerTranslateX: number | Animated.AnimatedInterpolation = 0;\n if (drawerSlide) {\n const closedDrawerOffset = fromLeft ? -drawerWidth! : drawerWidth!;\n drawerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [closedDrawerOffset, 0],\n extrapolate: 'clamp',\n });\n }\n const drawerStyles: {\n transform: { translateX: number | Animated.AnimatedInterpolation }[];\n flexDirection: 'row-reverse' | 'row';\n } = {\n transform: [{ translateX: drawerTranslateX }],\n flexDirection: reverseContentDirection ? 'row-reverse' : 'row',\n };\n\n return (\n <Animated.View style={styles.main} onLayout={this.handleContainerLayout}>\n <Animated.View\n style={[\n drawerType === 'front'\n ? styles.containerOnBack\n : styles.containerInFront,\n containerStyles,\n contentContainerStyle,\n ]}\n importantForAccessibility={\n this.drawerShown ? 'no-hide-descendants' : 'yes'\n }>\n {typeof this.props.children === 'function'\n ? this.props.children(this.openValue)\n : this.props.children}\n {this.renderOverlay()}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n ref={this.accessibilityIsModalView}\n accessibilityViewIsModal={this.drawerShown}\n style={[styles.drawerContainer, drawerStyles, drawerContainerStyle]}>\n <View style={dynamicDrawerStyles}>\n {this.props.renderNavigationView(this.openValue as Animated.Value)}\n </View>\n </Animated.View>\n </Animated.View>\n );\n };\n\n private setPanGestureRef = (ref: PanGestureHandler) => {\n // TODO(TS): make sure it is OK taken from\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842\n (this\n .panGestureHandler as React.MutableRefObject<PanGestureHandler>).current = ref;\n this.props.onGestureRef?.(ref);\n };\n\n render() {\n const {\n drawerPosition,\n drawerLockMode,\n edgeWidth,\n minSwipeDistance,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: this.drawerShown ? undefined : edgeWidth }\n : { right: 0, width: this.drawerShown ? undefined : edgeWidth };\n\n return (\n <PanGestureHandler\n // @ts-ignore could be fixed in handler types\n ref={this.setPanGestureRef}\n hitSlop={hitSlop}\n activeOffsetX={gestureOrientation * minSwipeDistance!}\n failOffsetY={[-15, 15]}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.openingHandlerStateChange}\n enableTrackpadTwoFingerGesture={\n this.props.enableTrackpadTwoFingerGesture\n }\n enabled={\n drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'\n }>\n {this.renderDrawer()}\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n drawerContainer: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1001,\n flexDirection: 'row',\n },\n containerInFront: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1002,\n },\n containerOnBack: {\n ...StyleSheet.absoluteFillObject,\n },\n main: {\n flex: 1,\n zIndex: 0,\n overflow: 'hidden',\n },\n overlay: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1000,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["DrawerLayout.tsx"],"names":["DRAG_TOSS","IDLE","DRAGGING","SETTLING","DrawerLayout","Component","constructor","props","React","createRef","state","drawerPosition","drawerWidth","drawerType","dragX","dragXValue","touchX","touchXValue","drawerTranslation","containerWidth","Animated","multiply","Value","add","setValue","translationX","startPositionX","dragOffsetFromOnStartPosition","interpolate","inputRange","outputRange","openValue","extrapolate","gestureOptions","useNativeDriver","useNativeAnimations","onDrawerSlide","listener","ev","Math","floor","abs","nativeEvent","position","onGestureEvent","event","x","setState","layout","width","newState","drawerWillShow","onDrawerStateChanged","oldState","State","ACTIVE","handleRelease","emitStateChanged","keyboardDismissMode","Keyboard","dismiss","hideStatusBar","StatusBar","setHidden","statusBarAnimation","drawerShown","drawerLockMode","closeDrawer","velocityX","gestureStartX","dragOffsetBasedOnStart","startOffsetX","projOffsetX","shouldOpen","animateDrawer","showing","accessibilityIsModalView","current","setNativeProps","accessibilityViewIsModal","pointerEventsView","pointerEvents","minSwipeDistance","edgeWidth","fromLeft","gestureOrientation","hitSlop","left","undefined","right","panGestureHandler","activeOffsetX","fromValue","toValue","velocity","speed","nextFramePosition","min","max","willShow","updateShowing","spring","bounciness","start","finished","onDrawerOpen","onDrawerClose","options","forceUpdate","overlayOpacity","dynamicOverlayStyles","opacity","backgroundColor","overlayColor","onTapHandlerStateChange","styles","overlay","drawerBackgroundColor","drawerContainerStyle","contentContainerStyle","drawerSlide","containerSlide","reverseContentDirection","I18nManager","isRTL","dynamicDrawerStyles","containerStyles","containerTranslateX","transform","translateX","drawerTranslateX","closedDrawerOffset","drawerStyles","flexDirection","main","handleContainerLayout","containerOnBack","containerInFront","children","renderOverlay","drawerContainer","renderNavigationView","ref","onGestureRef","updateAnimatedEvent","UNSAFE_componentWillUpdate","render","setPanGestureRef","openingHandlerStateChange","enableTrackpadTwoFingerGesture","renderDrawer","Left","Right","StyleSheet","create","absoluteFillObject","zIndex","flex","overflow"],"mappings":";;;;;;;AAQA;;AAEA;;AACA;;AAkBA;;AAIA;;AAIA;;;;;;;;;;AAEA,MAAMA,SAAS,GAAG,IAAlB;AAEA,MAAMC,IAAiB,GAAG,MAA1B;AACA,MAAMC,QAAqB,GAAG,UAA9B;AACA,MAAMC,QAA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deserves to be put in a separate repo, but since it relies on\n// react-native-gesture-handler library which isn't very popular at the moment I\n// decided to keep it here for the time being. It will allow us to move faster\n// and fix issues that may arise in gesture handler library that could be found\n// when using the drawer component\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport invariant from 'invariant';\nimport {\n Animated,\n StyleSheet,\n View,\n Keyboard,\n StatusBar,\n I18nManager,\n StatusBarAnimation,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n NativeSyntheticEvent,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\nconst IDLE: DrawerState = 'Idle';\nconst DRAGGING: DrawerState = 'Dragging';\nconst SETTLING: DrawerState = 'Settling';\n\nexport type DrawerPosition = 'left' | 'right';\n\nexport type DrawerState = 'Idle' | 'Dragging' | 'Settling';\n\nexport type DrawerType = 'front' | 'back' | 'slide';\n\nexport type DrawerLockMode = 'unlocked' | 'locked-closed' | 'locked-open';\n\nexport type DrawerKeyboardDismissMode = 'none' | 'on-drag';\n\nexport interface DrawerLayoutProps {\n /**\n * This attribute is present in the standard implementation already and is one\n * of the required params. Gesture handler version of DrawerLayout make it\n * possible for the function passed as `renderNavigationView` to take an\n * Animated value as a parameter that indicates the progress of drawer\n * opening/closing animation (progress value is 0 when closed and 1 when\n * opened). This can be used by the drawer component to animated its children\n * while the drawer is opening or closing.\n */\n renderNavigationView: (\n progressAnimatedValue: Animated.Value\n ) => React.ReactNode;\n\n drawerPosition?: DrawerPosition;\n\n drawerWidth?: number;\n\n drawerBackgroundColor?: string;\n\n drawerLockMode?: DrawerLockMode;\n\n keyboardDismissMode?: DrawerKeyboardDismissMode;\n\n /**\n * Called when the drawer is closed.\n */\n onDrawerClose?: () => void;\n\n /**\n * Called when the drawer is opened.\n */\n onDrawerOpen?: () => void;\n\n /**\n * Called when the status of the drawer changes.\n */\n onDrawerStateChanged?: (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => void;\n useNativeAnimations?: boolean;\n\n drawerType?: DrawerType;\n\n /**\n * Defines how far from the edge of the content view the gesture should\n * activate.\n */\n edgeWidth?: number;\n\n minSwipeDistance?: number;\n\n /**\n * When set to true Drawer component will use\n * {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS\n * status bar whenever the drawer is pulled or when its in an \"open\" state.\n */\n hideStatusBar?: boolean;\n\n /**\n * @default 'slide'\n *\n * Can be used when hideStatusBar is set to true and will select the animation\n * used for hiding/showing the status bar. See\n * {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for\n * more details\n */\n statusBarAnimation?: StatusBarAnimation;\n\n /**\n * @default black\n *\n * Color of a semi-transparent overlay to be displayed on top of the content\n * view when drawer gets open. A solid color should be used as the opacity is\n * added by the Drawer itself and the opacity of the overlay is animated (from\n * 0% to 70%).\n */\n overlayColor?: string;\n\n contentContainerStyle?: StyleProp<ViewStyle>;\n\n drawerContainerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n onDrawerSlide?: (position: number) => void;\n\n onGestureRef?: (ref: PanGestureHandler) => void;\n}\n\nexport type DrawerLayoutState = {\n dragX: Animated.Value;\n touchX: Animated.Value;\n drawerTranslation: Animated.Value;\n containerWidth: number;\n};\n\nexport type DrawerMovementOption = {\n velocity?: number;\n speed?: number;\n};\nexport default class DrawerLayout extends Component<\n DrawerLayoutProps,\n DrawerLayoutState\n> {\n static defaultProps = {\n drawerWidth: 200,\n drawerPosition: 'left',\n useNativeAnimations: true,\n drawerType: 'front',\n edgeWidth: 20,\n minSwipeDistance: 3,\n overlayColor: 'rgba(0, 0, 0, 0.7)',\n drawerLockMode: 'unlocked',\n enableTrackpadTwoFingerGesture: false,\n };\n\n constructor(props: DrawerLayoutProps) {\n super(props);\n\n const dragX = new Animated.Value(0);\n const touchX = new Animated.Value(0);\n const drawerTranslation = new Animated.Value(0);\n\n this.state = {\n dragX,\n touchX,\n drawerTranslation,\n containerWidth: 0,\n };\n\n this.updateAnimatedEvent(props, this.state);\n }\n\n UNSAFE_componentWillUpdate(\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) {\n if (\n this.props.drawerPosition !== props.drawerPosition ||\n this.props.drawerWidth !== props.drawerWidth ||\n this.props.drawerType !== props.drawerType ||\n this.state.containerWidth !== state.containerWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n }\n\n private openValue?: Animated.AnimatedInterpolation;\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private accessibilityIsModalView = React.createRef<View>();\n private pointerEventsView = React.createRef<View>();\n private panGestureHandler = React.createRef<PanGestureHandler | null>();\n private drawerShown = false;\n\n static positions = {\n Left: 'left',\n Right: 'right',\n };\n\n private updateAnimatedEvent = (\n props: DrawerLayoutProps,\n state: DrawerLayoutState\n ) => {\n // Event definition is based on\n const { drawerPosition, drawerWidth, drawerType } = props;\n const {\n dragX: dragXValue,\n touchX: touchXValue,\n drawerTranslation,\n containerWidth,\n } = state;\n\n let dragX = dragXValue;\n let touchX = touchXValue;\n\n if (drawerPosition !== 'left') {\n // Most of the code is written in a way to handle left-side drawer. In\n // order to handle right-side drawer the only thing we need to do is to\n // reverse events coming from gesture handler in a way they emulate\n // left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is\n // calulcated by subtracing real touchX from the width of the container\n // (such that when touch happens at the right edge the value is simply 0)\n dragX = Animated.multiply(\n new Animated.Value(-1),\n dragXValue\n ) as Animated.Value; // TODO(TS): (for all \"as\" in this file) make sure we can map this\n touchX = Animated.add(\n new Animated.Value(containerWidth),\n Animated.multiply(new Animated.Value(-1), touchXValue)\n ) as Animated.Value; // TODO(TS): make sure we can map this;\n touchXValue.setValue(containerWidth);\n } else {\n touchXValue.setValue(0);\n }\n\n // While closing the drawer when user starts gesture outside of its area (in greyed\n // out part of the window), we want the drawer to follow only once finger reaches the\n // edge of the drawer.\n // E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by\n // dots. The touch gesture starts at '*' and moves left, touch path is indicated by\n // an arrow pointing left\n // 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|\n // +---------------+ +---------------+ +---------------+ +---------------+\n //\n // For the above to work properly we define animated value that will keep\n // start position of the gesture. Then we use that value to calculate how\n // much we need to subtract from the dragX. If the gesture started on the\n // greyed out area we take the distance from the edge of the drawer to the\n // start position. Otherwise we don't subtract at all and the drawer be\n // pulled back as soon as you start the pan.\n //\n // This is used only when drawerType is \"front\"\n //\n let translationX = dragX;\n if (drawerType === 'front') {\n const startPositionX = Animated.add(\n touchX,\n Animated.multiply(new Animated.Value(-1), dragX)\n );\n\n const dragOffsetFromOnStartPosition = startPositionX.interpolate({\n inputRange: [drawerWidth! - 1, drawerWidth!, drawerWidth! + 1],\n outputRange: [0, 0, 1],\n });\n translationX = Animated.add(\n dragX,\n dragOffsetFromOnStartPosition\n ) as Animated.Value; // TODO: as above\n }\n\n this.openValue = Animated.add(translationX, drawerTranslation).interpolate({\n inputRange: [0, drawerWidth!],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n\n const gestureOptions: {\n useNativeDriver: boolean;\n // TODO: make sure it is correct\n listener?: (\n ev: NativeSyntheticEvent<PanGestureHandlerEventPayload>\n ) => void;\n } = {\n useNativeDriver: props.useNativeAnimations!,\n };\n\n if (this.props.onDrawerSlide) {\n gestureOptions.listener = (ev) => {\n const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));\n const position = translationX / this.state.containerWidth;\n\n this.props.onDrawerSlide?.(position);\n };\n }\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragXValue, x: touchXValue } }],\n gestureOptions\n );\n };\n\n private handleContainerLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ containerWidth: nativeEvent.layout.width });\n };\n\n private emitStateChanged = (\n newState: DrawerState,\n drawerWillShow: boolean\n ) => {\n this.props.onDrawerStateChanged?.(newState, drawerWillShow);\n };\n\n private openingHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease({ nativeEvent });\n } else if (nativeEvent.state === State.ACTIVE) {\n this.emitStateChanged(DRAGGING, false);\n if (this.props.keyboardDismissMode === 'on-drag') {\n Keyboard.dismiss();\n }\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');\n }\n }\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (\n this.drawerShown &&\n nativeEvent.oldState === State.ACTIVE &&\n this.props.drawerLockMode !== 'locked-open'\n ) {\n this.closeDrawer();\n }\n };\n\n private handleRelease = ({\n nativeEvent,\n }: HandlerStateChangeEvent<PanGestureHandlerEventPayload>) => {\n const { drawerWidth, drawerPosition, drawerType } = this.props;\n const { containerWidth } = this.state;\n let { translationX: dragX, velocityX, x: touchX } = nativeEvent;\n\n if (drawerPosition !== 'left') {\n // See description in _updateAnimatedEvent about why events are flipped\n // for right-side drawer\n dragX = -dragX;\n touchX = containerWidth - touchX;\n velocityX = -velocityX;\n }\n\n const gestureStartX = touchX - dragX;\n let dragOffsetBasedOnStart = 0;\n\n if (drawerType === 'front') {\n dragOffsetBasedOnStart =\n gestureStartX > drawerWidth! ? gestureStartX - drawerWidth! : 0;\n }\n\n const startOffsetX =\n dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth! : 0);\n const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;\n\n const shouldOpen = projOffsetX > drawerWidth! / 2;\n\n if (shouldOpen) {\n this.animateDrawer(startOffsetX, drawerWidth!, velocityX);\n } else {\n this.animateDrawer(startOffsetX, 0, velocityX);\n }\n };\n\n private updateShowing = (showing: boolean) => {\n this.drawerShown = showing;\n this.accessibilityIsModalView.current?.setNativeProps({\n accessibilityViewIsModal: showing,\n });\n this.pointerEventsView.current?.setNativeProps({\n pointerEvents: showing ? 'auto' : 'none',\n });\n const { drawerPosition, minSwipeDistance, edgeWidth } = this.props;\n const fromLeft = drawerPosition === 'left';\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: showing ? undefined : edgeWidth }\n : { right: 0, width: showing ? undefined : edgeWidth };\n // @ts-ignore internal API, maybe could be fixed in handler types\n this.panGestureHandler.current?.setNativeProps({\n hitSlop,\n activeOffsetX: gestureOrientation * minSwipeDistance!,\n });\n };\n\n private animateDrawer = (\n fromValue: number | null | undefined,\n toValue: number,\n velocity: number,\n speed?: number\n ) => {\n this.state.dragX.setValue(0);\n this.state.touchX.setValue(\n this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth\n );\n\n if (fromValue != null) {\n let nextFramePosition = fromValue;\n if (this.props.useNativeAnimations) {\n // When using native driver, we predict the next position of the\n // animation because it takes one frame of a roundtrip to pass RELEASE\n // event from native driver to JS before we can start animating. Without\n // it, it is more noticable that the frame is dropped.\n if (fromValue < toValue && velocity > 0) {\n nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);\n } else if (fromValue > toValue && velocity < 0) {\n nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);\n }\n }\n this.state.drawerTranslation.setValue(nextFramePosition);\n }\n\n const willShow = toValue !== 0;\n this.updateShowing(willShow);\n this.emitStateChanged(SETTLING, willShow);\n if (this.props.hideStatusBar) {\n StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');\n }\n Animated.spring(this.state.drawerTranslation, {\n velocity,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n speed: speed ?? undefined,\n }).start(({ finished }) => {\n if (finished) {\n this.emitStateChanged(IDLE, willShow);\n if (willShow) {\n this.props.onDrawerOpen?.();\n } else {\n this.props.onDrawerClose?.();\n }\n }\n });\n };\n\n openDrawer = (options: DrawerMovementOption = {}) => {\n this.animateDrawer(\n // TODO: decide if it should be null or undefined is the proper value\n undefined,\n this.props.drawerWidth!,\n options.velocity ? options.velocity : 0,\n options.speed\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would not be clickable\n this.forceUpdate();\n };\n\n closeDrawer = (options: DrawerMovementOption = {}) => {\n // TODO: decide if it should be null or undefined is the proper value\n this.animateDrawer(\n undefined,\n 0,\n options.velocity ? options.velocity : 0,\n options.speed\n );\n\n // We need to force the update, otherwise the overlay is not rerendered and\n // it would be still clickable\n this.forceUpdate();\n };\n\n private renderOverlay = () => {\n /* Overlay styles */\n invariant(this.openValue, 'should be set');\n const overlayOpacity = this.openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [0, 1],\n extrapolate: 'clamp',\n });\n const dynamicOverlayStyles = {\n opacity: overlayOpacity,\n backgroundColor: this.props.overlayColor,\n };\n\n return (\n <TapGestureHandler onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={this.drawerShown ? 'auto' : 'none'}\n ref={this.pointerEventsView}\n style={[styles.overlay, dynamicOverlayStyles]}\n />\n </TapGestureHandler>\n );\n };\n\n private renderDrawer = () => {\n const {\n drawerBackgroundColor,\n drawerWidth,\n drawerPosition,\n drawerType,\n drawerContainerStyle,\n contentContainerStyle,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n const drawerSlide = drawerType !== 'back';\n const containerSlide = drawerType !== 'front';\n\n // we rely on row and row-reverse flex directions to position the drawer\n // properly. Apparently for RTL these are flipped which requires us to use\n // the opposite setting for the drawer to appear from left or right\n // according to the drawerPosition prop\n const reverseContentDirection = I18nManager.isRTL ? fromLeft : !fromLeft;\n\n const dynamicDrawerStyles = {\n backgroundColor: drawerBackgroundColor,\n width: drawerWidth,\n };\n const openValue = this.openValue;\n invariant(openValue, 'should be set');\n\n let containerStyles;\n if (containerSlide) {\n const containerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: fromLeft ? [0, drawerWidth!] : [0, -drawerWidth!],\n extrapolate: 'clamp',\n });\n containerStyles = {\n transform: [{ translateX: containerTranslateX }],\n };\n }\n\n let drawerTranslateX: number | Animated.AnimatedInterpolation = 0;\n if (drawerSlide) {\n const closedDrawerOffset = fromLeft ? -drawerWidth! : drawerWidth!;\n drawerTranslateX = openValue.interpolate({\n inputRange: [0, 1],\n outputRange: [closedDrawerOffset, 0],\n extrapolate: 'clamp',\n });\n }\n const drawerStyles: {\n transform: { translateX: number | Animated.AnimatedInterpolation }[];\n flexDirection: 'row-reverse' | 'row';\n } = {\n transform: [{ translateX: drawerTranslateX }],\n flexDirection: reverseContentDirection ? 'row-reverse' : 'row',\n };\n\n return (\n <Animated.View style={styles.main} onLayout={this.handleContainerLayout}>\n <Animated.View\n style={[\n drawerType === 'front'\n ? styles.containerOnBack\n : styles.containerInFront,\n containerStyles,\n contentContainerStyle,\n ]}\n importantForAccessibility={\n this.drawerShown ? 'no-hide-descendants' : 'yes'\n }>\n {typeof this.props.children === 'function'\n ? this.props.children(this.openValue)\n : this.props.children}\n {this.renderOverlay()}\n </Animated.View>\n <Animated.View\n pointerEvents=\"box-none\"\n ref={this.accessibilityIsModalView}\n accessibilityViewIsModal={this.drawerShown}\n style={[styles.drawerContainer, drawerStyles, drawerContainerStyle]}>\n <View style={dynamicDrawerStyles}>\n {this.props.renderNavigationView(this.openValue as Animated.Value)}\n </View>\n </Animated.View>\n </Animated.View>\n );\n };\n\n private setPanGestureRef = (ref: PanGestureHandler) => {\n // TODO(TS): make sure it is OK taken from\n // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842\n (this\n .panGestureHandler as React.MutableRefObject<PanGestureHandler>).current = ref;\n this.props.onGestureRef?.(ref);\n };\n\n render() {\n const {\n drawerPosition,\n drawerLockMode,\n edgeWidth,\n minSwipeDistance,\n } = this.props;\n\n const fromLeft = drawerPosition === 'left';\n\n // gestureOrientation is 1 if the expected gesture is from left to right and\n // -1 otherwise e.g. when drawer is on the left and is closed we expect left\n // to right gesture, thus orientation will be 1.\n const gestureOrientation =\n (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1);\n\n // When drawer is closed we want the hitSlop to be horizontally shorter than\n // the container size by the value of SLOP. This will make it only activate\n // when gesture happens not further than SLOP away from the edge\n const hitSlop = fromLeft\n ? { left: 0, width: this.drawerShown ? undefined : edgeWidth }\n : { right: 0, width: this.drawerShown ? undefined : edgeWidth };\n\n return (\n <PanGestureHandler\n // @ts-ignore could be fixed in handler types\n ref={this.setPanGestureRef}\n hitSlop={hitSlop}\n activeOffsetX={gestureOrientation * minSwipeDistance!}\n failOffsetY={[-15, 15]}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.openingHandlerStateChange}\n enableTrackpadTwoFingerGesture={\n this.props.enableTrackpadTwoFingerGesture\n }\n enabled={\n drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'\n }>\n {this.renderDrawer()}\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n drawerContainer: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1001,\n flexDirection: 'row',\n },\n containerInFront: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1002,\n },\n containerOnBack: {\n ...StyleSheet.absoluteFillObject,\n },\n main: {\n flex: 1,\n zIndex: 0,\n overflow: 'hidden',\n },\n overlay: {\n ...StyleSheet.absoluteFillObject,\n zIndex: 1000,\n },\n});\n"]}
|
|
@@ -7,7 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
13
|
+
const RNGestureHandlerButtonNativeComponent = (0, _utils.isFabric)() ? require('../fabric/RNGestureHandlerButtonNativeComponent').default : (0, _reactNative.requireNativeComponent)('RNGestureHandlerButton');
|
|
14
|
+
var _default = RNGestureHandlerButtonNativeComponent;
|
|
12
15
|
exports.default = _default;
|
|
13
16
|
//# sourceMappingURL=GestureHandlerButton.js.map
|