0
我試圖動畫視圖時按下按鈕向右滑動,我現在有下面的代碼,但不斷收到陣營本土動畫不確定是不是一個對象錯誤
不確定是不是一個對象(評估此。 state.panelPos)錯誤。我不明白代碼有什麼問題。有什麼建議麼?
constructor(props){
super(props)
this.state = {
initialLife : 200,
panelPos: new Animated.Value(0),
};
};
slideOutPanel(){
Animated.timing(this.state.panelPos,{
toValue: 300,
duration: 1000,
}).start();
};
render(){return(
<View style = {styles.container}>
<View style = {styles.lContainer}>
<View style = {styles.playerLife}>
<View style = {styles.lifeButtonRow}>
<LifeButton/>
<LifeButton/>
</View>
<View style = {styles.lifeButtonRow}>
<LifeButton/>
<LifeButton/>
</View>
<Text>text</Text>
</View>
<Animated.View style = {[styles.panel,{transform: [{translateX: this.state.panelPos}]}]}>
<Image style = {styles.cmd_panel} source={require('image')}/>
</Animated.View>
</View>
<View style = {styles.portrait}>
<Button title = {'push'} onPress = {this.slideOutPanel}/>
</View>
</View>);
當然是謝謝 – user3074140