Lottie-web: Forcing `true` on `.playSegments` restricts future playing

Created on 17 Jun 2016  路  6Comments  路  Source: airbnb/lottie-web

If we do something like anim.playSegments([0, 10], true); and then later, after it finishes, try to do something like anim.play() to finish the animation, it does not play.

If we do anim.playSegments([0, 10], true); then later, after it finished, do anim.goToAndStop(0, true); then anim.play(), it only plays until the 10th frame, set by the .playSegments.

The only way to play the rest of the animation as it stands is to use anim.playSegments([10, endFrameNum], true);, essentially overriding the previous (though it is done playing already), which is a pain.

Can .playSegments be improved to where the animation can be finished using .play() after it? And also not restrict playback if an earlier frame is navigated to then played from?

Most helpful comment

I wasn't aware resetSegments existed! Haha. Maybe that should be in the "Usage" section

All 6 comments

playSegments works as if you were changing the "Work Area" in your composition in AE. So if you're looping or changing the speed / direction or controlling playback it will set the limits.
If you need to reset the segment to the original value, you should use resetSegments or as you suggest, set a new segment to play.

I wasn't aware resetSegments existed! Haha. Maybe that should be in the "Usage" section

But in any case, from a JS animator perspective I expect it to work as I commented above. Maybe both functionalities could be had, changing the name of one?

I think this should be handled with events and play - pause actions, otherwise it might get confusing having two similar behaviors that don't work well together.
I'll have a look into it.

To be more clear, my idea is to have:

  • A playSegments([start, end], true) which jumps to the starting frame, plays until the end and allows more playing to occur afterwards if later commanded (without resetting)
  • A setAnimationArea([start, end], true) (or something named similarly) which restricts playback to those frames (likely changing the current play time to the beginning of that section for convenience but leaving it paused)

done in the latest release
setSegment(init,end)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

casillasluisn12 picture casillasluisn12  路  4Comments

zhengs picture zhengs  路  3Comments

cpdt picture cpdt  路  4Comments

Sandok-voc picture Sandok-voc  路  4Comments

jumostudio picture jumostudio  路  3Comments