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

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

Issue 1021723005: Load stocks data off the network (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/examples/stocks-fn/main.sky ('k') | sky/framework/net/fetch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4b5f86d1dac22c60c5b3b25c7fa428688328d5a2..7343b553037cb75738edd1ba3aa9c60aae38cef0 100644
--- a/sky/framework/components/fixed_height_scrollable.dart
+++ b/sky/framework/components/fixed_height_scrollable.dart
@@ -6,6 +6,7 @@ import '../animation/scroll_behavior.dart';
import '../fn.dart';
import 'dart:math' as math;
import 'dart:sky' as sky;
+import 'dart:async';
import 'scrollable.dart';
abstract class FixedHeightScrollable extends Scrollable {
@@ -26,13 +27,17 @@ abstract class FixedHeightScrollable extends Scrollable {
FixedHeightScrollable({
Object key,
ScrollBehavior scrollBehavior
- }) : super(key: key, scrollBehavior: scrollBehavior) {
- onDidMount(_measureHeights);
- }
+ }) : super(key: key, scrollBehavior: scrollBehavior);
void _measureHeights() {
+ if (_itemHeight != null)
+ return;
var root = getRoot();
+ if (root == null)
+ return;
var item = root.firstChild.firstChild;
+ if (item == null)
+ return;
sky.ClientRect scrollRect = root.getBoundingClientRect();
sky.ClientRect itemRect = item.getBoundingClientRect();
assert(scrollRect.height > 0);
@@ -49,7 +54,10 @@ abstract class FixedHeightScrollable extends Scrollable {
var drawCount = 1;
var transformStyle = '';
- if (_height > 0.0) {
+ if (_itemHeight == null)
+ new Future.microtask(_measureHeights);
+
+ if (_height > 0.0 && _itemHeight != null) {
if (scrollOffset < 0.0) {
double visibleHeight = _height + scrollOffset;
drawCount = (visibleHeight / _itemHeight).round() + 1;
« no previous file with comments | « sky/examples/stocks-fn/main.sky ('k') | sky/framework/net/fetch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698