Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Re-use the existing interuptable animator (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSilvis authored and Matt Banach committed Jul 18, 2019
1 parent 03ac9f0 commit 9f8e2c4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions GTHalfSheet/GTSheet/Animators/DismissalAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class DismissalAnimator: UIPercentDrivenInteractiveTransition, UIViewCont

var isFromGesture: Bool = false
var animator: UIViewPropertyAnimator?
var interuptableAnimator: UIViewImplicitlyAnimating?

public init(manager: HalfSheetPresentationManager) {
super.init()
Expand All @@ -25,14 +26,19 @@ public class DismissalAnimator: UIPercentDrivenInteractiveTransition, UIViewCont
}

public func interruptibleAnimator(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating {
return transition(using: transitionContext)
guard let interupt = interuptableAnimator else {
interuptableAnimator = transition(using: transitionContext)
return interuptableAnimator!
}

return interupt
}

public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
transition(using: transitionContext)
interuptableAnimator = transition(using: transitionContext)
}

@discardableResult private func transition(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating {
private func transition(using transitionContext: UIViewControllerContextTransitioning) -> UIViewImplicitlyAnimating {

let presentedControllerView = transitionContext.view(forKey: UITransitionContextViewKey.from)!

Expand Down

0 comments on commit 9f8e2c4

Please sign in to comment.