Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm

Issue 1137623007: [iOS] Upstream changes to swipe recognizer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/side_swipe_gesture_recognizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm
diff --git a/ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm b/ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm
index 47bf38a5a972736a91e7ec98145482dff91829c3..5b50c858ae76eaa337cf02450cccdec726dba3f7 100644
--- a/ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm
+++ b/ios/chrome/browser/ui/side_swipe_gesture_recognizer.mm
@@ -18,8 +18,6 @@ const CGFloat kMinSwipeXThreshold = 4;
} // namespace
@implementation SideSwipeGestureRecognizer {
- // Starting point of swipe.
- CGPoint _startPoint;
// Expected direction of the swipe, based on starting point.
UISwipeGestureRecognizerDirection _direction;
}
@@ -27,6 +25,7 @@ const CGFloat kMinSwipeXThreshold = 4;
@synthesize swipeEdge = _swipeEdge;
@synthesize direction = _direction;
@synthesize swipeOffset = _swipeOffset;
+@synthesize startPoint = _startPoint;
// To quickly avoid interference with other gesture recognizers, fail
// immediately if the touches aren't at the edge of the touched view.
@@ -34,16 +33,21 @@ const CGFloat kMinSwipeXThreshold = 4;
[super touchesBegan:touches withEvent:event];
UITouch* touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
- if (location.x > _swipeEdge &&
- location.x < CGRectGetMaxX([self.view bounds]) - _swipeEdge) {
- self.state = UIGestureRecognizerStateFailed;
- } else {
- if (location.x < _swipeEdge) {
- _direction = UISwipeGestureRecognizerDirectionRight;
+ if (_swipeEdge > 0) {
+ if (location.x > _swipeEdge &&
+ location.x < CGRectGetMaxX([self.view bounds]) - _swipeEdge) {
+ self.state = UIGestureRecognizerStateFailed;
} else {
- _direction = UISwipeGestureRecognizerDirectionLeft;
+ if (location.x < _swipeEdge) {
+ _direction = UISwipeGestureRecognizerDirectionRight;
+ } else {
+ _direction = UISwipeGestureRecognizerDirectionLeft;
+ }
+ _startPoint = location;
}
+ } else {
_startPoint = location;
+ _direction = 0;
}
}
@@ -80,6 +84,14 @@ const CGFloat kMinSwipeXThreshold = 4;
return;
}
+ if (_swipeEdge == 0 && _direction == 0) {
+ if (currentPoint.x > _startPoint.x) {
+ _direction = UISwipeGestureRecognizerDirectionRight;
+ } else {
+ _direction = UISwipeGestureRecognizerDirectionLeft;
+ }
+ }
+
// Begin recognizer after |kMinSwipeXThreshold| distance swiped.
if (std::abs(currentPoint.x - _startPoint.x) > kMinSwipeXThreshold) {
if (_direction == UISwipeGestureRecognizerDirectionRight) {
« no previous file with comments | « ios/chrome/browser/ui/side_swipe_gesture_recognizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698