Skip to content

Commit 19f0124

Browse files
committed
Allow limiting the pan gesture to the sides of the view only. This would be helpful if you want to use the slide-delete functionality of the UITableView and have slide-menu-pan-gesture at the same time
1 parent 3aff93e commit 19f0124

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

SlideMenu/Source/SlideNavigationController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ typedef enum{
5151
@property (nonatomic, strong) UIBarButtonItem *rightBarButtonItem;
5252
@property (nonatomic, assign) CGFloat portraitSlideOffset;
5353
@property (nonatomic, assign) CGFloat landscapeSlideOffset;
54+
@property (nonatomic, assign) CGFloat panGestureSideOffset;
5455
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
5556

5657
+ (SlideNavigationController *)sharedInstance;

SlideMenu/Source/SlideNavigationController.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
PopTypeRoot
3434
} PopType;
3535

36-
@interface SlideNavigationController()
36+
@interface SlideNavigationController() <UIGestureRecognizerDelegate>
3737
@property (nonatomic, strong) UITapGestureRecognizer *tapRecognizer;
3838
@property (nonatomic, strong) UIPanGestureRecognizer *panRecognizer;
3939
@property (nonatomic, assign) CGPoint draggingPoint;
@@ -104,6 +104,7 @@ - (void)setup
104104

105105
self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
106106
self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
107+
self.panGestureSideOffset = 0;
107108
self.avoidSwitchingToSameClassViewController = YES;
108109
self.enableShadow = YES;
109110
self.enableSwipeGesture = YES;
@@ -638,6 +639,19 @@ - (void)tapDetected:(UITapGestureRecognizer *)tapRecognizer
638639
[self closeMenuWithCompletion:nil];
639640
}
640641

642+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
643+
{
644+
if (self.panGestureSideOffset == 0)
645+
return YES;
646+
647+
CGPoint pointInView = [touch locationInView:self.view];
648+
CGFloat horizontalSize = [self horizontalSize];
649+
650+
return (pointInView.x <= self.panGestureSideOffset || pointInView.x >= horizontalSize - self.panGestureSideOffset)
651+
? YES
652+
: NO;
653+
}
654+
641655
- (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer
642656
{
643657
CGPoint translation = [aPanRecognizer translationInView:aPanRecognizer.view];
@@ -761,6 +775,7 @@ - (UIPanGestureRecognizer *)panRecognizer
761775
if (!_panRecognizer)
762776
{
763777
_panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];
778+
_panRecognizer.delegate = self;
764779
}
765780

766781
return _panRecognizer;

0 commit comments

Comments
 (0)