Commit 2fc4f207 authored by Adam Barth's avatar Adam Barth

Merge pull request #2818 from abarth/scroll_tolerance

Scrollable sometimes pushes frames forever
parents 33d7d6dc 5a5fcb95
......@@ -444,7 +444,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
Simulation _createFlingSimulation(double scrollVelocity) {
final Simulation simulation = scrollBehavior.createScrollSimulation(scrollOffset, scrollVelocity);
if (simulation != null) {
final double endVelocity = pixelOffsetToScrollOffset(kPixelScrollTolerance.velocity).abs() * (scrollVelocity < 0.0 ? -1.0 : 1.0);
final double endVelocity = pixelOffsetToScrollOffset(kPixelScrollTolerance.velocity).abs();
final double endDistance = pixelOffsetToScrollOffset(kPixelScrollTolerance.distance).abs();
simulation.tolerance = new Tolerance(velocity: endVelocity, distance: endDistance);
}
......
......@@ -47,7 +47,7 @@ class FrictionSimulation extends Simulation {
double dx(double time) => _v * math.pow(_drag, time);
@override
bool isDone(double time) => dx(time).abs() < this.tolerance.velocity;
bool isDone(double time) => dx(time).abs() < tolerance.velocity;
}
class BoundedFrictionSimulation extends FrictionSimulation {
......
......@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
bool nearEqual(double a, double b, double epsilon) =>
(a > (b - epsilon)) && (a < (b + epsilon));
bool nearEqual(double a, double b, double epsilon) {
assert(epsilon >= 0.0);
return (a > (b - epsilon)) && (a < (b + epsilon));
}
bool nearZero(double a, double epsilon) => nearEqual(a, 0.0, epsilon);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment