From 8cd5520677030c615de463832339f1e69f582417 Mon Sep 17 00:00:00 2001 From: Chelsea Lo Date: Sat, 25 Feb 2023 15:19:30 -0500 Subject: [PATCH] Add property to check whether an AnimationQueue has an in-progress animation --- Sources/Stagehand/AnimationQueue.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/Stagehand/AnimationQueue.swift b/Sources/Stagehand/AnimationQueue.swift index 6757c15..0a86fff 100644 --- a/Sources/Stagehand/AnimationQueue.swift +++ b/Sources/Stagehand/AnimationQueue.swift @@ -25,6 +25,21 @@ public final class AnimationQueue { self.element = element } + // MARK: - Public Properties + + public var hasInProgressAnimation: Bool { + guard let currentAnimation = queue.first else { + return false + } + + switch currentAnimation.instance.status { + case .pending, .animating: + return true + case .complete, .canceled: + return false + } + } + // MARK: - Private Properties private let element: ElementType