在React Native中的相同元素上的Out / In动画

问题描述 投票:1回答:1

我有一个TextViewfadeOutDown旧数据和fadeInDown下一个渲染的新数据。我该如何做到这一点?我正在使用react-native-animatable库并设法做一个动画,但不知道如何做两个。

<Animatable.View animation={this.props.animation} style = {styles.innerView2}>
  <Text text = "abcd" style = {{alignItems: 'flex-start', width: DEVICE_WIDTH - 20, textAlign: 'left'}}/>
</Animatable.View>
javascript reactjs react-native react-native-animatable
1个回答
1
投票

ref分配给Animatable组件,然后例如在componentDidUpdate上,您可以重新触发动画

componentDidUpdate() {
  if (this.view !== undefined && this.view !== null) {
    this.view.fadeIn(1000);
  }
}

<Animatable.View
  ref={ref => (this.view = ref)}
  animation="fadeIn"
  easing="ease-in">
  <Text>{this.state.newText}</Text>
</Animatable.View>

这是一个snack供您参考

© www.soinside.com 2019 - 2024. All rights reserved.