|
22 | 22 |
|
23 | 23 | import UIKit |
24 | 24 |
|
| 25 | +// MARK: - Dance Animation State |
| 26 | + |
| 27 | +@available(iOS 10.0, *) |
| 28 | +public enum DanceAnimationState { |
| 29 | + case inactive // animation hasn't started yet, or no animation associated with view |
| 30 | + case active // animation exists and has started |
| 31 | +} |
| 32 | + |
25 | 33 | // MARK: - Dance Implementation |
26 | 34 |
|
27 | 35 | fileprivate class DanceFactory { |
@@ -160,9 +168,16 @@ fileprivate class DanceFactory { |
160 | 168 | } |
161 | 169 |
|
162 | 170 | /// Returns the view's UIViewPropertyAnimator current state (inactive, active, stopped). |
163 | | - func getState(tag: Int) -> UIViewAnimatingState { |
| 171 | + func getState(tag: Int) -> DanceAnimationState { |
164 | 172 | if let animator = animators[tag] { |
165 | | - return animator.state |
| 173 | + switch animator.state { |
| 174 | + case .inactive: |
| 175 | + return DanceAnimationState.inactive |
| 176 | + case .active: |
| 177 | + return DanceAnimationState.active |
| 178 | + case .stopped: |
| 179 | + return DanceAnimationState.inactive |
| 180 | + } |
166 | 181 | } else { |
167 | 182 | handle(error: .noAnimation, forViewWithTag: tag) |
168 | 183 | return .inactive |
@@ -228,6 +243,7 @@ fileprivate class DanceFactory { |
228 | 243 | // This class should only be accessed through the 'dance' variable declared in the UIView extension below. |
229 | 244 | // (Dance needs to have a public modifier in order to be accessed globally through the UIView Extension.) |
230 | 245 |
|
| 246 | +@available(iOS 10.0, *) |
231 | 247 | public class Dance { |
232 | 248 |
|
233 | 249 | fileprivate var dancingView: UIView! |
@@ -257,8 +273,8 @@ public class Dance { |
257 | 273 | } |
258 | 274 | } |
259 | 275 |
|
260 | | - /// GET: Returns the view's current animation state (inactive, active, stopped). Dance ensures that your animation doesn't run into any problems, so you should only ever receive .inactive or .active for any view. |
261 | | - public var state: UIViewAnimatingState { |
| 276 | + /// GET: Returns the view's current animation state (inactive or active.) If a view has a dance animation associated with it and has not been started, then state will return .inactive. Once the animation has been started, even if it is then paused, state will return .active until the animation finishes. |
| 277 | + public var state: DanceAnimationState { |
262 | 278 | get { |
263 | 279 | return DanceFactory.instance.getState(tag: self.tag) |
264 | 280 | } |
|
0 commit comments