react-native-reanimated 3.8.0 → 3.9.0-layout-animation-experimental
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/Common/cpp/Fabric/ShadowTreeCloner.cpp +5 -2
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +42 -32
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +5 -7
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +565 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +74 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +140 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +216 -58
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +32 -11
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +2 -17
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -8
- package/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp +3 -0
- package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +3 -4
- package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +8 -3
- package/Common/cpp/SharedItems/Shareables.cpp +31 -5
- package/Common/cpp/SharedItems/Shareables.h +18 -2
- package/Common/cpp/Tools/JSScheduler.cpp +29 -5
- package/Common/cpp/Tools/JSScheduler.h +21 -4
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -2
- package/Common/cpp/Tools/UIRuntimeDecorator.cpp +6 -0
- package/Common/cpp/Tools/UIRuntimeDecorator.h +1 -0
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +17 -5
- package/android/src/main/cpp/NativeProxy.cpp +77 -12
- package/android/src/main/cpp/NativeProxy.h +35 -1
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +58 -19
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +7 -2
- package/android/src/{reactNativeVersionPatch/ReanimatedUIManager/latest → main/java}/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +5 -5
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -6
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +18 -1
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +105 -17
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +2 -1
- package/android/src/paper/java/com/swmansion/reanimated/NativeReanimatedModuleSpec.java +37 -0
- package/android/src/{main/java/com/swmansion/reanimated → reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion}/ReanimatedModule.java +4 -3
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/{70 → 73}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -22
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedModule.java +176 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -26
- package/android/src/{fabric/java → reactNativeVersionPatch/RuntimeExecutor/73}/com/swmansion/reanimated/NativeProxy.java +16 -4
- package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +143 -0
- package/apple/LayoutReanimation/REAAnimationsManager.h +3 -0
- package/apple/LayoutReanimation/REAAnimationsManager.m +11 -0
- package/apple/LayoutReanimation/REASharedTransitionManager.m +99 -23
- package/apple/LayoutReanimation/REASnapshot.h +1 -0
- package/apple/LayoutReanimation/REASnapshot.m +78 -37
- package/apple/REAModule.h +22 -2
- package/apple/REAModule.mm +97 -46
- package/apple/REANodesManager.h +3 -3
- package/apple/REANodesManager.mm +46 -22
- package/apple/native/NativeProxy.h +28 -2
- package/apple/native/NativeProxy.mm +65 -195
- package/apple/native/PlatformDepMethodsHolderImpl.h +59 -0
- package/apple/native/PlatformDepMethodsHolderImpl.mm +429 -0
- package/apple/sensor/ReanimatedSensor.m +5 -5
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +1 -1
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/animationBuilder.js +1 -0
- package/lib/module/animationBuilder.js.map +1 -1
- package/lib/module/createAnimatedComponent/InlinePropManager.js +4 -4
- package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +9 -6
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js +11 -0
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -0
- package/lib/module/createAnimatedComponent/PropsFilter.js +25 -9
- package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
- package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +83 -52
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/getViewInfo.js +37 -0
- package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -0
- package/lib/module/createAnimatedComponent/index.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/createAnimatedComponent/utils.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/mock.js +12 -12
- package/lib/module/mock.js.map +1 -1
- package/lib/module/propsAllowlists.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +4 -11
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -7
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -13
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js +2 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +1 -1
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/PropsRegistry.js +1 -2
- package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
- package/lib/module/reanimated2/Sensor.js +2 -2
- package/lib/module/reanimated2/Sensor.js.map +1 -1
- package/lib/module/reanimated2/SensorContainer.js +2 -2
- package/lib/module/reanimated2/SensorContainer.js.map +1 -1
- package/lib/module/reanimated2/UpdateLayoutAnimations.js +30 -8
- package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/clamp.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +1 -6
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +1 -5
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +8 -10
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +4 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +22 -2
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +3 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +1 -0
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js +1 -0
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/PerformanceMonitor.js +169 -0
- package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -0
- package/lib/module/reanimated2/component/ScrollView.js +1 -0
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js +1 -0
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js +1 -0
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -15
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +8 -8
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +33 -8
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +12 -7
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +4 -5
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +3 -1
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +60 -16
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +2 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +1 -5
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +2 -6
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +1 -1
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/isSharedValue.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +3 -6
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +5 -9
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +2 -2
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +12 -11
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +12 -10
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +11 -4
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +17 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js +16 -12
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +13 -7
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +2 -4
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -4
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/publicGlobals.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +11 -19
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js +20 -0
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js +41 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js +4 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/index.js +5 -0
- package/lib/module/reanimated2/screenTransition/index.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/presets.js +157 -0
- package/lib/module/reanimated2/screenTransition/presets.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js +62 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js +190 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -0
- package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +27 -10
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +9 -34
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/reanimated2/valueUnpacker.js +4 -3
- package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
- package/lib/module/specs/NativeReanimatedModule.js +5 -0
- package/lib/module/specs/NativeReanimatedModule.js.map +1 -0
- package/lib/typescript/ConfigHelper.d.ts +1 -0
- package/lib/typescript/createAnimatedComponent/InlinePropManager.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/JSPropsUpdater.web.d.ts +6 -0
- package/lib/typescript/createAnimatedComponent/PropsFilter.d.ts +3 -0
- package/lib/typescript/createAnimatedComponent/getViewInfo.d.ts +9 -0
- package/lib/typescript/reanimated2/NativeReanimated/NativeReanimated.d.ts +8 -13
- package/lib/typescript/reanimated2/UpdateLayoutAnimations.d.ts +12 -1
- package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -0
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
- package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -0
- package/lib/typescript/reanimated2/core.d.ts +3 -4
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +6 -0
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
- package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +3 -1
- package/lib/typescript/reanimated2/index.d.ts +3 -0
- package/lib/typescript/reanimated2/js-reanimated/JSReanimated.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +2 -1
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +2 -2
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/screenTransition/RNScreensTurboModule.d.ts +2 -0
- package/lib/typescript/reanimated2/screenTransition/animationManager.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/commonTypes.d.ts +38 -0
- package/lib/typescript/reanimated2/screenTransition/index.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/presets.d.ts +11 -0
- package/lib/typescript/reanimated2/screenTransition/styleUpdater.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/swipeSimulator.d.ts +2 -0
- package/lib/typescript/specs/NativeReanimatedModule.d.ts +6 -0
- package/package.json +29 -17
- package/plugin/build/plugin.js +7 -2
- package/src/ConfigHelper.ts +1 -1
- package/src/animationBuilder.tsx +2 -0
- package/src/createAnimatedComponent/InlinePropManager.ts +2 -2
- package/src/createAnimatedComponent/JSPropsUpdater.ts +7 -6
- package/src/createAnimatedComponent/JSPropsUpdater.web.ts +26 -0
- package/src/createAnimatedComponent/PropsFilter.tsx +31 -6
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +108 -60
- package/src/createAnimatedComponent/getViewInfo.ts +39 -0
- package/src/mock.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +33 -35
- package/src/reanimated2/PlatformChecker.ts +3 -2
- package/src/reanimated2/PropsRegistry.ts +1 -3
- package/src/reanimated2/UpdateLayoutAnimations.ts +53 -13
- package/src/reanimated2/WorkletEventHandler.ts +98 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -6
- package/src/reanimated2/animation/timing.ts +9 -1
- package/src/reanimated2/animation/util.ts +28 -3
- package/src/reanimated2/commonTypes.ts +4 -1
- package/src/reanimated2/component/PerformanceMonitor.tsx +216 -0
- package/src/reanimated2/core.ts +9 -31
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/fabricUtils.ts +43 -18
- package/src/reanimated2/globals.d.ts +11 -1
- package/src/reanimated2/hook/commonTypes.ts +10 -0
- package/src/reanimated2/hook/useAnimatedRef.ts +20 -11
- package/src/reanimated2/hook/useEvent.ts +4 -4
- package/src/reanimated2/hook/useScrollViewOffset.ts +94 -23
- package/src/reanimated2/index.ts +11 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +7 -7
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationsManager.ts +10 -2
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts +17 -8
- package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +26 -7
- package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
- package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
- package/src/reanimated2/screenTransition/RNScreensTurboModule.ts +29 -0
- package/src/reanimated2/screenTransition/animationManager.ts +45 -0
- package/src/reanimated2/screenTransition/commonTypes.ts +63 -0
- package/src/reanimated2/screenTransition/index.ts +12 -0
- package/src/reanimated2/screenTransition/presets.ts +137 -0
- package/src/reanimated2/screenTransition/styleUpdater.ts +73 -0
- package/src/reanimated2/screenTransition/swipeSimulator.ts +238 -0
- package/src/reanimated2/shareables.ts +29 -6
- package/src/reanimated2/valueUnpacker.ts +10 -3
- package/src/specs/NativeReanimatedModule.ts +9 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +0 -16
- package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +0 -12
|
@@ -14,7 +14,7 @@ import { FadingTransition } from './transition/Fading.web';
|
|
|
14
14
|
import { insertWebAnimation } from './domUtils';
|
|
15
15
|
|
|
16
16
|
// Translate values are passed as numbers. However, if `translate` property receives number, it will not automatically
|
|
17
|
-
// convert it to `px`. Therefore if we want to keep
|
|
17
|
+
// convert it to `px`. Therefore if we want to keep existing transform we have to add 'px' suffix to each of translate values
|
|
18
18
|
// that are present inside transform.
|
|
19
19
|
function addPxToTranslate(
|
|
20
20
|
existingTransform: NonNullable<TransformsStyle['transform']>
|
|
@@ -43,7 +43,7 @@ function addPxToTranslate(
|
|
|
43
43
|
return newTransform;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// In order to keep
|
|
46
|
+
// In order to keep existing transform throughout animation, we have to add it to each of keyframe step.
|
|
47
47
|
function addExistingTransform(
|
|
48
48
|
newAnimationData: AnimationData,
|
|
49
49
|
newTransform: ReanimatedWebTransformProperties[]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import type { RNScreensTurboModuleType } from './commonTypes';
|
|
3
|
+
|
|
4
|
+
function noopFactory<T>(defaultReturnValue?: T): () => T {
|
|
5
|
+
return () => {
|
|
6
|
+
'worklet';
|
|
7
|
+
console.warn(
|
|
8
|
+
'[Reanimated] RNScreensTurboModule has not been found. Check that you have installed `react-native-screens@3.30.0` or newer in your project and rebuilt your app.'
|
|
9
|
+
);
|
|
10
|
+
return defaultReturnValue as T;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type TransactionConfig = {
|
|
15
|
+
topScreenId: number;
|
|
16
|
+
belowTopScreenId: number;
|
|
17
|
+
canStartTransition: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const RNScreensTurboModule: RNScreensTurboModuleType =
|
|
21
|
+
global.RNScreensTurboModule || {
|
|
22
|
+
startTransition: noopFactory<TransactionConfig>({
|
|
23
|
+
topScreenId: -1,
|
|
24
|
+
belowTopScreenId: -1,
|
|
25
|
+
canStartTransition: false,
|
|
26
|
+
}),
|
|
27
|
+
updateTransition: noopFactory(),
|
|
28
|
+
finishTransition: noopFactory(),
|
|
29
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { LockAxis, ScreenTransitionConfig } from './commonTypes';
|
|
4
|
+
import { configureProps } from '../../ConfigHelper';
|
|
5
|
+
import { applyStyle } from './styleUpdater';
|
|
6
|
+
import { getSwipeSimulator } from './swipeSimulator';
|
|
7
|
+
|
|
8
|
+
configureProps();
|
|
9
|
+
|
|
10
|
+
export function startScreenTransition(
|
|
11
|
+
screenTransitionConfig: ScreenTransitionConfig
|
|
12
|
+
) {
|
|
13
|
+
'worklet';
|
|
14
|
+
const { stackTag, sharedEvent } = screenTransitionConfig;
|
|
15
|
+
sharedEvent.addListener(stackTag, () => {
|
|
16
|
+
applyStyle(screenTransitionConfig, sharedEvent.value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getLockAxis(goBackGesture: string): LockAxis {
|
|
21
|
+
'worklet';
|
|
22
|
+
if (['swipeRight', 'swipeLeft', 'horizontalSwipe'].includes(goBackGesture)) {
|
|
23
|
+
return 'x';
|
|
24
|
+
} else if (
|
|
25
|
+
['swipeUp', 'swipeDown', 'verticalSwipe'].includes(goBackGesture)
|
|
26
|
+
) {
|
|
27
|
+
return 'y';
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function finishScreenTransition(
|
|
33
|
+
screenTransitionConfig: ScreenTransitionConfig
|
|
34
|
+
) {
|
|
35
|
+
'worklet';
|
|
36
|
+
const { stackTag, sharedEvent, goBackGesture } = screenTransitionConfig;
|
|
37
|
+
sharedEvent.removeListener(stackTag);
|
|
38
|
+
const lockAxis = getLockAxis(goBackGesture);
|
|
39
|
+
const step = getSwipeSimulator(
|
|
40
|
+
sharedEvent.value,
|
|
41
|
+
screenTransitionConfig,
|
|
42
|
+
lockAxis
|
|
43
|
+
);
|
|
44
|
+
step();
|
|
45
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
MeasuredDimensions,
|
|
5
|
+
ShadowNodeWrapper,
|
|
6
|
+
SharedValue,
|
|
7
|
+
} from '../commonTypes';
|
|
8
|
+
|
|
9
|
+
export type PanGestureHandlerEventPayload = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
absoluteX: number;
|
|
13
|
+
absoluteY: number;
|
|
14
|
+
translationX: number;
|
|
15
|
+
translationY: number;
|
|
16
|
+
velocityX: number;
|
|
17
|
+
velocityY: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type AnimatedScreenTransition = {
|
|
21
|
+
topScreenStyle: (
|
|
22
|
+
event: PanGestureHandlerEventPayload,
|
|
23
|
+
screenDimensions: MeasuredDimensions
|
|
24
|
+
) => Record<string, unknown>;
|
|
25
|
+
belowTopScreenStyle: (
|
|
26
|
+
event: PanGestureHandlerEventPayload,
|
|
27
|
+
screenDimensions: MeasuredDimensions
|
|
28
|
+
) => Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type GoBackGesture =
|
|
32
|
+
| 'swipeRight'
|
|
33
|
+
| 'swipeLeft'
|
|
34
|
+
| 'swipeUp'
|
|
35
|
+
| 'swipeDown'
|
|
36
|
+
| 'verticalSwipe'
|
|
37
|
+
| 'horizontalSwipe'
|
|
38
|
+
| 'twoDimensionalSwipe';
|
|
39
|
+
|
|
40
|
+
export type ScreenTransitionConfig = {
|
|
41
|
+
stackTag: number;
|
|
42
|
+
belowTopScreenId: number | ShadowNodeWrapper;
|
|
43
|
+
topScreenId: number | ShadowNodeWrapper;
|
|
44
|
+
screenTransition: AnimatedScreenTransition;
|
|
45
|
+
sharedEvent: SharedValue<PanGestureHandlerEventPayload>;
|
|
46
|
+
startingGesturePosition: SharedValue<PanGestureHandlerEventPayload>;
|
|
47
|
+
onFinishAnimation?: () => void;
|
|
48
|
+
isTransitionCanceled: boolean;
|
|
49
|
+
goBackGesture: GoBackGesture;
|
|
50
|
+
screenDimensions: MeasuredDimensions;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type RNScreensTurboModuleType = {
|
|
54
|
+
startTransition: (stackTag: number) => {
|
|
55
|
+
topScreenId: number | ShadowNodeWrapper;
|
|
56
|
+
belowTopScreenId: number | ShadowNodeWrapper;
|
|
57
|
+
canStartTransition: boolean;
|
|
58
|
+
};
|
|
59
|
+
updateTransition: (stackTag: number, progress: number) => void;
|
|
60
|
+
finishTransition: (stackTag: number, isCanceled: boolean) => void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type LockAxis = 'x' | 'y' | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
startScreenTransition,
|
|
5
|
+
finishScreenTransition,
|
|
6
|
+
} from './animationManager';
|
|
7
|
+
export { ScreenTransition } from './presets';
|
|
8
|
+
export type {
|
|
9
|
+
AnimatedScreenTransition,
|
|
10
|
+
GoBackGesture,
|
|
11
|
+
ScreenTransitionConfig,
|
|
12
|
+
} from './commonTypes';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { AnimatedScreenTransition } from './commonTypes';
|
|
4
|
+
|
|
5
|
+
const SwipeRight: AnimatedScreenTransition = {
|
|
6
|
+
topScreenStyle: (event) => {
|
|
7
|
+
'worklet';
|
|
8
|
+
return {
|
|
9
|
+
transform: [{ translateX: event.translationX }],
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
belowTopScreenStyle: (event, screenSize) => {
|
|
13
|
+
'worklet';
|
|
14
|
+
return {
|
|
15
|
+
transform: [
|
|
16
|
+
{ translateX: (event.translationX - screenSize.width) * 0.3 },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const SwipeLeft: AnimatedScreenTransition = {
|
|
23
|
+
topScreenStyle: (event) => {
|
|
24
|
+
'worklet';
|
|
25
|
+
return {
|
|
26
|
+
transform: [{ translateX: event.translationX }],
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
belowTopScreenStyle: (event, screenSize) => {
|
|
30
|
+
'worklet';
|
|
31
|
+
return {
|
|
32
|
+
transform: [
|
|
33
|
+
{ translateX: (event.translationX + screenSize.width) * 0.3 },
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const SwipeDown: AnimatedScreenTransition = {
|
|
40
|
+
topScreenStyle: (event) => {
|
|
41
|
+
'worklet';
|
|
42
|
+
return {
|
|
43
|
+
transform: [{ translateY: event.translationY }],
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
belowTopScreenStyle: (event, screenSize) => {
|
|
47
|
+
'worklet';
|
|
48
|
+
return {
|
|
49
|
+
transform: [
|
|
50
|
+
{ translateY: (event.translationY - screenSize.height) * 0.3 },
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const SwipeUp: AnimatedScreenTransition = {
|
|
57
|
+
topScreenStyle: (event) => {
|
|
58
|
+
'worklet';
|
|
59
|
+
return {
|
|
60
|
+
transform: [{ translateY: event.translationY }],
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
belowTopScreenStyle: (event, screenSize) => {
|
|
64
|
+
'worklet';
|
|
65
|
+
return {
|
|
66
|
+
transform: [
|
|
67
|
+
{ translateY: (event.translationY + screenSize.height) * 0.3 },
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const TwoDimensional: AnimatedScreenTransition = {
|
|
74
|
+
topScreenStyle: (event, _screenSize) => {
|
|
75
|
+
'worklet';
|
|
76
|
+
return {
|
|
77
|
+
transform: [
|
|
78
|
+
{ translateX: event.translationX },
|
|
79
|
+
{ translateY: event.translationY },
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
belowTopScreenStyle: (_event, _screenSize) => {
|
|
84
|
+
'worklet';
|
|
85
|
+
return {};
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const Horizontal: AnimatedScreenTransition = {
|
|
90
|
+
topScreenStyle: (event, _screenSize) => {
|
|
91
|
+
'worklet';
|
|
92
|
+
return {
|
|
93
|
+
transform: [{ translateX: event.translationX }],
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
belowTopScreenStyle: (_event, _screenSize) => {
|
|
97
|
+
'worklet';
|
|
98
|
+
return {};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const Vertical: AnimatedScreenTransition = {
|
|
103
|
+
topScreenStyle: (event, _screenSize) => {
|
|
104
|
+
'worklet';
|
|
105
|
+
return {
|
|
106
|
+
transform: [{ translateY: event.translationY }],
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
belowTopScreenStyle: (_event, _screenSize) => {
|
|
110
|
+
'worklet';
|
|
111
|
+
return {};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const SwipeRightFade: AnimatedScreenTransition = {
|
|
116
|
+
topScreenStyle: (event, screenSize) => {
|
|
117
|
+
'worklet';
|
|
118
|
+
return {
|
|
119
|
+
opacity: 1 - Math.abs(event.translationX / screenSize.width),
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
belowTopScreenStyle: (_event, _screenSize) => {
|
|
123
|
+
'worklet';
|
|
124
|
+
return {};
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const ScreenTransition = {
|
|
129
|
+
SwipeRight,
|
|
130
|
+
SwipeLeft,
|
|
131
|
+
SwipeDown,
|
|
132
|
+
SwipeUp,
|
|
133
|
+
Horizontal,
|
|
134
|
+
Vertical,
|
|
135
|
+
TwoDimensional,
|
|
136
|
+
SwipeRightFade,
|
|
137
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { isFabric } from '../PlatformChecker';
|
|
3
|
+
import updateProps from '../UpdateProps';
|
|
4
|
+
import type { ShadowNodeWrapper, SharedValue } from '../commonTypes';
|
|
5
|
+
import type { Descriptor } from '../hook/commonTypes';
|
|
6
|
+
import type {
|
|
7
|
+
PanGestureHandlerEventPayload,
|
|
8
|
+
ScreenTransitionConfig,
|
|
9
|
+
} from './commonTypes';
|
|
10
|
+
|
|
11
|
+
const IS_FABRIC = isFabric();
|
|
12
|
+
|
|
13
|
+
function createViewDescriptorPaper(screenId: number | ShadowNodeWrapper) {
|
|
14
|
+
'worklet';
|
|
15
|
+
return { tag: screenId, name: 'RCTView' };
|
|
16
|
+
}
|
|
17
|
+
function createViewDescriptorFabric(screenId: number | ShadowNodeWrapper) {
|
|
18
|
+
'worklet';
|
|
19
|
+
return { shadowNodeWrapper: screenId };
|
|
20
|
+
}
|
|
21
|
+
const createViewDescriptor = IS_FABRIC
|
|
22
|
+
? createViewDescriptorFabric
|
|
23
|
+
: createViewDescriptorPaper;
|
|
24
|
+
|
|
25
|
+
function applyStyleForTopScreen(
|
|
26
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
27
|
+
event: PanGestureHandlerEventPayload
|
|
28
|
+
) {
|
|
29
|
+
'worklet';
|
|
30
|
+
const { screenDimensions, topScreenId, screenTransition } =
|
|
31
|
+
screenTransitionConfig;
|
|
32
|
+
const { topScreenStyle: computeTopScreenStyle } = screenTransition;
|
|
33
|
+
const topScreenStyle = computeTopScreenStyle(event, screenDimensions);
|
|
34
|
+
const topScreenDescriptor = {
|
|
35
|
+
value: [createViewDescriptor(topScreenId)],
|
|
36
|
+
};
|
|
37
|
+
updateProps(
|
|
38
|
+
topScreenDescriptor as SharedValue<Descriptor[]>,
|
|
39
|
+
topScreenStyle,
|
|
40
|
+
undefined
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function applyStyleForBelowTopScreen(
|
|
45
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
46
|
+
event: PanGestureHandlerEventPayload
|
|
47
|
+
) {
|
|
48
|
+
'worklet';
|
|
49
|
+
const { screenDimensions, belowTopScreenId, screenTransition } =
|
|
50
|
+
screenTransitionConfig;
|
|
51
|
+
const { belowTopScreenStyle: computeBelowTopScreenStyle } = screenTransition;
|
|
52
|
+
const belowTopScreenStyle = computeBelowTopScreenStyle(
|
|
53
|
+
event,
|
|
54
|
+
screenDimensions
|
|
55
|
+
);
|
|
56
|
+
const belowTopScreenDescriptor = {
|
|
57
|
+
value: [createViewDescriptor(belowTopScreenId)],
|
|
58
|
+
};
|
|
59
|
+
updateProps(
|
|
60
|
+
belowTopScreenDescriptor as SharedValue<Descriptor[]>,
|
|
61
|
+
belowTopScreenStyle,
|
|
62
|
+
undefined
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function applyStyle(
|
|
67
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
68
|
+
event: PanGestureHandlerEventPayload
|
|
69
|
+
) {
|
|
70
|
+
'worklet';
|
|
71
|
+
applyStyleForTopScreen(screenTransitionConfig, event);
|
|
72
|
+
applyStyleForBelowTopScreen(screenTransitionConfig, event);
|
|
73
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import type {
|
|
3
|
+
PanGestureHandlerEventPayload,
|
|
4
|
+
ScreenTransitionConfig,
|
|
5
|
+
LockAxis,
|
|
6
|
+
} from './commonTypes';
|
|
7
|
+
import { applyStyle, applyStyleForBelowTopScreen } from './styleUpdater';
|
|
8
|
+
import { RNScreensTurboModule } from './RNScreensTurboModule';
|
|
9
|
+
|
|
10
|
+
const BASE_VELOCITY = 400;
|
|
11
|
+
const ADDITIONAL_VELOCITY_FACTOR_X = 400;
|
|
12
|
+
const ADDITIONAL_VELOCITY_FACTOR_Y = 500;
|
|
13
|
+
const ADDITIONAL_VELOCITY_FACTOR_XY = 600;
|
|
14
|
+
|
|
15
|
+
function computeEasingProgress(
|
|
16
|
+
startingTimestamp: number,
|
|
17
|
+
distance: number,
|
|
18
|
+
velocity: number
|
|
19
|
+
) {
|
|
20
|
+
'worklet';
|
|
21
|
+
if (Math.abs(distance) < 1) {
|
|
22
|
+
return 1;
|
|
23
|
+
}
|
|
24
|
+
const elapsedTime = (_getAnimationTimestamp() - startingTimestamp) / 1000;
|
|
25
|
+
const currentPosition = velocity * elapsedTime;
|
|
26
|
+
const progress = currentPosition / distance;
|
|
27
|
+
return progress;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function easing(x: number): number {
|
|
31
|
+
'worklet';
|
|
32
|
+
// based on https://easings.net/#easeOutQuart
|
|
33
|
+
return 1 - Math.pow(1 - x, 5);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function computeProgress(
|
|
37
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
38
|
+
event: PanGestureHandlerEventPayload,
|
|
39
|
+
isTransitionCanceled: boolean
|
|
40
|
+
) {
|
|
41
|
+
'worklet';
|
|
42
|
+
const screenDimensions = screenTransitionConfig.screenDimensions;
|
|
43
|
+
const progressX = Math.abs(event.translationX / screenDimensions.width);
|
|
44
|
+
const progressY = Math.abs(event.translationY / screenDimensions.height);
|
|
45
|
+
const maxProgress = Math.max(progressX, progressY);
|
|
46
|
+
const progress = isTransitionCanceled ? maxProgress / 2 : maxProgress;
|
|
47
|
+
return progress;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function maybeScheduleNextFrame(
|
|
51
|
+
step: () => void,
|
|
52
|
+
didScreenReachDestination: boolean,
|
|
53
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
54
|
+
event: PanGestureHandlerEventPayload,
|
|
55
|
+
isTransitionCanceled: boolean
|
|
56
|
+
) {
|
|
57
|
+
'worklet';
|
|
58
|
+
if (!didScreenReachDestination) {
|
|
59
|
+
const stackTag = screenTransitionConfig.stackTag;
|
|
60
|
+
const progress = computeProgress(
|
|
61
|
+
screenTransitionConfig,
|
|
62
|
+
event,
|
|
63
|
+
isTransitionCanceled
|
|
64
|
+
);
|
|
65
|
+
RNScreensTurboModule.updateTransition(stackTag, progress);
|
|
66
|
+
requestAnimationFrame(step);
|
|
67
|
+
} else {
|
|
68
|
+
screenTransitionConfig.onFinishAnimation?.();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function getSwipeSimulator(
|
|
73
|
+
event: PanGestureHandlerEventPayload,
|
|
74
|
+
screenTransitionConfig: ScreenTransitionConfig,
|
|
75
|
+
lockAxis?: LockAxis
|
|
76
|
+
) {
|
|
77
|
+
'worklet';
|
|
78
|
+
const screenDimensions = screenTransitionConfig.screenDimensions;
|
|
79
|
+
const startTimestamp = _getAnimationTimestamp();
|
|
80
|
+
const { isTransitionCanceled } = screenTransitionConfig;
|
|
81
|
+
const startingPosition = {
|
|
82
|
+
x: event.translationX,
|
|
83
|
+
y: event.translationY,
|
|
84
|
+
};
|
|
85
|
+
const direction = {
|
|
86
|
+
x: Math.sign(event.translationX),
|
|
87
|
+
y: Math.sign(event.translationY),
|
|
88
|
+
};
|
|
89
|
+
const finalPosition = isTransitionCanceled
|
|
90
|
+
? { x: 0, y: 0 }
|
|
91
|
+
: {
|
|
92
|
+
x: direction.x * screenDimensions.width,
|
|
93
|
+
y: direction.y * screenDimensions.height,
|
|
94
|
+
};
|
|
95
|
+
const distance = {
|
|
96
|
+
x: Math.abs(finalPosition.x - startingPosition.x),
|
|
97
|
+
y: Math.abs(finalPosition.y - startingPosition.y),
|
|
98
|
+
};
|
|
99
|
+
const didScreenReachDestination = {
|
|
100
|
+
x: false,
|
|
101
|
+
y: false,
|
|
102
|
+
};
|
|
103
|
+
const velocity = { x: BASE_VELOCITY, y: BASE_VELOCITY };
|
|
104
|
+
if (lockAxis === 'x') {
|
|
105
|
+
velocity.y = 0;
|
|
106
|
+
velocity.x +=
|
|
107
|
+
(ADDITIONAL_VELOCITY_FACTOR_X * distance.x) / screenDimensions.width;
|
|
108
|
+
} else if (lockAxis === 'y') {
|
|
109
|
+
velocity.x = 0;
|
|
110
|
+
velocity.y +=
|
|
111
|
+
(ADDITIONAL_VELOCITY_FACTOR_Y * distance.y) / screenDimensions.height;
|
|
112
|
+
} else {
|
|
113
|
+
const euclideanDistance = Math.sqrt(distance.x ** 2 + distance.y ** 2);
|
|
114
|
+
const screenDiagonal = Math.sqrt(
|
|
115
|
+
screenDimensions.width ** 2 + screenDimensions.height ** 2
|
|
116
|
+
);
|
|
117
|
+
const velocityVectorLength =
|
|
118
|
+
BASE_VELOCITY +
|
|
119
|
+
(ADDITIONAL_VELOCITY_FACTOR_XY * euclideanDistance) / screenDiagonal;
|
|
120
|
+
if (Math.abs(startingPosition.x) > Math.abs(startingPosition.y)) {
|
|
121
|
+
velocity.x = velocityVectorLength;
|
|
122
|
+
velocity.y =
|
|
123
|
+
velocityVectorLength *
|
|
124
|
+
Math.abs(startingPosition.y / startingPosition.x);
|
|
125
|
+
} else {
|
|
126
|
+
velocity.x =
|
|
127
|
+
velocityVectorLength *
|
|
128
|
+
Math.abs(startingPosition.x / startingPosition.y);
|
|
129
|
+
velocity.y = velocityVectorLength;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (isTransitionCanceled) {
|
|
134
|
+
function didScreenReachDestinationCheck() {
|
|
135
|
+
if (lockAxis === 'x') {
|
|
136
|
+
return didScreenReachDestination.x;
|
|
137
|
+
} else if (lockAxis === 'y') {
|
|
138
|
+
return didScreenReachDestination.y;
|
|
139
|
+
} else {
|
|
140
|
+
return didScreenReachDestination.x && didScreenReachDestination.y;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function restoreOriginalStyleForBelowTopScreen() {
|
|
145
|
+
event.translationX = direction.x * screenDimensions.width;
|
|
146
|
+
event.translationY = direction.y * screenDimensions.height;
|
|
147
|
+
applyStyleForBelowTopScreen(screenTransitionConfig, event);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const computeFrame = () => {
|
|
151
|
+
const progress = {
|
|
152
|
+
x: computeEasingProgress(startTimestamp, distance.x, velocity.x),
|
|
153
|
+
y: computeEasingProgress(startTimestamp, distance.y, velocity.y),
|
|
154
|
+
};
|
|
155
|
+
event.translationX =
|
|
156
|
+
startingPosition.x - direction.x * distance.x * easing(progress.x);
|
|
157
|
+
event.translationY =
|
|
158
|
+
startingPosition.y - direction.y * distance.y * easing(progress.y);
|
|
159
|
+
if (direction.x > 0) {
|
|
160
|
+
if (event.translationX <= 0) {
|
|
161
|
+
didScreenReachDestination.x = true;
|
|
162
|
+
event.translationX = 0;
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
if (event.translationX >= 0) {
|
|
166
|
+
didScreenReachDestination.x = true;
|
|
167
|
+
event.translationX = 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (direction.y > 0) {
|
|
171
|
+
if (event.translationY <= 0) {
|
|
172
|
+
didScreenReachDestination.y = true;
|
|
173
|
+
event.translationY = 0;
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
if (event.translationY >= 0) {
|
|
177
|
+
didScreenReachDestination.y = true;
|
|
178
|
+
event.translationY = 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
applyStyle(screenTransitionConfig, event);
|
|
182
|
+
const finished = didScreenReachDestinationCheck();
|
|
183
|
+
if (finished) {
|
|
184
|
+
restoreOriginalStyleForBelowTopScreen();
|
|
185
|
+
}
|
|
186
|
+
maybeScheduleNextFrame(
|
|
187
|
+
computeFrame,
|
|
188
|
+
finished,
|
|
189
|
+
screenTransitionConfig,
|
|
190
|
+
event,
|
|
191
|
+
isTransitionCanceled
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
return computeFrame;
|
|
195
|
+
} else {
|
|
196
|
+
const computeFrame = () => {
|
|
197
|
+
const progress = {
|
|
198
|
+
x: computeEasingProgress(startTimestamp, distance.x, velocity.x),
|
|
199
|
+
y: computeEasingProgress(startTimestamp, distance.y, velocity.y),
|
|
200
|
+
};
|
|
201
|
+
event.translationX =
|
|
202
|
+
startingPosition.x + direction.x * distance.x * easing(progress.x);
|
|
203
|
+
event.translationY =
|
|
204
|
+
startingPosition.y + direction.y * distance.y * easing(progress.y);
|
|
205
|
+
if (direction.x > 0) {
|
|
206
|
+
if (event.translationX >= screenDimensions.width) {
|
|
207
|
+
didScreenReachDestination.x = true;
|
|
208
|
+
event.translationX = screenDimensions.width;
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
if (event.translationX <= -screenDimensions.width) {
|
|
212
|
+
didScreenReachDestination.x = true;
|
|
213
|
+
event.translationX = -screenDimensions.width;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (direction.y > 0) {
|
|
217
|
+
if (event.translationY >= screenDimensions.height) {
|
|
218
|
+
didScreenReachDestination.y = true;
|
|
219
|
+
event.translationY = screenDimensions.height;
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
if (event.translationY <= -screenDimensions.height) {
|
|
223
|
+
didScreenReachDestination.y = true;
|
|
224
|
+
event.translationY = -screenDimensions.height;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
applyStyle(screenTransitionConfig, event);
|
|
228
|
+
maybeScheduleNextFrame(
|
|
229
|
+
computeFrame,
|
|
230
|
+
didScreenReachDestination.x || didScreenReachDestination.y,
|
|
231
|
+
screenTransitionConfig,
|
|
232
|
+
event,
|
|
233
|
+
isTransitionCanceled
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
return computeFrame;
|
|
237
|
+
}
|
|
238
|
+
}
|