diff --git a/Sica/Source/Animator.swift b/Sica/Source/Animator.swift index 7488212..5bb9ad9 100644 --- a/Sica/Source/Animator.swift +++ b/Sica/Source/Animator.swift @@ -24,6 +24,9 @@ public final class Animator { case parallel } + /// Flag whether or not to include the delay in the duration calculation when parallel. + public static var shouldIncludeDelayInParallelDuration: Bool = false + private weak var layer: CALayer? private var group = CAAnimationGroup() private var animations = [CAAnimation]() @@ -70,7 +73,11 @@ public final class Animator { case .sequence: return animations.last.map { $0.beginTime + $0.duration } ?? 0 case .parallel: - return animations.map { $0.duration }.max() ?? 0 + if Self.shouldIncludeDelayInParallelDuration { + return animations.map { $0.beginTime + $0.duration }.max() ?? 0 + } else { + return animations.map { $0.duration }.max() ?? 0 + } } }