Index: sky/framework/animation/scroll_curve.dart |
diff --git a/sky/framework/animation/scroll_curve.dart b/sky/framework/animation/scroll_curve.dart |
index 07940aee1337040426a9e52e7a36d3f083adc384..54b6385bd1e5d10cccb8fc4dc209ca919b0ab0d9 100644 |
--- a/sky/framework/animation/scroll_curve.dart |
+++ b/sky/framework/animation/scroll_curve.dart |
@@ -24,3 +24,18 @@ class BoundedScrollCurve extends ScrollCurve { |
return newScrollOffset; |
} |
} |
+ |
+class OverscrollCurve extends ScrollCurve { |
+ double apply(double scrollOffset, double scrollDelta) { |
+ double newScrollOffset = scrollOffset + scrollDelta; |
+ if (newScrollOffset < 0.0) { |
+ // If we're overscrolling, we want move the scroll offset 2x slower than |
+ // we would otherwise. Therefore, we "rewind" the newScrollOffset by half |
+ // the amount that we moved it above. Notice that we clap the "old" value |
+ // to 0.0 so that we only reduce the portion of scrollDelta that's applied |
+ // beyond 0.0. |
+ newScrollOffset -= (newScrollOffset - math.min(0.0, scrollOffset)) / 2.0; |
+ } |
+ return newScrollOffset; |
+ } |
+} |