From e3d0e7c74f4edffc4aa49157e89b5c12da06f0d8 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Tue, 25 Sep 2018 05:31:17 +0400 Subject: [PATCH 1/3] Fixed MotionViewTransition animations were not removed Removing animations is done through accessing animations on animator which was cleaned before the access. Fixed by swapping order of method calls --- Sources/MotionViewTransition.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From c515a4f7850d24fcf81099511dde4c5772136883 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Tue, 25 Sep 2018 05:32:25 +0400 Subject: [PATCH 2/3] Added setCompletionCallbackForNextTransition --- Sources/Transition/MotionTransition.swift | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { From 66bf027f821433033c809ec5125752585fa0db29 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Tue, 25 Sep 2018 05:35:25 +0400 Subject: [PATCH 3/3] Removed redundant completionCallback mapping --- .../MotionTransition+CustomTransition.swift | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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() } }