Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Panning restriction #21

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions Example/Shared/MSAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[self.window makeKeyAndVisible];
#endif

// Restrict panning area
self.navigationPaneViewController.panningArea = CGRectMake(0, 0, 80, self.navigationPaneViewController.view.frame.size.height);

return YES;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ typedef NS_ENUM(NSUInteger, MSNavigationPaneAppearanceType) {
@property (nonatomic, readonly) UIView *masterView;
@property (nonatomic, readonly) UIView *paneView;

// If you want to pan the view, the first touch needs to be contained in this area
@property (nonatomic, assign) CGRect panningArea;

// The width that the pane should open to reveal the master
@property (nonatomic, assign) CGFloat openStateRevealWidth;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ - (void)initialize
{
self.view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

_panningArea = self.view.frame;

_paneState = MSNavigationPaneStateClosed;
_appearanceType = MSNavigationPaneAppearanceTypeNone;
_openDirection = MSNavigationPaneOpenDirectionLeft;
Expand Down Expand Up @@ -638,6 +640,10 @@ - (void)panePanned:(UIPanGestureRecognizer *)gestureRecognizer
}
case UIGestureRecognizerStateChanged: {
CGPoint panLocationInPaneView = [gestureRecognizer locationInView:self.paneView];

// If you want to pan the view, the first touch needs to be contained in this area
if (! CGRectContainsPoint(self.panningArea, self.paneStartLocation)) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Else


// Pane Sliding
CGRect newFrame = self.paneView.frame;
switch (self.openDirection) {
Expand Down