@@ -711,6 +711,32 @@ open class SideMenuController: UIViewController {
711
711
}
712
712
}
713
713
714
+ private func updateSideMenuWidth( ) {
715
+ let fifteenPercent = 0.15
716
+ let size = UIScreen . main. bounds. size
717
+ SideMenuController . preferences. basic. menuWidth = size. width - ( size. width * CGFloat( fifteenPercent) )
718
+ }
719
+
720
+ private func keepSideMenuOpenOnRotation( ) {
721
+ if menuViewController != nil {
722
+ if self . isMenuRevealed {
723
+ self . hideMenu ( animated: false , completion: nil )
724
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 , execute: {
725
+ self . updateSideMenuWidth ( )
726
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 , execute: {
727
+ self . revealMenu ( animated: false , completion: nil )
728
+ } )
729
+ } )
730
+ } else {
731
+ self . revealMenu ( animated: false ) { _ in
732
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.1 , execute: {
733
+ self . hideMenu ( animated: false , completion: nil )
734
+ } )
735
+ }
736
+ }
737
+ }
738
+ }
739
+
714
740
// MARK: Orientation
715
741
716
742
open override var shouldAutorotate : Bool {
@@ -728,16 +754,20 @@ open class SideMenuController: UIViewController {
728
754
}
729
755
730
756
open override func viewWillTransition( to size: CGSize , with coordinator: UIViewControllerTransitionCoordinator ) {
731
- hideMenu ( animated: false , completion: { _ in
732
- // Temporally hide the menu container view for smooth animation
733
- self . menuContainerView. isHidden = true
734
- coordinator. animate ( alongsideTransition: { _ in
735
- self . contentContainerView. frame = self . contentFrame ( visibility: self . isMenuRevealed, targetSize: size)
736
- } , completion: { ( _) in
737
- self . menuContainerView. isHidden = false
738
- self . menuContainerView. frame = self . sideMenuFrame ( visibility: self . isMenuRevealed, targetSize: size)
757
+ if preferences. basic. shouldKeepMenuOpen {
758
+ self . keepSideMenuOpenOnRotation ( )
759
+ } else {
760
+ hideMenu ( animated: false , completion: { _ in
761
+ // Temporally hide the menu container view for smooth animation
762
+ self . menuContainerView. isHidden = true
763
+ coordinator. animate ( alongsideTransition: { _ in
764
+ self . contentContainerView. frame = self . contentFrame ( visibility: self . isMenuRevealed, targetSize: size)
765
+ } , completion: { ( _) in
766
+ self . menuContainerView. isHidden = false
767
+ self . menuContainerView. frame = self . sideMenuFrame ( visibility: self . isMenuRevealed, targetSize: size)
768
+ } )
739
769
} )
740
- } )
770
+ }
741
771
742
772
super. viewWillTransition ( to: size, with: coordinator)
743
773
}
0 commit comments