Index: Source/platform/mac/ScrollElasticityController.mm |
diff --git a/Source/platform/mac/ScrollElasticityController.mm b/Source/platform/mac/ScrollElasticityController.mm |
index 0ab305b6ab91823e3ff09e4e30feebf082a77ac4..e4529d34c5ed63b48d219a8f9e6ff0e596ab9660 100644 |
--- a/Source/platform/mac/ScrollElasticityController.mm |
+++ b/Source/platform/mac/ScrollElasticityController.mm |
@@ -107,9 +107,22 @@ ScrollElasticityController::ScrollElasticityController(ScrollElasticityControlle |
{ |
} |
-bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& wheelEvent) |
+// |canRubberbandLeft| and |canRubberbandRight| prevent the start of rubber-banding in their respective directions. |
+// Once rubber banding has started, the two parameters have no effect. |
+bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& wheelEvent, bool canRubberbandLeft, bool canRubberbandRight) |
{ |
if (wheelEvent.phase() == PlatformWheelEventPhaseBegan) { |
+ // Don't allow rubber banding to start in a direction that explicitly disallows rubberbanding. |
+ if (!canRubberbandLeft && wheelEvent.deltaX() > 0) { |
+ printf("cannot rubberband left"); |
+ return false; |
+ } |
+ if (!canRubberbandRight && wheelEvent.deltaX() < 0) { |
+ printf("cannot rubberband right"); |
+ return false; |
+ } |
+ |
+ |
// First, check if we should rubber-band at all. |
if (m_client->pinnedInDirection(FloatSize(-wheelEvent.deltaX(), 0)) && |
!shouldRubberBandInHorizontalDirection(wheelEvent)) |
Nico
2014/03/14 17:51:46
Should the checks be in shouldRubberBandInHorizont
erikchen
2014/03/20 18:04:26
I've moved all the relevant logic into the method.
|
@@ -185,6 +198,13 @@ bool ScrollElasticityController::handleWheelEvent(const PlatformWheelEvent& whee |
// If we are starting momentum scrolling then do some setup. |
if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhaseBegan || momentumPhase == PlatformWheelEventPhaseChanged)) { |
+ // Momentum events should not trigger rubber banding in a disallowed direction. |
+ if (!canRubberbandLeft && wheelEvent.deltaX() > 0) { |
+ return false; |
+ } |
+ if (!canRubberbandRight && wheelEvent.deltaX() < 0) { |
+ return false; |
+ } |
m_momentumScrollInProgress = true; |
// Start the snap rubber band timer if it's not running. This is needed to |
// snap back from the over scroll caused by momentum events. |