From f80759690f7b05c43e7202284de62948fc75bfd3 Mon Sep 17 00:00:00 2001 From: Diego Arena Date: Thu, 29 Oct 2020 13:26:58 -0300 Subject: [PATCH 1/2] Fix weird transition Based on the fix of the PR #650 by @2h4u to fix the weird transition opening the app. Adding the inactive case will fix the weird transition when the device is rotated --- Pod/Classes/SideMenuNavigationController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/SideMenuNavigationController.swift b/Pod/Classes/SideMenuNavigationController.swift index d88bb8b6..6957a484 100644 --- a/Pod/Classes/SideMenuNavigationController.swift +++ b/Pod/Classes/SideMenuNavigationController.swift @@ -265,7 +265,9 @@ open class SideMenuNavigationController: UINavigationController { super.viewWillTransition(to: size, with: coordinator) // Don't bother resizing if the view isn't visible - guard let transitionController = transitionController, !view.isHidden else { return } + guard let transitionController = transitionController, !view.isHidden, + UIApplication.shared.applicationState != UIApplication.State.background, + UIApplication.shared.applicationState != UIApplication.State.inactive else { return } rotating = true From 6ce48181d6a29d55b1ea048a09acc20d78e9ce51 Mon Sep 17 00:00:00 2001 From: Laurenz Lazarus Date: Fri, 30 Oct 2020 17:08:20 +0100 Subject: [PATCH 2/2] SideMenuAnimationController needs presentationController to operate as indented --- Pod/Classes/SideMenuAnimationController.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Pod/Classes/SideMenuAnimationController.swift b/Pod/Classes/SideMenuAnimationController.swift index aa6ff8d3..0edc29b4 100644 --- a/Pod/Classes/SideMenuAnimationController.swift +++ b/Pod/Classes/SideMenuAnimationController.swift @@ -35,7 +35,7 @@ internal final class SideMenuAnimationController: NSObject, UIViewControllerAnim private weak var containerView: UIView? private let leftSide: Bool private weak var originalSuperview: UIView? - private var presentationController: SideMenuPresentationController? + private var presentationController: SideMenuPresentationController! private unowned var presentedViewController: UIViewController? private unowned var presentingViewController: UIViewController? weak var delegate: SideMenuAnimationControllerDelegate? @@ -104,6 +104,7 @@ internal final class SideMenuAnimationController: NSObject, UIViewControllerAnim } func layout() { + guard presentationController != nil else { fatalError("presentationController not initialized") } presentationController?.containerViewWillLayoutSubviews() } } @@ -128,28 +129,32 @@ private extension SideMenuAnimationController { } func transitionWillBegin(presenting: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } + // prevent any other menu gestures from firing containerView?.isUserInteractionEnabled = false if presenting { - presentationController?.presentationTransitionWillBegin() + presentationController.presentationTransitionWillBegin() } else { - presentationController?.dismissalTransitionWillBegin() + presentationController.dismissalTransitionWillBegin() } } func transition(presenting: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } if presenting { - presentationController?.presentationTransition() + presentationController.presentationTransition() } else { - presentationController?.dismissalTransition() + presentationController.dismissalTransition() } } func transitionDidEnd(presenting: Bool, completed: Bool) { + guard presentationController != nil else { fatalError("presentationController not initialized") } if presenting { - presentationController?.presentationTransitionDidEnd(completed) + presentationController.presentationTransitionDidEnd(completed) } else { - presentationController?.dismissalTransitionDidEnd(completed) + presentationController.dismissalTransitionDidEnd(completed) } containerView?.isUserInteractionEnabled = true }