React Native Lottie Animations OnAnimationFinish do n do n do

发布于 2025-02-04 02:12:35 字数 837 浏览 2 评论 0原文

您好,我是第一次在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甩你一脸翔 2025-02-11 02:12:35

我在其中添加了一些属性并开始工作:

autoPlay
loop
speed={1}

尤其是speed = {1}使其正常工作。

希望它也对您有用:)

I added some attributes in it and started working:

autoPlay
loop
speed={1}

Especially speed={1} made it work.

Hope it works for you too :)

于我来说 2025-02-11 02:12:35

旧问题,但如果有人想知道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}.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文