react-native-gesture-handler 1.10.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/DrawerLayout/package.json +3 -3
- package/README.md +7 -6
- package/Swipeable/package.json +3 -3
- package/android/build.gradle +23 -1
- package/android/gradle.properties +19 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +710 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +562 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +289 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +88 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +79 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
- package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
- package/ios/Handlers/RNFlingHandler.m +78 -5
- package/ios/Handlers/RNForceTouchHandler.m +29 -4
- package/ios/Handlers/RNLongPressHandler.m +105 -3
- package/ios/Handlers/RNManualHandler.h +4 -0
- package/ios/Handlers/RNManualHandler.m +73 -0
- package/ios/Handlers/RNNativeViewHandler.m +30 -2
- package/ios/Handlers/RNPanHandler.m +64 -4
- package/ios/Handlers/RNPinchHandler.m +61 -2
- package/ios/Handlers/RNRotationHandler.m +60 -1
- package/ios/Handlers/RNTapHandler.m +55 -8
- package/ios/RNGestureHandler.h +18 -4
- package/ios/RNGestureHandler.m +123 -13
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/RNGestureHandler.xcscheme +80 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/xcschememanagement.plist +27 -0
- package/ios/RNGestureHandlerEvents.h +9 -0
- package/ios/RNGestureHandlerEvents.m +34 -0
- package/ios/RNGestureHandlerManager.h +7 -0
- package/ios/RNGestureHandlerManager.m +62 -34
- package/ios/RNGestureHandlerModule.m +39 -3
- package/ios/RNGestureHandlerPointerTracker.h +25 -0
- package/ios/RNGestureHandlerPointerTracker.m +237 -0
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/RNManualActivationRecognizer.h +10 -0
- package/ios/RNManualActivationRecognizer.m +80 -0
- package/ios/RNRootViewGestureRecognizer.m +1 -1
- package/ios/RNTouchEventType.h +9 -0
- package/jestSetup.js +7 -0
- package/lib/commonjs/Directions.js +15 -0
- package/lib/commonjs/Directions.js.map +1 -0
- package/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +24 -0
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.js +20 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -0
- package/lib/commonjs/PlatformConstants.js +15 -0
- package/lib/commonjs/PlatformConstants.js.map +1 -0
- package/lib/commonjs/PlatformConstants.web.js +14 -0
- package/lib/commonjs/PlatformConstants.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +22 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js +80 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/commonjs/State.js +18 -0
- package/lib/commonjs/State.js.map +1 -0
- package/lib/commonjs/components/DrawerLayout.js +535 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js +207 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +76 -0
- package/lib/commonjs/components/GestureComponents.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.web.js +46 -0
- package/lib/commonjs/components/GestureComponents.web.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -0
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js +24 -0
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/commonjs/components/Swipeable.js +365 -0
- package/lib/commonjs/components/Swipeable.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +278 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js +109 -0
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +100 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js +12 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js +75 -0
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +26 -0
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/lib/commonjs/components/touchables/index.js +40 -0
- package/lib/commonjs/components/touchables/index.js.map +1 -0
- package/lib/commonjs/gestureHandlerRootHOC.js +39 -0
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
- package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +25 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
- package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
- package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
- package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +373 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -0
- package/lib/commonjs/handlers/createNativeWrapper.js +70 -0
- package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/commonjs/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +415 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +112 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +39 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +177 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/panGesture.js +116 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js +19 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/commonjs/handlers/handlersRegistry.js +31 -0
- package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
- package/lib/commonjs/index.js +338 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +64 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/typeUtils.js +2 -0
- package/lib/commonjs/typeUtils.js.map +1 -0
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js +105 -0
- package/lib/commonjs/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/DraggingGestureHandler.js +53 -0
- package/lib/commonjs/web/DraggingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/Errors.js +16 -0
- package/lib/commonjs/web/Errors.js.map +1 -0
- package/lib/commonjs/web/FlingGestureHandler.js +170 -0
- package/lib/commonjs/web/FlingGestureHandler.js.map +1 -0
- package/lib/commonjs/web/GestureHandler.js +533 -0
- package/lib/commonjs/web/GestureHandler.js.map +1 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js +54 -0
- package/lib/commonjs/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/commonjs/web/LongPressGestureHandler.js +71 -0
- package/lib/commonjs/web/LongPressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js +62 -0
- package/lib/commonjs/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web/NodeManager.js +43 -0
- package/lib/commonjs/web/NodeManager.js.map +1 -0
- package/lib/commonjs/web/PanGestureHandler.js +189 -0
- package/lib/commonjs/web/PanGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PinchGestureHandler.js +40 -0
- package/lib/commonjs/web/PinchGestureHandler.js.map +1 -0
- package/lib/commonjs/web/PressGestureHandler.js +188 -0
- package/lib/commonjs/web/PressGestureHandler.js.map +1 -0
- package/lib/commonjs/web/RotationGestureHandler.js +44 -0
- package/lib/commonjs/web/RotationGestureHandler.js.map +1 -0
- package/lib/commonjs/web/TapGestureHandler.js +192 -0
- package/lib/commonjs/web/TapGestureHandler.js.map +1 -0
- package/lib/commonjs/web/constants.js +64 -0
- package/lib/commonjs/web/constants.js.map +1 -0
- package/lib/commonjs/web/utils.js +42 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/module/Directions.js +7 -0
- package/lib/module/Directions.js.map +1 -0
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +10 -0
- package/lib/module/GestureHandlerRootView.android.js.map +1 -0
- package/lib/module/GestureHandlerRootView.js +7 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -0
- package/lib/module/PlatformConstants.js +5 -0
- package/lib/module/PlatformConstants.js.map +1 -0
- package/lib/module/PlatformConstants.web.js +7 -0
- package/lib/module/PlatformConstants.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +13 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.web.js +56 -0
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -0
- package/lib/module/State.js +10 -0
- package/lib/module/State.js.map +1 -0
- package/lib/module/components/DrawerLayout.js +520 -0
- package/lib/module/components/DrawerLayout.js.map +1 -0
- package/lib/module/components/GestureButtons.js +172 -0
- package/lib/module/components/GestureButtons.js.map +1 -0
- package/lib/module/components/GestureComponents.js +53 -0
- package/lib/module/components/GestureComponents.js.map +1 -0
- package/lib/module/components/GestureComponents.web.js +25 -0
- package/lib/module/components/GestureComponents.web.js.map +1 -0
- package/{dist/src → lib/module}/components/GestureHandlerButton.js +1 -0
- package/lib/module/components/GestureHandlerButton.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.web.js +9 -0
- package/lib/module/components/GestureHandlerButton.web.js.map +1 -0
- package/lib/module/components/Swipeable.js +347 -0
- package/lib/module/components/Swipeable.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js +262 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -0
- package/lib/module/components/touchables/TouchableHighlight.js +95 -0
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +84 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/TouchableNativeFeedback.js +1 -0
- package/lib/module/components/touchables/TouchableNativeFeedback.js.map +1 -0
- package/lib/module/components/touchables/TouchableOpacity.js +61 -0
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +10 -0
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -0
- package/{dist/src → lib/module}/components/touchables/index.js +1 -0
- package/lib/module/components/touchables/index.js.map +1 -0
- package/lib/module/gestureHandlerRootHOC.js +21 -0
- package/lib/module/gestureHandlerRootHOC.js.map +1 -0
- package/lib/module/handlers/FlingGestureHandler.js +10 -0
- package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
- package/lib/module/handlers/LongPressGestureHandler.js +10 -0
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
- package/lib/module/handlers/NativeViewGestureHandler.js +11 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/handlers/PanGestureHandler.js +106 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -0
- package/lib/module/handlers/PinchGestureHandler.js +9 -0
- package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
- package/lib/module/handlers/RotationGestureHandler.js +9 -0
- package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
- package/lib/module/handlers/TapGestureHandler.js +10 -0
- package/lib/module/handlers/TapGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +348 -0
- package/lib/module/handlers/createHandler.js.map +1 -0
- package/lib/module/handlers/createNativeWrapper.js +58 -0
- package/lib/module/handlers/createNativeWrapper.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js +2 -0
- package/lib/module/handlers/gestureHandlerTypesCompat.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +378 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +97 -0
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
- package/lib/module/handlers/gestures/flingGesture.js +24 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js +29 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +159 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +79 -0
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
- package/lib/module/handlers/gestures/longPressGesture.js +24 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
- package/lib/module/handlers/gestures/manualGesture.js +9 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
- package/lib/module/handlers/gestures/nativeGesture.js +24 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/handlers/gestures/panGesture.js +106 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +9 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
- package/lib/module/handlers/gestures/rotationGesture.js +9 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
- package/lib/module/handlers/gestures/tapGesture.js +49 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
- package/lib/module/handlers/handlersRegistry.js +16 -0
- package/lib/module/handlers/handlersRegistry.js.map +1 -0
- package/lib/module/index.js +34 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +54 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/typeUtils.js +2 -0
- package/lib/module/typeUtils.js.map +1 -0
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/DiscreteGestureHandler.js +94 -0
- package/lib/module/web/DiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/DraggingGestureHandler.js +40 -0
- package/lib/module/web/DraggingGestureHandler.js.map +1 -0
- package/lib/module/web/Errors.js +7 -0
- package/lib/module/web/Errors.js.map +1 -0
- package/lib/module/web/FlingGestureHandler.js +156 -0
- package/lib/module/web/FlingGestureHandler.js.map +1 -0
- package/lib/module/web/GestureHandler.js +518 -0
- package/lib/module/web/GestureHandler.js.map +1 -0
- package/lib/module/web/IndiscreteGestureHandler.js +44 -0
- package/lib/module/web/IndiscreteGestureHandler.js.map +1 -0
- package/lib/module/web/LongPressGestureHandler.js +58 -0
- package/lib/module/web/LongPressGestureHandler.js.map +1 -0
- package/lib/module/web/NativeViewGestureHandler.js +45 -0
- package/lib/module/web/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web/NodeManager.js +30 -0
- package/lib/module/web/NodeManager.js.map +1 -0
- package/lib/module/web/PanGestureHandler.js +175 -0
- package/lib/module/web/PanGestureHandler.js.map +1 -0
- package/lib/module/web/PinchGestureHandler.js +29 -0
- package/lib/module/web/PinchGestureHandler.js.map +1 -0
- package/lib/module/web/PressGestureHandler.js +174 -0
- package/lib/module/web/PressGestureHandler.js.map +1 -0
- package/lib/module/web/RotationGestureHandler.js +32 -0
- package/lib/module/web/RotationGestureHandler.js.map +1 -0
- package/lib/module/web/TapGestureHandler.js +180 -0
- package/lib/module/web/TapGestureHandler.js.map +1 -0
- package/lib/module/web/constants.js +43 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/utils.js +19 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/typescript/Directions.d.ts +7 -0
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -0
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -0
- package/{dist/src → lib/typescript}/PlatformConstants.d.ts +0 -0
- package/{dist/src → lib/typescript}/PlatformConstants.web.d.ts +0 -0
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.d.ts +1 -8
- package/{dist/src → lib/typescript}/RNGestureHandlerModule.web.d.ts +1 -1
- package/{dist/src → lib/typescript}/State.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/DrawerLayout.d.ts +52 -2
- package/{dist/src → lib/typescript}/components/GestureButtons.d.ts +37 -1
- package/lib/typescript/components/GestureComponents.d.ts +18 -0
- package/lib/typescript/components/GestureComponents.web.d.ts +7 -0
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/GestureHandlerButton.web.d.ts +1 -1
- package/lib/typescript/components/Swipeable.d.ts +150 -0
- package/{dist/src → lib/typescript}/components/touchables/GenericTouchable.d.ts +3 -3
- package/{dist/src → lib/typescript}/components/touchables/TouchableHighlight.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.android.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableNativeFeedback.d.ts +0 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableOpacity.d.ts +1 -0
- package/{dist/src → lib/typescript}/components/touchables/TouchableWithoutFeedback.d.ts +4 -2
- package/{dist/src → lib/typescript}/components/touchables/index.d.ts +0 -0
- package/lib/typescript/gestureHandlerRootHOC.d.ts +3 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +27 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
- package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
- package/{dist/src → lib/typescript}/handlers/createHandler.d.ts +2 -2
- package/{dist/src → lib/typescript}/handlers/createNativeWrapper.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/{dist/src → lib/typescript}/handlers/gestureHandlerTypesCompat.d.ts +17 -2
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +10 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +90 -0
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +5 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +19 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
- package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
- package/lib/typescript/index.d.ts +44 -0
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +43 -0
- package/{dist/src → lib/typescript}/typeUtils.d.ts +0 -0
- package/lib/typescript/utils.d.ts +1 -0
- package/{dist/src → lib/typescript}/web/DiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/DraggingGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/Errors.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/FlingGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/GestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/IndiscreteGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/LongPressGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NativeViewGestureHandler.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/NodeManager.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/PanGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PinchGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/PressGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/RotationGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/TapGestureHandler.d.ts +0 -1
- package/{dist/src → lib/typescript}/web/constants.d.ts +0 -0
- package/{dist/src → lib/typescript}/web/utils.d.ts +0 -0
- package/package.json +38 -16
- package/src/Directions.ts +8 -2
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +10 -25
- package/src/GestureHandlerRootView.tsx +12 -0
- package/src/PlatformConstants.ts +3 -2
- package/src/RNGestureHandlerModule.ts +15 -9
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +117 -43
- package/src/components/GestureButtons.tsx +46 -6
- package/src/components/GestureComponents.tsx +48 -41
- package/src/components/GestureComponents.web.tsx +1 -1
- package/src/components/{GestureHandlerButton.ts → GestureHandlerButton.tsx} +0 -0
- package/src/components/GestureHandlerButton.web.tsx +1 -1
- package/src/components/Swipeable.tsx +110 -22
- package/src/components/touchables/GenericTouchable.tsx +5 -3
- package/src/components/touchables/TouchableHighlight.tsx +2 -1
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -1
- package/src/components/touchables/{TouchableNativeFeedback.ts → TouchableNativeFeedback.tsx} +0 -0
- package/src/components/touchables/TouchableOpacity.tsx +3 -2
- package/src/components/touchables/TouchableWithoutFeedback.tsx +3 -2
- package/src/gestureHandlerRootHOC.tsx +5 -5
- package/src/handlers/FlingGestureHandler.ts +57 -0
- package/src/handlers/ForceTouchGestureHandler.ts +83 -0
- package/src/handlers/LongPressGestureHandler.ts +84 -0
- package/src/handlers/NativeViewGestureHandler.ts +31 -7
- package/src/handlers/PanGestureHandler.ts +321 -0
- package/src/handlers/PinchGestureHandler.ts +46 -0
- package/src/handlers/RotationGestureHandler.ts +46 -0
- package/src/handlers/TapGestureHandler.ts +90 -0
- package/src/handlers/createHandler.ts +61 -83
- package/src/handlers/createNativeWrapper.tsx +3 -2
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +37 -4
- package/src/handlers/gestures/GestureDetector.tsx +490 -0
- package/src/handlers/gestures/eventReceiver.ts +129 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +32 -0
- package/src/handlers/gestures/gesture.ts +262 -0
- package/src/handlers/gestures/gestureComposition.ts +109 -0
- package/src/handlers/gestures/gestureObjects.ts +79 -0
- package/src/handlers/gestures/gestureStateManager.ts +60 -0
- package/src/handlers/gestures/longPressGesture.ts +27 -0
- package/src/handlers/gestures/manualGesture.ts +11 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +105 -0
- package/src/handlers/gestures/pinchGesture.ts +12 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +12 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +156 -0
- package/src/init.ts +5 -0
- package/src/mocks.ts +65 -0
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +3 -4
- package/src/web/NativeViewGestureHandler.ts +0 -2
- package/src/web/NodeManager.ts +5 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
- package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
- package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
- package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
- package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
- package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
- package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -16
- package/dist/src/Directions.d.ts +0 -7
- package/dist/src/Directions.js +0 -2
- package/dist/src/GestureHandlerRootView.android.d.ts +0 -4
- package/dist/src/GestureHandlerRootView.android.expo.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.android.expo.js +0 -2
- package/dist/src/GestureHandlerRootView.android.js +0 -21
- package/dist/src/GestureHandlerRootView.d.ts +0 -2
- package/dist/src/GestureHandlerRootView.js +0 -2
- package/dist/src/PlatformConstants.js +0 -2
- package/dist/src/PlatformConstants.web.js +0 -5
- package/dist/src/RNGestureHandlerModule.js +0 -3
- package/dist/src/RNGestureHandlerModule.web.js +0 -47
- package/dist/src/State.js +0 -9
- package/dist/src/__mocks__/RNGestureHandlerModule.d.ts +0 -23
- package/dist/src/__mocks__/RNGestureHandlerModule.js +0 -25
- package/dist/src/components/DrawerLayout.js +0 -390
- package/dist/src/components/GestureButtons.js +0 -113
- package/dist/src/components/GestureComponents.d.ts +0 -45
- package/dist/src/components/GestureComponents.js +0 -18
- package/dist/src/components/GestureComponents.web.d.ts +0 -7
- package/dist/src/components/GestureComponents.web.js +0 -18
- package/dist/src/components/GestureHandlerButton.web.js +0 -3
- package/dist/src/components/Swipeable.d.ts +0 -82
- package/dist/src/components/Swipeable.js +0 -248
- package/dist/src/components/touchables/GenericTouchable.js +0 -209
- package/dist/src/components/touchables/TouchableHighlight.js +0 -72
- package/dist/src/components/touchables/TouchableNativeFeedback.android.js +0 -62
- package/dist/src/components/touchables/TouchableOpacity.js +0 -49
- package/dist/src/components/touchables/TouchableWithoutFeedback.js +0 -5
- package/dist/src/gestureHandlerRootHOC.d.ts +0 -3
- package/dist/src/gestureHandlerRootHOC.js +0 -17
- package/dist/src/handlers/NativeViewGestureHandler.d.ts +0 -12
- package/dist/src/handlers/NativeViewGestureHandler.js +0 -13
- package/dist/src/handlers/createHandler.js +0 -292
- package/dist/src/handlers/createNativeWrapper.js +0 -50
- package/dist/src/handlers/gestureHandlerTypesCompat.js +0 -1
- package/dist/src/handlers/gestureHandlers.d.ts +0 -158
- package/dist/src/handlers/gestureHandlers.js +0 -247
- package/dist/src/typeUtils.js +0 -1
- package/dist/src/web/DiscreteGestureHandler.js +0 -48
- package/dist/src/web/DraggingGestureHandler.js +0 -25
- package/dist/src/web/Errors.js +0 -5
- package/dist/src/web/FlingGestureHandler.js +0 -119
- package/dist/src/web/GestureHandler.js +0 -413
- package/dist/src/web/IndiscreteGestureHandler.js +0 -26
- package/dist/src/web/LongPressGestureHandler.js +0 -46
- package/dist/src/web/NativeViewGestureHandler.js +0 -39
- package/dist/src/web/NodeManager.js +0 -22
- package/dist/src/web/PanGestureHandler.js +0 -145
- package/dist/src/web/PinchGestureHandler.js +0 -19
- package/dist/src/web/PressGestureHandler.js +0 -135
- package/dist/src/web/RotationGestureHandler.js +0 -20
- package/dist/src/web/TapGestureHandler.js +0 -143
- package/dist/src/web/constants.js +0 -42
- package/dist/src/web/utils.js +0 -15
- package/index.ts +0 -103
- package/src/GestureHandlerRootView.android.expo.ts +0 -3
- package/src/GestureHandlerRootView.ts +0 -3
- package/src/__mocks__/RNGestureHandlerModule.ts +0 -27
- package/src/handlers/gestureHandlers.ts +0 -511
@@ -0,0 +1,535 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
11
|
+
|
12
|
+
var _reactNative = require("react-native");
|
13
|
+
|
14
|
+
var _PanGestureHandler = require("../handlers/PanGestureHandler");
|
15
|
+
|
16
|
+
var _TapGestureHandler = require("../handlers/TapGestureHandler");
|
17
|
+
|
18
|
+
var _State = require("../State");
|
19
|
+
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
+
|
22
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
23
|
+
|
24
|
+
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; }
|
25
|
+
|
26
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
27
|
+
|
28
|
+
const DRAG_TOSS = 0.05;
|
29
|
+
const IDLE = 'Idle';
|
30
|
+
const DRAGGING = 'Dragging';
|
31
|
+
const SETTLING = 'Settling';
|
32
|
+
|
33
|
+
class DrawerLayout extends React.Component {
|
34
|
+
constructor(_props) {
|
35
|
+
super(_props);
|
36
|
+
|
37
|
+
_defineProperty(this, "openValue", void 0);
|
38
|
+
|
39
|
+
_defineProperty(this, "onGestureEvent", void 0);
|
40
|
+
|
41
|
+
_defineProperty(this, "accessibilityIsModalView", /*#__PURE__*/React.createRef());
|
42
|
+
|
43
|
+
_defineProperty(this, "pointerEventsView", /*#__PURE__*/React.createRef());
|
44
|
+
|
45
|
+
_defineProperty(this, "panGestureHandler", /*#__PURE__*/React.createRef());
|
46
|
+
|
47
|
+
_defineProperty(this, "drawerShown", false);
|
48
|
+
|
49
|
+
_defineProperty(this, "updateAnimatedEvent", (props, state) => {
|
50
|
+
// Event definition is based on
|
51
|
+
const {
|
52
|
+
drawerPosition,
|
53
|
+
drawerWidth,
|
54
|
+
drawerType
|
55
|
+
} = props;
|
56
|
+
const {
|
57
|
+
dragX: dragXValue,
|
58
|
+
touchX: touchXValue,
|
59
|
+
drawerTranslation,
|
60
|
+
containerWidth
|
61
|
+
} = state;
|
62
|
+
let dragX = dragXValue;
|
63
|
+
let touchX = touchXValue;
|
64
|
+
|
65
|
+
if (drawerPosition !== 'left') {
|
66
|
+
// Most of the code is written in a way to handle left-side drawer. In
|
67
|
+
// order to handle right-side drawer the only thing we need to do is to
|
68
|
+
// reverse events coming from gesture handler in a way they emulate
|
69
|
+
// left-side drawer gestures. E.g. dragX is simply -dragX, and touchX is
|
70
|
+
// calulcated by subtracing real touchX from the width of the container
|
71
|
+
// (such that when touch happens at the right edge the value is simply 0)
|
72
|
+
dragX = _reactNative.Animated.multiply(new _reactNative.Animated.Value(-1), dragXValue); // TODO(TS): (for all "as" in this file) make sure we can map this
|
73
|
+
|
74
|
+
touchX = _reactNative.Animated.add(new _reactNative.Animated.Value(containerWidth), _reactNative.Animated.multiply(new _reactNative.Animated.Value(-1), touchXValue)); // TODO(TS): make sure we can map this;
|
75
|
+
|
76
|
+
touchXValue.setValue(containerWidth);
|
77
|
+
} else {
|
78
|
+
touchXValue.setValue(0);
|
79
|
+
} // While closing the drawer when user starts gesture outside of its area (in greyed
|
80
|
+
// out part of the window), we want the drawer to follow only once finger reaches the
|
81
|
+
// edge of the drawer.
|
82
|
+
// E.g. on the diagram below drawer is illustrate by X signs and the greyed out area by
|
83
|
+
// dots. The touch gesture starts at '*' and moves left, touch path is indicated by
|
84
|
+
// an arrow pointing left
|
85
|
+
// 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+
|
86
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
87
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
88
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
89
|
+
// |XXXXXXXX|......| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|
|
90
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
91
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
92
|
+
// |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
|
93
|
+
// +---------------+ +---------------+ +---------------+ +---------------+
|
94
|
+
//
|
95
|
+
// For the above to work properly we define animated value that will keep
|
96
|
+
// start position of the gesture. Then we use that value to calculate how
|
97
|
+
// much we need to subtract from the dragX. If the gesture started on the
|
98
|
+
// greyed out area we take the distance from the edge of the drawer to the
|
99
|
+
// start position. Otherwise we don't subtract at all and the drawer be
|
100
|
+
// pulled back as soon as you start the pan.
|
101
|
+
//
|
102
|
+
// This is used only when drawerType is "front"
|
103
|
+
//
|
104
|
+
|
105
|
+
|
106
|
+
let translationX = dragX;
|
107
|
+
|
108
|
+
if (drawerType === 'front') {
|
109
|
+
const startPositionX = _reactNative.Animated.add(touchX, _reactNative.Animated.multiply(new _reactNative.Animated.Value(-1), dragX));
|
110
|
+
|
111
|
+
const dragOffsetFromOnStartPosition = startPositionX.interpolate({
|
112
|
+
inputRange: [drawerWidth - 1, drawerWidth, drawerWidth + 1],
|
113
|
+
outputRange: [0, 0, 1]
|
114
|
+
});
|
115
|
+
translationX = _reactNative.Animated.add(dragX, dragOffsetFromOnStartPosition); // TODO: as above
|
116
|
+
}
|
117
|
+
|
118
|
+
this.openValue = _reactNative.Animated.add(translationX, drawerTranslation).interpolate({
|
119
|
+
inputRange: [0, drawerWidth],
|
120
|
+
outputRange: [0, 1],
|
121
|
+
extrapolate: 'clamp'
|
122
|
+
});
|
123
|
+
const gestureOptions = {
|
124
|
+
useNativeDriver: props.useNativeAnimations
|
125
|
+
};
|
126
|
+
|
127
|
+
if (this.props.onDrawerSlide) {
|
128
|
+
gestureOptions.listener = ev => {
|
129
|
+
var _this$props$onDrawerS, _this$props;
|
130
|
+
|
131
|
+
const translationX = Math.floor(Math.abs(ev.nativeEvent.translationX));
|
132
|
+
const position = translationX / this.state.containerWidth;
|
133
|
+
(_this$props$onDrawerS = (_this$props = this.props).onDrawerSlide) === null || _this$props$onDrawerS === void 0 ? void 0 : _this$props$onDrawerS.call(_this$props, position);
|
134
|
+
};
|
135
|
+
}
|
136
|
+
|
137
|
+
this.onGestureEvent = _reactNative.Animated.event([{
|
138
|
+
nativeEvent: {
|
139
|
+
translationX: dragXValue,
|
140
|
+
x: touchXValue
|
141
|
+
}
|
142
|
+
}], gestureOptions);
|
143
|
+
});
|
144
|
+
|
145
|
+
_defineProperty(this, "handleContainerLayout", ({
|
146
|
+
nativeEvent
|
147
|
+
}) => {
|
148
|
+
this.setState({
|
149
|
+
containerWidth: nativeEvent.layout.width
|
150
|
+
});
|
151
|
+
});
|
152
|
+
|
153
|
+
_defineProperty(this, "emitStateChanged", (newState, drawerWillShow) => {
|
154
|
+
var _this$props$onDrawerS2, _this$props2;
|
155
|
+
|
156
|
+
(_this$props$onDrawerS2 = (_this$props2 = this.props).onDrawerStateChanged) === null || _this$props$onDrawerS2 === void 0 ? void 0 : _this$props$onDrawerS2.call(_this$props2, newState, drawerWillShow);
|
157
|
+
});
|
158
|
+
|
159
|
+
_defineProperty(this, "openingHandlerStateChange", ({
|
160
|
+
nativeEvent
|
161
|
+
}) => {
|
162
|
+
if (nativeEvent.oldState === _State.State.ACTIVE) {
|
163
|
+
this.handleRelease({
|
164
|
+
nativeEvent
|
165
|
+
});
|
166
|
+
} else if (nativeEvent.state === _State.State.ACTIVE) {
|
167
|
+
this.emitStateChanged(DRAGGING, false);
|
168
|
+
|
169
|
+
if (this.props.keyboardDismissMode === 'on-drag') {
|
170
|
+
_reactNative.Keyboard.dismiss();
|
171
|
+
}
|
172
|
+
|
173
|
+
if (this.props.hideStatusBar) {
|
174
|
+
_reactNative.StatusBar.setHidden(true, this.props.statusBarAnimation || 'slide');
|
175
|
+
}
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
_defineProperty(this, "onTapHandlerStateChange", ({
|
180
|
+
nativeEvent
|
181
|
+
}) => {
|
182
|
+
if (this.drawerShown && nativeEvent.oldState === _State.State.ACTIVE && this.props.drawerLockMode !== 'locked-open') {
|
183
|
+
this.closeDrawer();
|
184
|
+
}
|
185
|
+
});
|
186
|
+
|
187
|
+
_defineProperty(this, "handleRelease", ({
|
188
|
+
nativeEvent
|
189
|
+
}) => {
|
190
|
+
const {
|
191
|
+
drawerWidth,
|
192
|
+
drawerPosition,
|
193
|
+
drawerType
|
194
|
+
} = this.props;
|
195
|
+
const {
|
196
|
+
containerWidth
|
197
|
+
} = this.state;
|
198
|
+
let {
|
199
|
+
translationX: dragX,
|
200
|
+
velocityX,
|
201
|
+
x: touchX
|
202
|
+
} = nativeEvent;
|
203
|
+
|
204
|
+
if (drawerPosition !== 'left') {
|
205
|
+
// See description in _updateAnimatedEvent about why events are flipped
|
206
|
+
// for right-side drawer
|
207
|
+
dragX = -dragX;
|
208
|
+
touchX = containerWidth - touchX;
|
209
|
+
velocityX = -velocityX;
|
210
|
+
}
|
211
|
+
|
212
|
+
const gestureStartX = touchX - dragX;
|
213
|
+
let dragOffsetBasedOnStart = 0;
|
214
|
+
|
215
|
+
if (drawerType === 'front') {
|
216
|
+
dragOffsetBasedOnStart = gestureStartX > drawerWidth ? gestureStartX - drawerWidth : 0;
|
217
|
+
}
|
218
|
+
|
219
|
+
const startOffsetX = dragX + dragOffsetBasedOnStart + (this.drawerShown ? drawerWidth : 0);
|
220
|
+
const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;
|
221
|
+
const shouldOpen = projOffsetX > drawerWidth / 2;
|
222
|
+
|
223
|
+
if (shouldOpen) {
|
224
|
+
this.animateDrawer(startOffsetX, drawerWidth, velocityX);
|
225
|
+
} else {
|
226
|
+
this.animateDrawer(startOffsetX, 0, velocityX);
|
227
|
+
}
|
228
|
+
});
|
229
|
+
|
230
|
+
_defineProperty(this, "updateShowing", showing => {
|
231
|
+
var _this$accessibilityIs, _this$pointerEventsVi, _this$panGestureHandl;
|
232
|
+
|
233
|
+
this.drawerShown = showing;
|
234
|
+
(_this$accessibilityIs = this.accessibilityIsModalView.current) === null || _this$accessibilityIs === void 0 ? void 0 : _this$accessibilityIs.setNativeProps({
|
235
|
+
accessibilityViewIsModal: showing
|
236
|
+
});
|
237
|
+
(_this$pointerEventsVi = this.pointerEventsView.current) === null || _this$pointerEventsVi === void 0 ? void 0 : _this$pointerEventsVi.setNativeProps({
|
238
|
+
pointerEvents: showing ? 'auto' : 'none'
|
239
|
+
});
|
240
|
+
const {
|
241
|
+
drawerPosition,
|
242
|
+
minSwipeDistance,
|
243
|
+
edgeWidth
|
244
|
+
} = this.props;
|
245
|
+
const fromLeft = drawerPosition === 'left'; // gestureOrientation is 1 if the expected gesture is from left to right and
|
246
|
+
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
|
247
|
+
// to right gesture, thus orientation will be 1.
|
248
|
+
|
249
|
+
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1); // When drawer is closed we want the hitSlop to be horizontally shorter than
|
250
|
+
// the container size by the value of SLOP. This will make it only activate
|
251
|
+
// when gesture happens not further than SLOP away from the edge
|
252
|
+
|
253
|
+
const hitSlop = fromLeft ? {
|
254
|
+
left: 0,
|
255
|
+
width: showing ? undefined : edgeWidth
|
256
|
+
} : {
|
257
|
+
right: 0,
|
258
|
+
width: showing ? undefined : edgeWidth
|
259
|
+
}; // @ts-ignore internal API, maybe could be fixed in handler types
|
260
|
+
|
261
|
+
(_this$panGestureHandl = this.panGestureHandler.current) === null || _this$panGestureHandl === void 0 ? void 0 : _this$panGestureHandl.setNativeProps({
|
262
|
+
hitSlop,
|
263
|
+
activeOffsetX: gestureOrientation * minSwipeDistance
|
264
|
+
});
|
265
|
+
});
|
266
|
+
|
267
|
+
_defineProperty(this, "animateDrawer", (fromValue, toValue, velocity, speed) => {
|
268
|
+
this.state.dragX.setValue(0);
|
269
|
+
this.state.touchX.setValue(this.props.drawerPosition === 'left' ? 0 : this.state.containerWidth);
|
270
|
+
|
271
|
+
if (fromValue != null) {
|
272
|
+
let nextFramePosition = fromValue;
|
273
|
+
|
274
|
+
if (this.props.useNativeAnimations) {
|
275
|
+
// When using native driver, we predict the next position of the
|
276
|
+
// animation because it takes one frame of a roundtrip to pass RELEASE
|
277
|
+
// event from native driver to JS before we can start animating. Without
|
278
|
+
// it, it is more noticable that the frame is dropped.
|
279
|
+
if (fromValue < toValue && velocity > 0) {
|
280
|
+
nextFramePosition = Math.min(fromValue + velocity / 60.0, toValue);
|
281
|
+
} else if (fromValue > toValue && velocity < 0) {
|
282
|
+
nextFramePosition = Math.max(fromValue + velocity / 60.0, toValue);
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
this.state.drawerTranslation.setValue(nextFramePosition);
|
287
|
+
}
|
288
|
+
|
289
|
+
const willShow = toValue !== 0;
|
290
|
+
this.updateShowing(willShow);
|
291
|
+
this.emitStateChanged(SETTLING, willShow);
|
292
|
+
|
293
|
+
if (this.props.hideStatusBar) {
|
294
|
+
_reactNative.StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
|
295
|
+
}
|
296
|
+
|
297
|
+
_reactNative.Animated.spring(this.state.drawerTranslation, {
|
298
|
+
velocity,
|
299
|
+
bounciness: 0,
|
300
|
+
toValue,
|
301
|
+
useNativeDriver: this.props.useNativeAnimations,
|
302
|
+
speed: speed !== null && speed !== void 0 ? speed : undefined
|
303
|
+
}).start(({
|
304
|
+
finished
|
305
|
+
}) => {
|
306
|
+
if (finished) {
|
307
|
+
this.emitStateChanged(IDLE, willShow);
|
308
|
+
|
309
|
+
if (willShow) {
|
310
|
+
var _this$props$onDrawerO, _this$props3;
|
311
|
+
|
312
|
+
(_this$props$onDrawerO = (_this$props3 = this.props).onDrawerOpen) === null || _this$props$onDrawerO === void 0 ? void 0 : _this$props$onDrawerO.call(_this$props3);
|
313
|
+
} else {
|
314
|
+
var _this$props$onDrawerC, _this$props4;
|
315
|
+
|
316
|
+
(_this$props$onDrawerC = (_this$props4 = this.props).onDrawerClose) === null || _this$props$onDrawerC === void 0 ? void 0 : _this$props$onDrawerC.call(_this$props4);
|
317
|
+
}
|
318
|
+
}
|
319
|
+
});
|
320
|
+
});
|
321
|
+
|
322
|
+
_defineProperty(this, "openDrawer", (options = {}) => {
|
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
|
325
|
+
// it would not be clickable
|
326
|
+
|
327
|
+
this.forceUpdate();
|
328
|
+
});
|
329
|
+
|
330
|
+
_defineProperty(this, "closeDrawer", (options = {}) => {
|
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
|
333
|
+
// it would be still clickable
|
334
|
+
|
335
|
+
this.forceUpdate();
|
336
|
+
});
|
337
|
+
|
338
|
+
_defineProperty(this, "renderOverlay", () => {
|
339
|
+
/* Overlay styles */
|
340
|
+
(0, _invariant.default)(this.openValue, 'should be set');
|
341
|
+
const overlayOpacity = this.openValue.interpolate({
|
342
|
+
inputRange: [0, 1],
|
343
|
+
outputRange: [0, 1],
|
344
|
+
extrapolate: 'clamp'
|
345
|
+
});
|
346
|
+
const dynamicOverlayStyles = {
|
347
|
+
opacity: overlayOpacity,
|
348
|
+
backgroundColor: this.props.overlayColor
|
349
|
+
};
|
350
|
+
return /*#__PURE__*/React.createElement(_TapGestureHandler.TapGestureHandler, {
|
351
|
+
onHandlerStateChange: this.onTapHandlerStateChange
|
352
|
+
}, /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
|
353
|
+
pointerEvents: this.drawerShown ? 'auto' : 'none',
|
354
|
+
ref: this.pointerEventsView,
|
355
|
+
style: [styles.overlay, dynamicOverlayStyles]
|
356
|
+
}));
|
357
|
+
});
|
358
|
+
|
359
|
+
_defineProperty(this, "renderDrawer", () => {
|
360
|
+
const {
|
361
|
+
drawerBackgroundColor,
|
362
|
+
drawerWidth,
|
363
|
+
drawerPosition,
|
364
|
+
drawerType,
|
365
|
+
drawerContainerStyle,
|
366
|
+
contentContainerStyle
|
367
|
+
} = this.props;
|
368
|
+
const fromLeft = drawerPosition === 'left';
|
369
|
+
const drawerSlide = drawerType !== 'back';
|
370
|
+
const containerSlide = drawerType !== 'front'; // we rely on row and row-reverse flex directions to position the drawer
|
371
|
+
// properly. Apparently for RTL these are flipped which requires us to use
|
372
|
+
// the opposite setting for the drawer to appear from left or right
|
373
|
+
// according to the drawerPosition prop
|
374
|
+
|
375
|
+
const reverseContentDirection = _reactNative.I18nManager.isRTL ? fromLeft : !fromLeft;
|
376
|
+
const dynamicDrawerStyles = {
|
377
|
+
backgroundColor: drawerBackgroundColor,
|
378
|
+
width: drawerWidth
|
379
|
+
};
|
380
|
+
const openValue = this.openValue;
|
381
|
+
(0, _invariant.default)(openValue, 'should be set');
|
382
|
+
let containerStyles;
|
383
|
+
|
384
|
+
if (containerSlide) {
|
385
|
+
const containerTranslateX = openValue.interpolate({
|
386
|
+
inputRange: [0, 1],
|
387
|
+
outputRange: fromLeft ? [0, drawerWidth] : [0, -drawerWidth],
|
388
|
+
extrapolate: 'clamp'
|
389
|
+
});
|
390
|
+
containerStyles = {
|
391
|
+
transform: [{
|
392
|
+
translateX: containerTranslateX
|
393
|
+
}]
|
394
|
+
};
|
395
|
+
}
|
396
|
+
|
397
|
+
let drawerTranslateX = 0;
|
398
|
+
|
399
|
+
if (drawerSlide) {
|
400
|
+
const closedDrawerOffset = fromLeft ? -drawerWidth : drawerWidth;
|
401
|
+
drawerTranslateX = openValue.interpolate({
|
402
|
+
inputRange: [0, 1],
|
403
|
+
outputRange: [closedDrawerOffset, 0],
|
404
|
+
extrapolate: 'clamp'
|
405
|
+
});
|
406
|
+
}
|
407
|
+
|
408
|
+
const drawerStyles = {
|
409
|
+
transform: [{
|
410
|
+
translateX: drawerTranslateX
|
411
|
+
}],
|
412
|
+
flexDirection: reverseContentDirection ? 'row-reverse' : 'row'
|
413
|
+
};
|
414
|
+
return /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
|
415
|
+
style: styles.main,
|
416
|
+
onLayout: this.handleContainerLayout
|
417
|
+
}, /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
|
418
|
+
style: [drawerType === 'front' ? styles.containerOnBack : styles.containerInFront, containerStyles, contentContainerStyle],
|
419
|
+
importantForAccessibility: this.drawerShown ? 'no-hide-descendants' : 'yes'
|
420
|
+
}, typeof this.props.children === 'function' ? this.props.children(this.openValue) : this.props.children, this.renderOverlay()), /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
|
421
|
+
pointerEvents: "box-none",
|
422
|
+
ref: this.accessibilityIsModalView,
|
423
|
+
accessibilityViewIsModal: this.drawerShown,
|
424
|
+
style: [styles.drawerContainer, drawerStyles, drawerContainerStyle]
|
425
|
+
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
426
|
+
style: dynamicDrawerStyles
|
427
|
+
}, this.props.renderNavigationView(this.openValue))));
|
428
|
+
});
|
429
|
+
|
430
|
+
_defineProperty(this, "setPanGestureRef", ref => {
|
431
|
+
var _this$props$onGesture, _this$props5;
|
432
|
+
|
433
|
+
// TODO(TS): make sure it is OK taken from
|
434
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31065#issuecomment-596081842
|
435
|
+
this.panGestureHandler.current = ref;
|
436
|
+
(_this$props$onGesture = (_this$props5 = this.props).onGestureRef) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props5, ref);
|
437
|
+
});
|
438
|
+
|
439
|
+
const _dragX = new _reactNative.Animated.Value(0);
|
440
|
+
|
441
|
+
const _touchX = new _reactNative.Animated.Value(0);
|
442
|
+
|
443
|
+
const _drawerTranslation = new _reactNative.Animated.Value(0);
|
444
|
+
|
445
|
+
this.state = {
|
446
|
+
dragX: _dragX,
|
447
|
+
touchX: _touchX,
|
448
|
+
drawerTranslation: _drawerTranslation,
|
449
|
+
containerWidth: 0
|
450
|
+
};
|
451
|
+
this.updateAnimatedEvent(_props, this.state);
|
452
|
+
}
|
453
|
+
|
454
|
+
UNSAFE_componentWillUpdate(props, state) {
|
455
|
+
if (this.props.drawerPosition !== props.drawerPosition || this.props.drawerWidth !== props.drawerWidth || this.props.drawerType !== props.drawerType || this.state.containerWidth !== state.containerWidth) {
|
456
|
+
this.updateAnimatedEvent(props, state);
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
render() {
|
461
|
+
const {
|
462
|
+
drawerPosition,
|
463
|
+
drawerLockMode,
|
464
|
+
edgeWidth,
|
465
|
+
minSwipeDistance
|
466
|
+
} = this.props;
|
467
|
+
const fromLeft = drawerPosition === 'left'; // gestureOrientation is 1 if the expected gesture is from left to right and
|
468
|
+
// -1 otherwise e.g. when drawer is on the left and is closed we expect left
|
469
|
+
// to right gesture, thus orientation will be 1.
|
470
|
+
|
471
|
+
const gestureOrientation = (fromLeft ? 1 : -1) * (this.drawerShown ? -1 : 1); // When drawer is closed we want the hitSlop to be horizontally shorter than
|
472
|
+
// the container size by the value of SLOP. This will make it only activate
|
473
|
+
// when gesture happens not further than SLOP away from the edge
|
474
|
+
|
475
|
+
const hitSlop = fromLeft ? {
|
476
|
+
left: 0,
|
477
|
+
width: this.drawerShown ? undefined : edgeWidth
|
478
|
+
} : {
|
479
|
+
right: 0,
|
480
|
+
width: this.drawerShown ? undefined : edgeWidth
|
481
|
+
};
|
482
|
+
return /*#__PURE__*/React.createElement(_PanGestureHandler.PanGestureHandler // @ts-ignore could be fixed in handler types
|
483
|
+
, {
|
484
|
+
ref: this.setPanGestureRef,
|
485
|
+
hitSlop: hitSlop,
|
486
|
+
activeOffsetX: gestureOrientation * minSwipeDistance,
|
487
|
+
failOffsetY: [-15, 15],
|
488
|
+
onGestureEvent: this.onGestureEvent,
|
489
|
+
onHandlerStateChange: this.openingHandlerStateChange,
|
490
|
+
enableTrackpadTwoFingerGesture: this.props.enableTrackpadTwoFingerGesture,
|
491
|
+
enabled: drawerLockMode !== 'locked-closed' && drawerLockMode !== 'locked-open'
|
492
|
+
}, this.renderDrawer());
|
493
|
+
}
|
494
|
+
|
495
|
+
}
|
496
|
+
|
497
|
+
exports.default = DrawerLayout;
|
498
|
+
|
499
|
+
_defineProperty(DrawerLayout, "defaultProps", {
|
500
|
+
drawerWidth: 200,
|
501
|
+
drawerPosition: 'left',
|
502
|
+
useNativeAnimations: true,
|
503
|
+
drawerType: 'front',
|
504
|
+
edgeWidth: 20,
|
505
|
+
minSwipeDistance: 3,
|
506
|
+
overlayColor: 'rgba(0, 0, 0, 0.7)',
|
507
|
+
drawerLockMode: 'unlocked',
|
508
|
+
enableTrackpadTwoFingerGesture: false
|
509
|
+
});
|
510
|
+
|
511
|
+
_defineProperty(DrawerLayout, "positions", {
|
512
|
+
Left: 'left',
|
513
|
+
Right: 'right'
|
514
|
+
});
|
515
|
+
|
516
|
+
const styles = _reactNative.StyleSheet.create({
|
517
|
+
drawerContainer: { ..._reactNative.StyleSheet.absoluteFillObject,
|
518
|
+
zIndex: 1001,
|
519
|
+
flexDirection: 'row'
|
520
|
+
},
|
521
|
+
containerInFront: { ..._reactNative.StyleSheet.absoluteFillObject,
|
522
|
+
zIndex: 1002
|
523
|
+
},
|
524
|
+
containerOnBack: { ..._reactNative.StyleSheet.absoluteFillObject
|
525
|
+
},
|
526
|
+
main: {
|
527
|
+
flex: 1,
|
528
|
+
zIndex: 0,
|
529
|
+
overflow: 'hidden'
|
530
|
+
},
|
531
|
+
overlay: { ..._reactNative.StyleSheet.absoluteFillObject,
|
532
|
+
zIndex: 1000
|
533
|
+
}
|
534
|
+
});
|
535
|
+
//# sourceMappingURL=DrawerLayout.js.map
|
@@ -0,0 +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,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EAAAA,mBAAmB,EAAE,IAHD;AAIpBtB,EAAAA,UAAU,EAAE,OAJQ;AAKpBsE,EAAAA,SAAS,EAAE,EALS;AAMpBD,EAAAA,gBAAgB,EAAE,CANE;AAOpB+B,EAAAA,YAAY,EAAE,oBAPM;AAQpB/C,EAAAA,cAAc,EAAE,UARI;AASpBmF,EAAAA,8BAA8B,EAAE;AATZ,C;;gBAJHjJ,Y,eAwDA;AACjBmJ,EAAAA,IAAI,EAAE,MADW;AAEjBC,EAAAA,KAAK,EAAE;AAFU,C;;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"]}
|