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

Unified Diff: sky/sdk/lib/widgets/fixed_height_scrollable.dart

Issue 1226373003: demo_launcher/lib/main.dart does not have bottom-overscroll (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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/sdk/lib/animation/scroll_behavior.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/fixed_height_scrollable.dart
diff --git a/sky/sdk/lib/widgets/fixed_height_scrollable.dart b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
index 81cdb20cc9b8c82926eb107271572e3f1eeee935..42d0c7903c8fae75b68deb5ecdd2f54b90ca64a0 100644
--- a/sky/sdk/lib/widgets/fixed_height_scrollable.dart
+++ b/sky/sdk/lib/widgets/fixed_height_scrollable.dart
@@ -23,6 +23,7 @@ abstract class FixedHeightScrollable extends Scrollable {
/// Subclasses must implement `get itemCount` to tell FixedHeightScrollable
/// how many items there are in the list.
int get itemCount;
+ int _previousItemCount;
void syncFields(FixedHeightScrollable source) {
padding = source.padding;
@@ -39,14 +40,7 @@ abstract class FixedHeightScrollable extends Scrollable {
_height = newSize.height;
scrollBehavior.containerHeight = _height;
});
- }
-
- bool scrollTo(double newScrollOffset) {
- if (_height != null && _height > 0.0) {
- double maxScrollOffset = math.max(0.0, itemCount * itemHeight - _height);
- newScrollOffset = math.min(newScrollOffset, maxScrollOffset);
- }
- return super.scrollTo(newScrollOffset);
+ _updateScrollOffset();
eseidel 2015/07/09 20:40:07 Unneeded.
}
void _updateContentsHeight() {
@@ -56,8 +50,17 @@ abstract class FixedHeightScrollable extends Scrollable {
scrollBehavior.contentsHeight = contentsHeight;
}
+ void _updateScrollOffset() {
+ if (scrollOffset > scrollBehavior.maxScrollOffset)
+ settleScrollOffset();
+ }
+
Widget buildContent() {
- _updateContentsHeight();
+ if (itemCount != _previousItemCount) {
+ _previousItemCount = itemCount;
+ _updateContentsHeight();
+ _updateScrollOffset();
+ }
var itemShowIndex = 0;
var itemShowCount = 0;
« no previous file with comments | « sky/sdk/lib/animation/scroll_behavior.dart ('k') | sky/sdk/lib/widgets/scrollable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698