react-native-reanimated 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +67 -60
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +18 -35
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +4 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +16 -12
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +45 -0
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +38 -11
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +18 -34
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +101 -16
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +4 -9
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -10
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +45 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +38 -9
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +4 -8
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +128 -0
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +47 -11
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
package com.swmansion.reanimated.layoutReanimation;
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
|
+
import android.graphics.Point;
|
|
5
|
+
import android.graphics.Rect;
|
|
4
6
|
import android.util.DisplayMetrics;
|
|
5
7
|
import android.util.Log;
|
|
6
8
|
import android.view.View;
|
|
@@ -10,6 +12,7 @@ import com.facebook.react.bridge.JavaOnlyMap;
|
|
|
10
12
|
import com.facebook.react.bridge.ReactContext;
|
|
11
13
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
|
+
import com.facebook.react.bridge.ReadableNativeArray;
|
|
13
16
|
import com.facebook.react.bridge.WritableMap;
|
|
14
17
|
import com.facebook.react.uimanager.IViewManagerWithChildren;
|
|
15
18
|
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
@@ -24,6 +27,7 @@ import java.util.ArrayList;
|
|
|
24
27
|
import java.util.HashMap;
|
|
25
28
|
import java.util.HashSet;
|
|
26
29
|
import java.util.Map;
|
|
30
|
+
import javax.annotation.Nullable;
|
|
27
31
|
|
|
28
32
|
public class AnimationsManager implements ViewHierarchyObserver {
|
|
29
33
|
private WeakReference<Scheduler> mScheduler;
|
|
@@ -31,12 +35,15 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
31
35
|
private UIManagerModule mUIManager;
|
|
32
36
|
private NativeMethodsHolder mNativeMethodsHolder;
|
|
33
37
|
|
|
38
|
+
private HashSet<Integer> mEnteringViews = new HashSet<>();
|
|
39
|
+
private HashMap<Integer, Rect> mEnteringViewTargetValues = new HashMap<>();
|
|
34
40
|
private HashMap<Integer, View> mExitingViews = new HashMap<>();
|
|
35
41
|
private HashMap<Integer, Integer> mExitingSubviewCountMap = new HashMap<>();
|
|
36
42
|
private HashSet<Integer> mAncestorsToRemove = new HashSet<>();
|
|
37
43
|
private HashMap<Integer, Runnable> mCallbacks = new HashMap<>();
|
|
38
44
|
private ReanimatedNativeHierarchyManager mReanimatedNativeHierarchyManager;
|
|
39
45
|
private boolean isCatalystInstanceDestroyed;
|
|
46
|
+
private SharedTransitionManager mSharedTransitionManager;
|
|
40
47
|
|
|
41
48
|
public void setReanimatedNativeHierarchyManager(
|
|
42
49
|
ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager) {
|
|
@@ -55,6 +62,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
55
62
|
mContext = context;
|
|
56
63
|
mUIManager = uiManagerModule;
|
|
57
64
|
isCatalystInstanceDestroyed = false;
|
|
65
|
+
mSharedTransitionManager = new SharedTransitionManager(this);
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
public void onCatalystInstanceDestroy() {
|
|
@@ -86,8 +94,9 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
86
94
|
if (isCatalystInstanceDestroyed) {
|
|
87
95
|
return;
|
|
88
96
|
}
|
|
97
|
+
maybeRegisterSharedView(view);
|
|
89
98
|
|
|
90
|
-
if (!hasAnimationForTag(view.getId(),
|
|
99
|
+
if (!hasAnimationForTag(view.getId(), LayoutAnimations.Types.ENTERING)) {
|
|
91
100
|
return;
|
|
92
101
|
}
|
|
93
102
|
|
|
@@ -99,8 +108,9 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
99
108
|
HashMap<String, Object> targetValues = after.toTargetMap();
|
|
100
109
|
|
|
101
110
|
if (targetValues != null) {
|
|
102
|
-
HashMap<String,
|
|
103
|
-
mNativeMethodsHolder.startAnimation(tag,
|
|
111
|
+
HashMap<String, Object> preparedValues = prepareDataForAnimationWorklet(targetValues, true);
|
|
112
|
+
mNativeMethodsHolder.startAnimation(tag, LayoutAnimations.Types.ENTERING, preparedValues);
|
|
113
|
+
mEnteringViews.add(tag);
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
|
|
@@ -111,12 +121,29 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
111
121
|
}
|
|
112
122
|
int tag = view.getId();
|
|
113
123
|
|
|
114
|
-
if (!hasAnimationForTag(tag,
|
|
124
|
+
if (!hasAnimationForTag(tag, LayoutAnimations.Types.LAYOUT)) {
|
|
125
|
+
if (mEnteringViews.contains(tag)) {
|
|
126
|
+
// store values to restore after `entering` finishes
|
|
127
|
+
mEnteringViewTargetValues.put(
|
|
128
|
+
tag,
|
|
129
|
+
new Rect(
|
|
130
|
+
after.originX,
|
|
131
|
+
after.originY,
|
|
132
|
+
after.originX + after.width,
|
|
133
|
+
after.originY + after.height));
|
|
134
|
+
// restore layout before the update, so the `entering`
|
|
135
|
+
// can continue from its current location
|
|
136
|
+
view.layout(
|
|
137
|
+
before.originX,
|
|
138
|
+
before.originY,
|
|
139
|
+
before.originX + before.width,
|
|
140
|
+
before.originY + before.height);
|
|
141
|
+
}
|
|
115
142
|
return;
|
|
116
143
|
}
|
|
117
144
|
|
|
118
|
-
HashMap<String, Object> targetValues = after.toTargetMap();
|
|
119
145
|
HashMap<String, Object> startValues = before.toCurrentMap();
|
|
146
|
+
HashMap<String, Object> targetValues = after.toTargetMap();
|
|
120
147
|
|
|
121
148
|
// If startValues are equal to targetValues it means that there was no UI Operation changing
|
|
122
149
|
// layout of the View. So dirtiness of that View is false positive
|
|
@@ -135,17 +162,25 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
135
162
|
}
|
|
136
163
|
|
|
137
164
|
// View must be in Layout state
|
|
138
|
-
HashMap<String,
|
|
139
|
-
|
|
165
|
+
HashMap<String, Object> preparedStartValues =
|
|
166
|
+
prepareDataForAnimationWorklet(startValues, false);
|
|
167
|
+
HashMap<String, Object> preparedTargetValues =
|
|
140
168
|
prepareDataForAnimationWorklet(targetValues, true);
|
|
141
|
-
HashMap<String,
|
|
169
|
+
HashMap<String, Object> preparedValues = new HashMap<>(preparedTargetValues);
|
|
142
170
|
for (String key : preparedStartValues.keySet()) {
|
|
143
171
|
preparedValues.put(key, preparedStartValues.get(key));
|
|
144
172
|
}
|
|
145
|
-
mNativeMethodsHolder.startAnimation(tag,
|
|
173
|
+
mNativeMethodsHolder.startAnimation(tag, LayoutAnimations.Types.LAYOUT, preparedValues);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public void maybeRegisterSharedView(View view) {
|
|
177
|
+
if (hasAnimationForTag(view.getId(), LayoutAnimations.Types.SHARED_ELEMENT_TRANSITION)) {
|
|
178
|
+
mSharedTransitionManager.notifyAboutNewView(view);
|
|
179
|
+
}
|
|
146
180
|
}
|
|
147
181
|
|
|
148
|
-
public void progressLayoutAnimation(
|
|
182
|
+
public void progressLayoutAnimation(
|
|
183
|
+
int tag, Map<String, Object> newStyle, boolean isSharedTransition) {
|
|
149
184
|
View view = resolveView(tag);
|
|
150
185
|
|
|
151
186
|
if (view == null) {
|
|
@@ -161,24 +196,39 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
161
196
|
ViewManager viewManager = resolveViewManager(tag);
|
|
162
197
|
ViewManager parentViewManager = resolveViewManager(parent.getId());
|
|
163
198
|
|
|
164
|
-
|
|
199
|
+
if (viewManager == null) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setNewProps(newStyle, view, viewManager, parentViewManager, parent.getId(), isSharedTransition);
|
|
165
204
|
}
|
|
166
205
|
|
|
167
206
|
public void endLayoutAnimation(int tag, boolean cancelled, boolean removeView) {
|
|
168
|
-
View
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
207
|
+
View view = resolveView(tag);
|
|
208
|
+
|
|
209
|
+
if (view == null) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
Rect target = mEnteringViewTargetValues.get(tag);
|
|
214
|
+
if (!removeView && mEnteringViews.contains(tag) && target != null) {
|
|
215
|
+
view.layout(target.left, target.top, target.right, target.bottom);
|
|
216
|
+
}
|
|
217
|
+
mEnteringViews.remove(tag);
|
|
218
|
+
mEnteringViewTargetValues.remove(tag);
|
|
219
|
+
|
|
220
|
+
if (removeView) {
|
|
221
|
+
if (view instanceof ViewGroup && mAncestorsToRemove.contains(tag)) {
|
|
222
|
+
cancelAnimationsInSubviews((ViewGroup) view);
|
|
172
223
|
}
|
|
173
224
|
|
|
174
225
|
mExitingViews.remove(tag);
|
|
175
|
-
maybeDropAncestors(
|
|
226
|
+
maybeDropAncestors(view);
|
|
176
227
|
|
|
177
|
-
ViewGroup parent = (ViewGroup)
|
|
178
|
-
|
|
179
|
-
removeView(exitingView, parent);
|
|
180
|
-
}
|
|
228
|
+
ViewGroup parent = (ViewGroup) view.getParent();
|
|
229
|
+
removeView(view, parent);
|
|
181
230
|
}
|
|
231
|
+
mSharedTransitionManager.finishSharedAnimation(tag);
|
|
182
232
|
}
|
|
183
233
|
|
|
184
234
|
public void printSubTree(View view, int level) {
|
|
@@ -205,9 +255,14 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
205
255
|
}
|
|
206
256
|
}
|
|
207
257
|
|
|
208
|
-
public HashMap<String,
|
|
258
|
+
public HashMap<String, Object> prepareDataForAnimationWorklet(
|
|
209
259
|
HashMap<String, Object> values, boolean isTargetValues) {
|
|
210
|
-
|
|
260
|
+
return prepareDataForAnimationWorklet(values, isTargetValues, false);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public HashMap<String, Object> prepareDataForAnimationWorklet(
|
|
264
|
+
HashMap<String, Object> values, boolean isTargetValues, boolean addTransform) {
|
|
265
|
+
HashMap<String, Object> preparedValues = new HashMap<>();
|
|
211
266
|
ArrayList<String> keys;
|
|
212
267
|
if (isTargetValues) {
|
|
213
268
|
keys = Snapshot.targetKeysToTransform;
|
|
@@ -218,6 +273,12 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
218
273
|
preparedValues.put(key, PixelUtil.toDIPFromPixel((int) values.get(key)));
|
|
219
274
|
}
|
|
220
275
|
|
|
276
|
+
if (addTransform) {
|
|
277
|
+
String key =
|
|
278
|
+
isTargetValues ? Snapshot.TARGET_TRANSFORM_MATRIX : Snapshot.CURRENT_TRANSFORM_MATRIX;
|
|
279
|
+
preparedValues.put(key, values.get(key));
|
|
280
|
+
}
|
|
281
|
+
|
|
221
282
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
222
283
|
Activity currentActivity = mContext.getCurrentActivity();
|
|
223
284
|
if (currentActivity != null) {
|
|
@@ -235,6 +296,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
235
296
|
|
|
236
297
|
public void setNativeMethods(NativeMethodsHolder nativeMethods) {
|
|
237
298
|
mNativeMethodsHolder = nativeMethods;
|
|
299
|
+
mSharedTransitionManager.setNativeMethods(nativeMethods);
|
|
238
300
|
}
|
|
239
301
|
|
|
240
302
|
public void setNewProps(
|
|
@@ -242,7 +304,8 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
242
304
|
View view,
|
|
243
305
|
ViewManager viewManager,
|
|
244
306
|
ViewManager parentViewManager,
|
|
245
|
-
Integer parentTag
|
|
307
|
+
Integer parentTag,
|
|
308
|
+
boolean isPositionAbsolute) {
|
|
246
309
|
float x =
|
|
247
310
|
(props.get(Snapshot.ORIGIN_X) != null)
|
|
248
311
|
? ((Double) props.get(Snapshot.ORIGIN_X)).floatValue()
|
|
@@ -259,9 +322,37 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
259
322
|
(props.get(Snapshot.HEIGHT) != null)
|
|
260
323
|
? ((Double) props.get(Snapshot.HEIGHT)).floatValue()
|
|
261
324
|
: PixelUtil.toDIPFromPixel(view.getHeight());
|
|
262
|
-
|
|
325
|
+
|
|
326
|
+
if (props.containsKey(Snapshot.TRANSFORM_MATRIX)) {
|
|
327
|
+
float[] matrixValues = new float[9];
|
|
328
|
+
if (props.get(Snapshot.TRANSFORM_MATRIX) instanceof ReadableNativeArray) {
|
|
329
|
+
// this array comes from JavaScript
|
|
330
|
+
ReadableNativeArray matrixArray =
|
|
331
|
+
(ReadableNativeArray) props.get(Snapshot.TRANSFORM_MATRIX);
|
|
332
|
+
for (int i = 0; i < 9; i++) {
|
|
333
|
+
matrixValues[i] = ((Double) matrixArray.getDouble(i)).floatValue();
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
// this array comes from Java
|
|
337
|
+
ArrayList<Float> casted = (ArrayList<Float>) props.get(Snapshot.TRANSFORM_MATRIX);
|
|
338
|
+
for (int i = 0; i < 9; i++) {
|
|
339
|
+
matrixValues[i] = casted.get(i);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
view.setScaleX(matrixValues[0]);
|
|
343
|
+
view.setScaleY(matrixValues[4]);
|
|
344
|
+
// as far, let's support only scale and translation. Rotation maybe the future feature
|
|
345
|
+
// (http://eecs.qmul.ac.uk/~gslabaugh/publications/euler.pdf)
|
|
346
|
+
|
|
347
|
+
props.remove(Snapshot.TRANSFORM_MATRIX);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
updateLayout(
|
|
351
|
+
view, parentViewManager, parentTag, view.getId(), x, y, width, height, isPositionAbsolute);
|
|
263
352
|
props.remove(Snapshot.ORIGIN_X);
|
|
264
353
|
props.remove(Snapshot.ORIGIN_Y);
|
|
354
|
+
props.remove(Snapshot.GLOBAL_ORIGIN_X);
|
|
355
|
+
props.remove(Snapshot.GLOBAL_ORIGIN_Y);
|
|
265
356
|
props.remove(Snapshot.WIDTH);
|
|
266
357
|
props.remove(Snapshot.HEIGHT);
|
|
267
358
|
|
|
@@ -307,7 +398,8 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
307
398
|
float xf,
|
|
308
399
|
float yf,
|
|
309
400
|
float widthf,
|
|
310
|
-
float heightf
|
|
401
|
+
float heightf,
|
|
402
|
+
boolean isPositionAbsolute) {
|
|
311
403
|
|
|
312
404
|
int x = Math.round(PixelUtil.toPixelFromDIP(xf));
|
|
313
405
|
int y = Math.round(PixelUtil.toPixelFromDIP(yf));
|
|
@@ -348,7 +440,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
348
440
|
}
|
|
349
441
|
|
|
350
442
|
// Check if the parent of the view has to layout the view, or the child has to lay itself out.
|
|
351
|
-
if (parentTag % 10 == 1) { // ParentIsARoot
|
|
443
|
+
if (parentTag % 10 == 1 && parentViewManager != null) { // parentTag % 10 == 1 - ParentIsARoot
|
|
352
444
|
IViewManagerWithChildren parentViewManagerWithChildren;
|
|
353
445
|
if (parentViewManager instanceof IViewManagerWithChildren) {
|
|
354
446
|
parentViewManagerWithChildren = (IViewManagerWithChildren) parentViewManager;
|
|
@@ -362,11 +454,18 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
362
454
|
viewToUpdate.layout(x, y, x + width, y + height);
|
|
363
455
|
}
|
|
364
456
|
} else {
|
|
457
|
+
if (isPositionAbsolute) {
|
|
458
|
+
Point newPoint = new Point(x, y);
|
|
459
|
+
View viewToUpdateParent = (View) viewToUpdate.getParent();
|
|
460
|
+
Point convertedPoint = convertScreenLocationToViewCoordinates(newPoint, viewToUpdateParent);
|
|
461
|
+
x = convertedPoint.x;
|
|
462
|
+
y = convertedPoint.y;
|
|
463
|
+
}
|
|
365
464
|
viewToUpdate.layout(x, y, x + width, y + height);
|
|
366
465
|
}
|
|
367
466
|
}
|
|
368
467
|
|
|
369
|
-
public boolean hasAnimationForTag(int tag,
|
|
468
|
+
public boolean hasAnimationForTag(int tag, int type) {
|
|
370
469
|
return mNativeMethodsHolder.hasAnimation(tag, type);
|
|
371
470
|
}
|
|
372
471
|
|
|
@@ -376,10 +475,23 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
376
475
|
|
|
377
476
|
private boolean removeOrAnimateExitRecursive(View view, ViewGroup parent, boolean shouldRemove) {
|
|
378
477
|
int tag = view.getId();
|
|
379
|
-
|
|
478
|
+
ViewManager viewManager = resolveViewManager(tag);
|
|
479
|
+
|
|
480
|
+
if (viewManager != null && viewManager.getName().equals("RNSScreenStack")) {
|
|
481
|
+
cancelAnimationsRecursive(view);
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
boolean hasExitAnimation =
|
|
486
|
+
hasAnimationForTag(tag, LayoutAnimations.Types.EXITING) || mExitingViews.containsKey(tag);
|
|
380
487
|
boolean hasAnimatedChildren = false;
|
|
381
488
|
shouldRemove = shouldRemove && !hasExitAnimation;
|
|
382
489
|
|
|
490
|
+
if (hasAnimationForTag(tag, LayoutAnimations.Types.SHARED_ELEMENT_TRANSITION)) {
|
|
491
|
+
mSharedTransitionManager.notifyAboutRemovedView(view);
|
|
492
|
+
mSharedTransitionManager.makeSnapshot(view);
|
|
493
|
+
}
|
|
494
|
+
|
|
383
495
|
ArrayList<View> toBeRemoved = new ArrayList<>();
|
|
384
496
|
|
|
385
497
|
// we might want to keep this view around
|
|
@@ -402,11 +514,11 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
402
514
|
if (hasExitAnimation) {
|
|
403
515
|
Snapshot before = new Snapshot(view, mReanimatedNativeHierarchyManager);
|
|
404
516
|
HashMap<String, Object> currentValues = before.toCurrentMap();
|
|
405
|
-
HashMap<String,
|
|
517
|
+
HashMap<String, Object> preparedValues = prepareDataForAnimationWorklet(currentValues, false);
|
|
406
518
|
if (!mExitingViews.containsKey(tag)) {
|
|
407
519
|
mExitingViews.put(tag, view);
|
|
408
520
|
registerExitingAncestors(view);
|
|
409
|
-
mNativeMethodsHolder.startAnimation(tag,
|
|
521
|
+
mNativeMethodsHolder.startAnimation(tag, LayoutAnimations.Types.EXITING, preparedValues);
|
|
410
522
|
}
|
|
411
523
|
}
|
|
412
524
|
|
|
@@ -427,6 +539,28 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
427
539
|
return true;
|
|
428
540
|
}
|
|
429
541
|
|
|
542
|
+
public void clearAnimationConfigForTag(int tag) {
|
|
543
|
+
View view = resolveView(tag);
|
|
544
|
+
if (view != null) {
|
|
545
|
+
clearAnimationConfigRecursive(view);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
public void clearAnimationConfigRecursive(View view) {
|
|
550
|
+
mNativeMethodsHolder.clearAnimationConfig(view.getId());
|
|
551
|
+
if (view instanceof ViewGroup) {
|
|
552
|
+
ViewGroup viewGroup = (ViewGroup) view;
|
|
553
|
+
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
|
554
|
+
clearAnimationConfigRecursive(viewGroup.getChildAt(i));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
public void cancelAnimationsInSubviews(View view) {
|
|
560
|
+
cancelAnimationsRecursive(view);
|
|
561
|
+
clearAnimationConfigRecursive(view);
|
|
562
|
+
}
|
|
563
|
+
|
|
430
564
|
private void registerExitingAncestors(View view) {
|
|
431
565
|
View parent = (View) view.getParent();
|
|
432
566
|
while (parent != null && !(parent instanceof RootView)) {
|
|
@@ -440,6 +574,9 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
440
574
|
}
|
|
441
575
|
|
|
442
576
|
private void maybeDropAncestors(View exitingView) {
|
|
577
|
+
if (!(exitingView.getParent() instanceof View)) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
443
580
|
View parent = (View) exitingView.getParent();
|
|
444
581
|
while (parent != null && !(parent instanceof RootView)) {
|
|
445
582
|
View view = parent;
|
|
@@ -461,7 +598,7 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
461
598
|
}
|
|
462
599
|
}
|
|
463
600
|
|
|
464
|
-
private void removeView(View view, ViewGroup parent) {
|
|
601
|
+
private void removeView(View view, @Nullable ViewGroup parent) {
|
|
465
602
|
int tag = view.getId();
|
|
466
603
|
if (mCallbacks.containsKey(tag)) {
|
|
467
604
|
Runnable callback = mCallbacks.get(tag);
|
|
@@ -473,16 +610,30 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
473
610
|
mReanimatedNativeHierarchyManager.publicDropView(view);
|
|
474
611
|
}
|
|
475
612
|
|
|
476
|
-
parent
|
|
613
|
+
if (parent != null) {
|
|
614
|
+
parent.removeView(view);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
public void cancelAnimationsRecursive(View view) {
|
|
619
|
+
if (mExitingViews.containsKey(view.getId())) {
|
|
620
|
+
endLayoutAnimation(view.getId(), true, true);
|
|
621
|
+
} else if (view instanceof ViewGroup && mExitingSubviewCountMap.containsKey(view.getId())) {
|
|
622
|
+
cancelAnimationsInSubviews((ViewGroup) view);
|
|
623
|
+
}
|
|
477
624
|
}
|
|
478
625
|
|
|
479
626
|
private void cancelAnimationsInSubviews(ViewGroup view) {
|
|
480
627
|
for (int i = view.getChildCount() - 1; i >= 0; i--) {
|
|
481
628
|
View child = view.getChildAt(i);
|
|
482
629
|
|
|
630
|
+
if (child == null) {
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
|
|
483
634
|
if (mExitingViews.containsKey(child.getId())) {
|
|
484
635
|
endLayoutAnimation(child.getId(), true, true);
|
|
485
|
-
} else if (child instanceof ViewGroup &&
|
|
636
|
+
} else if (child instanceof ViewGroup && mExitingSubviewCountMap.containsKey(child.getId())) {
|
|
486
637
|
cancelAnimationsInSubviews((ViewGroup) child);
|
|
487
638
|
}
|
|
488
639
|
}
|
|
@@ -491,12 +642,17 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
491
642
|
private View resolveView(int tag) {
|
|
492
643
|
if (mExitingViews.containsKey(tag)) {
|
|
493
644
|
return mExitingViews.get(tag);
|
|
645
|
+
} else {
|
|
646
|
+
View view = mSharedTransitionManager.getTransitioningView(tag);
|
|
647
|
+
if (view != null) {
|
|
648
|
+
return view;
|
|
649
|
+
}
|
|
494
650
|
}
|
|
651
|
+
|
|
495
652
|
try {
|
|
496
653
|
return mUIManager.resolveView(tag);
|
|
497
654
|
} catch (IllegalViewOperationException e) {
|
|
498
655
|
// view has been removed already
|
|
499
|
-
e.printStackTrace();
|
|
500
656
|
return null;
|
|
501
657
|
}
|
|
502
658
|
}
|
|
@@ -505,8 +661,35 @@ public class AnimationsManager implements ViewHierarchyObserver {
|
|
|
505
661
|
try {
|
|
506
662
|
return mReanimatedNativeHierarchyManager.resolveViewManager(tag);
|
|
507
663
|
} catch (Exception e) {
|
|
508
|
-
e.printStackTrace();
|
|
509
664
|
return null;
|
|
510
665
|
}
|
|
511
666
|
}
|
|
667
|
+
|
|
668
|
+
private static Point convertScreenLocationToViewCoordinates(Point fromPoint, View parentView) {
|
|
669
|
+
int[] toPoint = {0, 0};
|
|
670
|
+
if (parentView != null) {
|
|
671
|
+
parentView.getLocationOnScreen(toPoint);
|
|
672
|
+
}
|
|
673
|
+
return new Point(fromPoint.x - toPoint[0], fromPoint.y - toPoint[1]);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
public void screenDidLayout() {
|
|
677
|
+
mSharedTransitionManager.screenDidLayout();
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
public void viewDidLayout(View view) {
|
|
681
|
+
mSharedTransitionManager.viewDidLayout(view);
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
public void notifyAboutViewsRemoval(int[] tagsToDelete) {
|
|
685
|
+
mSharedTransitionManager.onViewsRemoval(tagsToDelete);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
public void makeSnapshotOfTopScreenViews(ViewGroup stack) {
|
|
689
|
+
mSharedTransitionManager.doSnapshotForTopScreenViews(stack);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
protected ReactContext getContext() {
|
|
693
|
+
return mContext;
|
|
694
|
+
}
|
|
512
695
|
}
|
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java
CHANGED
|
@@ -9,6 +9,13 @@ import java.lang.ref.WeakReference;
|
|
|
9
9
|
import java.util.Map;
|
|
10
10
|
|
|
11
11
|
public class LayoutAnimations {
|
|
12
|
+
public static class Types {
|
|
13
|
+
static final int ENTERING = 1;
|
|
14
|
+
static final int EXITING = 2;
|
|
15
|
+
static final int LAYOUT = 3;
|
|
16
|
+
static final int SHARED_ELEMENT_TRANSITION = 4;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
static {
|
|
13
20
|
SoLoader.loadLibrary("reanimated");
|
|
14
21
|
}
|
|
@@ -17,7 +24,8 @@ public class LayoutAnimations {
|
|
|
17
24
|
@SuppressWarnings("unused")
|
|
18
25
|
private final HybridData mHybridData;
|
|
19
26
|
|
|
20
|
-
private WeakReference<ReactApplicationContext> mContext;
|
|
27
|
+
private final WeakReference<ReactApplicationContext> mContext;
|
|
28
|
+
private WeakReference<AnimationsManager> mWeakAnimationsManager = new WeakReference<>(null);
|
|
21
29
|
|
|
22
30
|
public LayoutAnimations(ReactApplicationContext context) {
|
|
23
31
|
mContext = new WeakReference<>(context);
|
|
@@ -27,33 +35,51 @@ public class LayoutAnimations {
|
|
|
27
35
|
private native HybridData initHybrid();
|
|
28
36
|
|
|
29
37
|
// LayoutReanimation
|
|
30
|
-
public native void startAnimationForTag(int tag,
|
|
38
|
+
public native void startAnimationForTag(int tag, int type, Map<String, String> values);
|
|
31
39
|
|
|
32
|
-
public native boolean hasAnimationForTag(int tag,
|
|
40
|
+
public native boolean hasAnimationForTag(int tag, int type);
|
|
33
41
|
|
|
34
42
|
public native void clearAnimationConfigForTag(int tag);
|
|
35
43
|
|
|
44
|
+
public native void cancelAnimationForTag(
|
|
45
|
+
int tag, int type, boolean cancelled, boolean removeView);
|
|
46
|
+
|
|
36
47
|
public native boolean isLayoutAnimationEnabled();
|
|
37
48
|
|
|
49
|
+
public native int findPrecedingViewTagForTransition(int tag);
|
|
50
|
+
|
|
38
51
|
private void endLayoutAnimation(int tag, boolean cancelled, boolean removeView) {
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
AnimationsManager animationsManager = getAnimationsManager();
|
|
53
|
+
if (animationsManager == null) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
animationsManager.endLayoutAnimation(tag, cancelled, removeView);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void progressLayoutAnimation(
|
|
60
|
+
int tag, Map<String, Object> newStyle, boolean isSharedTransition) {
|
|
61
|
+
AnimationsManager animationsManager = getAnimationsManager();
|
|
62
|
+
if (animationsManager == null) {
|
|
63
|
+
return;
|
|
46
64
|
}
|
|
65
|
+
animationsManager.progressLayoutAnimation(tag, newStyle, isSharedTransition);
|
|
47
66
|
}
|
|
48
67
|
|
|
49
|
-
private
|
|
68
|
+
private AnimationsManager getAnimationsManager() {
|
|
69
|
+
AnimationsManager animationsManager = mWeakAnimationsManager.get();
|
|
70
|
+
if (animationsManager != null) {
|
|
71
|
+
return mWeakAnimationsManager.get();
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
ReactApplicationContext context = mContext.get();
|
|
51
|
-
if (context
|
|
52
|
-
|
|
53
|
-
.getNativeModule(ReanimatedModule.class)
|
|
54
|
-
.getNodesManager()
|
|
55
|
-
.getAnimationsManager()
|
|
56
|
-
.progressLayoutAnimation(tag, newStyle);
|
|
75
|
+
if (context == null) {
|
|
76
|
+
return null;
|
|
57
77
|
}
|
|
78
|
+
|
|
79
|
+
animationsManager =
|
|
80
|
+
context.getNativeModule(ReanimatedModule.class).getNodesManager().getAnimationsManager();
|
|
81
|
+
|
|
82
|
+
mWeakAnimationsManager = new WeakReference<>(animationsManager);
|
|
83
|
+
return animationsManager;
|
|
58
84
|
}
|
|
59
85
|
}
|
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java
CHANGED
|
@@ -3,11 +3,15 @@ package com.swmansion.reanimated.layoutReanimation;
|
|
|
3
3
|
import java.util.HashMap;
|
|
4
4
|
|
|
5
5
|
public interface NativeMethodsHolder {
|
|
6
|
-
void startAnimation(int tag,
|
|
6
|
+
void startAnimation(int tag, int type, HashMap<String, Object> values);
|
|
7
7
|
|
|
8
|
-
boolean hasAnimation(int tag,
|
|
8
|
+
boolean hasAnimation(int tag, int type);
|
|
9
9
|
|
|
10
10
|
void clearAnimationConfig(int tag);
|
|
11
11
|
|
|
12
|
+
void cancelAnimation(int tag, int type, boolean cancelled, boolean removeView);
|
|
13
|
+
|
|
12
14
|
boolean isLayoutAnimationEnabled();
|
|
15
|
+
|
|
16
|
+
int findPrecedingViewTagForTransition(int tag);
|
|
13
17
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.swmansion.reanimated.layoutReanimation;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
|
|
5
|
+
public class SharedElement {
|
|
6
|
+
|
|
7
|
+
public View sourceView;
|
|
8
|
+
public Snapshot sourceViewSnapshot;
|
|
9
|
+
public View targetView;
|
|
10
|
+
public Snapshot targetViewSnapshot;
|
|
11
|
+
|
|
12
|
+
public SharedElement(
|
|
13
|
+
View sourceView, Snapshot sourceViewSnapshot, View targetView, Snapshot targetViewSnapshot) {
|
|
14
|
+
this.sourceView = sourceView;
|
|
15
|
+
this.sourceViewSnapshot = sourceViewSnapshot;
|
|
16
|
+
this.targetView = targetView;
|
|
17
|
+
this.targetViewSnapshot = targetViewSnapshot;
|
|
18
|
+
}
|
|
19
|
+
}
|