Index: ui/gfx/android/scroller.cc |
diff --git a/ui/gfx/android/scroller.cc b/ui/gfx/android/scroller.cc |
index 4a44741f52e86b85f92ec1e8102f1a881f3bfb0f..b9aea380d1ee33660fc8152439b24b48a1cf42d3 100644 |
--- a/ui/gfx/android/scroller.cc |
+++ b/ui/gfx/android/scroller.cc |
@@ -25,6 +25,10 @@ const float kInflexion = 0.35f; |
const float kEpsilon = 1e-5f; |
+// Fling scroll is stopped when the scroll position is |kThresholdForFlingEnd| |
+// pixels or closer from the end. |
+const float kThresholdForFlingEnd = 0.1; |
+ |
bool ApproxEquals(float a, float b) { |
return std::abs(a - b) < kEpsilon; |
} |
@@ -324,9 +328,10 @@ bool Scroller::ComputeScrollOffset(base::TimeTicks time) { |
curr_y_ = start_y_ + distance_coef * delta_y_; |
curr_y_ = Clamped(curr_y_, min_y_, max_y_); |
- if (ApproxEquals(curr_x_, final_x_) && ApproxEquals(curr_y_, final_y_)) { |
+ float diff_x = std::abs(curr_x_ - final_x_); |
+ float diff_y = std::abs(curr_y_ - final_y_); |
+ if (diff_x < kThresholdForFlingEnd && diff_y < kThresholdForFlingEnd) |
finished_ = true; |
- } |
} break; |
} |