Skip to content

Commit 4a4a710

Browse files
committed
I think the proper way to get the direction is through the velocity.
Relying on translation can cause a delay in catching the interaction. Also related to Issue 9.
1 parent 99be6bb commit 4a4a710

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

InteractionControllers/CEHorizontalSwipeInteractionController.m

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,12 @@ - (CGFloat)completionSpeed
3838

3939
- (void)handleGesture:(UIPanGestureRecognizer*)gestureRecognizer {
4040
CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view.superview];
41+
CGPoint vel = [gestureRecognizer velocityInView:gestureRecognizer.view];
4142

4243
switch (gestureRecognizer.state) {
4344
case UIGestureRecognizerStateBegan: {
4445

45-
// if the user performs a *very* slow swipe, the initiatlly returned x translation may be zero. This means
46-
// that we cannot effectively determine which direction the swipe is, so we just
47-
// ignore this interaction.
48-
if (translation.x == 0)
49-
break;
50-
51-
BOOL rightToLeftSwipe = translation.x < 0;
46+
BOOL rightToLeftSwipe = vel.x < 0;
5247

5348
// perform the required navigation operation ...
5449

0 commit comments

Comments
 (0)