From 6a15d7487fdf5c79e5f11be85cc74cddbd46d813 Mon Sep 17 00:00:00 2001 From: Ishan Khot Date: Wed, 20 May 2020 16:31:18 -0700 Subject: [PATCH] Revert D21587648: LayoutImplementations: implement all existing animation curves besides Keyboard Differential Revision: D21587648 Original commit changeset: 246ab7fd4039 fbshipit-source-id: 427e13ff821776feb4952c3438c15ea815fce5f0 --- ReactCommon/fabric/animations/BUCK | 1 - .../LayoutAnimationKeyFrameManager.cpp | 53 +++---------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/ReactCommon/fabric/animations/BUCK b/ReactCommon/fabric/animations/BUCK index 123fb6c45e2..fde3bc7decd 100644 --- a/ReactCommon/fabric/animations/BUCK +++ b/ReactCommon/fabric/animations/BUCK @@ -36,7 +36,6 @@ rn_xplat_cxx_library( "-frtti", "-std=c++14", "-Wall", - "-lm", ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), diff --git a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp index 034d871388b..4f617bf71f5 100644 --- a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp @@ -105,7 +105,7 @@ static better::optional parseAnimationConfig( double duration = defaultDuration; double delay = 0; - double springDamping = 0.5; + double springDamping = 0; double initialVelocity = 0; auto const durationIt = config.find("duration"); @@ -236,50 +236,13 @@ LayoutAnimationKeyFrameManager::calculateAnimationProgress( uint64_t startTime = animation.startTime; uint64_t delay = mutationConfig.delay; uint64_t endTime = startTime + delay + mutationConfig.duration; - - static const float PI = 3.14159265358979323846; - - if (now >= endTime) { - return {1, 1}; - } - if (now < startTime + delay) { - return {0, 0}; - } - - double linearTimeProgression = 1 - - (double)(endTime - delay - now) / (double)(endTime - animation.startTime); - - if (mutationConfig.animationType == AnimationType::Linear) { - return {linearTimeProgression, linearTimeProgression}; - } else if (mutationConfig.animationType == AnimationType::EaseIn) { - // This is an accelerator-style interpolator. - // In the future, this parameter (2.0) could be adjusted. This has been the - // default for Classic RN forever. - return {linearTimeProgression, pow(linearTimeProgression, 2.0)}; - } else if (mutationConfig.animationType == AnimationType::EaseOut) { - // This is an decelerator-style interpolator. - // In the future, this parameter (2.0) could be adjusted. This has been the - // default for Classic RN forever. - return {linearTimeProgression, 1.0 - pow(1 - linearTimeProgression, 2.0)}; - } else if (mutationConfig.animationType == AnimationType::EaseInEaseOut) { - // This is a combination of accelerate+decelerate. - // The animation starts and ends slowly, and speeds up in the middle. - return {linearTimeProgression, - cos((linearTimeProgression + 1.0) * PI) / 2 + 0.5}; - } else if (mutationConfig.animationType == AnimationType::Spring) { - // Using mSpringDamping in this equation is not really the exact - // mathematical springDamping, but a good approximation We need to replace - // this equation with the right Factor that accounts for damping and - // friction - double damping = mutationConfig.springDamping; - return { - linearTimeProgression, - (1 + - pow(2, -10 * linearTimeProgression) * - sin((linearTimeProgression - damping / 4) * PI * 2 / damping))}; - } else { - return {linearTimeProgression, linearTimeProgression}; - } + double progress = (now >= endTime) + ? 1 + : ((now < startTime + delay) ? 0 + : 1 - + (double)(endTime - delay - now) / + (double)(endTime - animation.startTime)); + return {progress, progress}; } void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation(