@@ -8,19 +8,23 @@ import UIKit
88
99open class MenuTransitionAnimator : NSObject {
1010 //MARK: Public properties
11- @objc public enum Mode : Int { case presentation, dismissal }
11+ @objc public enum Mode : Int { case presentation, dismissal }
12+ public enum Position { case left, right }
1213
1314 //MARK: Private properties
14- fileprivate let duration = 0.5
15- fileprivate let angle : CGFloat = 2
16- fileprivate var mode : Mode
17- fileprivate var shouldPassEventsOutsideMenu : Bool
18- fileprivate var tappedOutsideHandler : ( ( ) -> Void ) ?
15+ private let duration = 0.5
16+ private let angle : CGFloat = 2
17+ private var mode : Mode
18+ private var position : Position
19+ private var shouldPassEventsOutsideMenu : Bool
20+ private var tappedOutsideHandler : ( ( ) -> Void ) ?
1921
20- public init ( mode: Mode , shouldPassEventsOutsideMenu: Bool = true , tappedOutsideHandler: ( ( ) -> Void ) ? = nil ) {
22+ public init ( mode: Mode , position : Position = . left , shouldPassEventsOutsideMenu: Bool = true , tappedOutsideHandler: ( ( ) -> Void ) ? = nil ) {
2123 self . mode = mode
2224 self . tappedOutsideHandler = tappedOutsideHandler
2325 self . shouldPassEventsOutsideMenu = shouldPassEventsOutsideMenu
26+ self . position = position
27+
2428 super. init ( )
2529 }
2630}
@@ -41,8 +45,16 @@ extension MenuTransitionAnimator {
4145 let menu = context. viewController ( forKey: UITransitionContextViewControllerKey . to) !
4246
4347 let view = menu. view!
44- view. frame = CGRect ( x: 0 , y: 0 , width: menu. preferredContentSize. width, height: host. view. bounds. height)
45- view. autoresizingMask = [ . flexibleRightMargin, . flexibleHeight]
48+ switch position {
49+ case . left:
50+ view. frame = CGRect ( x: 0 , y: 0 , width: menu. preferredContentSize. width, height: host. view. bounds. height)
51+ view. autoresizingMask = [ . flexibleRightMargin, . flexibleHeight]
52+ case . right:
53+ let x = host. view. bounds. width - menu. preferredContentSize. width
54+ view. frame = CGRect ( x: x, y: 0 , width: menu. preferredContentSize. width, height: host. view. bounds. height)
55+ view. autoresizingMask = [ . flexibleRightMargin, . flexibleHeight]
56+ }
57+
4658 view. translatesAutoresizingMaskIntoConstraints = true
4759
4860 if shouldPassEventsOutsideMenu {
0 commit comments