react-native-gesture-handler 1.10.3 → 2.1.2
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/README.md +7 -6
- package/android/build.gradle +49 -1
- package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
- 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 +713 -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/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/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/lib/commonjs/EventType.js +16 -0
- package/lib/commonjs/EventType.js.map +1 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +11 -3
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +41 -37
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.js +31 -12
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js +10 -6
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
- package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
- 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 +6 -4
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
- 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 +52 -83
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -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 +65 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js +193 -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 +31 -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 +144 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -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 +45 -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 +146 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +13 -0
- package/lib/commonjs/init.js.map +1 -0
- package/lib/commonjs/mocks.js +31 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +15 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/commonjs/web/Errors.js +1 -1
- package/lib/commonjs/web/Errors.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -6
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/NodeManager.js +8 -2
- package/lib/commonjs/web/NodeManager.js.map +1 -1
- package/lib/module/EventType.js +8 -0
- package/lib/module/EventType.js.map +1 -0
- package/lib/module/GestureHandlerRootView.android.js +2 -14
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -1
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +3 -1
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +2 -2
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +43 -40
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureComponents.js +29 -11
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/Swipeable.js +9 -6
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -1
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/gestureHandlerRootHOC.js +1 -1
- package/lib/module/gestureHandlerRootHOC.js.map +1 -1
- 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 +4 -3
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
- 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 +41 -76
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +66 -0
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +402 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
- package/lib/module/handlers/gestures/eventReceiver.js +120 -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 +56 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js +175 -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 +22 -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 +135 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -0
- package/lib/module/handlers/gestures/pinchGesture.js +36 -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 +36 -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 +22 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +5 -0
- package/lib/module/init.js.map +1 -0
- package/lib/module/mocks.js +31 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +8 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/module/web/Errors.js +1 -1
- package/lib/module/web/Errors.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -6
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/module/web/NodeManager.js +8 -2
- package/lib/module/web/NodeManager.js.map +1 -1
- package/lib/typescript/EventType.d.ts +8 -0
- package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
- package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +50 -1
- package/lib/typescript/components/GestureButtons.d.ts +36 -0
- package/lib/typescript/components/GestureComponents.d.ts +8 -35
- package/lib/typescript/components/Swipeable.d.ts +73 -6
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -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 +19 -4
- 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/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
- 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 +16 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +97 -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 +7 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -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 +29 -2
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +21 -2
- package/lib/typescript/utils.d.ts +1 -0
- package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
- package/lib/typescript/web/GestureHandler.d.ts +0 -1
- package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
- package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
- package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
- package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
- package/package.json +8 -5
- package/src/EventType.ts +10 -0
- package/src/GestureHandlerRootView.android.tsx +9 -25
- package/src/GestureHandlerRootView.tsx +11 -2
- package/src/RNGestureHandlerModule.ts +5 -1
- package/src/RNGestureHandlerModule.web.ts +1 -0
- package/src/components/DrawerLayout.tsx +114 -41
- package/src/components/GestureButtons.tsx +45 -5
- package/src/components/GestureComponents.tsx +47 -41
- package/src/components/Swipeable.tsx +108 -21
- package/src/components/touchables/GenericTouchable.tsx +2 -1
- package/src/components/touchables/TouchableOpacity.tsx +1 -1
- 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 +54 -79
- package/src/handlers/gestureHandlerCommon.ts +185 -0
- package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
- package/src/handlers/gestures/GestureDetector.tsx +519 -0
- package/src/handlers/gestures/eventReceiver.ts +151 -0
- package/src/handlers/gestures/flingGesture.ts +27 -0
- package/src/handlers/gestures/forceTouchGesture.ts +74 -0
- package/src/handlers/gestures/gesture.ts +292 -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 +31 -0
- package/src/handlers/gestures/nativeGesture.ts +27 -0
- package/src/handlers/gestures/panGesture.ts +147 -0
- package/src/handlers/gestures/pinchGesture.ts +51 -0
- package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
- package/src/handlers/gestures/rotationGesture.ts +51 -0
- package/src/handlers/gestures/tapGesture.ts +52 -0
- package/src/handlers/handlersRegistry.ts +22 -0
- package/src/index.ts +57 -17
- package/src/init.ts +5 -0
- package/src/mocks.ts +42 -2
- package/src/utils.ts +7 -0
- package/src/web/GestureHandler.ts +1 -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/lib/commonjs/handlers/gestureHandlers.js +0 -236
- package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
- package/lib/module/handlers/gestureHandlers.js +0 -216
- package/lib/module/handlers/gestureHandlers.js.map +0 -1
- package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
- package/src/handlers/gestureHandlers.ts +0 -511
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FlingGesture = void 0;
|
|
7
|
+
|
|
8
|
+
var _gesture = require("./gesture");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
class FlingGesture extends _gesture.BaseGesture {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "config", {});
|
|
17
|
+
|
|
18
|
+
this.handlerName = 'FlingGestureHandler';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
numberOfPointers(pointers) {
|
|
22
|
+
this.config.numberOfPointers = pointers;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
direction(direction) {
|
|
27
|
+
this.config.direction = direction;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.FlingGesture = FlingGesture;
|
|
34
|
+
//# sourceMappingURL=flingGesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["flingGesture.ts"],"names":["FlingGesture","BaseGesture","constructor","handlerName","numberOfPointers","pointers","config","direction"],"mappings":";;;;;;;AAAA;;;;AAMO,MAAMA,YAAN,SAA2BC,oBAA3B,CAAwE;AAG7EC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;;AAEDC,EAAAA,gBAAgB,CAACC,QAAD,EAAmB;AACjC,SAAKC,MAAL,CAAYF,gBAAZ,GAA+BC,QAA/B;AACA,WAAO,IAAP;AACD;;AAEDE,EAAAA,SAAS,CAACA,SAAD,EAAoB;AAC3B,SAAKD,MAAL,CAAYC,SAAZ,GAAwBA,SAAxB;AACA,WAAO,IAAP;AACD;;AAjB4E","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n FlingGestureConfig,\n FlingGestureHandlerEventPayload,\n} from '../FlingGestureHandler';\n\nexport class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {\n public config: BaseGestureConfig & FlingGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'FlingGestureHandler';\n }\n\n numberOfPointers(pointers: number) {\n this.config.numberOfPointers = pointers;\n return this;\n }\n\n direction(direction: number) {\n this.config.direction = direction;\n return this;\n }\n}\n\nexport type FlingGestureType = InstanceType<typeof FlingGesture>;\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ForceTouchGesture = void 0;
|
|
7
|
+
|
|
8
|
+
var _gesture = require("./gesture");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
function changeEventCalculator(current, previous) {
|
|
13
|
+
'worklet';
|
|
14
|
+
|
|
15
|
+
let changePayload;
|
|
16
|
+
|
|
17
|
+
if (previous === undefined) {
|
|
18
|
+
changePayload = {
|
|
19
|
+
forceChange: current.force
|
|
20
|
+
};
|
|
21
|
+
} else {
|
|
22
|
+
changePayload = {
|
|
23
|
+
forceChange: current.force - previous.force
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return { ...current,
|
|
28
|
+
...changePayload
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class ForceTouchGesture extends _gesture.ContinousBaseGesture {
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
|
|
36
|
+
_defineProperty(this, "config", {});
|
|
37
|
+
|
|
38
|
+
this.handlerName = 'ForceTouchGestureHandler';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
minForce(force) {
|
|
42
|
+
this.config.minForce = force;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
maxForce(force) {
|
|
47
|
+
this.config.maxForce = force;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
feedbackOnActivation(value) {
|
|
52
|
+
this.config.feedbackOnActivation = value;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onChange(callback) {
|
|
57
|
+
// @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record
|
|
58
|
+
this.handlers.changeEventCalculator = changeEventCalculator;
|
|
59
|
+
return super.onChange(callback);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.ForceTouchGesture = ForceTouchGesture;
|
|
65
|
+
//# sourceMappingURL=forceTouchGesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["forceTouchGesture.ts"],"names":["changeEventCalculator","current","previous","changePayload","undefined","forceChange","force","ForceTouchGesture","ContinousBaseGesture","constructor","handlerName","minForce","config","maxForce","feedbackOnActivation","value","onChange","callback","handlers"],"mappings":";;;;;;;AAAA;;;;AAWA,SAASA,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAEM,MAAMI,iBAAN,SAAgCC,6BAAhC,CAGL;AAGAC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;;AAEDC,EAAAA,QAAQ,CAACL,KAAD,EAAgB;AACtB,SAAKM,MAAL,CAAYD,QAAZ,GAAuBL,KAAvB;AACA,WAAO,IAAP;AACD;;AAEDO,EAAAA,QAAQ,CAACP,KAAD,EAAgB;AACtB,SAAKM,MAAL,CAAYC,QAAZ,GAAuBP,KAAvB;AACA,WAAO,IAAP;AACD;;AAEDQ,EAAAA,oBAAoB,CAACC,KAAD,EAAiB;AACnC,SAAKH,MAAL,CAAYE,oBAAZ,GAAmCC,KAAnC;AACA,WAAO,IAAP;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EASN;AACA;AACA,SAAKC,QAAL,CAAclB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMgB,QAAN,CAAeC,QAAf,CAAP;AACD;;AArCD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport {\n ForceTouchGestureConfig,\n ForceTouchGestureHandlerEventPayload,\n} from '../ForceTouchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype ForceTouchGestureChangeEventPayload = {\n forceChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: ForceTouchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n forceChange: current.force,\n };\n } else {\n changePayload = {\n forceChange: current.force - previous.force,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class ForceTouchGesture extends ContinousBaseGesture<\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & ForceTouchGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'ForceTouchGestureHandler';\n }\n\n minForce(force: number) {\n this.config.minForce = force;\n return this;\n }\n\n maxForce(force: number) {\n this.config.maxForce = force;\n return this;\n }\n\n feedbackOnActivation(value: boolean) {\n this.config.feedbackOnActivation = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n GestureUpdateEvent<\n ForceTouchGestureHandlerEventPayload &\n ForceTouchGestureChangeEventPayload\n >\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;\n"]}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ContinousBaseGesture = exports.BaseGesture = exports.Gesture = exports.CALLBACK_TYPE = void 0;
|
|
7
|
+
|
|
8
|
+
var _handlersRegistry = require("../handlersRegistry");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
const CALLBACK_TYPE = {
|
|
13
|
+
UNDEFINED: 0,
|
|
14
|
+
BEGAN: 1,
|
|
15
|
+
START: 2,
|
|
16
|
+
UPDATE: 3,
|
|
17
|
+
CHANGE: 4,
|
|
18
|
+
END: 5,
|
|
19
|
+
FINALIZE: 6,
|
|
20
|
+
TOUCHES_DOWN: 7,
|
|
21
|
+
TOUCHES_MOVE: 8,
|
|
22
|
+
TOUCHES_UP: 9,
|
|
23
|
+
TOUCHES_CANCELLED: 10
|
|
24
|
+
}; // Allow using CALLBACK_TYPE as object and type
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
26
|
+
|
|
27
|
+
exports.CALLBACK_TYPE = CALLBACK_TYPE;
|
|
28
|
+
|
|
29
|
+
class Gesture {}
|
|
30
|
+
|
|
31
|
+
exports.Gesture = Gesture;
|
|
32
|
+
|
|
33
|
+
class BaseGesture extends Gesture {
|
|
34
|
+
constructor(...args) {
|
|
35
|
+
super(...args);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "handlerTag", -1);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "handlerName", '');
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "config", {});
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "handlers", {
|
|
44
|
+
handlerTag: -1,
|
|
45
|
+
isWorklet: [false, false, false, false]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
addDependency(key, gesture) {
|
|
50
|
+
const value = this.config[key];
|
|
51
|
+
this.config[key] = value ? Array().concat(value, gesture) : [gesture];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
withRef(ref) {
|
|
55
|
+
this.config.ref = ref;
|
|
56
|
+
return this;
|
|
57
|
+
} // eslint-disable-next-line @typescript-eslint/ban-types
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
isWorklet(callback) {
|
|
61
|
+
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
|
62
|
+
return callback.__workletHash !== undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onBegin(callback) {
|
|
66
|
+
this.handlers.onBegin = callback;
|
|
67
|
+
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onStart(callback) {
|
|
72
|
+
this.handlers.onStart = callback;
|
|
73
|
+
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onEnd(callback) {
|
|
78
|
+
this.handlers.onEnd = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
|
79
|
+
|
|
80
|
+
this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onFinalize(callback) {
|
|
85
|
+
this.handlers.onFinalize = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
|
86
|
+
|
|
87
|
+
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onTouchesDown(callback) {
|
|
92
|
+
this.config.needsPointerData = true;
|
|
93
|
+
this.handlers.onTouchesDown = callback;
|
|
94
|
+
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(callback);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onTouchesMove(callback) {
|
|
99
|
+
this.config.needsPointerData = true;
|
|
100
|
+
this.handlers.onTouchesMove = callback;
|
|
101
|
+
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(callback);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
onTouchesUp(callback) {
|
|
106
|
+
this.config.needsPointerData = true;
|
|
107
|
+
this.handlers.onTouchesUp = callback;
|
|
108
|
+
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(callback);
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
onTouchesCancelled(callback) {
|
|
113
|
+
this.config.needsPointerData = true;
|
|
114
|
+
this.handlers.onTouchesCancelled = callback;
|
|
115
|
+
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(callback);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
enabled(enabled) {
|
|
120
|
+
this.config.enabled = enabled;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
shouldCancelWhenOutside(value) {
|
|
125
|
+
this.config.shouldCancelWhenOutside = value;
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
hitSlop(hitSlop) {
|
|
130
|
+
this.config.hitSlop = hitSlop;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
simultaneousWithExternalGesture(...gestures) {
|
|
135
|
+
for (const gesture of gestures) {
|
|
136
|
+
this.addDependency('simultaneousWith', gesture);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
requireExternalGestureToFail(...gestures) {
|
|
143
|
+
for (const gesture of gestures) {
|
|
144
|
+
this.addDependency('requireToFail', gesture);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
initialize() {
|
|
151
|
+
this.handlerTag = (0, _handlersRegistry.getNextHandlerTag)();
|
|
152
|
+
this.handlers = { ...this.handlers,
|
|
153
|
+
handlerTag: this.handlerTag
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (this.config.ref) {
|
|
157
|
+
this.config.ref.current = this;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
toGestureArray() {
|
|
162
|
+
return [this];
|
|
163
|
+
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
prepare() {}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
exports.BaseGesture = BaseGesture;
|
|
171
|
+
|
|
172
|
+
class ContinousBaseGesture extends BaseGesture {
|
|
173
|
+
onUpdate(callback) {
|
|
174
|
+
this.handlers.onUpdate = callback;
|
|
175
|
+
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
onChange(callback) {
|
|
180
|
+
this.handlers.onChange = callback;
|
|
181
|
+
this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
manualActivation(manualActivation) {
|
|
186
|
+
this.config.manualActivation = manualActivation;
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
exports.ContinousBaseGesture = ContinousBaseGesture;
|
|
193
|
+
//# sourceMappingURL=gesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["gesture.ts"],"names":["CALLBACK_TYPE","UNDEFINED","BEGAN","START","UPDATE","CHANGE","END","FINALIZE","TOUCHES_DOWN","TOUCHES_MOVE","TOUCHES_UP","TOUCHES_CANCELLED","Gesture","BaseGesture","handlerTag","isWorklet","addDependency","key","gesture","value","config","Array","concat","withRef","ref","callback","__workletHash","undefined","onBegin","handlers","onStart","onEnd","onFinalize","onTouchesDown","needsPointerData","onTouchesMove","onTouchesUp","onTouchesCancelled","enabled","shouldCancelWhenOutside","hitSlop","simultaneousWithExternalGesture","gestures","requireExternalGestureToFail","initialize","current","toGestureArray","prepare","ContinousBaseGesture","onUpdate","onChange","manualActivation"],"mappings":"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","sourcesContent":["import { FlingGestureHandlerEventPayload } from '../FlingGestureHandler';\nimport { ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';\nimport {\n HitSlop,\n CommonGestureConfig,\n GestureTouchEvent,\n GestureStateChangeEvent,\n GestureUpdateEvent,\n} from '../gestureHandlerCommon';\nimport { getNextHandlerTag } from '../handlersRegistry';\nimport { GestureStateManagerType } from './gestureStateManager';\nimport { LongPressGestureHandlerEventPayload } from '../LongPressGestureHandler';\nimport { PanGestureHandlerEventPayload } from '../PanGestureHandler';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { TapGestureHandlerEventPayload } from '../TapGestureHandler';\nimport { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';\n\nexport type GestureType =\n | BaseGesture<Record<string, unknown>>\n | BaseGesture<Record<string, never>>\n | BaseGesture<TapGestureHandlerEventPayload>\n | BaseGesture<PanGestureHandlerEventPayload>\n | BaseGesture<LongPressGestureHandlerEventPayload>\n | BaseGesture<RotationGestureHandlerEventPayload>\n | BaseGesture<PinchGestureHandlerEventPayload>\n | BaseGesture<FlingGestureHandlerEventPayload>\n | BaseGesture<ForceTouchGestureHandlerEventPayload>\n | BaseGesture<NativeViewGestureHandlerPayload>;\n\nexport type GestureRef =\n | number\n | GestureType\n | React.RefObject<GestureType | undefined>\n | React.RefObject<React.ComponentType | undefined>; // allow adding a ref to a gesture handler\nexport interface BaseGestureConfig\n extends CommonGestureConfig,\n Record<string, unknown> {\n ref?: React.MutableRefObject<GestureType | undefined>;\n requireToFail?: GestureRef[];\n simultaneousWith?: GestureRef[];\n needsPointerData?: boolean;\n manualActivation?: boolean;\n}\n\ntype TouchEventHandlerType = (\n event: GestureTouchEvent,\n stateManager: GestureStateManagerType\n) => void;\n\nexport type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {\n handlerTag: number;\n onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;\n onEnd?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onFinalize?: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void;\n onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;\n onChange?: (event: any) => void;\n onTouchesDown?: TouchEventHandlerType;\n onTouchesMove?: TouchEventHandlerType;\n onTouchesUp?: TouchEventHandlerType;\n onTouchesCancelled?: TouchEventHandlerType;\n changeEventCalculator?: (\n current: GestureUpdateEvent<Record<string, unknown>>,\n previous?: GestureUpdateEvent<Record<string, unknown>>\n ) => GestureUpdateEvent<Record<string, unknown>>;\n isWorklet: boolean[];\n};\n\nexport const CALLBACK_TYPE = {\n UNDEFINED: 0,\n BEGAN: 1,\n START: 2,\n UPDATE: 3,\n CHANGE: 4,\n END: 5,\n FINALIZE: 6,\n TOUCHES_DOWN: 7,\n TOUCHES_MOVE: 8,\n TOUCHES_UP: 9,\n TOUCHES_CANCELLED: 10,\n} as const;\n\n// Allow using CALLBACK_TYPE as object and type\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];\n\nexport abstract class Gesture {\n /**\n * Return array of gestures, providing the same interface for creating and updating\n * handlers, no matter which object was used to create gesture instance.\n */\n abstract toGestureArray(): GestureType[];\n\n /**\n * Assign handlerTag to the gesture instance and set ref.current (if a ref is set)\n */\n abstract initialize(): void;\n\n /**\n * Make sure that values of properties defining relations are arrays. Do any necessary\n * preprocessing required to configure relations between handlers. Called just before\n * updating the handler on the native side.\n */\n abstract prepare(): void;\n}\n\nexport abstract class BaseGesture<\n EventPayloadT extends Record<string, unknown>\n> extends Gesture {\n public handlerTag = -1;\n public handlerName = '';\n public config: BaseGestureConfig = {};\n public handlers: HandlerCallbacks<EventPayloadT> = {\n handlerTag: -1,\n isWorklet: [false, false, false, false],\n };\n\n private addDependency(\n key: 'simultaneousWith' | 'requireToFail',\n gesture: Exclude<GestureRef, number>\n ) {\n const value = this.config[key];\n this.config[key] = value\n ? Array<GestureRef>().concat(value, gesture)\n : [gesture];\n }\n\n withRef(ref: React.MutableRefObject<GestureType | undefined>) {\n this.config.ref = ref;\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected isWorklet(callback: Function) {\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n return callback.__workletHash !== undefined;\n }\n\n onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onBegin = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);\n return this;\n }\n\n onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {\n this.handlers.onStart = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);\n return this;\n }\n\n onEnd(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onEnd = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);\n return this;\n }\n\n onFinalize(\n callback: (\n event: GestureStateChangeEvent<EventPayloadT>,\n success: boolean\n ) => void\n ) {\n this.handlers.onFinalize = callback;\n //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false\n this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);\n return this;\n }\n\n onTouchesDown(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesDown = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesMove(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesMove = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesUp(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesUp = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n onTouchesCancelled(callback: TouchEventHandlerType) {\n this.config.needsPointerData = true;\n this.handlers.onTouchesCancelled = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(\n callback\n );\n\n return this;\n }\n\n enabled(enabled: boolean) {\n this.config.enabled = enabled;\n return this;\n }\n\n shouldCancelWhenOutside(value: boolean) {\n this.config.shouldCancelWhenOutside = value;\n return this;\n }\n\n hitSlop(hitSlop: HitSlop) {\n this.config.hitSlop = hitSlop;\n return this;\n }\n\n simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('simultaneousWith', gesture);\n }\n return this;\n }\n\n requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {\n for (const gesture of gestures) {\n this.addDependency('requireToFail', gesture);\n }\n return this;\n }\n\n initialize() {\n this.handlerTag = getNextHandlerTag();\n this.handlers = { ...this.handlers, handlerTag: this.handlerTag };\n\n if (this.config.ref) {\n this.config.ref.current = this as GestureType;\n }\n }\n\n toGestureArray(): GestureType[] {\n return [this as GestureType];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prepare() {}\n}\n\nexport abstract class ContinousBaseGesture<\n EventPayloadT extends Record<string, unknown>,\n EventChangePayloadT extends Record<string, unknown>\n> extends BaseGesture<EventPayloadT> {\n onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {\n this.handlers.onUpdate = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>\n ) => void\n ) {\n this.handlers.onChange = callback;\n this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);\n return this;\n }\n\n manualActivation(manualActivation: boolean) {\n this.config.manualActivation = manualActivation;\n return this;\n }\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ExclusiveGesture = exports.SimultaneousGesture = exports.ComposedGesture = void 0;
|
|
7
|
+
|
|
8
|
+
var _gesture = require("./gesture");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
function extendRelation(currentRelation, extendWith) {
|
|
13
|
+
if (currentRelation === undefined) {
|
|
14
|
+
return [...extendWith];
|
|
15
|
+
} else {
|
|
16
|
+
return [...currentRelation, ...extendWith];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class ComposedGesture extends _gesture.Gesture {
|
|
21
|
+
constructor(...gestures) {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "gestures", []);
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "simultaneousGestures", []);
|
|
27
|
+
|
|
28
|
+
_defineProperty(this, "requireGesturesToFail", []);
|
|
29
|
+
|
|
30
|
+
this.gestures = gestures;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
prepareSingleGesture(gesture, simultaneousGestures, requireGesturesToFail) {
|
|
34
|
+
if (gesture instanceof _gesture.BaseGesture) {
|
|
35
|
+
const newConfig = { ...gesture.config
|
|
36
|
+
};
|
|
37
|
+
newConfig.simultaneousWith = extendRelation(newConfig.simultaneousWith, simultaneousGestures);
|
|
38
|
+
newConfig.requireToFail = extendRelation(newConfig.requireToFail, requireGesturesToFail);
|
|
39
|
+
gesture.config = newConfig;
|
|
40
|
+
} else if (gesture instanceof ComposedGesture) {
|
|
41
|
+
gesture.simultaneousGestures = simultaneousGestures;
|
|
42
|
+
gesture.requireGesturesToFail = requireGesturesToFail;
|
|
43
|
+
gesture.prepare();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
prepare() {
|
|
48
|
+
for (const gesture of this.gestures) {
|
|
49
|
+
this.prepareSingleGesture(gesture, this.simultaneousGestures, this.requireGesturesToFail);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
initialize() {
|
|
54
|
+
for (const gesture of this.gestures) {
|
|
55
|
+
gesture.initialize();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
toGestureArray() {
|
|
60
|
+
return this.gestures.flatMap(gesture => gesture.toGestureArray());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.ComposedGesture = ComposedGesture;
|
|
66
|
+
|
|
67
|
+
class SimultaneousGesture extends ComposedGesture {
|
|
68
|
+
prepare() {
|
|
69
|
+
const simultaneousArray = this.gestures.flatMap(gesture => gesture.toGestureArray()).concat(this.simultaneousGestures);
|
|
70
|
+
|
|
71
|
+
for (const gesture of this.gestures) {
|
|
72
|
+
this.prepareSingleGesture(gesture, simultaneousArray, this.requireGesturesToFail);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exports.SimultaneousGesture = SimultaneousGesture;
|
|
79
|
+
|
|
80
|
+
class ExclusiveGesture extends ComposedGesture {
|
|
81
|
+
prepare() {
|
|
82
|
+
const gestureArrays = this.gestures.map(gesture => gesture.toGestureArray());
|
|
83
|
+
let requireToFail = [];
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < this.gestures.length; i++) {
|
|
86
|
+
this.prepareSingleGesture(this.gestures[i], this.simultaneousGestures, this.requireGesturesToFail.concat(requireToFail));
|
|
87
|
+
requireToFail = requireToFail.concat(gestureArrays[i]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.ExclusiveGesture = ExclusiveGesture;
|
|
94
|
+
//# sourceMappingURL=gestureComposition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["gestureComposition.ts"],"names":["extendRelation","currentRelation","extendWith","undefined","ComposedGesture","Gesture","constructor","gestures","prepareSingleGesture","gesture","simultaneousGestures","requireGesturesToFail","BaseGesture","newConfig","config","simultaneousWith","requireToFail","prepare","initialize","toGestureArray","flatMap","SimultaneousGesture","simultaneousArray","concat","ExclusiveGesture","gestureArrays","map","i","length"],"mappings":"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","sourcesContent":["import { BaseGesture, Gesture, GestureRef, GestureType } from './gesture';\n\nfunction extendRelation(\n currentRelation: GestureRef[] | undefined,\n extendWith: GestureType[]\n) {\n if (currentRelation === undefined) {\n return [...extendWith];\n } else {\n return [...currentRelation, ...extendWith];\n }\n}\n\nexport class ComposedGesture extends Gesture {\n protected gestures: Gesture[] = [];\n protected simultaneousGestures: GestureType[] = [];\n protected requireGesturesToFail: GestureType[] = [];\n\n constructor(...gestures: Gesture[]) {\n super();\n this.gestures = gestures;\n }\n\n protected prepareSingleGesture(\n gesture: Gesture,\n simultaneousGestures: GestureType[],\n requireGesturesToFail: GestureType[]\n ) {\n if (gesture instanceof BaseGesture) {\n const newConfig = { ...gesture.config };\n\n newConfig.simultaneousWith = extendRelation(\n newConfig.simultaneousWith,\n simultaneousGestures\n );\n newConfig.requireToFail = extendRelation(\n newConfig.requireToFail,\n requireGesturesToFail\n );\n\n gesture.config = newConfig;\n } else if (gesture instanceof ComposedGesture) {\n gesture.simultaneousGestures = simultaneousGestures;\n gesture.requireGesturesToFail = requireGesturesToFail;\n gesture.prepare();\n }\n }\n\n prepare() {\n for (const gesture of this.gestures) {\n this.prepareSingleGesture(\n gesture,\n this.simultaneousGestures,\n this.requireGesturesToFail\n );\n }\n }\n\n initialize() {\n for (const gesture of this.gestures) {\n gesture.initialize();\n }\n }\n\n toGestureArray(): GestureType[] {\n return this.gestures.flatMap((gesture) => gesture.toGestureArray());\n }\n}\n\nexport class SimultaneousGesture extends ComposedGesture {\n prepare() {\n const simultaneousArray = this.gestures\n .flatMap((gesture) => gesture.toGestureArray())\n .concat(this.simultaneousGestures);\n\n for (const gesture of this.gestures) {\n this.prepareSingleGesture(\n gesture,\n simultaneousArray,\n this.requireGesturesToFail\n );\n }\n }\n}\n\nexport class ExclusiveGesture extends ComposedGesture {\n prepare() {\n const gestureArrays = this.gestures.map((gesture) =>\n gesture.toGestureArray()\n );\n\n let requireToFail: GestureType[] = [];\n\n for (let i = 0; i < this.gestures.length; i++) {\n this.prepareSingleGesture(\n this.gestures[i],\n this.simultaneousGestures,\n this.requireGesturesToFail.concat(requireToFail)\n );\n\n requireToFail = requireToFail.concat(gestureArrays[i]);\n }\n }\n}\n\nexport type ComposedGestureType = InstanceType<typeof ComposedGesture>;\nexport type RaceGestureType = ComposedGestureType;\nexport type SimultaneousGestureType = InstanceType<typeof SimultaneousGesture>;\nexport type ExclusiveGestureType = InstanceType<typeof ExclusiveGesture>;\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GestureObjects = void 0;
|
|
7
|
+
|
|
8
|
+
var _flingGesture = require("./flingGesture");
|
|
9
|
+
|
|
10
|
+
var _forceTouchGesture = require("./forceTouchGesture");
|
|
11
|
+
|
|
12
|
+
var _gestureComposition = require("./gestureComposition");
|
|
13
|
+
|
|
14
|
+
var _longPressGesture = require("./longPressGesture");
|
|
15
|
+
|
|
16
|
+
var _panGesture = require("./panGesture");
|
|
17
|
+
|
|
18
|
+
var _pinchGesture = require("./pinchGesture");
|
|
19
|
+
|
|
20
|
+
var _rotationGesture = require("./rotationGesture");
|
|
21
|
+
|
|
22
|
+
var _tapGesture = require("./tapGesture");
|
|
23
|
+
|
|
24
|
+
var _nativeGesture = require("./nativeGesture");
|
|
25
|
+
|
|
26
|
+
var _manualGesture = require("./manualGesture");
|
|
27
|
+
|
|
28
|
+
const GestureObjects = {
|
|
29
|
+
Tap: () => {
|
|
30
|
+
return new _tapGesture.TapGesture();
|
|
31
|
+
},
|
|
32
|
+
Pan: () => {
|
|
33
|
+
return new _panGesture.PanGesture();
|
|
34
|
+
},
|
|
35
|
+
Pinch: () => {
|
|
36
|
+
return new _pinchGesture.PinchGesture();
|
|
37
|
+
},
|
|
38
|
+
Rotation: () => {
|
|
39
|
+
return new _rotationGesture.RotationGesture();
|
|
40
|
+
},
|
|
41
|
+
Fling: () => {
|
|
42
|
+
return new _flingGesture.FlingGesture();
|
|
43
|
+
},
|
|
44
|
+
LongPress: () => {
|
|
45
|
+
return new _longPressGesture.LongPressGesture();
|
|
46
|
+
},
|
|
47
|
+
ForceTouch: () => {
|
|
48
|
+
return new _forceTouchGesture.ForceTouchGesture();
|
|
49
|
+
},
|
|
50
|
+
Native: () => {
|
|
51
|
+
return new _nativeGesture.NativeGesture();
|
|
52
|
+
},
|
|
53
|
+
Manual: () => {
|
|
54
|
+
return new _manualGesture.ManualGesture();
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Builds a composed gesture consisting of gestures provided as parameters.
|
|
59
|
+
* The first one that becomes active cancels the rest of gestures.
|
|
60
|
+
*/
|
|
61
|
+
Race: (...gestures) => {
|
|
62
|
+
return new _gestureComposition.ComposedGesture(...gestures);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Builds a composed gesture that allows all base gestures to run simultaneously.
|
|
67
|
+
*/
|
|
68
|
+
Simultaneous(...gestures) {
|
|
69
|
+
return new _gestureComposition.SimultaneousGesture(...gestures);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Builds a composed gesture where only one of the provided gestures can become active.
|
|
74
|
+
* Priority is decided through the order of gestures: the first one has higher priority
|
|
75
|
+
* than the second one, second one has higher priority than the third one, and so on.
|
|
76
|
+
* For example, to make a gesture that recognizes both single and double tap you need
|
|
77
|
+
* to call Exclusive(doubleTap, singleTap).
|
|
78
|
+
*/
|
|
79
|
+
Exclusive(...gestures) {
|
|
80
|
+
return new _gestureComposition.ExclusiveGesture(...gestures);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
};
|
|
84
|
+
exports.GestureObjects = GestureObjects;
|
|
85
|
+
//# sourceMappingURL=gestureObjects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["gestureObjects.ts"],"names":["GestureObjects","Tap","TapGesture","Pan","PanGesture","Pinch","PinchGesture","Rotation","RotationGesture","Fling","FlingGesture","LongPress","LongPressGesture","ForceTouch","ForceTouchGesture","Native","NativeGesture","Manual","ManualGesture","Race","gestures","ComposedGesture","Simultaneous","SimultaneousGesture","Exclusive","ExclusiveGesture"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,cAAc,GAAG;AAC5BC,EAAAA,GAAG,EAAE,MAAM;AACT,WAAO,IAAIC,sBAAJ,EAAP;AACD,GAH2B;AAK5BC,EAAAA,GAAG,EAAE,MAAM;AACT,WAAO,IAAIC,sBAAJ,EAAP;AACD,GAP2B;AAS5BC,EAAAA,KAAK,EAAE,MAAM;AACX,WAAO,IAAIC,0BAAJ,EAAP;AACD,GAX2B;AAa5BC,EAAAA,QAAQ,EAAE,MAAM;AACd,WAAO,IAAIC,gCAAJ,EAAP;AACD,GAf2B;AAiB5BC,EAAAA,KAAK,EAAE,MAAM;AACX,WAAO,IAAIC,0BAAJ,EAAP;AACD,GAnB2B;AAqB5BC,EAAAA,SAAS,EAAE,MAAM;AACf,WAAO,IAAIC,kCAAJ,EAAP;AACD,GAvB2B;AAyB5BC,EAAAA,UAAU,EAAE,MAAM;AAChB,WAAO,IAAIC,oCAAJ,EAAP;AACD,GA3B2B;AA6B5BC,EAAAA,MAAM,EAAE,MAAM;AACZ,WAAO,IAAIC,4BAAJ,EAAP;AACD,GA/B2B;AAiC5BC,EAAAA,MAAM,EAAE,MAAM;AACZ,WAAO,IAAIC,4BAAJ,EAAP;AACD,GAnC2B;;AAqC5B;AACF;AACA;AACA;AACEC,EAAAA,IAAI,EAAE,CAAC,GAAGC,QAAJ,KAA4B;AAChC,WAAO,IAAIC,mCAAJ,CAAoB,GAAGD,QAAvB,CAAP;AACD,GA3C2B;;AA6C5B;AACF;AACA;AACEE,EAAAA,YAAY,CAAC,GAAGF,QAAJ,EAAyB;AACnC,WAAO,IAAIG,uCAAJ,CAAwB,GAAGH,QAA3B,CAAP;AACD,GAlD2B;;AAoD5B;AACF;AACA;AACA;AACA;AACA;AACA;AACEI,EAAAA,SAAS,CAAC,GAAGJ,QAAJ,EAAyB;AAChC,WAAO,IAAIK,oCAAJ,CAAqB,GAAGL,QAAxB,CAAP;AACD;;AA7D2B,CAAvB","sourcesContent":["import { FlingGesture } from './flingGesture';\nimport { ForceTouchGesture } from './forceTouchGesture';\nimport { Gesture } from './gesture';\nimport {\n ComposedGesture,\n ExclusiveGesture,\n SimultaneousGesture,\n} from './gestureComposition';\nimport { LongPressGesture } from './longPressGesture';\nimport { PanGesture } from './panGesture';\nimport { PinchGesture } from './pinchGesture';\nimport { RotationGesture } from './rotationGesture';\nimport { TapGesture } from './tapGesture';\nimport { NativeGesture } from './nativeGesture';\nimport { ManualGesture } from './manualGesture';\n\nexport const GestureObjects = {\n Tap: () => {\n return new TapGesture();\n },\n\n Pan: () => {\n return new PanGesture();\n },\n\n Pinch: () => {\n return new PinchGesture();\n },\n\n Rotation: () => {\n return new RotationGesture();\n },\n\n Fling: () => {\n return new FlingGesture();\n },\n\n LongPress: () => {\n return new LongPressGesture();\n },\n\n ForceTouch: () => {\n return new ForceTouchGesture();\n },\n\n Native: () => {\n return new NativeGesture();\n },\n\n Manual: () => {\n return new ManualGesture();\n },\n\n /**\n * Builds a composed gesture consisting of gestures provided as parameters.\n * The first one that becomes active cancels the rest of gestures.\n */\n Race: (...gestures: Gesture[]) => {\n return new ComposedGesture(...gestures);\n },\n\n /**\n * Builds a composed gesture that allows all base gestures to run simultaneously.\n */\n Simultaneous(...gestures: Gesture[]) {\n return new SimultaneousGesture(...gestures);\n },\n\n /**\n * Builds a composed gesture where only one of the provided gestures can become active.\n * Priority is decided through the order of gestures: the first one has higher priority\n * than the second one, second one has higher priority than the third one, and so on.\n * For example, to make a gesture that recognizes both single and double tap you need\n * to call Exclusive(doubleTap, singleTap).\n */\n Exclusive(...gestures: Gesture[]) {\n return new ExclusiveGesture(...gestures);\n },\n};\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GestureStateManager = void 0;
|
|
7
|
+
|
|
8
|
+
var _reanimatedWrapper = require("./reanimatedWrapper");
|
|
9
|
+
|
|
10
|
+
var _State = require("../../State");
|
|
11
|
+
|
|
12
|
+
const GestureStateManager = {
|
|
13
|
+
create(handlerTag) {
|
|
14
|
+
'worklet';
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
begin: () => {
|
|
18
|
+
'worklet';
|
|
19
|
+
|
|
20
|
+
if (_reanimatedWrapper.Reanimated) {
|
|
21
|
+
_reanimatedWrapper.Reanimated.setGestureState(handlerTag, _State.State.BEGAN);
|
|
22
|
+
} else {
|
|
23
|
+
console.warn('react-native-reanimated is required in order to use synchronous state management');
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
activate: () => {
|
|
27
|
+
'worklet';
|
|
28
|
+
|
|
29
|
+
if (_reanimatedWrapper.Reanimated) {
|
|
30
|
+
_reanimatedWrapper.Reanimated.setGestureState(handlerTag, _State.State.ACTIVE);
|
|
31
|
+
} else {
|
|
32
|
+
console.warn('react-native-reanimated is required in order to use synchronous state management');
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
fail: () => {
|
|
36
|
+
'worklet';
|
|
37
|
+
|
|
38
|
+
if (_reanimatedWrapper.Reanimated) {
|
|
39
|
+
_reanimatedWrapper.Reanimated.setGestureState(handlerTag, _State.State.FAILED);
|
|
40
|
+
} else {
|
|
41
|
+
console.warn('react-native-reanimated is required in order to use synchronous state management');
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
end: () => {
|
|
45
|
+
'worklet';
|
|
46
|
+
|
|
47
|
+
if (_reanimatedWrapper.Reanimated) {
|
|
48
|
+
_reanimatedWrapper.Reanimated.setGestureState(handlerTag, _State.State.END);
|
|
49
|
+
} else {
|
|
50
|
+
console.warn('react-native-reanimated is required in order to use synchronous state management');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
};
|
|
57
|
+
exports.GestureStateManager = GestureStateManager;
|
|
58
|
+
//# sourceMappingURL=gestureStateManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["gestureStateManager.ts"],"names":["GestureStateManager","create","handlerTag","begin","Reanimated","setGestureState","State","BEGAN","console","warn","activate","ACTIVE","fail","FAILED","end","END"],"mappings":";;;;;;;AAAA;;AACA;;AASO,MAAMA,mBAAmB,GAAG;AACjCC,EAAAA,MAAM,CAACC,UAAD,EAA8C;AAClD;;AACA,WAAO;AACLC,MAAAA,KAAK,EAAE,MAAM;AACX;;AACA,YAAIC,6BAAJ,EAAgB;AACdA,wCAAWC,eAAX,CAA2BH,UAA3B,EAAuCI,aAAMC,KAA7C;AACD,SAFD,MAEO;AACLC,UAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;AACF,OAVI;AAYLC,MAAAA,QAAQ,EAAE,MAAM;AACd;;AACA,YAAIN,6BAAJ,EAAgB;AACdA,wCAAWC,eAAX,CAA2BH,UAA3B,EAAuCI,aAAMK,MAA7C;AACD,SAFD,MAEO;AACLH,UAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;AACF,OArBI;AAuBLG,MAAAA,IAAI,EAAE,MAAM;AACV;;AACA,YAAIR,6BAAJ,EAAgB;AACdA,wCAAWC,eAAX,CAA2BH,UAA3B,EAAuCI,aAAMO,MAA7C;AACD,SAFD,MAEO;AACLL,UAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;AACF,OAhCI;AAkCLK,MAAAA,GAAG,EAAE,MAAM;AACT;;AACA,YAAIV,6BAAJ,EAAgB;AACdA,wCAAWC,eAAX,CAA2BH,UAA3B,EAAuCI,aAAMS,GAA7C;AACD,SAFD,MAEO;AACLP,UAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;AACF;AA3CI,KAAP;AA6CD;;AAhDgC,CAA5B","sourcesContent":["import { Reanimated } from './reanimatedWrapper';\nimport { State } from '../../State';\n\nexport interface GestureStateManagerType {\n begin: () => void;\n activate: () => void;\n fail: () => void;\n end: () => void;\n}\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n 'worklet';\n return {\n begin: () => {\n 'worklet';\n if (Reanimated) {\n Reanimated.setGestureState(handlerTag, State.BEGAN);\n } else {\n console.warn(\n 'react-native-reanimated is required in order to use synchronous state management'\n );\n }\n },\n\n activate: () => {\n 'worklet';\n if (Reanimated) {\n Reanimated.setGestureState(handlerTag, State.ACTIVE);\n } else {\n console.warn(\n 'react-native-reanimated is required in order to use synchronous state management'\n );\n }\n },\n\n fail: () => {\n 'worklet';\n if (Reanimated) {\n Reanimated.setGestureState(handlerTag, State.FAILED);\n } else {\n console.warn(\n 'react-native-reanimated is required in order to use synchronous state management'\n );\n }\n },\n\n end: () => {\n 'worklet';\n if (Reanimated) {\n Reanimated.setGestureState(handlerTag, State.END);\n } else {\n console.warn(\n 'react-native-reanimated is required in order to use synchronous state management'\n );\n }\n },\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LongPressGesture = void 0;
|
|
7
|
+
|
|
8
|
+
var _gesture = require("./gesture");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
class LongPressGesture extends _gesture.BaseGesture {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "config", {});
|
|
17
|
+
|
|
18
|
+
this.handlerName = 'LongPressGestureHandler';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
minDuration(duration) {
|
|
22
|
+
this.config.minDurationMs = duration;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
maxDistance(distance) {
|
|
27
|
+
this.config.maxDist = distance;
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.LongPressGesture = LongPressGesture;
|
|
34
|
+
//# sourceMappingURL=longPressGesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["longPressGesture.ts"],"names":["LongPressGesture","BaseGesture","constructor","handlerName","minDuration","duration","config","minDurationMs","maxDistance","distance","maxDist"],"mappings":";;;;;;;AAAA;;;;AAMO,MAAMA,gBAAN,SAA+BC,oBAA/B,CAAgF;AAGrFC,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF8C,EAE9C;;AAGZ,SAAKC,WAAL,GAAmB,yBAAnB;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AAjBoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n }\n\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}
|