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

Unified Diff: sky/framework/components/scrollable.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/framework/components/fixed_height_scrollable.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/scrollable.dart
diff --git a/sky/framework/components/scrollable.dart b/sky/framework/components/scrollable.dart
index 9a62a067dd1e8324e69e6407f2627cbda6dbcd43..20f285866ef2bc171fe1cec966d8b358b490f107 100644
--- a/sky/framework/components/scrollable.dart
+++ b/sky/framework/components/scrollable.dart
@@ -3,24 +3,19 @@
// found in the LICENSE file.
import '../animation/fling_curve.dart';
+import '../animation/scroll_curve.dart';
import '../fn.dart';
import 'dart:sky' as sky;
abstract class Scrollable extends Component {
- double minOffset;
- double maxOffset;
-
+ ScrollCurve scrollCurve;
double get scrollOffset => _scrollOffset;
double _scrollOffset = 0.0;
FlingCurve _flingCurve;
int _flingAnimationId;
- Scrollable({
- Object key,
- this.minOffset,
- this.maxOffset
- }) : super(key: key) {
+ Scrollable({Object key, this.scrollCurve}) : super(key: key) {
events.listen('gestureflingstart', _handleFlingStart);
events.listen('gestureflingcancel', _handleFlingCancel);
events.listen('gesturescrollupdate', _handleScrollUpdate);
@@ -33,15 +28,9 @@ abstract class Scrollable extends Component {
}
bool scrollBy(double scrollDelta) {
- var newScrollOffset = _scrollOffset + scrollDelta;
- if (minOffset != null && newScrollOffset < minOffset)
- newScrollOffset = minOffset;
- else if (maxOffset != null && newScrollOffset > maxOffset)
- newScrollOffset = maxOffset;
-
+ var newScrollOffset = scrollCurve.apply(_scrollOffset, scrollDelta);
if (newScrollOffset == _scrollOffset)
return false;
-
setState(() {
_scrollOffset = newScrollOffset;
});
« no previous file with comments | « sky/framework/components/fixed_height_scrollable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698