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

Configurable sensible touch space #37

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ support coming soon)
var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5)
var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7)
var endAllEditing: Bool = false
var touchSpace: CGFloat = 20
}

// MARK : Storyboard Support
Expand Down Expand Up @@ -140,6 +141,7 @@ support coming soon)
@IBInspectable var panMinimumOpenThreshold: UInt = 60
@IBInspectable var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5)
@IBInspectable var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7)
@IBInspectable var touchSpace: CGFloat = 20

// MARK : Public Properties

Expand Down
10 changes: 7 additions & 3 deletions SSASideMenu/SSASideMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {
var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5)
var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7)
var endAllEditing: Bool = false
var touchSpace: CGFloat = 20

init(animationDuration: Float = 0.35, panGestureEnabled: Bool = true, panDirection: SSASideMenuPanDirection = .Edge, type: SSASideMenuType = .Scale, panMinimumOpenThreshold: UInt = 60, menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5), backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7), endAllEditing: Bool = false) {
init(animationDuration: Float = 0.35, panGestureEnabled: Bool = true, panDirection: SSASideMenuPanDirection = .Edge, type: SSASideMenuType = .Scale, panMinimumOpenThreshold: UInt = 60, menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5), backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7), endAllEditing: Bool = false, touchSpace: CGFloat = 20) {

self.animationDuration = animationDuration
self.panGestureEnabled = panGestureEnabled
Expand All @@ -154,6 +155,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {
self.menuViewControllerTransformation = menuViewControllerTransformation
self.backgroundTransformation = backgroundTransformation
self.endAllEditing = endAllEditing
self.touchSpace = touchSpace
}
}

Expand Down Expand Up @@ -191,6 +193,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {
menuViewControllerTransformation = configuration.menuViewControllerTransformation
backgroundTransformation = configuration.backgroundTransformation
endAllEditing = configuration.endAllEditing
touchSpace = configuration.touchSpace
}

// MARK : Storyboard Support
Expand Down Expand Up @@ -235,6 +238,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {
@IBInspectable var panMinimumOpenThreshold: UInt = 60
@IBInspectable var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5)
@IBInspectable var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7)
@IBInspectable var touchSpace: CGFloat = 20

// MARK : Internal Private Properties

Expand Down Expand Up @@ -950,7 +954,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {
return true
case .Edge:
let point = touch.locationInView(gestureRecognizer.view)
if point.x < 20.0 || point.x > view.frame.size.width - 20.0 { return true }
if point.x < touchSpace || point.x > view.frame.size.width - touchSpace { return true }
else { return false }
}
}
Expand Down Expand Up @@ -1122,4 +1126,4 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate {

}

}
}