@react-native-ohos/react-native-reanimated 4.0.0-rc.1 → 4.0.2-beta.1
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/compatibility.json +161 -161
- package/harmony/reanimated/BuildProfile.ets +16 -16
- package/harmony/reanimated/build-profile.json5 +18 -18
- package/harmony/reanimated/hvigorfile.ts +4 -4
- package/harmony/reanimated/index.ets +4 -4
- package/harmony/reanimated/oh-package-lock.json5 +39 -0
- package/harmony/reanimated/oh-package.json5 +12 -12
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +65 -62
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +390 -390
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +16 -16
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +30 -30
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/filters/FilterOp.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.cpp +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/Quaternion.h +21 -21
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.cpp +166 -166
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.cpp +368 -368
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix2D.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.cpp +594 -594
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformMatrix3D.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.cpp +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/TransformOp.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.cpp +156 -156
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/transforms/vectors.h +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +94 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.cpp +48 -48
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSBoolean.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +135 -135
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.h +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +45 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.cpp +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSKeyword.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +122 -122
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.h +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +63 -63
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +118 -118
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +111 -111
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.cpp +196 -196
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSBoxShadow.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.cpp +134 -134
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +174 -174
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +90 -90
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +127 -127
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +145 -145
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.cpp +69 -69
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingFunctions.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.cpp +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/cubicBezier.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/linear.h +15 -15
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.cpp +13 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/steps.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +157 -157
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +189 -189
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +76 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +66 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/configs.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +136 -136
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.cpp +38 -38
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperationInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterStyleInterpolator.h +24 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/blur.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/brightness.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/contrast.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/dropShadow.h +17 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/grayscale.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/hueRotate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/invert.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/opacity.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/saturate.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/operations/sepia.h +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +95 -95
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/GroupPropertiesInterpolator.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +99 -99
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +308 -308
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +100 -100
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.cpp +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +94 -94
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperationInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +26 -26
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +103 -103
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +224 -224
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.h +52 -52
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +218 -218
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +89 -89
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformsStyleInterpolator.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +208 -208
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.h +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.cpp +42 -42
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/perspective.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/rotate.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.cpp +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/scale.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.cpp +14 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/skew.h +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.cpp +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/translate.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +47 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.h +43 -43
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +70 -70
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.h +40 -40
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +155 -155
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +53 -53
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +170 -170
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/KeyframeProgressProvider.h +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +41 -41
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +193 -193
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +77 -77
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +340 -340
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +29 -29
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +167 -167
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +51 -51
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +61 -61
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.cpp +80 -80
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGBrush.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +111 -110
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +33 -33
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +75 -75
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +45 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.cpp +12 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/algorithms.h +10 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.cpp +36 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/interpolators.h +23 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +149 -149
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +32 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +113 -113
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +49 -49
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitShadowNode.h +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +37 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +104 -104
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +22 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -72
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +25 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +160 -160
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +71 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +161 -161
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +65 -65
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationType.h +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +137 -137
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +82 -82
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +79 -79
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +81 -81
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +864 -864
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +214 -214
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +897 -897
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +220 -220
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.cpp +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +146 -146
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.cpp +456 -456
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/PropsDiffer.h +102 -102
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +544 -544
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.cpp +119 -119
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/PropValueProcessor.h +39 -39
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +1380 -1376
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +230 -228
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +183 -183
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +93 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +54 -54
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +28 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +58 -58
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +31 -31
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.cpp +18 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/FeatureFlags.h +44 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +67 -67
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +114 -114
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +18 -18
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +233 -230
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +56 -56
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +30 -30
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +44 -44
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +16 -16
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +265 -265
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +36 -36
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +35 -35
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +23 -23
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +19 -19
- package/harmony/reanimated/src/main/cpp/TransformParser.h +93 -93
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +60 -60
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +51 -51
- package/harmony/reanimated/src/main/ets/ReanimatedPackage.ts +25 -25
- package/harmony/reanimated/src/main/module.json5 +12 -12
- package/harmony/reanimated/src/main/resources/base/element/color.json +7 -7
- package/harmony/reanimated/src/main/resources/base/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/reanimated/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/reanimated/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/reanimated/ts.ts +6 -6
- package/harmony/reanimated.har +0 -0
- package/package.json +70 -68
- package/scripts/deploy.js +191 -191
- package/scripts/set-reanimated-version.js +37 -37
- package/scripts/update-version.js +119 -119
- package/scripts/validate-react-native-version.js +46 -46
- package/scripts/validate-worklets-build.js +17 -17
- package/scripts/validate-worklets-version.js +84 -79
- package/scripts/worklets-version.json +4 -4
- package/src/index.ts +9 -9
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp
CHANGED
|
@@ -1,544 +1,544 @@
|
|
|
1
|
-
#include <react/renderer/components/scrollview/ScrollViewState.h>
|
|
2
|
-
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h>
|
|
3
|
-
#include <reanimated/Tools/ReanimatedSystraceSection.h>
|
|
4
|
-
#ifndef ANDROID
|
|
5
|
-
#if __has_include(<react/renderer/components/rnscreens/Props.h>)
|
|
6
|
-
#define HAS_SCREENS_PROPS
|
|
7
|
-
#include <react/renderer/components/rnscreens/Props.h>
|
|
8
|
-
#endif
|
|
9
|
-
#endif // !ANDROID
|
|
10
|
-
|
|
11
|
-
#include <folly/dynamic.h>
|
|
12
|
-
|
|
13
|
-
#include <ranges>
|
|
14
|
-
|
|
15
|
-
namespace reanimated {
|
|
16
|
-
|
|
17
|
-
// MARK: Shared Element Transitions
|
|
18
|
-
|
|
19
|
-
std::shared_ptr<LightNode> LayoutAnimationsProxy_Experimental::findTopScreen(
|
|
20
|
-
const std::shared_ptr<LightNode> &node) const {
|
|
21
|
-
std::shared_ptr<LightNode> result = nullptr;
|
|
22
|
-
// TODO: We could get rid of the RNScreens c++ dependency if we create a custom native component that would be a boundary for Shared Element Transitions.
|
|
23
|
-
// This way we could allow for transitions without screens, and across components on the same screen.
|
|
24
|
-
if (isRNSScreen(node)) {
|
|
25
|
-
bool isActive = false;
|
|
26
|
-
#ifdef ANDROID
|
|
27
|
-
// TODO (future): this looks like a RNScreens bug - sometimes there is no active
|
|
28
|
-
// screen at a deeper level, when going back (uncomment the following when fixed)
|
|
29
|
-
// float f = node->current.props->rawProps.getDefault("activityState",
|
|
30
|
-
// 0).asDouble(); isActive = f == 2.0f;
|
|
31
|
-
isActive = true;
|
|
32
|
-
#elif defined(HAS_SCREENS_PROPS)
|
|
33
|
-
isActive = std::static_pointer_cast<const RNSScreenProps>(node->current.props)->activityState == 2.0f;
|
|
34
|
-
#endif
|
|
35
|
-
if (isActive) {
|
|
36
|
-
result = node;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
for (auto it = node->children.rbegin(); it != node->children.rend(); ++it) {
|
|
40
|
-
const auto& child = *it;
|
|
41
|
-
auto top = findTopScreen(child);
|
|
42
|
-
if (top) {
|
|
43
|
-
return top;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
void LayoutAnimationsProxy_Experimental::findSharedElementsOnScreen(
|
|
50
|
-
const std::shared_ptr<LightNode> &node,
|
|
51
|
-
BeforeOrAfter index,
|
|
52
|
-
const PropsParserContext &propsParserContext) const {
|
|
53
|
-
if (sharedTransitionManager_->tagToName_.contains(node->current.tag)) {
|
|
54
|
-
ShadowView copy = node->current;
|
|
55
|
-
std::vector<react::Point> absolutePositions;
|
|
56
|
-
absolutePositions = getAbsolutePositionsForRootPathView(node);
|
|
57
|
-
copy.layoutMetrics.frame.origin = absolutePositions[0];
|
|
58
|
-
|
|
59
|
-
auto sharedTag = sharedTransitionManager_->tagToName_[node->current.tag];
|
|
60
|
-
auto &transition = transitionMap_[sharedTag];
|
|
61
|
-
auto &[snapshot, parentTag, transform] = transition;
|
|
62
|
-
auto newTransform = parseParentTransforms(node, absolutePositions);
|
|
63
|
-
const auto &parent = node->parent.lock();
|
|
64
|
-
react_native_assert(parent && "Parent node is nullptr");
|
|
65
|
-
transform[index] = std::move(newTransform);
|
|
66
|
-
snapshot[index] = copy;
|
|
67
|
-
parentTag[index] = parent->current.tag;
|
|
68
|
-
|
|
69
|
-
if (parentTag[BEFORE] && parentTag[AFTER]) {
|
|
70
|
-
transitions_.emplace_back(sharedTag, transition);
|
|
71
|
-
} else if (parentTag[AFTER]) {
|
|
72
|
-
// TODO (future): this is adding unnecessary views to the list
|
|
73
|
-
tagsToRestore_.push_back(snapshot[AFTER].tag);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
for (auto &child : node->children) {
|
|
77
|
-
findSharedElementsOnScreen(child, index, propsParserContext);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
void LayoutAnimationsProxy_Experimental::handleProgressTransition(
|
|
82
|
-
ShadowViewMutationList &filteredMutations,
|
|
83
|
-
const ShadowViewMutationList &mutations,
|
|
84
|
-
const PropsParserContext &propsParserContext,
|
|
85
|
-
SurfaceId surfaceId) const {
|
|
86
|
-
if (!transitionUpdated_) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
transitionUpdated_ = false;
|
|
90
|
-
|
|
91
|
-
if (!mutations.empty() || !transitionState_) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (transitionState_ == START) {
|
|
96
|
-
auto root = lightNodes_[surfaceId];
|
|
97
|
-
auto beforeTopScreen = topScreen[surfaceId];
|
|
98
|
-
auto afterTopScreen = lightNodes_[transitionTag_];
|
|
99
|
-
if (beforeTopScreen && afterTopScreen && beforeTopScreen != afterTopScreen) {
|
|
100
|
-
findSharedElementsOnScreen(beforeTopScreen, BEFORE, propsParserContext);
|
|
101
|
-
findSharedElementsOnScreen(afterTopScreen, AFTER, propsParserContext);
|
|
102
|
-
hideTransitioningViews(BEFORE, filteredMutations, propsParserContext);
|
|
103
|
-
hideTransitioningViews(AFTER, filteredMutations, propsParserContext);
|
|
104
|
-
|
|
105
|
-
for (auto &[sharedTag, transition] : transitions_) {
|
|
106
|
-
auto &[before, after] = transition.snapshot;
|
|
107
|
-
const auto &transform = transition.transform;
|
|
108
|
-
overrideTransform(before, transform[BEFORE], propsParserContext);
|
|
109
|
-
overrideTransform(after, transform[AFTER], propsParserContext);
|
|
110
|
-
auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
|
|
111
|
-
transferConfigToContainer(containerTag, before.tag);
|
|
112
|
-
|
|
113
|
-
restoreMap_[containerTag][BEFORE] = before.tag;
|
|
114
|
-
restoreMap_[containerTag][AFTER] = after.tag;
|
|
115
|
-
before.tag = containerTag;
|
|
116
|
-
after.tag = containerTag;
|
|
117
|
-
activeTransitions_.insert(containerTag);
|
|
118
|
-
|
|
119
|
-
startProgressTransition(containerTag, before, after, surfaceId);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else if (transitionState_ == ACTIVE) {
|
|
123
|
-
for (auto tag : activeTransitions_) {
|
|
124
|
-
auto layoutAnimation = layoutAnimations_[tag];
|
|
125
|
-
auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
|
|
126
|
-
auto before = layoutAnimation.startView.layoutMetrics.frame;
|
|
127
|
-
auto after = layoutAnimation.finalView.layoutMetrics.frame;
|
|
128
|
-
auto x = before.origin.x + transitionProgress_ * (after.origin.x - before.origin.x);
|
|
129
|
-
auto y = before.origin.y + transitionProgress_ * (after.origin.y - before.origin.y);
|
|
130
|
-
auto width = before.size.width + transitionProgress_ * (after.size.width - before.size.width);
|
|
131
|
-
auto height = before.size.height + transitionProgress_ * (after.size.height - before.size.height);
|
|
132
|
-
|
|
133
|
-
auto beforeProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.startView.props);
|
|
134
|
-
auto afterProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.finalView.props);
|
|
135
|
-
auto beforeRadius = beforeProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
|
|
136
|
-
auto afterRadius = afterProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
|
|
137
|
-
|
|
138
|
-
// TODO (future): Support more props in progress transitions.
|
|
139
|
-
auto borderRadiusDynamic =
|
|
140
|
-
folly::dynamic::object("borderRadius", beforeRadius + transitionProgress_ * (afterRadius - beforeRadius));
|
|
141
|
-
|
|
142
|
-
#ifdef RN_SERIALIZABLE_STATE
|
|
143
|
-
// TODO (future): Support borderRadius on Android.
|
|
144
|
-
const Props::Shared newProps = nullptr;
|
|
145
|
-
#else
|
|
146
|
-
auto rawProps = RawProps(std::move(borderRadiusDynamic));
|
|
147
|
-
|
|
148
|
-
auto newProps = getComponentDescriptorForShadowView(layoutAnimation.finalView)
|
|
149
|
-
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(rawProps));
|
|
150
|
-
#endif
|
|
151
|
-
|
|
152
|
-
updateMap.insert_or_assign(tag, UpdateValues{newProps, {x, y, width, height}});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (transitionState_ == START) {
|
|
157
|
-
transitionState_ = ACTIVE;
|
|
158
|
-
} else if (transitionState_ == END || transitionState_ == CANCELLED) {
|
|
159
|
-
for (auto tag : activeTransitions_) {
|
|
160
|
-
sharedContainersToRemove_.push_back(tag);
|
|
161
|
-
tagsToRestore_.push_back(restoreMap_[tag][AFTER]);
|
|
162
|
-
if (transitionState_ == CANCELLED) {
|
|
163
|
-
tagsToRestore_.push_back(restoreMap_[tag][BEFORE]);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (transitionState_ == END) {
|
|
167
|
-
topScreen[surfaceId] = lightNodes_[transitionTag_];
|
|
168
|
-
synchronized_ = false;
|
|
169
|
-
}
|
|
170
|
-
sharedTransitionManager_->containerTags_.clear();
|
|
171
|
-
activeTransitions_.clear();
|
|
172
|
-
transitionState_ = NONE;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
void LayoutAnimationsProxy_Experimental::overrideTransform(
|
|
177
|
-
ShadowView &shadowView,
|
|
178
|
-
const std::optional<Transform> &transform,
|
|
179
|
-
const PropsParserContext &propsParserContext) const {
|
|
180
|
-
ReanimatedSystraceSection s("overrideTransfrom");
|
|
181
|
-
if (!transform) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
#ifdef ANDROID
|
|
185
|
-
auto array = folly::dynamic::array(folly::dynamic::object("matrix", transform->operator folly::dynamic()));
|
|
186
|
-
const folly::dynamic newTransformDynamic = folly::dynamic::object("transform", array);
|
|
187
|
-
auto newRawProps = folly::dynamic::merge(shadowView.props->rawProps, newTransformDynamic);
|
|
188
|
-
auto newProps = getComponentDescriptorForShadowView(shadowView)
|
|
189
|
-
.cloneProps(propsParserContext, shadowView.props, RawProps(newRawProps));
|
|
190
|
-
auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
|
|
191
|
-
#else
|
|
192
|
-
auto newProps = getComponentDescriptorForShadowView(shadowView).cloneProps(propsParserContext, shadowView.props, {});
|
|
193
|
-
auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
|
|
194
|
-
viewProps->transform = *transform;
|
|
195
|
-
#endif
|
|
196
|
-
shadowView.props = newProps;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
void LayoutAnimationsProxy_Experimental::transferConfigToContainer(Tag containerTag, Tag beforeTag) const {
|
|
200
|
-
layoutAnimationsManager_->transferSharedConfig(beforeTag, containerTag);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
Tag LayoutAnimationsProxy_Experimental::getOrCreateContainer(
|
|
204
|
-
const ShadowView &before,
|
|
205
|
-
const SharedTag &sharedTag,
|
|
206
|
-
ShadowViewMutationList &filteredMutations,
|
|
207
|
-
SurfaceId surfaceId) const {
|
|
208
|
-
auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
|
|
209
|
-
auto shouldCreateContainer = (containerTag == -1 || !layoutAnimations_.contains(containerTag));
|
|
210
|
-
|
|
211
|
-
if (shouldCreateContainer) {
|
|
212
|
-
containerTag = containerTag_;
|
|
213
|
-
containerTag_ += 2;
|
|
214
|
-
auto &root = lightNodes_[surfaceId];
|
|
215
|
-
ShadowView container = before;
|
|
216
|
-
sharedTransitionManager_->tagToName_[containerTag] = sharedTag;
|
|
217
|
-
|
|
218
|
-
container.tag = containerTag;
|
|
219
|
-
auto node = std::make_shared<LightNode>();
|
|
220
|
-
node->current = std::move(container);
|
|
221
|
-
root->children.push_back(node);
|
|
222
|
-
containersToInsert_.push_back(node);
|
|
223
|
-
lightNodes_[containerTag] = std::move(node);
|
|
224
|
-
|
|
225
|
-
sharedTransitionManager_->containerTags_[sharedTag] = containerTag;
|
|
226
|
-
}
|
|
227
|
-
return containerTag;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
void LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart(
|
|
231
|
-
const std::shared_ptr<LightNode> &afterTopScreen,
|
|
232
|
-
const std::shared_ptr<LightNode> &beforeTopScreen,
|
|
233
|
-
ShadowViewMutationList &filteredMutations,
|
|
234
|
-
const ShadowViewMutationList &mutations,
|
|
235
|
-
const PropsParserContext &propsParserContext,
|
|
236
|
-
SurfaceId surfaceId) const {
|
|
237
|
-
ReanimatedSystraceSection s1("LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart");
|
|
238
|
-
|
|
239
|
-
if (!beforeTopScreen || !afterTopScreen) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (beforeTopScreen != afterTopScreen) {
|
|
244
|
-
for (auto &[sharedTag, transition] : transitions_) {
|
|
245
|
-
auto &[before, after] = transition.snapshot;
|
|
246
|
-
const auto &transform = transition.transform;
|
|
247
|
-
overrideTransform(before, transform[BEFORE], propsParserContext);
|
|
248
|
-
overrideTransform(after, transform[AFTER], propsParserContext);
|
|
249
|
-
auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
|
|
250
|
-
|
|
251
|
-
transferConfigToContainer(containerTag, before.tag);
|
|
252
|
-
restoreMap_[containerTag][1] = after.tag;
|
|
253
|
-
before.tag = containerTag;
|
|
254
|
-
after.tag = containerTag;
|
|
255
|
-
|
|
256
|
-
startSharedTransition(containerTag, before, after, surfaceId);
|
|
257
|
-
}
|
|
258
|
-
} else if (!mutations.empty()) {
|
|
259
|
-
for (auto &[sharedTag, transition] : transitions_) {
|
|
260
|
-
auto &[_, after] = transition.snapshot;
|
|
261
|
-
|
|
262
|
-
auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
|
|
263
|
-
if (!layoutAnimations_.contains(containerTag)) {
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
after.tag = containerTag;
|
|
267
|
-
const auto &la = layoutAnimations_[containerTag];
|
|
268
|
-
if (la.finalView.layoutMetrics != after.layoutMetrics) {
|
|
269
|
-
overrideTransform(after, transition.transform[AFTER], propsParserContext);
|
|
270
|
-
startSharedTransition(containerTag, la.currentView, after, surfaceId);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
void LayoutAnimationsProxy_Experimental::hideTransitioningViews(
|
|
277
|
-
BeforeOrAfter index,
|
|
278
|
-
ShadowViewMutationList &filteredMutations,
|
|
279
|
-
const PropsParserContext &propsParserContext) const {
|
|
280
|
-
for (auto &[sharedTag, transition] : transitions_) {
|
|
281
|
-
const auto &shadowView = transition.snapshot[index];
|
|
282
|
-
const auto &parentTag = transition.parentTag[index];
|
|
283
|
-
auto m = ShadowViewMutation::UpdateMutation(
|
|
284
|
-
shadowView, cloneViewWithoutOpacity(shadowView, propsParserContext), parentTag);
|
|
285
|
-
filteredMutations.push_back(m);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onTransitionProgress(
|
|
290
|
-
int tag,
|
|
291
|
-
double progress,
|
|
292
|
-
bool isClosing,
|
|
293
|
-
bool isGoingForward) {
|
|
294
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
295
|
-
transitionUpdated_ = true;
|
|
296
|
-
bool isAndroid;
|
|
297
|
-
#ifdef ANDROID
|
|
298
|
-
isAndroid = true;
|
|
299
|
-
#else
|
|
300
|
-
isAndroid = false;
|
|
301
|
-
#endif
|
|
302
|
-
// TODO (future): this new approach causes all back transitions to be progress
|
|
303
|
-
// transitions (maybe that's ok?)
|
|
304
|
-
if (!isClosing && !isGoingForward && !isAndroid) {
|
|
305
|
-
transitionProgress_ = progress;
|
|
306
|
-
if (transitionState_ == NONE && progress < 1) {
|
|
307
|
-
transitionState_ = START;
|
|
308
|
-
transitionTag_ = tag;
|
|
309
|
-
} else if (transitionState_ == ACTIVE && progress == 1) {
|
|
310
|
-
transitionState_ = END;
|
|
311
|
-
}
|
|
312
|
-
const auto &node = lightNodes_[tag];
|
|
313
|
-
react_native_assert(node && "LightNode is nullptr");
|
|
314
|
-
|
|
315
|
-
transitioningSurfaceId_ = node->current.surfaceId;
|
|
316
|
-
return transitioningSurfaceId_;
|
|
317
|
-
}
|
|
318
|
-
return {};
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onGestureCancel() {
|
|
322
|
-
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
323
|
-
if (transitionState_) {
|
|
324
|
-
transitionState_ = CANCELLED;
|
|
325
|
-
transitionUpdated_ = true;
|
|
326
|
-
react_native_assert(transitioningSurfaceId_ != -1 && "Cancelling non-observed transition");
|
|
327
|
-
|
|
328
|
-
const auto surfaceId = transitioningSurfaceId_;
|
|
329
|
-
transitioningSurfaceId_ = -1;
|
|
330
|
-
return surfaceId;
|
|
331
|
-
}
|
|
332
|
-
return {};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
void LayoutAnimationsProxy_Experimental::startSurface(const SurfaceId surfaceId) {
|
|
336
|
-
const auto node = std::make_shared<LightNode>();
|
|
337
|
-
node->current.componentName = "RootView";
|
|
338
|
-
node->current.tag = surfaceId;
|
|
339
|
-
node->current.props = std::make_shared<BaseViewProps>();
|
|
340
|
-
lightNodes_[surfaceId] = node;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
void LayoutAnimationsProxy_Experimental::insertContainers(
|
|
344
|
-
ShadowViewMutationList &filteredMutations,
|
|
345
|
-
int &rootChildCount,
|
|
346
|
-
SurfaceId surfaceId) const {
|
|
347
|
-
ShadowViewMutationList currentMutations;
|
|
348
|
-
std::swap(currentMutations, filteredMutations);
|
|
349
|
-
filteredMutations.reserve(containersToInsert_.size() * 2);
|
|
350
|
-
auto root = lightNodes_[surfaceId];
|
|
351
|
-
for (auto &node : containersToInsert_) {
|
|
352
|
-
filteredMutations.push_back(ShadowViewMutation::CreateMutation(node->current));
|
|
353
|
-
filteredMutations.push_back(ShadowViewMutation::InsertMutation(surfaceId, node->current, rootChildCount++));
|
|
354
|
-
}
|
|
355
|
-
filteredMutations.insert(filteredMutations.end(), currentMutations.begin(), currentMutations.end());
|
|
356
|
-
containersToInsert_.clear();
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
void LayoutAnimationsProxy_Experimental::cleanupSharedTransitions(
|
|
360
|
-
ShadowViewMutationList &filteredMutations,
|
|
361
|
-
const PropsParserContext &propsParserContext,
|
|
362
|
-
SurfaceId surfaceId) const {
|
|
363
|
-
ReanimatedSystraceSection s1("cleanupSharedTransitions");
|
|
364
|
-
for (auto &tag : tagsToRestore_) {
|
|
365
|
-
ReanimatedSystraceSection s("Restore tag");
|
|
366
|
-
auto &node = lightNodes_[tag];
|
|
367
|
-
if (node) {
|
|
368
|
-
auto view = node->current;
|
|
369
|
-
const auto &parent = node->parent.lock();
|
|
370
|
-
react_native_assert(parent && "Parent node is nullptr");
|
|
371
|
-
auto parentTag = parent->current.tag;
|
|
372
|
-
auto m = ShadowViewMutation::UpdateMutation(
|
|
373
|
-
cloneViewWithoutOpacity(view, propsParserContext), cloneViewWithOpacity(view, propsParserContext), parentTag);
|
|
374
|
-
filteredMutations.push_back(m);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
tagsToRestore_.clear();
|
|
378
|
-
|
|
379
|
-
ReanimatedSystraceSection s2("remove shared containers");
|
|
380
|
-
for (auto &tag : sharedContainersToRemove_) {
|
|
381
|
-
auto root = lightNodes_[surfaceId];
|
|
382
|
-
for (int i = 0; i < root->children.size(); i++) {
|
|
383
|
-
auto &child = root->children[i];
|
|
384
|
-
if (child->current.tag == tag) {
|
|
385
|
-
filteredMutations.push_back(ShadowViewMutation::RemoveMutation(surfaceId, child->current, i));
|
|
386
|
-
filteredMutations.push_back(ShadowViewMutation::DeleteMutation(child->current));
|
|
387
|
-
root->children.erase(root->children.begin() + i);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
sharedContainersToRemove_.clear();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// MARK: Position Calculation
|
|
395
|
-
|
|
396
|
-
std::vector<react::Point> LayoutAnimationsProxy_Experimental::getAbsolutePositionsForRootPathView(
|
|
397
|
-
const std::shared_ptr<LightNode> &node) const {
|
|
398
|
-
std::vector<react::Point> viewsAbsolutePositions;
|
|
399
|
-
auto currentNode = node;
|
|
400
|
-
while (currentNode) {
|
|
401
|
-
react::Point viewPosition;
|
|
402
|
-
const auto &componentName = currentNode->current.componentName;
|
|
403
|
-
react_native_assert(componentName && "Component name is nullptr");
|
|
404
|
-
if (!strcmp(componentName, "ScrollView")) {
|
|
405
|
-
auto state = std::static_pointer_cast<const ConcreteState<ScrollViewState>>(currentNode->current.state);
|
|
406
|
-
auto data = state->getData();
|
|
407
|
-
viewPosition -= data.contentOffset;
|
|
408
|
-
}
|
|
409
|
-
if (!strcmp(componentName, "RNSScreen") && currentNode->children.size() >= 2) {
|
|
410
|
-
const auto &parent = currentNode->parent.lock();
|
|
411
|
-
react_native_assert(parent && "Parent node is nullptr");
|
|
412
|
-
|
|
413
|
-
const float headerHeight =
|
|
414
|
-
parent->current.layoutMetrics.frame.size.height - currentNode->current.layoutMetrics.frame.size.height;
|
|
415
|
-
viewPosition.y += headerHeight;
|
|
416
|
-
}
|
|
417
|
-
viewPosition += currentNode->current.layoutMetrics.frame.origin;
|
|
418
|
-
viewsAbsolutePositions.emplace_back(viewPosition);
|
|
419
|
-
currentNode = currentNode->parent.lock();
|
|
420
|
-
}
|
|
421
|
-
for (int i = static_cast<int>(viewsAbsolutePositions.size()) - 2; i >= 0; --i) {
|
|
422
|
-
viewsAbsolutePositions[i] += viewsAbsolutePositions[i + 1];
|
|
423
|
-
}
|
|
424
|
-
return viewsAbsolutePositions;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
std::optional<Transform> LayoutAnimationsProxy_Experimental::parseParentTransforms(
|
|
428
|
-
const std::shared_ptr<LightNode> &node,
|
|
429
|
-
const std::vector<react::Point> &absolutePositions) const {
|
|
430
|
-
std::vector<std::pair<Transform, TransformOrigin>> transforms;
|
|
431
|
-
auto currentNode = node;
|
|
432
|
-
while (currentNode) {
|
|
433
|
-
const auto &props = static_cast<const ViewProps &>(*currentNode->current.props);
|
|
434
|
-
auto origin = props.transformOrigin;
|
|
435
|
-
const auto &viewSize = currentNode->current.layoutMetrics.frame.size;
|
|
436
|
-
if (origin.xy[0].unit == facebook::react::UnitType::Percent) {
|
|
437
|
-
origin.xy[0] = {static_cast<float>(viewSize.width * origin.xy[0].value / 100), UnitType::Point};
|
|
438
|
-
} else if (origin.xy[0].unit == facebook::react::UnitType::Undefined) {
|
|
439
|
-
origin.xy[0] = {static_cast<float>(viewSize.width * 0.5), UnitType::Point};
|
|
440
|
-
}
|
|
441
|
-
if (origin.xy[1].unit == facebook::react::UnitType::Percent) {
|
|
442
|
-
origin.xy[1] = {static_cast<float>(viewSize.height * origin.xy[1].value / 100), UnitType::Point};
|
|
443
|
-
} else if (origin.xy[1].unit == facebook::react::UnitType::Undefined) {
|
|
444
|
-
origin.xy[1] = {static_cast<float>(viewSize.height * 0.5), UnitType::Point};
|
|
445
|
-
}
|
|
446
|
-
transforms.emplace_back(props.transform, origin);
|
|
447
|
-
currentNode = currentNode->parent.lock();
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
const auto &targetViewPosition = absolutePositions[0];
|
|
451
|
-
Transform combinedMatrix;
|
|
452
|
-
bool parentHasTransform = false;
|
|
453
|
-
for (int i = static_cast<int>(transforms.size()) - 1; i >= 0; --i) {
|
|
454
|
-
auto &[transform, transformOrigin] = transforms[i];
|
|
455
|
-
if (transform.operations.empty()) {
|
|
456
|
-
continue;
|
|
457
|
-
} else if (i > 0) {
|
|
458
|
-
parentHasTransform = true;
|
|
459
|
-
}
|
|
460
|
-
if (i == 0 && !parentHasTransform) {
|
|
461
|
-
// If only target view has transform, let's skip it, to matrix decomposition in JS
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
transformOrigin.xy[0].value -= targetViewPosition.x - absolutePositions[i].x;
|
|
465
|
-
transformOrigin.xy[1].value -= targetViewPosition.y - absolutePositions[i].y;
|
|
466
|
-
combinedMatrix = combinedMatrix * resolveTransform(node->current.layoutMetrics, transform, transformOrigin);
|
|
467
|
-
combinedMatrix.operations.clear();
|
|
468
|
-
}
|
|
469
|
-
if (parentHasTransform) {
|
|
470
|
-
react::TransformOperation transformOp {
|
|
471
|
-
react::TransformOperationType::Arbitrary,
|
|
472
|
-
{},
|
|
473
|
-
{},
|
|
474
|
-
{}
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
return Transform::FromTransformOperation(
|
|
478
|
-
transformOp, {}, combinedMatrix);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
return {};
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
// The methods resolveTransform and getTranslateForTransformOrigin are sourced
|
|
485
|
-
// from:
|
|
486
|
-
// https://github.com/facebook/react-native/blob/v0.80.0/packages/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.cpp#L548
|
|
487
|
-
// We need a copy of these methods to modify the `resolveTransform` method
|
|
488
|
-
// to accept the transform origin as a parameter instead of as a class field.
|
|
489
|
-
react::Transform LayoutAnimationsProxy_Experimental::resolveTransform(
|
|
490
|
-
const LayoutMetrics &layoutMetrics,
|
|
491
|
-
const Transform &transform,
|
|
492
|
-
const TransformOrigin &transformOrigin) const {
|
|
493
|
-
const auto &frameSize = layoutMetrics.frame.size;
|
|
494
|
-
auto transformMatrix = Transform{};
|
|
495
|
-
if (frameSize.width == 0 && frameSize.height == 0) {
|
|
496
|
-
return transformMatrix;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
if (transform.operations.size() == 1 &&
|
|
500
|
-
transform.operations[0].type == facebook::react::TransformOperationType::Arbitrary) {
|
|
501
|
-
transformMatrix = transform;
|
|
502
|
-
} else {
|
|
503
|
-
for (const auto &operation : transform.operations) {
|
|
504
|
-
transformMatrix =
|
|
505
|
-
transformMatrix * Transform::FromTransformOperation(operation, layoutMetrics.frame.size, transform);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (transformOrigin.isSet()) {
|
|
510
|
-
std::array<float, 3> translateOffsets =
|
|
511
|
-
getTranslateForTransformOrigin(frameSize.width, frameSize.height, transformOrigin);
|
|
512
|
-
transformMatrix = Transform::Translate(translateOffsets[0], translateOffsets[1], translateOffsets[2]) *
|
|
513
|
-
transformMatrix * Transform::Translate(-translateOffsets[0], -translateOffsets[1], -translateOffsets[2]);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
return transformMatrix;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
std::array<float, 3> LayoutAnimationsProxy_Experimental::getTranslateForTransformOrigin(
|
|
520
|
-
float viewWidth,
|
|
521
|
-
float viewHeight,
|
|
522
|
-
const TransformOrigin &transformOrigin) const {
|
|
523
|
-
const float viewCenterX = viewWidth / 2;
|
|
524
|
-
const float viewCenterY = viewHeight / 2;
|
|
525
|
-
|
|
526
|
-
std::array<float, 3> origin = {viewCenterX, viewCenterY, transformOrigin.z};
|
|
527
|
-
|
|
528
|
-
for (int i = 0; i < static_cast<int>(transformOrigin.xy.size()); ++i) {
|
|
529
|
-
const auto ¤tOrigin = transformOrigin.xy[i];
|
|
530
|
-
if (currentOrigin.unit == UnitType::Point) {
|
|
531
|
-
origin[i] = currentOrigin.value;
|
|
532
|
-
} else if (currentOrigin.unit == UnitType::Percent) {
|
|
533
|
-
origin[i] = ((i == 0) ? viewWidth : viewHeight) * currentOrigin.value / 100.0f;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
const float newTranslateX = -viewCenterX + origin[0];
|
|
538
|
-
const float newTranslateY = -viewCenterY + origin[1];
|
|
539
|
-
const float newTranslateZ = origin[2];
|
|
540
|
-
|
|
541
|
-
return {newTranslateX, newTranslateY, newTranslateZ};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
} // namespace reanimated
|
|
1
|
+
#include <react/renderer/components/scrollview/ScrollViewState.h>
|
|
2
|
+
#include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h>
|
|
3
|
+
#include <reanimated/Tools/ReanimatedSystraceSection.h>
|
|
4
|
+
#ifndef ANDROID
|
|
5
|
+
#if __has_include(<react/renderer/components/rnscreens/Props.h>)
|
|
6
|
+
#define HAS_SCREENS_PROPS
|
|
7
|
+
#include <react/renderer/components/rnscreens/Props.h>
|
|
8
|
+
#endif
|
|
9
|
+
#endif // !ANDROID
|
|
10
|
+
|
|
11
|
+
#include <folly/dynamic.h>
|
|
12
|
+
|
|
13
|
+
#include <ranges>
|
|
14
|
+
|
|
15
|
+
namespace reanimated {
|
|
16
|
+
|
|
17
|
+
// MARK: Shared Element Transitions
|
|
18
|
+
|
|
19
|
+
std::shared_ptr<LightNode> LayoutAnimationsProxy_Experimental::findTopScreen(
|
|
20
|
+
const std::shared_ptr<LightNode> &node) const {
|
|
21
|
+
std::shared_ptr<LightNode> result = nullptr;
|
|
22
|
+
// TODO: We could get rid of the RNScreens c++ dependency if we create a custom native component that would be a boundary for Shared Element Transitions.
|
|
23
|
+
// This way we could allow for transitions without screens, and across components on the same screen.
|
|
24
|
+
if (isRNSScreen(node)) {
|
|
25
|
+
bool isActive = false;
|
|
26
|
+
#ifdef ANDROID
|
|
27
|
+
// TODO (future): this looks like a RNScreens bug - sometimes there is no active
|
|
28
|
+
// screen at a deeper level, when going back (uncomment the following when fixed)
|
|
29
|
+
// float f = node->current.props->rawProps.getDefault("activityState",
|
|
30
|
+
// 0).asDouble(); isActive = f == 2.0f;
|
|
31
|
+
isActive = true;
|
|
32
|
+
#elif defined(HAS_SCREENS_PROPS)
|
|
33
|
+
isActive = std::static_pointer_cast<const RNSScreenProps>(node->current.props)->activityState == 2.0f;
|
|
34
|
+
#endif
|
|
35
|
+
if (isActive) {
|
|
36
|
+
result = node;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (auto it = node->children.rbegin(); it != node->children.rend(); ++it) {
|
|
40
|
+
const auto& child = *it;
|
|
41
|
+
auto top = findTopScreen(child);
|
|
42
|
+
if (top) {
|
|
43
|
+
return top;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void LayoutAnimationsProxy_Experimental::findSharedElementsOnScreen(
|
|
50
|
+
const std::shared_ptr<LightNode> &node,
|
|
51
|
+
BeforeOrAfter index,
|
|
52
|
+
const PropsParserContext &propsParserContext) const {
|
|
53
|
+
if (sharedTransitionManager_->tagToName_.contains(node->current.tag)) {
|
|
54
|
+
ShadowView copy = node->current;
|
|
55
|
+
std::vector<react::Point> absolutePositions;
|
|
56
|
+
absolutePositions = getAbsolutePositionsForRootPathView(node);
|
|
57
|
+
copy.layoutMetrics.frame.origin = absolutePositions[0];
|
|
58
|
+
|
|
59
|
+
auto sharedTag = sharedTransitionManager_->tagToName_[node->current.tag];
|
|
60
|
+
auto &transition = transitionMap_[sharedTag];
|
|
61
|
+
auto &[snapshot, parentTag, transform] = transition;
|
|
62
|
+
auto newTransform = parseParentTransforms(node, absolutePositions);
|
|
63
|
+
const auto &parent = node->parent.lock();
|
|
64
|
+
react_native_assert(parent && "Parent node is nullptr");
|
|
65
|
+
transform[index] = std::move(newTransform);
|
|
66
|
+
snapshot[index] = copy;
|
|
67
|
+
parentTag[index] = parent->current.tag;
|
|
68
|
+
|
|
69
|
+
if (parentTag[BEFORE] && parentTag[AFTER]) {
|
|
70
|
+
transitions_.emplace_back(sharedTag, transition);
|
|
71
|
+
} else if (parentTag[AFTER]) {
|
|
72
|
+
// TODO (future): this is adding unnecessary views to the list
|
|
73
|
+
tagsToRestore_.push_back(snapshot[AFTER].tag);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (auto &child : node->children) {
|
|
77
|
+
findSharedElementsOnScreen(child, index, propsParserContext);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void LayoutAnimationsProxy_Experimental::handleProgressTransition(
|
|
82
|
+
ShadowViewMutationList &filteredMutations,
|
|
83
|
+
const ShadowViewMutationList &mutations,
|
|
84
|
+
const PropsParserContext &propsParserContext,
|
|
85
|
+
SurfaceId surfaceId) const {
|
|
86
|
+
if (!transitionUpdated_) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
transitionUpdated_ = false;
|
|
90
|
+
|
|
91
|
+
if (!mutations.empty() || !transitionState_) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (transitionState_ == START) {
|
|
96
|
+
auto root = lightNodes_[surfaceId];
|
|
97
|
+
auto beforeTopScreen = topScreen[surfaceId];
|
|
98
|
+
auto afterTopScreen = lightNodes_[transitionTag_];
|
|
99
|
+
if (beforeTopScreen && afterTopScreen && beforeTopScreen != afterTopScreen) {
|
|
100
|
+
findSharedElementsOnScreen(beforeTopScreen, BEFORE, propsParserContext);
|
|
101
|
+
findSharedElementsOnScreen(afterTopScreen, AFTER, propsParserContext);
|
|
102
|
+
hideTransitioningViews(BEFORE, filteredMutations, propsParserContext);
|
|
103
|
+
hideTransitioningViews(AFTER, filteredMutations, propsParserContext);
|
|
104
|
+
|
|
105
|
+
for (auto &[sharedTag, transition] : transitions_) {
|
|
106
|
+
auto &[before, after] = transition.snapshot;
|
|
107
|
+
const auto &transform = transition.transform;
|
|
108
|
+
overrideTransform(before, transform[BEFORE], propsParserContext);
|
|
109
|
+
overrideTransform(after, transform[AFTER], propsParserContext);
|
|
110
|
+
auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
|
|
111
|
+
transferConfigToContainer(containerTag, before.tag);
|
|
112
|
+
|
|
113
|
+
restoreMap_[containerTag][BEFORE] = before.tag;
|
|
114
|
+
restoreMap_[containerTag][AFTER] = after.tag;
|
|
115
|
+
before.tag = containerTag;
|
|
116
|
+
after.tag = containerTag;
|
|
117
|
+
activeTransitions_.insert(containerTag);
|
|
118
|
+
|
|
119
|
+
startProgressTransition(containerTag, before, after, surfaceId);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} else if (transitionState_ == ACTIVE) {
|
|
123
|
+
for (auto tag : activeTransitions_) {
|
|
124
|
+
auto layoutAnimation = layoutAnimations_[tag];
|
|
125
|
+
auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
|
|
126
|
+
auto before = layoutAnimation.startView.layoutMetrics.frame;
|
|
127
|
+
auto after = layoutAnimation.finalView.layoutMetrics.frame;
|
|
128
|
+
auto x = before.origin.x + transitionProgress_ * (after.origin.x - before.origin.x);
|
|
129
|
+
auto y = before.origin.y + transitionProgress_ * (after.origin.y - before.origin.y);
|
|
130
|
+
auto width = before.size.width + transitionProgress_ * (after.size.width - before.size.width);
|
|
131
|
+
auto height = before.size.height + transitionProgress_ * (after.size.height - before.size.height);
|
|
132
|
+
|
|
133
|
+
auto beforeProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.startView.props);
|
|
134
|
+
auto afterProps = std::static_pointer_cast<const BaseViewProps>(layoutAnimation.finalView.props);
|
|
135
|
+
auto beforeRadius = beforeProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
|
|
136
|
+
auto afterRadius = afterProps->borderRadii.all.value_or(ValueUnit(0, UnitType::Point)).value;
|
|
137
|
+
|
|
138
|
+
// TODO (future): Support more props in progress transitions.
|
|
139
|
+
auto borderRadiusDynamic =
|
|
140
|
+
folly::dynamic::object("borderRadius", beforeRadius + transitionProgress_ * (afterRadius - beforeRadius));
|
|
141
|
+
|
|
142
|
+
#ifdef RN_SERIALIZABLE_STATE
|
|
143
|
+
// TODO (future): Support borderRadius on Android.
|
|
144
|
+
const Props::Shared newProps = nullptr;
|
|
145
|
+
#else
|
|
146
|
+
auto rawProps = RawProps(std::move(borderRadiusDynamic));
|
|
147
|
+
|
|
148
|
+
auto newProps = getComponentDescriptorForShadowView(layoutAnimation.finalView)
|
|
149
|
+
.cloneProps(propsParserContext, layoutAnimation.finalView.props, std::move(rawProps));
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
updateMap.insert_or_assign(tag, UpdateValues{newProps, {x, y, width, height}});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (transitionState_ == START) {
|
|
157
|
+
transitionState_ = ACTIVE;
|
|
158
|
+
} else if (transitionState_ == END || transitionState_ == CANCELLED) {
|
|
159
|
+
for (auto tag : activeTransitions_) {
|
|
160
|
+
sharedContainersToRemove_.push_back(tag);
|
|
161
|
+
tagsToRestore_.push_back(restoreMap_[tag][AFTER]);
|
|
162
|
+
if (transitionState_ == CANCELLED) {
|
|
163
|
+
tagsToRestore_.push_back(restoreMap_[tag][BEFORE]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (transitionState_ == END) {
|
|
167
|
+
topScreen[surfaceId] = lightNodes_[transitionTag_];
|
|
168
|
+
synchronized_ = false;
|
|
169
|
+
}
|
|
170
|
+
sharedTransitionManager_->containerTags_.clear();
|
|
171
|
+
activeTransitions_.clear();
|
|
172
|
+
transitionState_ = NONE;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void LayoutAnimationsProxy_Experimental::overrideTransform(
|
|
177
|
+
ShadowView &shadowView,
|
|
178
|
+
const std::optional<Transform> &transform,
|
|
179
|
+
const PropsParserContext &propsParserContext) const {
|
|
180
|
+
ReanimatedSystraceSection s("overrideTransfrom");
|
|
181
|
+
if (!transform) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
#ifdef ANDROID
|
|
185
|
+
auto array = folly::dynamic::array(folly::dynamic::object("matrix", transform->operator folly::dynamic()));
|
|
186
|
+
const folly::dynamic newTransformDynamic = folly::dynamic::object("transform", array);
|
|
187
|
+
auto newRawProps = folly::dynamic::merge(shadowView.props->rawProps, newTransformDynamic);
|
|
188
|
+
auto newProps = getComponentDescriptorForShadowView(shadowView)
|
|
189
|
+
.cloneProps(propsParserContext, shadowView.props, RawProps(newRawProps));
|
|
190
|
+
auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
|
|
191
|
+
#else
|
|
192
|
+
auto newProps = getComponentDescriptorForShadowView(shadowView).cloneProps(propsParserContext, shadowView.props, {});
|
|
193
|
+
auto viewProps = std::const_pointer_cast<ViewProps>(std::static_pointer_cast<const ViewProps>(newProps));
|
|
194
|
+
viewProps->transform = *transform;
|
|
195
|
+
#endif
|
|
196
|
+
shadowView.props = newProps;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
void LayoutAnimationsProxy_Experimental::transferConfigToContainer(Tag containerTag, Tag beforeTag) const {
|
|
200
|
+
layoutAnimationsManager_->transferSharedConfig(beforeTag, containerTag);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
Tag LayoutAnimationsProxy_Experimental::getOrCreateContainer(
|
|
204
|
+
const ShadowView &before,
|
|
205
|
+
const SharedTag &sharedTag,
|
|
206
|
+
ShadowViewMutationList &filteredMutations,
|
|
207
|
+
SurfaceId surfaceId) const {
|
|
208
|
+
auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
|
|
209
|
+
auto shouldCreateContainer = (containerTag == -1 || !layoutAnimations_.contains(containerTag));
|
|
210
|
+
|
|
211
|
+
if (shouldCreateContainer) {
|
|
212
|
+
containerTag = containerTag_;
|
|
213
|
+
containerTag_ += 2;
|
|
214
|
+
auto &root = lightNodes_[surfaceId];
|
|
215
|
+
ShadowView container = before;
|
|
216
|
+
sharedTransitionManager_->tagToName_[containerTag] = sharedTag;
|
|
217
|
+
|
|
218
|
+
container.tag = containerTag;
|
|
219
|
+
auto node = std::make_shared<LightNode>();
|
|
220
|
+
node->current = std::move(container);
|
|
221
|
+
root->children.push_back(node);
|
|
222
|
+
containersToInsert_.push_back(node);
|
|
223
|
+
lightNodes_[containerTag] = std::move(node);
|
|
224
|
+
|
|
225
|
+
sharedTransitionManager_->containerTags_[sharedTag] = containerTag;
|
|
226
|
+
}
|
|
227
|
+
return containerTag;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
void LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart(
|
|
231
|
+
const std::shared_ptr<LightNode> &afterTopScreen,
|
|
232
|
+
const std::shared_ptr<LightNode> &beforeTopScreen,
|
|
233
|
+
ShadowViewMutationList &filteredMutations,
|
|
234
|
+
const ShadowViewMutationList &mutations,
|
|
235
|
+
const PropsParserContext &propsParserContext,
|
|
236
|
+
SurfaceId surfaceId) const {
|
|
237
|
+
ReanimatedSystraceSection s1("LayoutAnimationsProxy_Experimental::handleSharedTransitionsStart");
|
|
238
|
+
|
|
239
|
+
if (!beforeTopScreen || !afterTopScreen) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (beforeTopScreen != afterTopScreen) {
|
|
244
|
+
for (auto &[sharedTag, transition] : transitions_) {
|
|
245
|
+
auto &[before, after] = transition.snapshot;
|
|
246
|
+
const auto &transform = transition.transform;
|
|
247
|
+
overrideTransform(before, transform[BEFORE], propsParserContext);
|
|
248
|
+
overrideTransform(after, transform[AFTER], propsParserContext);
|
|
249
|
+
auto containerTag = getOrCreateContainer(before, sharedTag, filteredMutations, surfaceId);
|
|
250
|
+
|
|
251
|
+
transferConfigToContainer(containerTag, before.tag);
|
|
252
|
+
restoreMap_[containerTag][1] = after.tag;
|
|
253
|
+
before.tag = containerTag;
|
|
254
|
+
after.tag = containerTag;
|
|
255
|
+
|
|
256
|
+
startSharedTransition(containerTag, before, after, surfaceId);
|
|
257
|
+
}
|
|
258
|
+
} else if (!mutations.empty()) {
|
|
259
|
+
for (auto &[sharedTag, transition] : transitions_) {
|
|
260
|
+
auto &[_, after] = transition.snapshot;
|
|
261
|
+
|
|
262
|
+
auto containerTag = sharedTransitionManager_->containerTags_[sharedTag];
|
|
263
|
+
if (!layoutAnimations_.contains(containerTag)) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
after.tag = containerTag;
|
|
267
|
+
const auto &la = layoutAnimations_[containerTag];
|
|
268
|
+
if (la.finalView.layoutMetrics != after.layoutMetrics) {
|
|
269
|
+
overrideTransform(after, transition.transform[AFTER], propsParserContext);
|
|
270
|
+
startSharedTransition(containerTag, la.currentView, after, surfaceId);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
void LayoutAnimationsProxy_Experimental::hideTransitioningViews(
|
|
277
|
+
BeforeOrAfter index,
|
|
278
|
+
ShadowViewMutationList &filteredMutations,
|
|
279
|
+
const PropsParserContext &propsParserContext) const {
|
|
280
|
+
for (auto &[sharedTag, transition] : transitions_) {
|
|
281
|
+
const auto &shadowView = transition.snapshot[index];
|
|
282
|
+
const auto &parentTag = transition.parentTag[index];
|
|
283
|
+
auto m = ShadowViewMutation::UpdateMutation(
|
|
284
|
+
shadowView, cloneViewWithoutOpacity(shadowView, propsParserContext), parentTag);
|
|
285
|
+
filteredMutations.push_back(m);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onTransitionProgress(
|
|
290
|
+
int tag,
|
|
291
|
+
double progress,
|
|
292
|
+
bool isClosing,
|
|
293
|
+
bool isGoingForward) {
|
|
294
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
295
|
+
transitionUpdated_ = true;
|
|
296
|
+
bool isAndroid;
|
|
297
|
+
#ifdef ANDROID
|
|
298
|
+
isAndroid = true;
|
|
299
|
+
#else
|
|
300
|
+
isAndroid = false;
|
|
301
|
+
#endif
|
|
302
|
+
// TODO (future): this new approach causes all back transitions to be progress
|
|
303
|
+
// transitions (maybe that's ok?)
|
|
304
|
+
if (!isClosing && !isGoingForward && !isAndroid) {
|
|
305
|
+
transitionProgress_ = progress;
|
|
306
|
+
if (transitionState_ == NONE && progress < 1) {
|
|
307
|
+
transitionState_ = START;
|
|
308
|
+
transitionTag_ = tag;
|
|
309
|
+
} else if (transitionState_ == ACTIVE && progress == 1) {
|
|
310
|
+
transitionState_ = END;
|
|
311
|
+
}
|
|
312
|
+
const auto &node = lightNodes_[tag];
|
|
313
|
+
react_native_assert(node && "LightNode is nullptr");
|
|
314
|
+
|
|
315
|
+
transitioningSurfaceId_ = node->current.surfaceId;
|
|
316
|
+
return transitioningSurfaceId_;
|
|
317
|
+
}
|
|
318
|
+
return {};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onGestureCancel() {
|
|
322
|
+
auto lock = std::unique_lock<std::recursive_mutex>(mutex);
|
|
323
|
+
if (transitionState_) {
|
|
324
|
+
transitionState_ = CANCELLED;
|
|
325
|
+
transitionUpdated_ = true;
|
|
326
|
+
react_native_assert(transitioningSurfaceId_ != -1 && "Cancelling non-observed transition");
|
|
327
|
+
|
|
328
|
+
const auto surfaceId = transitioningSurfaceId_;
|
|
329
|
+
transitioningSurfaceId_ = -1;
|
|
330
|
+
return surfaceId;
|
|
331
|
+
}
|
|
332
|
+
return {};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
void LayoutAnimationsProxy_Experimental::startSurface(const SurfaceId surfaceId) {
|
|
336
|
+
const auto node = std::make_shared<LightNode>();
|
|
337
|
+
node->current.componentName = "RootView";
|
|
338
|
+
node->current.tag = surfaceId;
|
|
339
|
+
node->current.props = std::make_shared<BaseViewProps>();
|
|
340
|
+
lightNodes_[surfaceId] = node;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
void LayoutAnimationsProxy_Experimental::insertContainers(
|
|
344
|
+
ShadowViewMutationList &filteredMutations,
|
|
345
|
+
int &rootChildCount,
|
|
346
|
+
SurfaceId surfaceId) const {
|
|
347
|
+
ShadowViewMutationList currentMutations;
|
|
348
|
+
std::swap(currentMutations, filteredMutations);
|
|
349
|
+
filteredMutations.reserve(containersToInsert_.size() * 2);
|
|
350
|
+
auto root = lightNodes_[surfaceId];
|
|
351
|
+
for (auto &node : containersToInsert_) {
|
|
352
|
+
filteredMutations.push_back(ShadowViewMutation::CreateMutation(node->current));
|
|
353
|
+
filteredMutations.push_back(ShadowViewMutation::InsertMutation(surfaceId, node->current, rootChildCount++));
|
|
354
|
+
}
|
|
355
|
+
filteredMutations.insert(filteredMutations.end(), currentMutations.begin(), currentMutations.end());
|
|
356
|
+
containersToInsert_.clear();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
void LayoutAnimationsProxy_Experimental::cleanupSharedTransitions(
|
|
360
|
+
ShadowViewMutationList &filteredMutations,
|
|
361
|
+
const PropsParserContext &propsParserContext,
|
|
362
|
+
SurfaceId surfaceId) const {
|
|
363
|
+
ReanimatedSystraceSection s1("cleanupSharedTransitions");
|
|
364
|
+
for (auto &tag : tagsToRestore_) {
|
|
365
|
+
ReanimatedSystraceSection s("Restore tag");
|
|
366
|
+
auto &node = lightNodes_[tag];
|
|
367
|
+
if (node) {
|
|
368
|
+
auto view = node->current;
|
|
369
|
+
const auto &parent = node->parent.lock();
|
|
370
|
+
react_native_assert(parent && "Parent node is nullptr");
|
|
371
|
+
auto parentTag = parent->current.tag;
|
|
372
|
+
auto m = ShadowViewMutation::UpdateMutation(
|
|
373
|
+
cloneViewWithoutOpacity(view, propsParserContext), cloneViewWithOpacity(view, propsParserContext), parentTag);
|
|
374
|
+
filteredMutations.push_back(m);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
tagsToRestore_.clear();
|
|
378
|
+
|
|
379
|
+
ReanimatedSystraceSection s2("remove shared containers");
|
|
380
|
+
for (auto &tag : sharedContainersToRemove_) {
|
|
381
|
+
auto root = lightNodes_[surfaceId];
|
|
382
|
+
for (int i = 0; i < root->children.size(); i++) {
|
|
383
|
+
auto &child = root->children[i];
|
|
384
|
+
if (child->current.tag == tag) {
|
|
385
|
+
filteredMutations.push_back(ShadowViewMutation::RemoveMutation(surfaceId, child->current, i));
|
|
386
|
+
filteredMutations.push_back(ShadowViewMutation::DeleteMutation(child->current));
|
|
387
|
+
root->children.erase(root->children.begin() + i);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
sharedContainersToRemove_.clear();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// MARK: Position Calculation
|
|
395
|
+
|
|
396
|
+
std::vector<react::Point> LayoutAnimationsProxy_Experimental::getAbsolutePositionsForRootPathView(
|
|
397
|
+
const std::shared_ptr<LightNode> &node) const {
|
|
398
|
+
std::vector<react::Point> viewsAbsolutePositions;
|
|
399
|
+
auto currentNode = node;
|
|
400
|
+
while (currentNode) {
|
|
401
|
+
react::Point viewPosition;
|
|
402
|
+
const auto &componentName = currentNode->current.componentName;
|
|
403
|
+
react_native_assert(componentName && "Component name is nullptr");
|
|
404
|
+
if (!strcmp(componentName, "ScrollView")) {
|
|
405
|
+
auto state = std::static_pointer_cast<const ConcreteState<ScrollViewState>>(currentNode->current.state);
|
|
406
|
+
auto data = state->getData();
|
|
407
|
+
viewPosition -= data.contentOffset;
|
|
408
|
+
}
|
|
409
|
+
if (!strcmp(componentName, "RNSScreen") && currentNode->children.size() >= 2) {
|
|
410
|
+
const auto &parent = currentNode->parent.lock();
|
|
411
|
+
react_native_assert(parent && "Parent node is nullptr");
|
|
412
|
+
|
|
413
|
+
const float headerHeight =
|
|
414
|
+
parent->current.layoutMetrics.frame.size.height - currentNode->current.layoutMetrics.frame.size.height;
|
|
415
|
+
viewPosition.y += headerHeight;
|
|
416
|
+
}
|
|
417
|
+
viewPosition += currentNode->current.layoutMetrics.frame.origin;
|
|
418
|
+
viewsAbsolutePositions.emplace_back(viewPosition);
|
|
419
|
+
currentNode = currentNode->parent.lock();
|
|
420
|
+
}
|
|
421
|
+
for (int i = static_cast<int>(viewsAbsolutePositions.size()) - 2; i >= 0; --i) {
|
|
422
|
+
viewsAbsolutePositions[i] += viewsAbsolutePositions[i + 1];
|
|
423
|
+
}
|
|
424
|
+
return viewsAbsolutePositions;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
std::optional<Transform> LayoutAnimationsProxy_Experimental::parseParentTransforms(
|
|
428
|
+
const std::shared_ptr<LightNode> &node,
|
|
429
|
+
const std::vector<react::Point> &absolutePositions) const {
|
|
430
|
+
std::vector<std::pair<Transform, TransformOrigin>> transforms;
|
|
431
|
+
auto currentNode = node;
|
|
432
|
+
while (currentNode) {
|
|
433
|
+
const auto &props = static_cast<const ViewProps &>(*currentNode->current.props);
|
|
434
|
+
auto origin = props.transformOrigin;
|
|
435
|
+
const auto &viewSize = currentNode->current.layoutMetrics.frame.size;
|
|
436
|
+
if (origin.xy[0].unit == facebook::react::UnitType::Percent) {
|
|
437
|
+
origin.xy[0] = {static_cast<float>(viewSize.width * origin.xy[0].value / 100), UnitType::Point};
|
|
438
|
+
} else if (origin.xy[0].unit == facebook::react::UnitType::Undefined) {
|
|
439
|
+
origin.xy[0] = {static_cast<float>(viewSize.width * 0.5), UnitType::Point};
|
|
440
|
+
}
|
|
441
|
+
if (origin.xy[1].unit == facebook::react::UnitType::Percent) {
|
|
442
|
+
origin.xy[1] = {static_cast<float>(viewSize.height * origin.xy[1].value / 100), UnitType::Point};
|
|
443
|
+
} else if (origin.xy[1].unit == facebook::react::UnitType::Undefined) {
|
|
444
|
+
origin.xy[1] = {static_cast<float>(viewSize.height * 0.5), UnitType::Point};
|
|
445
|
+
}
|
|
446
|
+
transforms.emplace_back(props.transform, origin);
|
|
447
|
+
currentNode = currentNode->parent.lock();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
const auto &targetViewPosition = absolutePositions[0];
|
|
451
|
+
Transform combinedMatrix;
|
|
452
|
+
bool parentHasTransform = false;
|
|
453
|
+
for (int i = static_cast<int>(transforms.size()) - 1; i >= 0; --i) {
|
|
454
|
+
auto &[transform, transformOrigin] = transforms[i];
|
|
455
|
+
if (transform.operations.empty()) {
|
|
456
|
+
continue;
|
|
457
|
+
} else if (i > 0) {
|
|
458
|
+
parentHasTransform = true;
|
|
459
|
+
}
|
|
460
|
+
if (i == 0 && !parentHasTransform) {
|
|
461
|
+
// If only target view has transform, let's skip it, to matrix decomposition in JS
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
transformOrigin.xy[0].value -= targetViewPosition.x - absolutePositions[i].x;
|
|
465
|
+
transformOrigin.xy[1].value -= targetViewPosition.y - absolutePositions[i].y;
|
|
466
|
+
combinedMatrix = combinedMatrix * resolveTransform(node->current.layoutMetrics, transform, transformOrigin);
|
|
467
|
+
combinedMatrix.operations.clear();
|
|
468
|
+
}
|
|
469
|
+
if (parentHasTransform) {
|
|
470
|
+
react::TransformOperation transformOp {
|
|
471
|
+
react::TransformOperationType::Arbitrary,
|
|
472
|
+
{},
|
|
473
|
+
{},
|
|
474
|
+
{}
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
return Transform::FromTransformOperation(
|
|
478
|
+
transformOp, {}, combinedMatrix);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return {};
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// The methods resolveTransform and getTranslateForTransformOrigin are sourced
|
|
485
|
+
// from:
|
|
486
|
+
// https://github.com/facebook/react-native/blob/v0.80.0/packages/react-native/ReactCommon/react/renderer/components/view/BaseViewProps.cpp#L548
|
|
487
|
+
// We need a copy of these methods to modify the `resolveTransform` method
|
|
488
|
+
// to accept the transform origin as a parameter instead of as a class field.
|
|
489
|
+
react::Transform LayoutAnimationsProxy_Experimental::resolveTransform(
|
|
490
|
+
const LayoutMetrics &layoutMetrics,
|
|
491
|
+
const Transform &transform,
|
|
492
|
+
const TransformOrigin &transformOrigin) const {
|
|
493
|
+
const auto &frameSize = layoutMetrics.frame.size;
|
|
494
|
+
auto transformMatrix = Transform{};
|
|
495
|
+
if (frameSize.width == 0 && frameSize.height == 0) {
|
|
496
|
+
return transformMatrix;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (transform.operations.size() == 1 &&
|
|
500
|
+
transform.operations[0].type == facebook::react::TransformOperationType::Arbitrary) {
|
|
501
|
+
transformMatrix = transform;
|
|
502
|
+
} else {
|
|
503
|
+
for (const auto &operation : transform.operations) {
|
|
504
|
+
transformMatrix =
|
|
505
|
+
transformMatrix * Transform::FromTransformOperation(operation, layoutMetrics.frame.size, transform);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (transformOrigin.isSet()) {
|
|
510
|
+
std::array<float, 3> translateOffsets =
|
|
511
|
+
getTranslateForTransformOrigin(frameSize.width, frameSize.height, transformOrigin);
|
|
512
|
+
transformMatrix = Transform::Translate(translateOffsets[0], translateOffsets[1], translateOffsets[2]) *
|
|
513
|
+
transformMatrix * Transform::Translate(-translateOffsets[0], -translateOffsets[1], -translateOffsets[2]);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
return transformMatrix;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
std::array<float, 3> LayoutAnimationsProxy_Experimental::getTranslateForTransformOrigin(
|
|
520
|
+
float viewWidth,
|
|
521
|
+
float viewHeight,
|
|
522
|
+
const TransformOrigin &transformOrigin) const {
|
|
523
|
+
const float viewCenterX = viewWidth / 2;
|
|
524
|
+
const float viewCenterY = viewHeight / 2;
|
|
525
|
+
|
|
526
|
+
std::array<float, 3> origin = {viewCenterX, viewCenterY, transformOrigin.z};
|
|
527
|
+
|
|
528
|
+
for (int i = 0; i < static_cast<int>(transformOrigin.xy.size()); ++i) {
|
|
529
|
+
const auto ¤tOrigin = transformOrigin.xy[i];
|
|
530
|
+
if (currentOrigin.unit == UnitType::Point) {
|
|
531
|
+
origin[i] = currentOrigin.value;
|
|
532
|
+
} else if (currentOrigin.unit == UnitType::Percent) {
|
|
533
|
+
origin[i] = ((i == 0) ? viewWidth : viewHeight) * currentOrigin.value / 100.0f;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const float newTranslateX = -viewCenterX + origin[0];
|
|
538
|
+
const float newTranslateY = -viewCenterY + origin[1];
|
|
539
|
+
const float newTranslateZ = origin[2];
|
|
540
|
+
|
|
541
|
+
return {newTranslateX, newTranslateY, newTranslateZ};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
} // namespace reanimated
|