Skip to content

Commit e43acfc

Browse files
committed
Switch to simple mode without fancy animation added
1 parent 374a07b commit e43acfc

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

RESideMenu/RESideMenu.h

+2
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

+61
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,41 @@ - (void)commonInit
116116
_contentViewScaleValue = 0.7f;
117117
}
118118

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

@@ -566,9 +601,14 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
566601
}
567602

568603
if (recognizer.state == UIGestureRecognizerStateChanged) {
604+
CGFloat contentOffset = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX : self.contentViewInPortraitOffsetCenterX;
605+
CGFloat maxPanWidth = self.contentViewContainer.bounds.size.width/2 + contentOffset;
606+
569607
CGFloat delta = 0;
570608
if (self.visible) {
571609
delta = self.originalPoint.x != 0 ? (point.x + self.originalPoint.x) / self.originalPoint.x : 0;
610+
} else if (self.simpleMode) {
611+
delta = point.x / maxPanWidth;
572612
} else {
573613
delta = point.x / self.view.frame.size.width;
574614
}
@@ -616,6 +656,27 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)recognizer
616656
} else {
617657
point.x = MIN(point.x, [UIScreen mainScreen].bounds.size.height);
618658
}
659+
if (self.simpleMode) {
660+
if (self.leftMenuVisible && self.rightMenuVisible) {
661+
NSAssert(FALSE, @"WARNING: both left and right menu visible");
662+
} else if (self.leftMenuVisible) {
663+
if (point.x > 0) {
664+
point.x = 0;
665+
} else if (point.x < -maxPanWidth) {
666+
point.x = -maxPanWidth;
667+
}
668+
} else if (self.rightMenuVisible) {
669+
if (point.x < 0) {
670+
point.x = 0;
671+
} else if (point.x > maxPanWidth) {
672+
point.x = maxPanWidth;
673+
}
674+
} else if (point.x < -maxPanWidth){
675+
point.x = -maxPanWidth;
676+
} else if (point.x > maxPanWidth) {
677+
point.x = maxPanWidth;
678+
}
679+
}
619680
[recognizer setTranslation:point inView:self.view];
620681

621682
if (!self.didNotifyDelegate) {

0 commit comments

Comments
 (0)