From 1fc34e3862723810c5808b5fdd3736ad95b61add Mon Sep 17 00:00:00 2001 From: Darius Sabaliauskas Date: Wed, 21 May 2014 14:41:28 +0300 Subject: [PATCH] Switch to simple mode without fancy animation added --- RESideMenu/RESideMenu.h | 2 ++ RESideMenu/RESideMenu.m | 61 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/RESideMenu/RESideMenu.h b/RESideMenu/RESideMenu.h index 2167207a..bbca2e8a 100644 --- a/RESideMenu/RESideMenu.h +++ b/RESideMenu/RESideMenu.h @@ -35,6 +35,8 @@ @property (strong, readwrite, nonatomic) UIViewController *rightMenuViewController; @property (weak, readwrite, nonatomic) id 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; diff --git a/RESideMenu/RESideMenu.m b/RESideMenu/RESideMenu.m index 54752bb4..c5d5b494 100644 --- a/RESideMenu/RESideMenu.m +++ b/RESideMenu/RESideMenu.m @@ -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 @@ -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; } @@ -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) {