我的問題與React Native似乎是項目範圍。任何使用Animated API的東西都不會運行。我正在運行React Native 0.49.2, 似乎沒有任何工作,我已經嘗試了幾個人的代碼,沒有發生任何事情。這個問題似乎是每當我打電話給「Animated.Timing()。start();」它從來沒有真正開始。下面有一些簡短的示例代碼:反應本機動畫根本不運行
class Splash extends React.Component {
constructor(props){
super(props);
this.state = {
ShowSetup: true,
fadeAnim: new Animated.Value(0), // Initial value for opacity: 0
};
}
componentDidMount(){
this.Animator()
}
Animator(){
console.log("ANIMATOR RUNNING!")
Animated.timing( // Animate over time
this.state.fadeAnim, // The animated value to drive
{
toValue: 1, // Animate to opacity: 1 (opaque)
duration: 10000, // Make it take a while
}
).start(); // Starts the animation
}
render() {
let { fadeAnim } = this.state;
return (
<View style={{flex: 1, backgroundColor: 'blue'}}>
<Animated.View // Special animatable View
style={{
opacity: fadeAnim, // Bind opacity to animated value
}}
>
<Text>Fade In</Text>
</Animated.View>
</View>
);
}
}
無論你等多長時間,該值將不會出現。已成爲一個大摸不到頭腦的我,我不知道自己還能做些什麼
不要忘了你在ComponentDidMount中的分號,非常重要!另外,我認爲你需要在你的構造函數中綁定Animator或者在函數聲明中綁定它,所以你有選擇。 – fungusanthrax
Dosen't似乎是問題..我似乎無法解決這個問題 – joe
我想知道如果它有反應導航 – joe