Skip to content

Commit 7fa9e10

Browse files
author
Aryan Ghassemi
committed
Fixed glitch where quick swipe in opposite directions may cause the menu not to appear
1 parent d7ad0e1 commit 7fa9e10

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

SlideMenu/Source/SlideNavigationController.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,31 +576,33 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer
576576
CGPoint velocity = [aPanRecognizer velocityInView:aPanRecognizer.view];
577577
NSInteger movement = translation.x - self.draggingPoint.x;
578578

579-
Menu menu = (self.horizontalLocation > 0 || (self.horizontalLocation == 0 && translation.x > 0) ) ? MenuLeft : MenuRight;
579+
static Menu lastMenu;
580+
Menu menu = (self.horizontalLocation > 0 || (self.horizontalLocation == 0 && movement > 0) ) ? MenuLeft : MenuRight;
580581

581582
if (aPanRecognizer.state == UIGestureRecognizerStateBegan)
582583
{
583584
[self prepareMenuForReveal:menu forcePrepare:YES];
584585
self.draggingPoint = translation;
586+
lastMenu = menu;
585587
}
586588
else if (aPanRecognizer.state == UIGestureRecognizerStateChanged)
587589
{
588590
static CGFloat lastHorizontalLocation = 0;
589591
CGFloat newHorizontalLocation = [self horizontalLocation];
590592

591593
// Force prepare menu when slides quickly between left and right menu
592-
if ((lastHorizontalLocation < 0 && newHorizontalLocation > 0) ||
593-
(lastHorizontalLocation > 0 && newHorizontalLocation < 0))
594+
if (lastMenu != menu)
594595
[self prepareMenuForReveal:menu forcePrepare:YES];
595596

596597
lastHorizontalLocation = newHorizontalLocation;
597-
598+
598599
newHorizontalLocation += movement;
599600

600601
if (newHorizontalLocation >= self.minXForDragging && newHorizontalLocation <= self.maxXForDragging)
601602
[self moveHorizontallyToLocation:newHorizontalLocation];
602603

603604
self.draggingPoint = translation;
605+
lastMenu = menu;
604606
}
605607
else if (aPanRecognizer.state == UIGestureRecognizerStateEnded)
606608
{
@@ -647,6 +649,8 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer
647649
else
648650
[self openMenu:(currentX > 0) ? MenuLeft : MenuRight withCompletion:nil];
649651
}
652+
653+
lastMenu = -1;
650654
}
651655
}
652656

0 commit comments

Comments
 (0)