John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 988 forks source link

Pan gesture will open the left sidebar when right sidebar is open #431

Open amycheong19 opened 9 years ago

amycheong19 commented 9 years ago

When I'm opening my right sidebar, I pan gesture from left to the right(to close) the right sidebar but ended up open the left sidebar. It skips fast the front and goes to the left sidebar. Is there any way to stop this behavior? I know this bug has been around for a long time.

cbh2000 commented 9 years ago

I've noticed this too. It's annoying, but I haven't written any apps with a left and right sidebar yet.

shapljts commented 7 years ago

Any update on this? Or maybe a workaround?

iDevelopper commented 7 years ago

You can use the delegate method to check the location: (you have to import <UIKit/UIGestureRecognizerSubclass.h>;)

- (void)revealController:(SWRevealViewController *)revealController panGestureMovedToLocation:(CGFloat)location progress:(CGFloat)progress
{
    if ((revealController.frontViewPosition == FrontViewPositionRight && location <= 0)         // Rear view is open
        ||(revealController.frontViewPosition == FrontViewPositionLeftSide && location >= 0))   // Right view is open
    {
        revealController.panGestureRecognizer.state = UIGestureRecognizerStateCancelled;
        [revealController setFrontViewPosition:FrontViewPositionLeft];
    }
}