Skip to content

Commit

Permalink
Merge pull request airbnb#1106 from MariuszWisniewski/bugfix/fix-issu…
Browse files Browse the repository at this point in the history
…e-with-animating-frame-change

Fixes issue with layout changes being animated when it should be not.
  • Loading branch information
buba447 authored Jan 27, 2020
2 parents 0c6bbf6 + ca65c37 commit 74453e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lottie-swift/src/Public/Animation/AnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ final public class AnimationView: LottieView {
UIView Animation does not implicitly set CAAnimation time or timing fuctions.
If layout is changed in an animation we must get the current animation duration
and timing function and then manually create a CAAnimation to match the UIView animation.
If layout is changed without animation, explicitly set animation duration to 0.0
inside CATransaction to avoid unwanted artifacts.
*/

/// Check if any animation exist on the view's layer, and grab the duration and timing functions of the animation.
Expand Down Expand Up @@ -744,8 +746,12 @@ final public class AnimationView: LottieView {
animationLayer.transform = xform
animationLayer.add(group, forKey: animationKey)
} else {
CATransaction.begin()
CATransaction.setAnimationDuration(0.0)
CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: .linear))
animationLayer.position = position
animationLayer.transform = xform
CATransaction.commit()
}

if shouldForceUpdates {
Expand Down

0 comments on commit 74453e7

Please sign in to comment.