@react-native-ohos/react-native-reanimated 4.0.2-beta.1 → 4.1.0-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/CHANGELOG.md +1070 -0
- package/LICENSE +21 -0
- package/README.md +842 -0
- package/compatibility.json +20 -26
- package/harmony/reanimated/BuildProfile.ets +1 -1
- package/harmony/reanimated/index.ets +4 -2
- package/harmony/reanimated/oh-package-lock.json5 +1 -1
- package/harmony/reanimated/oh-package.json5 +1 -1
- package/harmony/reanimated/src/main/cpp/CMakeLists.txt +23 -9
- package/harmony/reanimated/src/main/cpp/Common/NativeView/CMakeLists.txt +56 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h +19 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryComponentDescriptor.h +30 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.cpp +15 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryShadowNode.h +41 -0
- package/harmony/reanimated/src/main/cpp/Common/NativeView/react/renderer/components/rnreanimated/REASharedTransitionBoundaryState.h +30 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.cpp +203 -150
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/InterpolatorRegistry.h +1 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/definitions.h +2 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSAngle.cpp +0 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSColor.cpp +2 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.cpp +11 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSDiscreteArray.h +2 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSLength.cpp +4 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.cpp +5 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSNumber.h +8 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValue.h +27 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +20 -20
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.h +2 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/common/values/complex/CSSDropShadow.h +3 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.cpp +10 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSAnimationConfig.h +5 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.cpp +20 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSKeyframesConfig.h +5 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.cpp +33 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/CSSTransitionConfig.h +29 -22
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.cpp +14 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/configs/common.h +8 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.cpp +50 -91
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimation.h +43 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.cpp +63 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSAnimationsGroup.h +37 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.cpp +100 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSLoopAnimation.h +49 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimation.h +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSPlatformAnimationFactory.h +32 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.cpp +156 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSLoopTransition.h +71 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.cpp +141 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSPlatformTransitionProxy.h +104 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.cpp +97 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/transition/CSSTransition.h +69 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.cpp +89 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/easing/EasingConfigs.h +36 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.cpp +12 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/InterpolatorFactory.h +11 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.h +3 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.cpp +3 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/filters/FilterOperation.h +1 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.cpp +38 -37
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/ArrayPropertiesInterpolator.h +3 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.cpp +54 -32
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/groups/RecordPropertiesInterpolator.h +5 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.cpp +46 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/OperationsStyleInterpolator.h +8 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/operations/StyleOperation.h +4 -57
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.cpp +23 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolator.h +10 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.cpp +77 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/AnimationStyleInterpolatorFactory.h +38 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.cpp +47 -68
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/styles/TransitionStyleInterpolator.h +21 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperation.cpp +4 -1
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.cpp +35 -78
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/TransformOperationInterpolator.h +44 -13
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/transforms/operations/matrix.cpp +13 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ResolvableValueInterpolator.cpp +4 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/SimpleValueInterpolator.cpp +7 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.cpp +20 -27
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/interpolation/values/ValueInterpolator.h +12 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp +63 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h +6 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.cpp +55 -46
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/AnimationProgressProvider.h +8 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp +1 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h +3 -2
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.cpp +76 -71
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/TransitionProgressProvider.h +17 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.cpp +145 -273
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSAnimationsRegistry.h +43 -44
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.cpp +19 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSKeyframesRegistry.h +16 -12
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.cpp +95 -114
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/CSSTransitionsRegistry.h +38 -25
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.cpp +9 -34
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/registries/StaticPropsRegistry.h +0 -10
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.cpp +47 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthArray.h +24 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.cpp +87 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/CSSLengthVector.h +28 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.cpp +326 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGPath.h +65 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.cpp +164 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStops.h +51 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.cpp +14 -66
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGStrokeDashArray.h +7 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.cpp +284 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/platform.h +31 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.cpp +13 -132
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/props.h +3 -21
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/reversingShortening.h +43 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.cpp +33 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandler.h +39 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +95 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +40 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +20 -23
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +26 -18
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +4 -8
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.cpp +16 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/ShadowTreeCloner.h +3 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +72 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.h +17 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.cpp +152 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/OperationsLoop.h +86 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/PropsLayoutFilter.h +98 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.cpp +162 -28
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistry.h +69 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.cpp +41 -17
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/UpdatesRegistryManager.h +14 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Fabric/updates/propNameFromString.h +130 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.cpp +1 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +5 -7
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.cpp +7 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +52 -9
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +174 -62
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +12 -11
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +251 -128
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +23 -19
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +34 -6
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +71 -64
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +938 -700
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +123 -76
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.cpp +313 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/SynchronousPropsBufferSerializer.h +18 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoSelector.h +41 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.cpp +113 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/PseudoStyles/PseudoStylesRegistry.h +73 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +4 -4
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +23 -48
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +13 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +20 -3
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReaJSIUtils.h +227 -0
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.cpp +51 -14
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/ReanimatedVersion.h +2 -5
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/Tools/SingleInstanceChecker.h +76 -0
- package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.cpp +353 -0
- package/harmony/reanimated/src/main/cpp/OHOSCSSPlatformTransitions.h +95 -0
- package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.cpp +140 -0
- package/harmony/reanimated/src/main/cpp/PseudoSelectorManager.h +52 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.cpp +45 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryComponentInstance.h +33 -0
- package/harmony/reanimated/src/main/cpp/REASharedTransitionBoundaryJSIBinder.h +20 -0
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.cpp +112 -19
- package/harmony/reanimated/src/main/cpp/ReanimatedModule.h +4 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.cpp +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedNodesManager.h +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.cpp +24 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedPackage.h +7 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.cpp +88 -57
- package/harmony/reanimated/src/main/cpp/ReanimatedSensor.h +4 -2
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.cpp +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedSensorContainer.h +1 -1
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.cpp +9 -7
- package/harmony/reanimated/src/main/cpp/ReanimatedUIScheduler.h +6 -5
- package/harmony/reanimated/src/main/cpp/TransformParser.h +1 -1
- package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/EventEmitters.h +19 -0
- package/harmony/reanimated/src/main/cpp/codegen/react/renderer/components/rnreanimated/Props.h +31 -0
- package/harmony/reanimated/src/main/ets/KeyboardState.ts +11 -0
- package/harmony/reanimated/src/main/ets/ReanimatedModule.ts +119 -19
- package/harmony/reanimated/src/main/ets/{ReanimatedPackage.ts → ReanimatedPackage.ets} +4 -3
- package/harmony/reanimated.har +0 -0
- package/package.json +52 -24
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.cpp +0 -145
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/core/CSSTransition.h +0 -47
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.cpp +0 -93
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/svg/values/SVGLength.h +0 -36
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +0 -75
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +0 -45
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp +0 -183
- package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h +0 -93
- package/harmony/reanimated/src/main/ets/AnimationManager.ts +0 -61
- /package/harmony/reanimated/{ts.ts → ts.ets} +0 -0
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.cpp
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include <reanimated/CSS/misc/ViewStylesRepository.h>
|
|
2
|
+
#include <reanimated/Tools/FeatureFlags.h>
|
|
2
3
|
|
|
3
4
|
#include <memory>
|
|
4
5
|
#include <string>
|
|
@@ -13,13 +14,11 @@ ViewStylesRepository::ViewStylesRepository(
|
|
|
13
14
|
jsi::Value ViewStylesRepository::getNodeProp(
|
|
14
15
|
const std::shared_ptr<const ShadowNode> &shadowNode,
|
|
15
16
|
const std::string &propName) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
auto &cachedNode = shadowNodeCache_[tag];
|
|
19
|
-
updateCacheIfNeeded(cachedNode, shadowNode);
|
|
17
|
+
const auto resolvedNode = getNewestNode(shadowNode);
|
|
18
|
+
const auto *layoutableShadowNode = dynamic_cast<const LayoutableShadowNode *>(resolvedNode.get());
|
|
20
19
|
|
|
21
20
|
if (propName == "width" || propName == "height" || propName == "top" || propName == "left") {
|
|
22
|
-
const auto
|
|
21
|
+
const auto layoutMetrics = layoutableShadowNode ? layoutableShadowNode->layoutMetrics_ : LayoutMetrics{};
|
|
23
22
|
|
|
24
23
|
if (propName == "width") {
|
|
25
24
|
return {layoutMetrics.frame.size.width};
|
|
@@ -31,7 +30,13 @@ jsi::Value ViewStylesRepository::getNodeProp(
|
|
|
31
30
|
return {layoutMetrics.frame.origin.x};
|
|
32
31
|
}
|
|
33
32
|
} else {
|
|
34
|
-
|
|
33
|
+
if (!layoutableShadowNode) {
|
|
34
|
+
return jsi::Value::undefined();
|
|
35
|
+
}
|
|
36
|
+
const auto viewProps = std::static_pointer_cast<const ViewProps>(resolvedNode->getProps());
|
|
37
|
+
if (!viewProps) {
|
|
38
|
+
return jsi::Value::undefined();
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
if (propName == "opacity") {
|
|
37
42
|
return {viewProps->opacity};
|
|
@@ -48,15 +53,7 @@ jsi::Value ViewStylesRepository::getNodeProp(
|
|
|
48
53
|
jsi::Value ViewStylesRepository::getParentNodeProp(
|
|
49
54
|
const std::shared_ptr<const ShadowNode> &shadowNode,
|
|
50
55
|
const std::string &propName) {
|
|
51
|
-
const auto
|
|
52
|
-
const auto &shadowTreeRegistry = uiManager_->getShadowTreeRegistry();
|
|
53
|
-
|
|
54
|
-
std::shared_ptr<const ShadowNode> parentNode = nullptr;
|
|
55
|
-
|
|
56
|
-
shadowTreeRegistry.visit(surfaceId, [&](ShadowTree const &shadowTree) {
|
|
57
|
-
auto currentRevision = shadowTree.getCurrentRevision();
|
|
58
|
-
parentNode = dom::getParentNode(currentRevision.rootShadowNode, *shadowNode);
|
|
59
|
-
});
|
|
56
|
+
const auto parentNode = getParentNode(shadowNode);
|
|
60
57
|
|
|
61
58
|
if (!parentNode) {
|
|
62
59
|
return jsi::Value::undefined();
|
|
@@ -65,37 +62,67 @@ jsi::Value ViewStylesRepository::getParentNodeProp(
|
|
|
65
62
|
return getNodeProp(parentNode, propName);
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
65
|
+
std::shared_ptr<const ShadowNode> ViewStylesRepository::getNewestNode(
|
|
66
|
+
const std::shared_ptr<const ShadowNode> &shadowNode) const {
|
|
67
|
+
if constexpr (StaticFeatureFlags::getFlag("USE_ANIMATION_BACKEND")) {
|
|
68
|
+
// Backend mode has no commit hook (it returns before taking the updates-registry
|
|
69
|
+
// lock), so reading the live tree here cannot deadlock and needs no snapshot.
|
|
70
|
+
const auto newestNode = uiManager_->getNewestCloneOfShadowNode(*shadowNode);
|
|
71
|
+
return newestNode ? newestNode : shadowNode;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
// Resolve shadowNode against the last mounted root without the ShadowTree lock (the
|
|
75
|
+
// deadlock) that getNewestCloneOfShadowNode takes, falling back to the passed node.
|
|
76
|
+
// Mirrors RN's getShadowNodeInSubtree:
|
|
77
|
+
// https://github.com/facebook/react-native/blob/v0.86.0-rc.3/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp#L339
|
|
78
|
+
const auto it = lastMountedRootBySurface_.find(shadowNode->getSurfaceId());
|
|
79
|
+
if (it == lastMountedRootBySurface_.end()) {
|
|
80
|
+
return shadowNode;
|
|
81
|
+
}
|
|
82
|
+
const auto &root = it->second;
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
if (ShadowNode::sameFamily(*root, *shadowNode)) {
|
|
85
|
+
return root;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const auto ancestors = shadowNode->getFamily().getAncestors(*root);
|
|
89
|
+
if (ancestors.empty()) {
|
|
90
|
+
return shadowNode;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const auto &deepest = ancestors.back();
|
|
94
|
+
return deepest.first.get().getChildren().at(deepest.second);
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
std::shared_ptr<const ShadowNode> ViewStylesRepository::getParentNode(
|
|
98
|
+
const std::shared_ptr<const ShadowNode> &shadowNode) const {
|
|
99
|
+
if constexpr (StaticFeatureFlags::getFlag("USE_ANIMATION_BACKEND")) {
|
|
100
|
+
// Backend mode resolves against the live tree (see getNewestNode).
|
|
101
|
+
std::shared_ptr<const ShadowNode> parentNode = nullptr;
|
|
102
|
+
uiManager_->getShadowTreeRegistry().visit(shadowNode->getSurfaceId(), [&](const ShadowTree &shadowTree) {
|
|
103
|
+
parentNode = dom::getParentNode(shadowTree.getCurrentRevision().rootShadowNode, *shadowNode);
|
|
104
|
+
});
|
|
105
|
+
return parentNode;
|
|
106
|
+
}
|
|
85
107
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return;
|
|
108
|
+
const auto it = lastMountedRootBySurface_.find(shadowNode->getSurfaceId());
|
|
109
|
+
if (it == lastMountedRootBySurface_.end()) {
|
|
110
|
+
return nullptr;
|
|
90
111
|
}
|
|
112
|
+
return dom::getParentNode(it->second, *shadowNode);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void ViewStylesRepository::setLastMountedRoot(const RootShadowNode::Shared &rootShadowNode) {
|
|
116
|
+
lastMountedRootBySurface_[rootShadowNode->getSurfaceId()] = rootShadowNode;
|
|
117
|
+
}
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
119
|
+
folly::dynamic ViewStylesRepository::getStyleProp(const Tag tag, const PropertyPath &propertyPath) {
|
|
120
|
+
auto animatedValue = getPropertyValue(animatedPropsRegistry_->get(tag), propertyPath);
|
|
121
|
+
if (!animatedValue.isNull()) {
|
|
122
|
+
return animatedValue;
|
|
95
123
|
}
|
|
96
124
|
|
|
97
|
-
|
|
98
|
-
cachedNode.viewProps = std::static_pointer_cast<const ViewProps>(newestCloneOfShadowNode->getProps());
|
|
125
|
+
return getPropertyValue(staticPropsRegistry_->get(tag), propertyPath);
|
|
99
126
|
}
|
|
100
127
|
|
|
101
128
|
folly::dynamic ViewStylesRepository::getPropertyValue(const folly::dynamic &value, const PropertyPath &propertyPath) {
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/misc/ViewStylesRepository.h
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
#include <reanimated/CSS/registries/StaticPropsRegistry.h>
|
|
5
5
|
#include <reanimated/Fabric/updates/AnimatedPropsRegistry.h>
|
|
6
6
|
|
|
7
|
+
#include <react/renderer/components/root/RootShadowNode.h>
|
|
7
8
|
#include <react/renderer/components/view/ViewProps.h>
|
|
8
9
|
#include <react/renderer/core/LayoutableShadowNode.h>
|
|
9
10
|
#include <react/renderer/dom/DOM.h>
|
|
11
|
+
#include <react/renderer/uimanager/UIManager.h>
|
|
10
12
|
|
|
11
13
|
#include <memory>
|
|
12
14
|
#include <string>
|
|
@@ -17,11 +19,6 @@ namespace reanimated::css {
|
|
|
17
19
|
using namespace facebook;
|
|
18
20
|
using namespace react;
|
|
19
21
|
|
|
20
|
-
struct CachedShadowNode {
|
|
21
|
-
LayoutMetrics layoutMetrics;
|
|
22
|
-
std::shared_ptr<const ViewProps> viewProps;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
22
|
class ViewStylesRepository {
|
|
26
23
|
public:
|
|
27
24
|
ViewStylesRepository(
|
|
@@ -36,16 +33,17 @@ class ViewStylesRepository {
|
|
|
36
33
|
jsi::Value getParentNodeProp(const std::shared_ptr<const ShadowNode> &shadowNode, const std::string &propName);
|
|
37
34
|
folly::dynamic getStyleProp(Tag tag, const PropertyPath &propertyPath);
|
|
38
35
|
|
|
39
|
-
void
|
|
36
|
+
void setLastMountedRoot(const RootShadowNode::Shared &rootShadowNode);
|
|
40
37
|
|
|
41
38
|
private:
|
|
42
39
|
std::shared_ptr<UIManager> uiManager_;
|
|
43
40
|
std::shared_ptr<StaticPropsRegistry> staticPropsRegistry_;
|
|
44
41
|
std::shared_ptr<AnimatedPropsRegistry> animatedPropsRegistry_;
|
|
45
42
|
|
|
46
|
-
std::unordered_map<
|
|
43
|
+
std::unordered_map<SurfaceId, RootShadowNode::Shared> lastMountedRootBySurface_;
|
|
47
44
|
|
|
48
|
-
|
|
45
|
+
std::shared_ptr<const ShadowNode> getNewestNode(const std::shared_ptr<const ShadowNode> &shadowNode) const;
|
|
46
|
+
std::shared_ptr<const ShadowNode> getParentNode(const std::shared_ptr<const ShadowNode> &shadowNode) const;
|
|
49
47
|
|
|
50
48
|
static folly::dynamic getPropertyValue(const folly::dynamic &value, const PropertyPath &propertyPath);
|
|
51
49
|
};
|
|
@@ -12,12 +12,12 @@ AnimationProgressProvider::AnimationProgressProvider(
|
|
|
12
12
|
const double iterationCount,
|
|
13
13
|
const AnimationDirection direction,
|
|
14
14
|
EasingFunction easingFunction,
|
|
15
|
-
const std::shared_ptr<
|
|
15
|
+
const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs)
|
|
16
16
|
: RawProgressProvider(timestamp, duration, delay),
|
|
17
17
|
iterationCount_(iterationCount),
|
|
18
18
|
direction_(direction),
|
|
19
19
|
easingFunction_(std::move(easingFunction)),
|
|
20
|
-
|
|
20
|
+
keyframeEasingConfigs_(keyframeEasingConfigs) {}
|
|
21
21
|
|
|
22
22
|
void AnimationProgressProvider::setIterationCount(double iterationCount) {
|
|
23
23
|
iterationCount_ = iterationCount;
|
|
@@ -39,34 +39,6 @@ double AnimationProgressProvider::getGlobalProgress() const {
|
|
|
39
39
|
return applyAnimationDirection(rawProgress_.value_or(0));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
AnimationProgressState AnimationProgressProvider::getState(const double timestamp) const {
|
|
43
|
-
if (shouldFinish(timestamp)) {
|
|
44
|
-
return AnimationProgressState::Finished;
|
|
45
|
-
}
|
|
46
|
-
if (pauseTimestamp_ > 0) {
|
|
47
|
-
return AnimationProgressState::Paused;
|
|
48
|
-
}
|
|
49
|
-
if (timestamp < getStartTimestamp(timestamp) || !rawProgress_.has_value()) {
|
|
50
|
-
return AnimationProgressState::Pending;
|
|
51
|
-
}
|
|
52
|
-
return AnimationProgressState::Running;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
double AnimationProgressProvider::getPauseTimestamp() const {
|
|
56
|
-
return pauseTimestamp_;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
double AnimationProgressProvider::getTotalPausedTime(const double timestamp) const {
|
|
60
|
-
return pauseTimestamp_ > 0 ? (totalPausedTime_ + (timestamp - pauseTimestamp_)) : totalPausedTime_;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
double AnimationProgressProvider::getStartTimestamp(const double timestamp) const {
|
|
64
|
-
// Start timestamp is the timestamp when the first animation keyframe
|
|
65
|
-
// should be applied (it depends on the animation delay and the total
|
|
66
|
-
// time when the animation was paused)
|
|
67
|
-
return creationTimestamp_ + delay_ + getTotalPausedTime(timestamp);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
42
|
double AnimationProgressProvider::getKeyframeProgress(const double fromOffset, const double toOffset) const {
|
|
71
43
|
if (fromOffset == toOffset) {
|
|
72
44
|
return 1;
|
|
@@ -76,14 +48,25 @@ double AnimationProgressProvider::getKeyframeProgress(const double fromOffset, c
|
|
|
76
48
|
|
|
77
49
|
// Use the overridden easing function if it was overridden for the
|
|
78
50
|
// current keyframe
|
|
79
|
-
const auto
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
51
|
+
const auto easingConfigIt = keyframeEasingConfigs_->find(fromOffset);
|
|
52
|
+
if (easingConfigIt != keyframeEasingConfigs_->end()) {
|
|
53
|
+
return getEasingFunctionFromConfig(easingConfigIt->second)(keyframeProgress);
|
|
82
54
|
}
|
|
83
55
|
|
|
84
56
|
return easingFunction_(keyframeProgress);
|
|
85
57
|
}
|
|
86
58
|
|
|
59
|
+
AnimationProgressState AnimationProgressProvider::getState() const {
|
|
60
|
+
return state_;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
double AnimationProgressProvider::getStartTimestamp(const double timestamp) const {
|
|
64
|
+
// Start timestamp is the timestamp when the first animation keyframe
|
|
65
|
+
// should be applied (it depends on the animation delay and the total
|
|
66
|
+
// time when the animation was paused)
|
|
67
|
+
return creationTimestamp_ + delay_ + getTotalPausedTime(timestamp);
|
|
68
|
+
}
|
|
69
|
+
|
|
87
70
|
void AnimationProgressProvider::pause(const double timestamp) {
|
|
88
71
|
pauseTimestamp_ = timestamp;
|
|
89
72
|
}
|
|
@@ -95,26 +78,21 @@ void AnimationProgressProvider::play(const double timestamp) {
|
|
|
95
78
|
pauseTimestamp_ = 0;
|
|
96
79
|
}
|
|
97
80
|
|
|
81
|
+
void AnimationProgressProvider::update(const double timestamp) {
|
|
82
|
+
RawProgressProvider::update(timestamp);
|
|
83
|
+
state_ = computeState(timestamp);
|
|
84
|
+
}
|
|
85
|
+
|
|
98
86
|
void AnimationProgressProvider::resetProgress() {
|
|
99
87
|
RawProgressProvider::resetProgress();
|
|
100
88
|
currentIteration_ = 1;
|
|
101
89
|
previousIterationsDuration_ = 0;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
bool AnimationProgressProvider::shouldFinish(const double timestamp) const {
|
|
105
|
-
if (iterationCount_ == 0) {
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
if (iterationCount_ == -1) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
const auto elapsedDuration = timestamp - getStartTimestamp(timestamp);
|
|
112
|
-
return elapsedDuration >= duration_ * iterationCount_;
|
|
90
|
+
state_ = AnimationProgressState::Pending;
|
|
113
91
|
}
|
|
114
92
|
|
|
115
93
|
std::optional<double> AnimationProgressProvider::calculateRawProgress(const double timestamp) {
|
|
116
|
-
const double
|
|
117
|
-
|
|
94
|
+
const double startTimestamp = getStartTimestamp(timestamp);
|
|
95
|
+
const double currentIterationElapsedTime = timestamp - (startTimestamp + previousIterationsDuration_);
|
|
118
96
|
|
|
119
97
|
if (currentIterationElapsedTime < 0) {
|
|
120
98
|
return std::nullopt;
|
|
@@ -132,6 +110,37 @@ std::optional<double> AnimationProgressProvider::calculateRawProgress(const doub
|
|
|
132
110
|
return iterationProgress;
|
|
133
111
|
}
|
|
134
112
|
|
|
113
|
+
double AnimationProgressProvider::getTotalPausedTime(const double timestamp) const {
|
|
114
|
+
if (pauseTimestamp_ > 0) {
|
|
115
|
+
return totalPausedTime_ + (timestamp - pauseTimestamp_);
|
|
116
|
+
}
|
|
117
|
+
return totalPausedTime_;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
bool AnimationProgressProvider::shouldFinish(const double timestamp) const {
|
|
121
|
+
if (iterationCount_ == 0) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (iterationCount_ == -1) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const auto elapsedDuration = timestamp - getStartTimestamp(timestamp);
|
|
128
|
+
return elapsedDuration >= duration_ * iterationCount_;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
AnimationProgressState AnimationProgressProvider::computeState(const double timestamp) const {
|
|
132
|
+
if (shouldFinish(timestamp)) {
|
|
133
|
+
return AnimationProgressState::Finished;
|
|
134
|
+
}
|
|
135
|
+
if (pauseTimestamp_ > 0) {
|
|
136
|
+
return AnimationProgressState::Paused;
|
|
137
|
+
}
|
|
138
|
+
if (timestamp < getStartTimestamp(timestamp) || !rawProgress_.has_value()) {
|
|
139
|
+
return AnimationProgressState::Pending;
|
|
140
|
+
}
|
|
141
|
+
return AnimationProgressState::Running;
|
|
142
|
+
}
|
|
143
|
+
|
|
135
144
|
double AnimationProgressProvider::updateIterationProgress(const double currentIterationElapsedTime) {
|
|
136
145
|
if (duration_ == 0) {
|
|
137
146
|
return 1;
|
|
@@ -26,7 +26,7 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
|
|
|
26
26
|
double iterationCount,
|
|
27
27
|
AnimationDirection direction,
|
|
28
28
|
EasingFunction easingFunction,
|
|
29
|
-
const std::shared_ptr<
|
|
29
|
+
const std::shared_ptr<KeyframeEasingConfigs> &keyframeEasingConfigs);
|
|
30
30
|
|
|
31
31
|
void setIterationCount(double iterationCount);
|
|
32
32
|
void setDirection(AnimationDirection direction);
|
|
@@ -35,13 +35,13 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
|
|
|
35
35
|
AnimationDirection getDirection() const;
|
|
36
36
|
double getGlobalProgress() const override;
|
|
37
37
|
double getKeyframeProgress(double fromOffset, double toOffset) const override;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
double getTotalPausedTime(double timestamp) const;
|
|
38
|
+
|
|
39
|
+
AnimationProgressState getState() const;
|
|
41
40
|
double getStartTimestamp(double timestamp) const;
|
|
42
41
|
|
|
43
42
|
void pause(double timestamp);
|
|
44
43
|
void play(double timestamp);
|
|
44
|
+
void update(double timestamp) override;
|
|
45
45
|
void resetProgress() override;
|
|
46
46
|
|
|
47
47
|
protected:
|
|
@@ -51,14 +51,17 @@ class AnimationProgressProvider final : public KeyframeProgressProvider, public
|
|
|
51
51
|
double iterationCount_;
|
|
52
52
|
AnimationDirection direction_;
|
|
53
53
|
EasingFunction easingFunction_;
|
|
54
|
-
std::shared_ptr<
|
|
54
|
+
std::shared_ptr<KeyframeEasingConfigs> keyframeEasingConfigs_;
|
|
55
55
|
|
|
56
|
+
AnimationProgressState state_ = AnimationProgressState::Pending;
|
|
56
57
|
unsigned currentIteration_ = 1;
|
|
57
58
|
double previousIterationsDuration_ = 0;
|
|
58
59
|
double pauseTimestamp_ = 0;
|
|
59
60
|
double totalPausedTime_ = 0;
|
|
60
61
|
|
|
62
|
+
double getTotalPausedTime(double timestamp) const;
|
|
61
63
|
bool shouldFinish(double timestamp) const;
|
|
64
|
+
AnimationProgressState computeState(double timestamp) const;
|
|
62
65
|
|
|
63
66
|
double updateIterationProgress(double currentIterationElapsedTime);
|
|
64
67
|
double applyAnimationDirection(double iterationProgress) const;
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.cpp
CHANGED
|
@@ -15,11 +15,10 @@ void RawProgressProvider::setDelay(double delay) {
|
|
|
15
15
|
|
|
16
16
|
void RawProgressProvider::resetProgress() {
|
|
17
17
|
rawProgress_.reset();
|
|
18
|
-
previousRawProgress_.reset();
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
void RawProgressProvider::update(const double timestamp) {
|
|
22
|
-
|
|
21
|
+
lastTimestamp_ = timestamp;
|
|
23
22
|
|
|
24
23
|
if (timestamp - creationTimestamp_ < delay_) {
|
|
25
24
|
rawProgress_.reset();
|
package/harmony/reanimated/src/main/cpp/Common/cpp/reanimated/CSS/progress/RawProgressProvider.h
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <optional>
|
|
4
|
+
|
|
4
5
|
namespace reanimated::css {
|
|
5
6
|
|
|
6
7
|
class RawProgressProvider {
|
|
@@ -11,15 +12,15 @@ class RawProgressProvider {
|
|
|
11
12
|
void setDelay(double delay);
|
|
12
13
|
|
|
13
14
|
virtual void resetProgress();
|
|
14
|
-
void update(double timestamp);
|
|
15
|
+
virtual void update(double timestamp);
|
|
15
16
|
|
|
16
17
|
protected:
|
|
17
18
|
double duration_;
|
|
18
19
|
double delay_;
|
|
19
20
|
double creationTimestamp_;
|
|
21
|
+
double lastTimestamp_{0};
|
|
20
22
|
|
|
21
23
|
std::optional<double> rawProgress_;
|
|
22
|
-
std::optional<double> previousRawProgress_;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Calculates the progress of the animation at the given timestamp without
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#include <reanimated/CSS/progress/TransitionProgressProvider.h>
|
|
2
2
|
|
|
3
|
+
#include <reanimated/CSS/utils/reversingShortening.h>
|
|
4
|
+
|
|
3
5
|
#include <limits>
|
|
4
6
|
#include <memory>
|
|
5
7
|
#include <string>
|
|
6
8
|
#include <unordered_set>
|
|
9
|
+
#include <utility>
|
|
7
10
|
|
|
8
11
|
namespace reanimated::css {
|
|
9
12
|
|
|
@@ -13,17 +16,20 @@ TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
|
|
|
13
16
|
const double timestamp,
|
|
14
17
|
const double duration,
|
|
15
18
|
const double delay,
|
|
16
|
-
|
|
17
|
-
: RawProgressProvider(timestamp, duration, delay),
|
|
19
|
+
EasingConfig easing)
|
|
20
|
+
: RawProgressProvider(timestamp, duration, delay),
|
|
21
|
+
easing_(std::move(easing)),
|
|
22
|
+
easingFunction_(getEasingFunctionFromConfig(easing_)) {}
|
|
18
23
|
|
|
19
24
|
TransitionPropertyProgressProvider::TransitionPropertyProgressProvider(
|
|
20
25
|
const double timestamp,
|
|
21
26
|
const double duration,
|
|
22
27
|
const double delay,
|
|
23
|
-
|
|
28
|
+
EasingConfig easing,
|
|
24
29
|
const double reversingShorteningFactor)
|
|
25
30
|
: RawProgressProvider(timestamp, duration, delay),
|
|
26
|
-
|
|
31
|
+
easing_(std::move(easing)),
|
|
32
|
+
easingFunction_(getEasingFunctionFromConfig(easing_)),
|
|
27
33
|
reversingShorteningFactor_(reversingShorteningFactor) {}
|
|
28
34
|
|
|
29
35
|
double TransitionPropertyProgressProvider::getGlobalProgress() const {
|
|
@@ -41,17 +47,18 @@ double TransitionPropertyProgressProvider::getRemainingDelay(const double timest
|
|
|
41
47
|
return delay_ - (timestamp - creationTimestamp_);
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
return reversingShorteningFactor_;
|
|
50
|
+
ReversingState TransitionPropertyProgressProvider::getReversingState() const {
|
|
51
|
+
return {reversingShorteningFactor_, creationTimestamp_ + delay_, duration_, delay_, easing_};
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
TransitionProgressState TransitionPropertyProgressProvider::getState() const {
|
|
55
|
+
// rawProgress_ is empty until the property's delay has passed
|
|
56
|
+
// (RawProgressProvider::update resets it while timestamp < creationTimestamp + delay)
|
|
49
57
|
if (!rawProgress_.has_value()) {
|
|
50
58
|
return TransitionProgressState::Pending;
|
|
51
59
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return TransitionProgressState::Finished;
|
|
60
|
+
if (rawProgress_.value() >= 1) {
|
|
61
|
+
return TransitionProgressState::Idle;
|
|
55
62
|
}
|
|
56
63
|
return TransitionProgressState::Running;
|
|
57
64
|
}
|
|
@@ -70,12 +77,14 @@ double TransitionPropertyProgressProvider::getElapsedTime(const double timestamp
|
|
|
70
77
|
// TransitionProgressProvider
|
|
71
78
|
|
|
72
79
|
TransitionProgressState TransitionProgressProvider::getState() const {
|
|
73
|
-
for (const auto &[_,
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
for (const auto &[_, progressProvider] : propertyProgressProviders_) {
|
|
81
|
+
const auto state = progressProvider->getState();
|
|
82
|
+
if (state != TransitionProgressState::Idle) {
|
|
83
|
+
return state;
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
|
|
86
|
+
|
|
87
|
+
return TransitionProgressState::Idle;
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
double TransitionProgressProvider::getMinDelay(const double timestamp) const {
|
|
@@ -102,63 +111,51 @@ std::unordered_set<std::string> TransitionProgressProvider::getRemovedProperties
|
|
|
102
111
|
return removedProperties_;
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
void TransitionProgressProvider::
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
void TransitionProgressProvider::runProgressProvider(
|
|
115
|
+
const std::string &propertyName,
|
|
116
|
+
const bool isReversed,
|
|
117
|
+
const double timestamp) {
|
|
118
|
+
|
|
119
|
+
const auto &settings = propertySettings_.at(propertyName);
|
|
120
|
+
|
|
121
|
+
const auto providerIt = propertyProgressProviders_.find(propertyName);
|
|
122
|
+
|
|
123
|
+
if (providerIt != propertyProgressProviders_.end()) {
|
|
124
|
+
const auto &progressProvider = providerIt->second;
|
|
125
|
+
progressProvider->update(timestamp);
|
|
126
|
+
|
|
127
|
+
if (isReversed && progressProvider->getState() != TransitionProgressState::Idle) {
|
|
128
|
+
// Create reversing shortening progress provider for interrupted reversing transition
|
|
129
|
+
propertyProgressProviders_.insert_or_assign(
|
|
130
|
+
propertyName, createReversingShorteningProgressProvider(timestamp, settings, *progressProvider));
|
|
131
|
+
return;
|
|
111
132
|
}
|
|
112
133
|
}
|
|
134
|
+
|
|
135
|
+
// Create progress provider with the new settings
|
|
136
|
+
propertyProgressProviders_.insert_or_assign(
|
|
137
|
+
propertyName,
|
|
138
|
+
std::make_shared<TransitionPropertyProgressProvider>(
|
|
139
|
+
timestamp, settings.duration, settings.delay, settings.easingConfig));
|
|
113
140
|
}
|
|
114
141
|
|
|
115
|
-
void TransitionProgressProvider::
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// Remove property progress providers for properties not specified in the
|
|
119
|
-
// transition property names
|
|
120
|
-
if (transitionPropertyNames.find(it->first) == transitionPropertyNames.end()) {
|
|
121
|
-
it = propertyProgressProviders_.erase(it);
|
|
122
|
-
} else {
|
|
123
|
-
++it;
|
|
124
|
-
}
|
|
142
|
+
void TransitionProgressProvider::removeProperties(const std::vector<std::string> &propertyNames) {
|
|
143
|
+
for (const auto &propertyName : propertyNames) {
|
|
144
|
+
propertyProgressProviders_.erase(propertyName);
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
|
|
128
|
-
void TransitionProgressProvider::
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const PropertyNames &changedPropertyNames,
|
|
132
|
-
const std::unordered_set<std::string> &reversedPropertyNames) {
|
|
133
|
-
for (const auto &propertyName : changedPropertyNames) {
|
|
134
|
-
const auto propertySettingsOptional = getTransitionPropertySettings(propertiesSettings, propertyName);
|
|
135
|
-
|
|
136
|
-
if (!propertySettingsOptional.has_value()) {
|
|
137
|
-
throw std::invalid_argument("[Reanimated] Property '" + propertyName + "' is not a valid transition property");
|
|
138
|
-
}
|
|
148
|
+
void TransitionProgressProvider::removeProperty(const std::string &propertyName) {
|
|
149
|
+
propertyProgressProviders_.erase(propertyName);
|
|
150
|
+
}
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (reversedPropertyNames.find(propertyName) != reversedPropertyNames.end() &&
|
|
148
|
-
progressProvider->getState() != TransitionProgressState::Finished) {
|
|
149
|
-
// Create reversing shortening progress provider for interrupted
|
|
150
|
-
// reversing transition
|
|
151
|
-
propertyProgressProviders_.insert_or_assign(
|
|
152
|
-
propertyName, createReversingShorteningProgressProvider(timestamp, propertySettings, *progressProvider));
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
152
|
+
void TransitionProgressProvider::discardFinishedProgressProviders() {
|
|
153
|
+
for (auto it = propertyProgressProviders_.begin(); it != propertyProgressProviders_.end();) {
|
|
154
|
+
if (it->second->getState() == TransitionProgressState::Idle) {
|
|
155
|
+
it = propertyProgressProviders_.erase(it);
|
|
156
|
+
} else {
|
|
157
|
+
++it;
|
|
155
158
|
}
|
|
156
|
-
|
|
157
|
-
// Create progress provider with the new settings
|
|
158
|
-
propertyProgressProviders_.insert_or_assign(
|
|
159
|
-
propertyName,
|
|
160
|
-
std::make_shared<TransitionPropertyProgressProvider>(
|
|
161
|
-
timestamp, propertySettings.duration, propertySettings.delay, propertySettings.easingFunction));
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
161
|
|
|
@@ -167,7 +164,7 @@ void TransitionProgressProvider::update(const double timestamp) {
|
|
|
167
164
|
|
|
168
165
|
for (const auto &[propertyName, propertyProgressProvider] : propertyProgressProviders_) {
|
|
169
166
|
propertyProgressProvider->update(timestamp);
|
|
170
|
-
if (propertyProgressProvider->getState() == TransitionProgressState::
|
|
167
|
+
if (propertyProgressProvider->getState() == TransitionProgressState::Idle) {
|
|
171
168
|
removedProperties_.insert(propertyName);
|
|
172
169
|
}
|
|
173
170
|
}
|
|
@@ -178,16 +175,24 @@ TransitionProgressProvider::createReversingShorteningProgressProvider(
|
|
|
178
175
|
const double timestamp,
|
|
179
176
|
const CSSTransitionPropertySettings &propertySettings,
|
|
180
177
|
const TransitionPropertyProgressProvider &existingProgressProvider) {
|
|
181
|
-
const auto
|
|
182
|
-
|
|
183
|
-
auto newReversingShorteningFactor = oldProgress * oldReversingShorteningFactor + (1 - oldReversingShorteningFactor);
|
|
184
|
-
|
|
185
|
-
return std::make_shared<TransitionPropertyProgressProvider>(
|
|
178
|
+
const auto rs = reverseShorten(
|
|
179
|
+
existingProgressProvider.getReversingState(),
|
|
186
180
|
timestamp,
|
|
187
|
-
propertySettings.duration
|
|
188
|
-
propertySettings.delay
|
|
189
|
-
propertySettings.
|
|
190
|
-
|
|
181
|
+
propertySettings.duration,
|
|
182
|
+
propertySettings.delay,
|
|
183
|
+
propertySettings.easingConfig);
|
|
184
|
+
|
|
185
|
+
return std::make_shared<TransitionPropertyProgressProvider>(timestamp, rs.duration, rs.delay, rs.easing, rs.factor);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
void TransitionProgressProvider::setPropertySettings(const PropertiesSettingsMap &changedPropertiesSettings) {
|
|
189
|
+
for (const auto &[propertyName, propertySettings] : changedPropertiesSettings) {
|
|
190
|
+
propertySettings_[propertyName] = propertySettings;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
CSSTransitionPropertySettings TransitionProgressProvider::getPropertySettings(const std::string &propertyName) const {
|
|
195
|
+
return propertySettings_.at(propertyName);
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
} // namespace reanimated::css
|