Skip to content

Commit

Permalink
Add option to remove animated bounds changes (airbnb#2218)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrick authored and iago849 committed Feb 8, 2024
1 parent e091700 commit 7a29a1e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/Public/Animation/LottieAnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@ open class LottieAnimationView: LottieAnimationViewBase {

// MARK: Public

/// Whether or not transform and position changes of the view should animate alongside
/// any existing animation context.
/// - Defaults to `true` which will grab the current animation context and animate position and
/// transform changes matching the current context's curve and duration.
/// `false` will cause transform and position changes to happen unanimated
public var animateLayoutChangesWithCurrentCoreAnimationContext = true

/// The configuration that this `LottieAnimationView` uses when playing its animation
public var configuration: LottieConfiguration {
get { lottieAnimationLayer.configuration }
Expand Down Expand Up @@ -933,7 +940,11 @@ open class LottieAnimationView: LottieAnimationViewBase {
// 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 match it.
if let key = lottieAnimationLayer.animationKeys()?.first, let animation = lottieAnimationLayer.animation(forKey: key) {
if
let key = lottieAnimationLayer.animationKeys()?.first,
let animation = lottieAnimationLayer.animation(forKey: key),
animateLayoutChangesWithCurrentCoreAnimationContext
{
// The layout is happening within an animation block. Grab the animation data.

let positionKey = "LayoutPositionAnimation"
Expand Down

0 comments on commit 7a29a1e

Please sign in to comment.