【发布时间】:2018-05-16 14:45:15
【问题描述】:
我正在尝试将以下动画置于无限循环中,直到出现特定状态:
class MyModal extends Component {
constructor() {
super()
this.springValue = new Animated.Value(0.3)
}
spring = () => {
this.springValue.setValue(0.3)
Animated.spring(
this.springValue,
{
toValue: 1,
friction: 1,
tension: 1,
duration:5000
}
).start()
}
componentDidMount() {
this.spring()
}
render() {
return (
<View>
<Modal
animationType="none"
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => null}
>
<View style={styles.backgroundStyle}>
<Animated.Image
source={require("./my-awesome-image.png")}
style={{ width: 143, height: 125, top: 100, transform: [{scale: this.springValue}]}}
/>
</View>
</Modal>
</View>
);
}
}
这里的一切都很好,动画完成一次(因为我没有在任何地方循环)。
如何让我的Animated.Image 循环直到我达到特定状态?我只希望它无限循环,并且能够在我准备好时停止动画或启动另一个动画。
【问题讨论】:
标签: react-native