nativescript-community / ui-lottie

NativeScript plugin to expose Airbnb Lottie
https://github.com/airbnb/lottie-android
Other
177 stars 57 forks source link

Frame support #44

Open vlowe85 opened 5 years ago

vlowe85 commented 5 years ago

Support setting the progress by frame and playing segments.

I think the following should be available:

setProgressWithFrame(frame)
playFromFrame(startFrame, endFrame)
bradmartin commented 5 years ago

Nothing here on readme to achieve that? @itstheceo did a lot of work lately with progress and aligning the plugin with the native SDKs. Maybe he has some info here 👍

itstheceo commented 5 years ago

This should be possible although some work would have to be done around aligning the underlying APIs as I can't see a uniform way of achieving it from my brief look at comparing LOTAnimationView.m and LottieAnimationView.java

iOS has nice support for this through playFromFrameToFrame seen here

On Android you would probably have to use setMinAndMaxFrame seen here and then subsequently handle playing it afterwards, and resetting things when other APIs are used afterwards. This is the approach I used for playAnimationFromProgressToProgress however I have noticed some issues when using it repeatedly in succession, where the native view can get into illegal states. For example animating from 0 to 50, then from 50 to 40. I need to invest some time into making this more robust but have been busy.

bradmartin commented 5 years ago

Thanks for the info @itstheceo 😄 much appreciated. If I find time, I'll look into it.