Skip to content

Commit

Permalink
Switch to simple mode without fancy animation added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamagas committed May 21, 2014
1 parent d2fa6e5 commit 1fc34e3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RESideMenu/RESideMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
@property (strong, readwrite, nonatomic) UIViewController *rightMenuViewController;
@property (weak, readwrite, nonatomic) id<RESideMenuDelegate> delegate;

@property (assign, readwrite, nonatomic) BOOL simpleMode;

@property (assign, readwrite, nonatomic) NSTimeInterval animationDuration;
@property (strong, readwrite, nonatomic) UIImage *backgroundImage;
@property (assign, readwrite, nonatomic) BOOL panGestureEnabled;
Expand Down
61 changes: 61 additions & 0 deletions RESideMenu/RESideMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,41 @@ - (void)__commonInit
_contentViewScaleValue = 0.7f;
}

#pragma mark -
#pragma mark Getters (Simple mode)

- (BOOL)scaleContentView
{
if (self.simpleMode) {
return NO;
}
return _scaleContentView;
}

- (BOOL)scaleMenuView
{
if (self.simpleMode) {
return NO;
}
return _scaleMenuView;
}

- (BOOL)scaleBackgroundImageView
{
if (self.simpleMode) {
return NO;
}
return _scaleBackgroundImageView;
}

- (BOOL)parallaxEnabled
{
if (self.simpleMode) {
return NO;
}
return _parallaxEnabled;
}

#pragma mark -
#pragma mark Public methods

Expand Down Expand Up @@ -526,9 +561,14 @@ - (void)__panGestureRecognized:(UIPanGestureRecognizer *)recognizer
}

if (recognizer.state == UIGestureRecognizerStateChanged) {
CGFloat contentOffset = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX : self.contentViewInPortraitOffsetCenterX;
CGFloat maxPanWidth = self.contentViewContainer.bounds.size.width/2 + contentOffset;

CGFloat delta = 0;
if (self.visible) {
delta = self.originalPoint.x != 0 ? (point.x + self.originalPoint.x) / self.originalPoint.x : 0;
} else if (self.simpleMode) {
delta = point.x / maxPanWidth;
} else {
delta = point.x / self.view.frame.size.width;
}
Expand Down Expand Up @@ -576,6 +616,27 @@ - (void)__panGestureRecognized:(UIPanGestureRecognizer *)recognizer
} else {
point.x = MIN(point.x, [UIScreen mainScreen].bounds.size.height);
}
if (self.simpleMode) {
if (self.leftMenuVisible && self.rightMenuVisible) {
NSAssert(FALSE, @"WARNING: both left and right menu visible");
} else if (self.leftMenuVisible) {
if (point.x > 0) {
point.x = 0;
} else if (point.x < -maxPanWidth) {
point.x = -maxPanWidth;
}
} else if (self.rightMenuVisible) {
if (point.x < 0) {
point.x = 0;
} else if (point.x > maxPanWidth) {
point.x = maxPanWidth;
}
} else if (point.x < -maxPanWidth){
point.x = -maxPanWidth;
} else if (point.x > maxPanWidth) {
point.x = maxPanWidth;
}
}
[recognizer setTranslation:point inView:self.view];

if (!self.didNotifyDelegate) {
Expand Down

0 comments on commit 1fc34e3

Please sign in to comment.