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

Unified Diff: client/samples/swarm/Views.dart

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove duplicated imports from html.dart Created 9 years, 2 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 | « client/samples/swarm/SwarmViews.dart ('k') | client/samples/total/src/DomUtils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/samples/swarm/Views.dart
diff --git a/client/samples/swarm/Views.dart b/client/samples/swarm/Views.dart
index 2efd0737e0cf8121fcfda884c07f70999bafa04c..c02a00e77238ae9f67e1a31a96de3333b6853b3b 100644
--- a/client/samples/swarm/Views.dart
+++ b/client/samples/swarm/Views.dart
@@ -220,7 +220,9 @@ class GenericListView<D> extends View {
num height = _layout.getHeight(_viewLength);
width = width != null ? width : 0;
height = height != null ? height : 0;
- return new Size(width, height);
+ final completer = new Completer<Size>();
+ completer.complete(new Size(width, height));
+ return completer.future;
},
_paginate && _snapToItems ?
Scroller.FAST_SNAP_DECELERATION_FACTOR : 1);
@@ -287,21 +289,15 @@ class GenericListView<D> extends View {
void onResize() {
int lastViewLength = _viewLength;
- calculateViewLength();
- if (_viewLength != lastViewLength) {
- if (_scrollbar != null) {
- _scrollbar.refresh();
+ node.rect.then((ElementRect rect) {
+ _viewLength = _vertical ? rect.offset.height : rect.offset.width;
+ if (_viewLength != lastViewLength) {
+ if (_scrollbar != null) {
+ _scrollbar.refresh();
+ }
+ renderVisibleItems(true);
}
- renderVisibleItems(true);
- }
- }
-
- void calculateViewLength() {
- if (_vertical) {
- _viewLength = node.offsetHeight;
- } else {
- _viewLength = node.offsetWidth;
- }
+ });
}
void enterDocument() {
« no previous file with comments | « client/samples/swarm/SwarmViews.dart ('k') | client/samples/total/src/DomUtils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698