From e912c462eb0b7166ca5947bb5a3ee20761d910b6 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Fri, 18 Feb 2022 08:19:19 -0800 Subject: [PATCH] Add a feature flag to disable Fabric layout animations Summary: tsia Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D34340023 fbshipit-source-id: 61956f1819f1f7e10dc2520c444fa5dd305d1363 --- Libraries/LayoutAnimation/LayoutAnimation.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 97126be4dbd..2001729e004 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -26,6 +26,12 @@ export type LayoutAnimationConfig = LayoutAnimationConfig_; type OnAnimationDidEndCallback = () => void; type OnAnimationDidFailCallback = () => void; +let isLayoutAnimationEnabled: boolean = true; + +function setEnabled(value: boolean) { + isLayoutAnimationEnabled = value; +} + /** * Configures the next commit to be animated. * @@ -43,6 +49,10 @@ function configureNext( return; } + if (!isLayoutAnimationEnabled) { + return; + } + // Since LayoutAnimations may possibly be disabled for now on iOS (Fabric), // or Android (non-Fabric) we race a setTimeout with animation completion, // in case onComplete is never called @@ -181,6 +191,7 @@ const LayoutAnimation = { spring: (configureNext.bind(null, Presets.spring): ( onAnimationDidEnd?: OnAnimationDidEndCallback, ) => void), + setEnabled, }; module.exports = LayoutAnimation;