Skip to content

Commit c397b3e

Browse files
committed
Switch to simple mode without fancy animation added
1 parent c755565 commit c397b3e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

RESideMenu/RESideMenu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
@property (strong, readwrite, nonatomic) UIViewController *rightMenuViewController;
4646
@property (weak, readwrite, nonatomic) id<RESideMenuDelegate> delegate;
4747

48+
@property (assign, readwrite, nonatomic) BOOL simpleMode;
49+
4850
@property (assign, readwrite, nonatomic) NSTimeInterval animationDuration;
4951
@property (strong, readwrite, nonatomic) UIImage *backgroundImage;
5052
@property (assign, readwrite, nonatomic) BOOL panGestureEnabled;

RESideMenu/RESideMenu.m

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,41 @@ - (void)commonInit
117117
_contentViewScaleValue = 0.7f;
118118
}
119119

120+
#pragma mark -
121+
#pragma mark Getters (Simple mode)
122+
123+
- (BOOL)scaleContentView
124+
{
125+
if (self.simpleMode) {
126+
return NO;
127+
}
128+
return _scaleContentView;
129+
}
130+
131+
- (BOOL)scaleMenuView
132+
{
133+
if (self.simpleMode) {
134+
return NO;
135+
}
136+
return _scaleMenuView;
137+
}
138+
139+
- (BOOL)scaleBackgroundImageView
140+
{
141+
if (self.simpleMode) {
142+
return NO;
143+
}
144+
return _scaleBackgroundImageView;
145+
}
146+
147+
- (BOOL)parallaxEnabled
148+
{
149+
if (self.simpleMode) {
150+
return NO;
151+
}
152+
return _parallaxEnabled;
153+
}
154+
120155
#pragma mark -
121156
#pragma mark Public methods
122157

@@ -571,9 +606,14 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
571606
}
572607

573608
if (recognizer.state == UIGestureRecognizerStateChanged) {
609+
CGFloat contentOffset = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX : self.contentViewInPortraitOffsetCenterX;
610+
CGFloat maxPanWidth = self.contentViewContainer.bounds.size.width/2 + contentOffset;
611+
574612
CGFloat delta = 0;
575613
if (self.visible) {
576614
delta = self.originalPoint.x != 0 ? (point.x + self.originalPoint.x) / self.originalPoint.x : 0;
615+
} else if (self.simpleMode) {
616+
delta = point.x / maxPanWidth;
577617
} else {
578618
delta = point.x / self.view.frame.size.width;
579619
}
@@ -622,6 +662,27 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
622662
} else {
623663
point.x = MIN(point.x, [UIScreen mainScreen].bounds.size.height);
624664
}
665+
if (self.simpleMode) {
666+
if (self.leftMenuVisible && self.rightMenuVisible) {
667+
NSAssert(FALSE, @"WARNING: both left and right menu visible");
668+
} else if (self.leftMenuVisible) {
669+
if (point.x > 0) {
670+
point.x = 0;
671+
} else if (point.x < -maxPanWidth) {
672+
point.x = -maxPanWidth;
673+
}
674+
} else if (self.rightMenuVisible) {
675+
if (point.x < 0) {
676+
point.x = 0;
677+
} else if (point.x > maxPanWidth) {
678+
point.x = maxPanWidth;
679+
}
680+
} else if (point.x < -maxPanWidth){
681+
point.x = -maxPanWidth;
682+
} else if (point.x > maxPanWidth) {
683+
point.x = maxPanWidth;
684+
}
685+
}
625686
[recognizer setTranslation:point inView:self.view];
626687

627688
if (!self.didNotifyDelegate) {

0 commit comments

Comments
 (0)