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>
使用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>