1
反応ネイティブでアニメーションを停止しようとしていますが、動作しません。 私はこれが私のコードであるstopAnimation method反応ネイティブアニメーションを停止する方法
でこれをやろう:私はwordGuessed
イベントを発射しています他のコンポーネント、およびコンソールログの作品で
constructor(props) {
super(props);
//...
this.state = {
posY: new Animated.Value(0),
posX: new Animated.Value(0),
//...
};
}
componentWillMount(){
//...
let eventEmitter = getGlobalEventEmitter();
eventEmitter.emit('initialize', {words : true});
eventEmitter.addListener('startGame',()=>{
this.setState({initialized: true});
this.updateText();
});
}
updateText(){
let currentText = [];
//... set some values to currentText
this.props.setText(currentText); // store in redux
this.startText(this.effects[textEffect]['duration']);
}
startText(duration) {
let viewHeight = 530;
let fallTo = 500;
Animated.timing(
this.state.posY,
{
toValue: fallTo,
duration: duration
}
).start();
let stopAnimation = function(){
this.state.posY.stopAnimation();
console.log("ANIMATION SHOULD STOP");
};
stopAnimation = stopAnimation.bind(this);
eventEmitter.addListener('wordGuessed',()=>{
stopAnimation();
});
}
。私が間違っていることは何ですか?