Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: sky/framework/animation/scroll_curve.dart

Issue 1005633002: Factor ScrollCurve out of Scrollable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « sky/examples/stocks-fn/stocksapp.dart ('k') | sky/framework/components/fixed_height_scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698