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

Swipe close menu #126

Open
aiQon opened this issue Jun 16, 2014 · 2 comments
Open

Swipe close menu #126

aiQon opened this issue Jun 16, 2014 · 2 comments

Comments

@aiQon
Copy link

aiQon commented Jun 16, 2014

Hi,
I want to show the menu in full screen width and close it with a swipe (similar to opening it with a swipe) is this possible?

I know that I can vary the menu's width with

-(CGFloat) leftMenuVisibleWidth{
    return 320;
}

But what about sliding it out with a gesture?

Thanks for the great library.

@stefanoa
Copy link
Owner

Currently it is not possible.

@aiQon
Copy link
Author

aiQon commented Jun 26, 2014

if someone comes by looking for the same. I worked around this in my NavigationMenuViewController (the table view holding the menu cells) with the following in the viewDidLoad:

/* Handles swipe closing the menu */
    UIPanGestureRecognizer* panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panItem:)];
    [panGesture setMinimumNumberOfTouches:1];
    [panGesture setMaximumNumberOfTouches:1];
    [panGesture setDelegate:self];
    [self.view addGestureRecognizer:panGesture];

and thats the callback:

-(void)panItem:(UIPanGestureRecognizer *)pan{
    CGPoint translation = [pan translationInView:self.rootController.leftMenu.view];

    if(translation.x < 0 && abs((int)translation.x) > MENU_DRAG_DISTANCE){
        [self backTriggered:nil];
        return;
    }
}

for the pangesturerecognizer to work you will also need these:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

-(BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
    return YES;
}

All of this has to be in your descendant of SASlideMenuViewController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants