Repository: airbnb/lottie-ios
File: Sources/Public/Animation/LottieAnimationLayer.swift (Swift)

Code before:
    }
    return animation.durationFrameTime(forMarker: named)
  }

  public func updateAnimationForBackgroundState() {
    if let currentContext = animationContext {
      switch backgroundBehavior {
      case .stop:
        removeCurrentAnimation()
        updateAnimationFrame(currentContext.playFrom)
      case .pause:
        removeCurrentAnimation()
      case .pauseAndRestore:
        currentContext.closure.ignoreDelegate = true
        removeCurrentAnimation()
        /// Keep the stale context around for when the app enters the foreground.
        animationContext = currentContext
      case .forceFinish:
        removeCurrentAnimation()
        updateAnimationFrame(currentContext.playTo)
      case .continuePlaying:
        break
      }
    }
  }
  public func updateAnimationForForegroundState(wasWaitingToPlayAnimation: Bool) {
    if let currentContext = animationContext {
      if wasWaitingToPlayAnimation {
        addNewAnimationForContext(currentContext)
      } else if backgroundBehavior == .pauseAndRestore {
        /// Restore animation from saved state
        updateInFlightAnimation()
      }
    }
  }

  // MARK: Internal

  var rootAnimationLayer: RootAnimationLayer? = nil

  /// Context describing the animation that is currently playing in this `LottieAnimationView`
  ///  - When non-nil, an animation is currently playing in this layer. Otherwise,
  ///    the layer is paused on a specific frame.
  fileprivate(set) var animationContext: AnimationContext?

  var hasAnimationContext: Bool {
    animationContext != nil
  }

  /// Set animation name from Interface Builder
  var animationName: String? {

Review comment (suggestion):
```suggestion

  public func updateAnimationForForegroundState(wasWaitingToPlayAnimation: Bool) {
```

Code after:
    }
    return animation.durationFrameTime(forMarker: named)
  }

  public func updateAnimationForBackgroundState() {
    if let currentContext = animationContext {
      switch backgroundBehavior {
      case .stop:
        removeCurrentAnimation()
        updateAnimationFrame(currentContext.playFrom)
      case .pause:
        removeCurrentAnimation()
      case .pauseAndRestore:
        currentContext.closure.ignoreDelegate = true
        removeCurrentAnimation()
        /// Keep the stale context around for when the app enters the foreground.
        animationContext = currentContext
      case .forceFinish:
        removeCurrentAnimation()
        updateAnimationFrame(currentContext.playTo)
      case .continuePlaying:
        break
      }
    }
  }

  public func updateAnimationForForegroundState(wasWaitingToPlayAnimation: Bool) {
    if let currentContext = animationContext {
      if wasWaitingToPlayAnimation {
        addNewAnimationForContext(currentContext)
      } else if backgroundBehavior == .pauseAndRestore {
        /// Restore animation from saved state
        updateInFlightAnimation()
      }
    }
  }

  // MARK: Internal

  var rootAnimationLayer: RootAnimationLayer? = nil

  /// Context describing the animation that is currently playing in this `LottieAnimationView`
  ///  - When non-nil, an animation is currently playing in this layer. Otherwise,
  ///    the layer is paused on a specific frame.
  fileprivate(set) var animationContext: AnimationContext?

  var hasAnimationContext: Bool {
    animationContext != nil
  }

  /// Set animation name from Interface Builder