From 250f78c3f32ea5a4f280e492e26e42dcb0962e57 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 13 Sep 2023 20:00:18 +0800 Subject: [PATCH] Handle cancel of swipe animation better --- .../App/Views/SlideAnimatedTransitioning.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/SlideAnimatedTransitioning.swift b/apple/OmnivoreKit/Sources/App/Views/SlideAnimatedTransitioning.swift index 1236c513c..164cae639 100644 --- a/apple/OmnivoreKit/Sources/App/Views/SlideAnimatedTransitioning.swift +++ b/apple/OmnivoreKit/Sources/App/Views/SlideAnimatedTransitioning.swift @@ -45,12 +45,14 @@ extension SlideAnimatedTransitioning: UIViewControllerAnimatedTransitioning { fromVC.view?.layer.shadowOpacity = 0.1 }, completion: { _ in - toVC.view?.layer.opacity = 1.0 - toVC.view?.layer.shadowOpacity = 0 - fromVC.view?.layer.opacity = 1.0 - fromVC.view?.layer.shadowOpacity = 0 + if !transitionContext.transitionWasCancelled { + toVC.view?.layer.opacity = 1.0 + toVC.view?.layer.shadowOpacity = 0 + fromVC.view?.layer.opacity = 1.0 + fromVC.view?.layer.shadowOpacity = 0 - fromVC.view.removeFromSuperview() + fromVC.view.removeFromSuperview() + } // when cancelling or completing the animation, ios simulator seems to sometimes flash black backgrounds during the animation. on devices, this doesn't seem to happen though. // containerView.backgroundColor = [UIColor whiteColor]; transitionContext.completeTransition(!transitionContext.transitionWasCancelled)