React native 循环动画序列
我试图在屏幕上制作一系列动画,其中一秒钟的动画将无限循环。我无法正确地给他们打电话。我试图从componentDidmount中删除.start(),并执行.start(()=>this.animate2),但它把整个动画搞乱了。我不知道怎样才能把它做好 提前谢谢 要简化代码,如下所示:React native 循环动画序列,react-native,react-native-ios,React Native,React Native Ios,我试图在屏幕上制作一系列动画,其中一秒钟的动画将无限循环。我无法正确地给他们打电话。我试图从componentDidmount中删除.start(),并执行.start(()=>this.animate2),但它把整个动画搞乱了。我不知道怎样才能把它做好 提前谢谢 要简化代码,如下所示: animate1(){Animated.sequence([...])} animate2(){Animated.sequence([...])} 在componentDidmount中,我将两者都称为: c
animate1(){Animated.sequence([...])}
animate2(){Animated.sequence([...])}
在componentDidmount中,我将两者都称为:
componentDidMount() {
Animated.sequence([
this.animate1(),
Animated.delay(3000),
this.animate2()
]).start();
你只想永远循环?如果您尝试分离这些动画会怎么样
componentDidMount() {
Animated.sequence([
this.animate1(),
Animated.delay(3000),
]).start(() => this.animate2());
}
animate2 = () => {
//not sure what this does but you would put that logic here
//for example
Animated.timing(
this.state.fadeAnim,
{
toValue: 1,
}
).start(() => this.animate2()); // recursively call this.animate2
}
我试着这样做,但问题是animate2()几乎立即开始动画,而不遵守componentDidMount()中的顺序。此外,在运行一次函数后,我得到一个错误:undefined不是对象(正在评估'animations[current].start')