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

Unified Diff: sky/framework/components/fixed_height_scrollable.dart

Issue 1097373002: [Effen] Prevent scrolling past the bottom of a scrollable list. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move the creation of the OverscrollBehavior class to FixedHeightScrollable, since we already assumeā€¦ Created 5 years, 8 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
Index: sky/framework/components/fixed_height_scrollable.dart
diff --git a/sky/framework/components/fixed_height_scrollable.dart b/sky/framework/components/fixed_height_scrollable.dart
index 6a9f358004c1d5cefaa24832b3547865a2bf130a..c9d0cb7596eabb93cffa0c9574c7239638214ed5 100644
--- a/sky/framework/components/fixed_height_scrollable.dart
+++ b/sky/framework/components/fixed_height_scrollable.dart
@@ -23,13 +23,24 @@ abstract class FixedHeightScrollable extends Scrollable {
will-change: transform;'''
);
+ FixedHeightScrollable({
+ Object key
+ }) : super(key: key);
+
+ ScrollBehavior createScrollBehavior() => new OverscrollBehavior();
+
double _height = 0.0;
double _itemHeight;
- FixedHeightScrollable({
- Object key,
- ScrollBehavior scrollBehavior
- }) : super(key: key, scrollBehavior: scrollBehavior);
+ int _itemCount = 0;
+ int get itemCount => _itemCount;
+ void set itemCount (int value) {
+ if (_itemCount != value) {
+ _itemCount = value;
+ if (_itemHeight != null)
+ scrollBehavior.contentsHeight = _itemHeight * _itemCount;
+ }
+ }
void _measureHeights() {
trace('FixedHeightScrollable::_measureHeights', () {
@@ -49,6 +60,8 @@ abstract class FixedHeightScrollable extends Scrollable {
setState(() {
_height = scrollRect.height;
_itemHeight = itemRect.height;
+ scrollBehavior.containerHeight = _height;
+ scrollBehavior.contentsHeight = _itemHeight * _itemCount;
});
});
}

Powered by Google App Engine
This is Rietveld 408576698