From 31a7eb29ca9bdbb17836f63ec1a4167057f692c9 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Wed, 22 Apr 2020 11:11:53 +0200 Subject: [PATCH 1/4] Adding a way to know if the menu is currently animating --- Library/ENSideMenu.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/ENSideMenu.swift b/Library/ENSideMenu.swift index 8db47f6..972b7c4 100644 --- a/Library/ENSideMenu.swift +++ b/Library/ENSideMenu.swift @@ -14,6 +14,7 @@ public protocol ENSideMenuDelegate: class { func sideMenuShouldOpenSideMenu () -> Bool func sideMenuDidOpen() func sideMenuDidClose() + func sideMenuIsAnimating() } public protocol ENSideMenuProtocol: class { @@ -334,6 +335,7 @@ open class ENSideMenu : NSObject, UIGestureRecognizerDelegate { withDuration: animationDuration, animations: { [weak self] () -> Void in self?.sideMenuContainerView.frame = destFrame + self?.delegate?.sideMenuIsAnimating() }, completion: { [weak self] (Bool) -> Void in guard let strongSelf = self else { return } From bd66fc43dcc30ad262d3058db455d6d851133918 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Wed, 22 Apr 2020 11:12:48 +0200 Subject: [PATCH 2/4] Adding a way to disable the menu when needed --- Library/ENSideMenu.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/ENSideMenu.swift b/Library/ENSideMenu.swift index 972b7c4..175aa06 100644 --- a/Library/ENSideMenu.swift +++ b/Library/ENSideMenu.swift @@ -151,6 +151,14 @@ open class ENSideMenu : NSObject, UIGestureRecognizerDelegate { open var allowRightSwipe : Bool = true open var allowPanGesture : Bool = true fileprivate var panRecognizer : UIPanGestureRecognizer? + open var isHidden: Bool { + get { + return sideMenuContainerView.isHidden + } + set { + sideMenuContainerView.isHidden = newValue + } + } /** Initializes an instance of a `ENSideMenu` object. From 66a7f2b06ec6e8dba1ac70f8c9ea792126b8dee7 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Wed, 22 Apr 2020 11:18:08 +0200 Subject: [PATCH 3/4] Fixing samples --- Example/SwiftSideMenu/MyNavigationController.swift | 4 ++++ Example/SwiftSideMenu/ViewController.swift | 4 ++++ Example/SwiftSideMenu/ViewController2.swift | 3 +++ 3 files changed, 11 insertions(+) diff --git a/Example/SwiftSideMenu/MyNavigationController.swift b/Example/SwiftSideMenu/MyNavigationController.swift index a3ef5fc..9653630 100644 --- a/Example/SwiftSideMenu/MyNavigationController.swift +++ b/Example/SwiftSideMenu/MyNavigationController.swift @@ -54,4 +54,8 @@ extension MyNavigationController: ENSideMenuDelegate { func sideMenuShouldOpenSideMenu() -> Bool { return true } + + func sideMenuIsAnimating() { + print("sideMenuIsAnimating") + } } diff --git a/Example/SwiftSideMenu/ViewController.swift b/Example/SwiftSideMenu/ViewController.swift index 54c9ab3..61522f1 100644 --- a/Example/SwiftSideMenu/ViewController.swift +++ b/Example/SwiftSideMenu/ViewController.swift @@ -46,5 +46,9 @@ class ViewController: UIViewController, ENSideMenuDelegate { func sideMenuDidOpen() { print("sideMenuDidOpen") } + + func sideMenuIsAnimating() { + print("sideMenuIsAnimating") + } } diff --git a/Example/SwiftSideMenu/ViewController2.swift b/Example/SwiftSideMenu/ViewController2.swift index ac12d42..c6bb30f 100644 --- a/Example/SwiftSideMenu/ViewController2.swift +++ b/Example/SwiftSideMenu/ViewController2.swift @@ -37,4 +37,7 @@ class ViewController2: UIViewController, ENSideMenuDelegate { return true } + func sideMenuIsAnimating() { + print("sideMenuIsAnimating") + } } From 6e47ed77a4f99c84844546868e6bff67d62eb06b Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Wed, 22 Apr 2020 11:18:19 +0200 Subject: [PATCH 4/4] Adding a way to know if menu is hidden without using the custom navigation controller --- Library/ENSideMenu.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/ENSideMenu.swift b/Library/ENSideMenu.swift index 175aa06..969c6aa 100644 --- a/Library/ENSideMenu.swift +++ b/Library/ENSideMenu.swift @@ -144,7 +144,7 @@ open class ENSideMenu : NSObject, UIGestureRecognizerDelegate { fileprivate var needUpdateApperance : Bool = false /// The delegate of the side menu open weak var delegate : ENSideMenuDelegate? - fileprivate(set) var isMenuOpen : Bool = false + fileprivate(set) open var isMenuOpen : Bool = false /// A Boolean value indicating whether the left swipe is enabled. open var allowLeftSwipe : Bool = true /// A Boolean value indicating whether the right swipe is enabled.