| 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) {
|
|
|