diff --git a/Sources/MotionViewTransition.swift b/Sources/MotionViewTransition.swift index 6909a17..fabaa3a 100644 --- a/Sources/MotionViewTransition.swift +++ b/Sources/MotionViewTransition.swift @@ -131,8 +131,8 @@ private extension MotionViewTransition { /// Finalizes the transition. func complete() { - clean() removeAnimations() + clean() } /// Resets the transition. diff --git a/Sources/Transition/MotionTransition+CustomTransition.swift b/Sources/Transition/MotionTransition+CustomTransition.swift index 840b9bc..cfae340 100644 --- a/Sources/Transition/MotionTransition+CustomTransition.swift +++ b/Sources/Transition/MotionTransition+CustomTransition.swift @@ -47,16 +47,7 @@ extension MotionTransition { fromViewController = from toViewController = to - completionCallback = { [weak self] in - guard let `self` = self else { - return - } - - completion?($0) - - self.state = .possible - } - + setCompletionCallbackForNextTransition(completion) start() } } diff --git a/Sources/Transition/MotionTransition.swift b/Sources/Transition/MotionTransition.swift index 4ea499e..23cf0e1 100644 --- a/Sources/Transition/MotionTransition.swift +++ b/Sources/Transition/MotionTransition.swift @@ -576,6 +576,14 @@ public extension MotionTransition { func setContainerBackgroundColorForNextTransition(_ color: UIColor) { containerBackgroundColor = color } + + /** + Set the completion callback closure for the next transition. + - Parameter _ completion: An optional closure receiving a Boolean indicating if transition is finishing or cancelling. + */ + func setCompletionCallbackForNextTransition(_ completion: ((Bool) -> Void)?) { + completionCallback = completion + } } internal extension MotionTransition {