OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 import 'dart:math' as math; |
| 6 |
| 7 abstract class ScrollCurve { |
| 8 // Returns the new scroll offset. |
| 9 double apply(double scrollOffset, double scrollDelta); |
| 10 } |
| 11 |
| 12 class BoundedScrollCurve extends ScrollCurve { |
| 13 double minOffset; |
| 14 double maxOffset; |
| 15 |
| 16 BoundedScrollCurve({this.minOffset: 0.0, this.maxOffset}); |
| 17 |
| 18 double apply(double scrollOffset, double scrollDelta) { |
| 19 double newScrollOffset = scrollOffset + scrollDelta; |
| 20 if (minOffset != null) |
| 21 newScrollOffset = math.max(minOffset, newScrollOffset); |
| 22 if (maxOffset != null) |
| 23 newScrollOffset = math.min(maxOffset, newScrollOffset); |
| 24 return newScrollOffset; |
| 25 } |
| 26 } |
OLD | NEW |