React Native Lottie Animations OnAnimationFinish do n do n do
您好,我是第一次在React Native中使用Lottie动画,我到达了Lottie Animation播放的地步,当动画以Onanimationfinish结束时,它应该导航到新页面,它可以在Android上工作,但是当我对其进行测试时iOS动画播放,当动画结束时,它将您留在同一页面上,而OnAnimationFinish并没有触发。
const progress = useRef(new Animated.Value(0)).current;
const handleLikeAnimation = () => {
Animated.timing(progress, {
toValue: 1,
duration: 3000,
useNativeDriver: true,
}).start();
};
<View style={{justifyContent:'center', width, height}}>
<LottieView style={{width:50, height:100, alignSelf:'center'}} progress={progress} source={require('../assets/lottie/loaderlottie.json')} autoPlay loop={false} onAnimationFinish={() => navigation.navigate("Leaderboard" , currentcomp)}></LottieView>
</View>
Hello I am using lottie animations for the first time in react native , I got to a point where the lottie animation playes and when the animation finish with onAnimationFinish it should navigate to a new page, it works perfectly on android but when I test it on ios the animation plays and the when the animation ends it leaves you on the same page and and the onAnimationFinish didn't trigger.
const progress = useRef(new Animated.Value(0)).current;
const handleLikeAnimation = () => {
Animated.timing(progress, {
toValue: 1,
duration: 3000,
useNativeDriver: true,
}).start();
};
<View style={{justifyContent:'center', width, height}}>
<LottieView style={{width:50, height:100, alignSelf:'center'}} progress={progress} source={require('../assets/lottie/loaderlottie.json')} autoPlay loop={false} onAnimationFinish={() => navigation.navigate("Leaderboard" , currentcomp)}></LottieView>
</View>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在其中添加了一些属性并开始工作:
尤其是
speed = {1}
使其正常工作。希望它也对您有用:)
I added some attributes in it and started working:
Especially
speed={1}
made it work.Hope it works for you too :)
旧问题,但如果有人想知道nanimationfinish仅在循环设置为false用
loop = {false}
时发射。Old question, but in case anyone is wondering onAnimationFinish only fires when loop is specifically set to false with
loop={false}
.