Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to simple mode without fancy animation #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RESideMenu/RESideMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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
63 changes: 62 additions & 1 deletion RESideMenu/RESideMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,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 @@ -289,7 +324,7 @@ - (void)showLeftMenuViewController
self.contentViewContainer.transform = CGAffineTransformIdentity;
}

if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_0) {
self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetWidth(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)), self.contentViewContainer.center.y);
} else {
self.contentViewContainer.center = CGPointMake((UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? self.contentViewInLandscapeOffsetCenterX + CGRectGetHeight(self.view.frame) : self.contentViewInPortraitOffsetCenterX + CGRectGetWidth(self.view.frame)), self.contentViewContainer.center.y);
Expand Down Expand Up @@ -578,9 +613,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 @@ -629,6 +669,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