我想在我的应用程序中显示一些图像并且我的代码中有一个列表。每次触摸屏幕时,我都会从列表中选择一个带有索引的图像。我想为过渡制作动画,但是我无法更改backGroundImage和动画。
我成功更改了过渡图像的不透明度。但这是我的问题:当过渡图像的不透明度为1时,backGroundImage必须更改。
因此用户看不到图像过渡。在backGroundImage更改后过渡图像可以为0。我尝试在过渡不透明度为1时更改backGroundImage,但无法中断整个动画。
handlePress = () => {
this.setState(
() => {
Animated.sequence([
Animated.parallel([
Animated.timing(this.state.opacity, {
toValue: 1,
duration: 300,
}),
]),
Animated.delay(30),
// I want to change random value here
// this.setState({random:this.renderRandom()})
Animated.delay(30),
Animated.parallel([
Animated.timing(this.state.opacity, {
toValue: 0,
duration: 300,
}),
]),
]).start();
}
);
this.setState({random:this.renderRandom()})};
图像在不透明度为1之前发生变化。但是不应该这样。不透明度为1时应该改变。如何解决?