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;