Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration setting to remove animated bounds changes #2218

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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