Commit bcf08d23 authored by Hans Muller's avatar Hans Muller

Merge pull request #2829 from HansMuller/super_fling_fast

Fix Fast Fling Failure
parents fb427a1e 1af58aee
...@@ -78,9 +78,9 @@ const double kWindowTouchSlop = 16.0; // Logical pixels ...@@ -78,9 +78,9 @@ const double kWindowTouchSlop = 16.0; // Logical pixels
/// gesture. /// gesture.
// TODO(ianh): Make sure nobody has their own version of this. // TODO(ianh): Make sure nobody has their own version of this.
const double kMinFlingVelocity = 50.0; // Logical pixels / second const double kMinFlingVelocity = 50.0; // Logical pixels / second
// const Velocity kMinFlingVelocity = const Velocity(pixelsPerSecond: 50.0);
/// The maximum velocity of a touch to consider that touch to trigger a fling /// Drag gesture fling velocities are clipped to this value.
/// gesture.
// TODO(ianh): Make sure nobody has their own version of this. // TODO(ianh): Make sure nobody has their own version of this.
const double kMaxFlingVelocity = 8000.0; // Logical pixels / second const double kMaxFlingVelocity = 8000.0; // Logical pixels / second
......
...@@ -31,8 +31,7 @@ typedef void _GesturePolymorphicUpdateCallback<T>(T delta); ...@@ -31,8 +31,7 @@ typedef void _GesturePolymorphicUpdateCallback<T>(T delta);
bool _isFlingGesture(Velocity velocity) { bool _isFlingGesture(Velocity velocity) {
assert(velocity != null); assert(velocity != null);
final double speedSquared = velocity.pixelsPerSecond.distanceSquared; final double speedSquared = velocity.pixelsPerSecond.distanceSquared;
return speedSquared > kMinFlingVelocity * kMinFlingVelocity return speedSquared > kMinFlingVelocity * kMinFlingVelocity;
&& speedSquared < kMaxFlingVelocity * kMaxFlingVelocity;
} }
abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGestureRecognizer { abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGestureRecognizer {
...@@ -119,10 +118,14 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest ...@@ -119,10 +118,14 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends OneSequenceGest
assert(tracker != null); assert(tracker != null);
Velocity velocity = tracker.getVelocity(); Velocity velocity = tracker.getVelocity();
if (velocity != null && _isFlingGesture(velocity)) if (velocity != null && _isFlingGesture(velocity)) {
final Offset pixelsPerSecond = velocity.pixelsPerSecond;
if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity)
velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity);
onEnd(velocity); onEnd(velocity);
else } else {
onEnd(Velocity.zero); onEnd(Velocity.zero);
}
} }
_velocityTrackers.clear(); _velocityTrackers.clear();
} }
......
...@@ -499,8 +499,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -499,8 +499,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
Future<Null> _handleDragEnd(Velocity velocity) { Future<Null> _handleDragEnd(Velocity velocity) {
double scrollVelocity = pixelDeltaToScrollOffset(velocity.pixelsPerSecond) / Duration.MILLISECONDS_PER_SECOND; double scrollVelocity = pixelDeltaToScrollOffset(velocity.pixelsPerSecond) / Duration.MILLISECONDS_PER_SECOND;
// The gesture velocity properties are pixels/second, config min,max limits are pixels/ms return fling(scrollVelocity).then(_endScroll);
return fling(scrollVelocity.clamp(-kMaxFlingVelocity, kMaxFlingVelocity)).then(_endScroll);
} }
Null _endScroll([Null _]) { Null _endScroll([Null _]) {
......
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