如何一次使用0到0.5播放动画,然后使用React native Animated
从0.5到1到0.5循环播放。
我有一个0-1-0循环。它工作正常,但从0开始。
Animated.loop(
Animated.sequence([
Animated.timing(this.state.progress, {
toValue: 1,
duration: 1075,
}),
Animated.timing(this.state.progress, {
toValue: 0,
duration: 1075,
}),
])
).start();
答案 0 :(得分:1)
constructor(props) {
super(props);
this.animatedValue = new Animated.Value(0)
}
componentDidMount() {
this.animate()
}
animate() {
this.animatedValue.setValue(0);
Animated.timing(
this.animatedValue,
{
toValue: 1,
duration: 1075,
easing: Easing.linear
}
).start(() => this.animate())
}
render() {
const animate = this.animatedValue.interpolate({
inputRange: [0, .5, 1],
outputRange: [.5, 1, .5]
});
}
答案 1 :(得分:0)
Animated.loop(
Animated.sequence([
Animated.timing(this.state.progress, {
toValue: 1,
duration: 1075,
}, () => {
Animated.timing(this.state.progress, {
toValue: 0,
duration: 1075,
})
}),
])
).start();