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

Unified Diff: ui/gfx/android/scroller.cc

Issue 606093002: android scroller: Stop fling earlier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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 | « no previous file | ui/gfx/android/scroller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | ui/gfx/android/scroller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698