我有一个TextView
将fadeOutDown
旧数据和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>
将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供您参考