アニメーションAPIを使用して、反応ネイティブのスタイルプロパティをアニメーション化できます。 一連のスタイル変更で変更を表すことができる場合、Animated APIはそれを行うことができます。たとえば、不透明度を1から0にアニメーション化して1に戻すと、フェードアウト効果が良くなります。ドキュメントは、はるかに明確にまた
あなたがコンポーネント
<View style={{/*style props that need to be animated*/}}
{ boolShowText? <Text/> : <View/> }
</View>
フェージング例をマウントまたは非表示にし、選択レンダリング反応し、ネイティブドキュメント
class FadeInView extends React.Component {
constructor(props) {
super(props);
this.state = {
fadeAnim: new Animated.Value(0), // init opacity 0
};
}
componentDidMount() {
Animated.timing( // Uses easing functions
this.state.fadeAnim, // The value to drive
{toValue: 1}, // Configuration
).start(); // Don't forget start!
}
render() {
return (
<Animated.View // Special animatable View
style={{opacity: this.state.fadeAnim}}> // Binds
{this.props.children}
</Animated.View>
);
}
}
ので@nishanthに見出すことができますようアニメーションを説明します上記の例を使用して、子ビューがフェードインしている間に、テキストがどのように消えていくのでしょうか?テキストに記載されているように – noahlively
を使用すると、不透明度の状態を1から0と1の順にアニメートできます。各アニメーションの後にコールバックを取得してコンポーネントを交換することもできます –