| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" | 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 withVelocity:(CGPoint)velocity | 472 withVelocity:(CGPoint)velocity |
| 473 targetContentOffset:(inout CGPoint*)targetContentOffset { | 473 targetContentOffset:(inout CGPoint*)targetContentOffset { |
| 474 DCHECK_EQ(static_cast<id>(webViewScrollViewProxy), [self scrollView]); | 474 DCHECK_EQ(static_cast<id>(webViewScrollViewProxy), [self scrollView]); |
| 475 [self scrollViewWillEndDraggingWithVelocity:velocity | 475 [self scrollViewWillEndDraggingWithVelocity:velocity |
| 476 targetContentOffset:targetContentOffset]; | 476 targetContentOffset:targetContentOffset]; |
| 477 } | 477 } |
| 478 | 478 |
| 479 #pragma mark - Pan gesture recognizer handling | 479 #pragma mark - Pan gesture recognizer handling |
| 480 | 480 |
| 481 - (void)panGesture:(UIPanGestureRecognizer*)gesture { | 481 - (void)panGesture:(UIPanGestureRecognizer*)gesture { |
| 482 if (gesture.state == UIGestureRecognizerStateEnded || |
| 483 gesture.state == UIGestureRecognizerStateCancelled) { |
| 484 [self setWebViewInteractionEnabled:YES]; |
| 485 } |
| 486 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { |
| 487 return; |
| 488 } |
| 489 |
| 482 if (gesture.state == UIGestureRecognizerStateBegan) { | 490 if (gesture.state == UIGestureRecognizerStateBegan) { |
| 483 [self setWebViewInteractionEnabled:NO]; | 491 [self setWebViewInteractionEnabled:NO]; |
| 484 } else if (gesture.state == UIGestureRecognizerStateEnded || | |
| 485 gesture.state == UIGestureRecognizerStateCancelled) { | |
| 486 [self setWebViewInteractionEnabled:YES]; | |
| 487 } | 492 } |
| 493 |
| 488 const CGPoint panPointScreen = [gesture locationInView:nil]; | 494 const CGPoint panPointScreen = [gesture locationInView:nil]; |
| 489 if (self.overscrollState == OverscrollState::ACTION_READY) { | 495 if (self.overscrollState == OverscrollState::ACTION_READY) { |
| 490 const CGFloat direction = UseRTLLayout() ? -1 : 1; | 496 const CGFloat direction = UseRTLLayout() ? -1 : 1; |
| 491 const CGFloat xOffset = direction * | 497 const CGFloat xOffset = direction * |
| 492 (panPointScreen.x - self.panPointScreenOrigin.x) / | 498 (panPointScreen.x - self.panPointScreenOrigin.x) / |
| 493 kHorizontalPanDistance; | 499 kHorizontalPanDistance; |
| 494 | 500 |
| 495 [self.overscrollActionView updateWithHorizontalOffset:xOffset]; | 501 [self.overscrollActionView updateWithHorizontalOffset:xOffset]; |
| 496 } | 502 } |
| 497 } | 503 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 overscrollActionsController:self | 917 overscrollActionsController:self |
| 912 didTriggerAction:self.overscrollActionView.selectedAction]; | 918 didTriggerAction:self.overscrollActionView.selectedAction]; |
| 913 } | 919 } |
| 914 | 920 |
| 915 - (void)overscrollActionsView:(OverscrollActionsView*)view | 921 - (void)overscrollActionsView:(OverscrollActionsView*)view |
| 916 selectedActionDidChange:(OverscrollAction)newAction { | 922 selectedActionDidChange:(OverscrollAction)newAction { |
| 917 TriggerHapticFeedbackForSelectionChange(); | 923 TriggerHapticFeedbackForSelectionChange(); |
| 918 } | 924 } |
| 919 | 925 |
| 920 @end | 926 @end |
| OLD | NEW |