【问题标题】:How can I trigger an event once Lottie animation reaches a certain frame?一旦 Lottie 动画到达某个帧,如何触发事件?
【发布时间】:2020-01-29 12:14:48
【问题描述】:

使用 Lottie/BodyMoving,如何在 Lottie 动画到达某个帧时触发事件。

例如:一旦 anim1 到达某个帧,我想让 anim2 播放。

谢谢

【问题讨论】:

    标签: javascript animation lottie bodymovin


    【解决方案1】:

    尝试enterFrame 事件

      const anim = lottie.loadAnimation({ ...options, path: 'URL_TO_JSON' });
    anim.addEventListener('enterFrame', () => {
      console.log('enterFrame', anim.currentFrame);
      if(anim.currentFrame == 55)
      {
      //stop and play 2nd one
      }
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.5.9/lottie.js"></script>
     <div style="width:1067px;height:600px"  class="lottie" data-animation-path="animation/" data-anim-loop="true" data-name="ninja"></div>

    【讨论】:

      猜你喜欢
      • 2022-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多