Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix weird transition #660

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions Pod/Classes/SideMenuAnimationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -104,6 +104,7 @@ internal final class SideMenuAnimationController: NSObject, UIViewControllerAnim
}

func layout() {
guard presentationController != nil else { fatalError("presentationController not initialized") }
presentationController?.containerViewWillLayoutSubviews()
}
}
Expand All @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion Pod/Classes/SideMenuNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down