Skip to content

Commit 52f5820

Browse files
committed
Merge pull request ECSlidingViewController#83 from GateGuru/velocity
Add property to allow configuration of the velocity threshold used to de...
2 parents 7963fe9 + e871755 commit 52f5820

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ typedef enum {
159159
*/
160160
@property (nonatomic, assign) ECResetStrategy resetStrategy;
161161

162+
/** Returns the X-axis velocity threshold used for determining whether or not to process a pan to the left or right
163+
164+
By default, this is set to 100
165+
*/
166+
@property (nonatomic, assign) NSUInteger panningVelocityXThreshold;
167+
162168
/** Returns a horizontal panning gesture for moving the top view.
163169
164170
This is typically added to the top view or a top view's navigation bar.

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ - (void)viewDidLoad
181181
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(updateTopViewHorizontalCenterWithRecognizer:)];
182182
self.resetTapGesture.enabled = NO;
183183
self.resetStrategy = ECTapping | ECPanning;
184+
self.panningVelocityXThreshold = 100;
184185

185186
self.topViewSnapshot = [[UIView alloc] initWithFrame:self.topView.bounds];
186187
[self.topViewSnapshot setAutoresizingMask:self.autoResizeToFillScreen];
@@ -273,9 +274,9 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
273274
CGPoint currentVelocityPoint = [recognizer velocityInView:self.view];
274275
CGFloat currentVelocityX = currentVelocityPoint.x;
275276

276-
if ([self underLeftShowing] && currentVelocityX > 100) {
277+
if ([self underLeftShowing] && currentVelocityX > self.panningVelocityXThreshold) {
277278
[self anchorTopViewTo:ECRight];
278-
} else if ([self underRightShowing] && currentVelocityX < 100) {
279+
} else if ([self underRightShowing] && currentVelocityX <= self.panningVelocityXThreshold) {
279280
[self anchorTopViewTo:ECLeft];
280281
} else {
281282
[self resetTopView];

0 commit comments

Comments
 (0)