OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/gfx/android/scroller.h" | 5 #include "ui/gfx/android/scroller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 | 10 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 final_y_ = start_y + total_distance * coeff_y; | 269 final_y_ = start_y + total_distance * coeff_y; |
270 final_y_ = Clamped(final_y_, min_y_, max_y_); | 270 final_y_ = Clamped(final_y_, min_y_, max_y_); |
271 | 271 |
272 RecomputeDeltas(); | 272 RecomputeDeltas(); |
273 } | 273 } |
274 | 274 |
275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) { | 275 bool Scroller::ComputeScrollOffset(base::TimeTicks time) { |
276 if (finished_) | 276 if (finished_) |
277 return false; | 277 return false; |
278 | 278 |
| 279 if (time == curr_time_) |
| 280 return true; |
| 281 |
279 base::TimeDelta time_passed = time - start_time_; | 282 base::TimeDelta time_passed = time - start_time_; |
280 | 283 |
281 if (time_passed < base::TimeDelta()) { | 284 if (time_passed < base::TimeDelta()) { |
282 time_passed = base::TimeDelta(); | 285 time_passed = base::TimeDelta(); |
283 } | 286 } |
284 | 287 |
285 if (time_passed >= duration_) { | 288 if (time_passed >= duration_) { |
286 curr_x_ = final_x_; | 289 curr_x_ = final_x_; |
287 curr_y_ = final_y_; | 290 curr_y_ = final_y_; |
288 curr_time_ = start_time_ + duration_; | 291 curr_time_ = start_time_ + duration_; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 } | 430 } |
428 | 431 |
429 double Scroller::GetSplineFlingDistance(float velocity) const { | 432 double Scroller::GetSplineFlingDistance(float velocity) const { |
430 const double l = GetSplineDeceleration(velocity); | 433 const double l = GetSplineDeceleration(velocity); |
431 const double decel_minus_one = kDecelerationRate - 1.0; | 434 const double decel_minus_one = kDecelerationRate - 1.0; |
432 return fling_friction_ * tuning_coeff_ * | 435 return fling_friction_ * tuning_coeff_ * |
433 std::exp(kDecelerationRate / decel_minus_one * l); | 436 std::exp(kDecelerationRate / decel_minus_one * l); |
434 } | 437 } |
435 | 438 |
436 } // namespace gfx | 439 } // namespace gfx |
OLD | NEW |