Index: sky/framework/animation/scroll_curve.dart |
diff --git a/sky/framework/animation/scroll_curve.dart b/sky/framework/animation/scroll_curve.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..07940aee1337040426a9e52e7a36d3f083adc384 |
--- /dev/null |
+++ b/sky/framework/animation/scroll_curve.dart |
@@ -0,0 +1,26 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+import 'dart:math' as math; |
+ |
+abstract class ScrollCurve { |
+ // Returns the new scroll offset. |
+ double apply(double scrollOffset, double scrollDelta); |
+} |
+ |
+class BoundedScrollCurve extends ScrollCurve { |
+ double minOffset; |
+ double maxOffset; |
+ |
+ BoundedScrollCurve({this.minOffset: 0.0, this.maxOffset}); |
+ |
+ double apply(double scrollOffset, double scrollDelta) { |
+ double newScrollOffset = scrollOffset + scrollDelta; |
+ if (minOffset != null) |
+ newScrollOffset = math.max(minOffset, newScrollOffset); |
+ if (maxOffset != null) |
+ newScrollOffset = math.min(maxOffset, newScrollOffset); |
+ return newScrollOffset; |
+ } |
+} |