使用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>
关于javascript - Lottie 动画到达特定帧后如何触发事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59966891/