chenqingspring / vue-lottie

Render After Effects animations on Vue based on Bodymovin
MIT License
1.31k stars 281 forks source link

PlaySegments not working properly #32

Closed charlesanim closed 5 years ago

charlesanim commented 5 years ago

handleAnimation2: function(anim2) { this.anim2 = anim2; this.anim2.playSegments([[138, 147], [148, 212], [212, 276]], true); },

I have this code in myLottie.vue component, but according to Hernan Torsi, the anim.PlaySegments should play the first two segments and loop on the last segment if the loop parameter is set during initialization.

But its not the case for this. The issue I'm having is the animation is skipping the first two segments and playing the last segment only.

Is there any way to fix this?

charlesanim commented 5 years ago

You have to wait for the DOMLoaded event before setting the segments.

Quoting reply from @bodymovin on Lottie-web

this.anim0 = anim0;
this.anim0.addEventListener('DOMLoaded', ()=>{
 this.anim0.playSegments([[0, 74], [74, 138]], true);
})