lottie-web
lottie-web copied to clipboard
getCurrentFrame not working as intended
I'm setting up a new animation and i want to store the current frame in a variable. Then i play the animation for the first 10 frames, then for the frames from 10 to 20.
The value of instance.currenFrame is wrong, it goes from 0 to 10 both times. Is there any way to know at which point of the whole animation i am at? This does not seem like something so hard to have, why is the instance.currenFrame behaviour is so counter-intuitive?
const instance = lottie.loadAnimation({
container: document.querySelector("#lottie"),
animationData: battery,
autoplay: false,
loop: false,
renderer: "svg",
});
instance.addEventListener('drawnFrame', (e) => {
setCurrentFrame(instance.currenFrame)
})
instance.playSegments([0, 10], true)
instance.playSegments([10, 20], true)