Skip to content

Commit

Permalink
Implement new flag that enables direction auto-switching.
Browse files Browse the repository at this point in the history
  • Loading branch information
kawoou committed Jan 9, 2018
1 parent 4466e58 commit b12509f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DrawerController/DrawerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
didSet { fadeView.backgroundColor = fadeColor }
}

@IBInspectable
public var isEnableAutoSwitchDirection: Bool = false

@IBInspectable
public var animationDuration: TimeInterval = 0.35

Expand Down Expand Up @@ -917,6 +920,17 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
return percentage
}

guard ss.isEnableAutoSwitchDirection else {
switch from {
case .left:
guard percentage > 0.0 else { return 0.0 }
case .right:
guard percentage < 0.0 else { return 0.0 }
default:
return percentage
}
return percentage
}
guard ss.contentMap[to] != nil else {
return 0.0
}
Expand Down

0 comments on commit b12509f

Please sign in to comment.