簡體   English   中英

一旦 Lottie 動畫達到特定幀,我如何觸發事件?

[英]How can I trigger an event once Lottie animation reaches a certain frame?

使用 Lottie/BodyMoving,一旦 Lottie 動畫達到特定幀,我如何觸發事件。

例如:一旦 anim1 到達某個幀,我希望 anim2 播放。

謝謝

嘗試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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM