microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.13k stars 1.13k forks source link

Layout Animation support #2494

Open stmoy opened 5 years ago

stmoy commented 5 years ago

ReactNative layout animations are a way to automatically animate when layout changes. Similar to other animation types, LayoutAnimation provides a set of easings (including spring, linear, easInEaseOut).

On Android, certain flags need to be set via UIManager. It's unclear if we'd need to do the same for RNW.

UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true);

{...}

changePosition = position => {
  LayoutAnimation.spring();
  this.setState({
    position
  });
};

More info on LayoutAnimation is here: https://facebook.github.io/react-native/docs/layoutanimation

When this work is completed, it should be possible to follow introduction guides like this one: https://blog.usejournal.com/react-native-animations-intro-a71439e07f70

RN_LayoutAnimation

chrisglein commented 4 years ago

Not in lean core. Moving outside MVP.

stmoy commented 4 years ago

For what it's worth, Xaml supports a set of implicit animations: https://docs.microsoft.com/en-us/windows/uwp/design/motion/motion-in-practice#implicit-animations

TheSavior commented 4 years ago

On Android, certain flags need to be set via UIManager. It's unclear if we'd need to do the same for RNW.

Those flags exist because there are bugs in the Android LayoutAnimation implementation that cause crashes and were never fixed. When LayoutAnimation was introduced it couldn't be enabled globally because it would have caused crashes for people so it was put behind an experimental flag. Well, we never resolved those crashes and never revisited removing the experimental flag.

In Fabric I believe LayoutAnimations will be enabled for default as Android and iOS will be using the same implementation. No need to add this flag and method for Windows.