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

added option to enable / disable left- and right pan gestures #270

Open
wants to merge 1 commit 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 RESideMenu/RESideMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
@property (assign, readwrite, nonatomic) NSTimeInterval animationDuration;
@property (strong, readwrite, nonatomic) UIImage *backgroundImage;
@property (assign, readwrite, nonatomic) BOOL panGestureEnabled;
@property (assign, readwrite, nonatomic) IBInspectable BOOL panGestureLeftEnabled;
@property (assign, readwrite, nonatomic) IBInspectable BOOL panGestureRightEnabled;
@property (assign, readwrite, nonatomic) BOOL panFromEdge;
@property (assign, readwrite, nonatomic) NSUInteger panMinimumOpenThreshold;
@property (assign, readwrite, nonatomic) IBInspectable BOOL interactivePopGestureRecognizerEnabled;
Expand Down
10 changes: 7 additions & 3 deletions RESideMenu/RESideMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ - (void)commonInit
_bouncesHorizontally = YES;

_panGestureEnabled = YES;
_panGestureLeftEnabled = YES;
_panGestureRightEnabled = YES;
_panFromEdge = YES;
_panMinimumOpenThreshold = 60.0;

Expand Down Expand Up @@ -537,11 +539,13 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceive

if (self.panFromEdge && [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && !self.visible) {
CGPoint point = [touch locationInView:gestureRecognizer.view];
if (point.x < 20.0 || point.x > self.view.frame.size.width - 20.0) {
if(self.panGestureLeftEnabled && point.x < 20.0) {
return YES;
} else if(self.panGestureRightEnabled && point.x > self.view.frame.size.width - 20.0) {
return YES;
} else {
return NO;
}

return NO;
}

return YES;
Expand Down