You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When animating back from on to off state the animation does not behave as expected.
I believe the root cause is that currentFrame is 0 at this point for the coreAnimationEngine but not for the mainThreadEngine.
Because of that, in addNewAnimationForContext(...) the playFrom value will be forced to 0:
switch loopMode {// When playing exactly once (and not looping), we can just set the// `playFrom` time to be the `currentFrame`. Since the animation duration// is based on `playFrom` and `playTo`, this automatically truncates the// duration (so the animation stops playing at `playFrom`).case.playOnce:
animationContext.playFrom = currentFrame
With the mainThreadEngine the currentFrame will be set to the expected value in didAnimationStop but this is not the case for the coreAnimationEngine.
if let animationLayer = animationLayer,let key = animationKey {
animationLayer.removeAnimation(forKey: key)
if flag {
animationLayer.currentFrame =(anim as!CABasicAnimation).toValue as!CGFloat}}
Temporary workaround, not sure if it is accurate :-)
Force setting the currentProgress also for coreAnimationEngine
- // For the Main Thread rendering engine, we freeze the animation at the expected final progress- // once the animation is complete. This isn't necessary on the Core Animation engine.- if finished, !(self.animationView.animationLayer is CoreAnimationLayer) {+ if finished {
self.animationView.currentProgress = finalProgress
}
Which Version of Lottie are you using?
Latest commit 3b90792
Description
We are using an AnimatedSwitch with the default settings for the progress for each state.
We do not call
setProgressForState(...)
When animating back from on to off state the animation does not behave as expected.
I believe the root cause is that
currentFrame
is 0 at this point for the coreAnimationEngine but not for the mainThreadEngine.Because of that, in
addNewAnimationForContext(...)
the playFrom value will be forced to 0:With the mainThreadEngine the currentFrame will be set to the expected value in didAnimationStop but this is not the case for the coreAnimationEngine.
Temporary workaround, not sure if it is accurate :-)
Force setting the currentProgress also for coreAnimationEngine
Expected Behavior
Screen.Recording.2022-12-22.at.18.16.51.mp4
Actual Behavior
Screen.Recording.2022-12-22.at.18.17.23.mp4
Animation JSON
myListButton.json.zip
The text was updated successfully, but these errors were encountered: