Hi,
I'm new to lottie/bodymovin and not very fluent in JS. So I would love to get a bit of help getting my animation to run twice (or loop once if you like) 鈥撀爋r preferably a way to define a set amount of loops.
Javascript:
var animation = bodymovin.loadAnimation({
container: document.getElementById('animation-test'),
renderer: 'svg',
loop: false,
autoplay: true,
path: 'data.json'
})
This works as expected, and it runs once.
Is there a way to define a set amount of loops?
Thank you!
you can pass a number to the loop param instead of false.
Thank you for the answer!
Is it possible to show a code example?
var animation = bodymovin.loadAnimation({
container: document.getElementById('animation-test'),
renderer: 'svg',
loop: 4,
autoplay: true,
path: 'data.json'
})
Thank you. Can't believe it was that easy, I was looking at all sorts of complicated solutions.
Much appreciated.
This only works the first time I play my animation. If I goToAndPlay(0) after that it only plays once, even if I set anim.loop = 2 before playing again.
Most helpful comment
you can pass a number to the loop param instead of
false.