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

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: take2 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
Index: client/samples/swarm/Views.dart
diff --git a/client/samples/swarm/Views.dart b/client/samples/swarm/Views.dart
index 2efd0737e0cf8121fcfda884c07f70999bafa04c..0b8442a9375d1d88be4182844ef1e900232ff022 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,19 @@ class GenericListView<D> extends View {
void onResize() {
int lastViewLength = _viewLength;
- calculateViewLength();
- if (_viewLength != lastViewLength) {
- if (_scrollbar != null) {
- _scrollbar.refresh();
+ node.rect.then((ElementRect rect) {
+ if (_vertical) {
+ _viewLength = rect.offset.height;
+ } else {
+ _viewLength = rect.offset.width;
}
- renderVisibleItems(true);
- }
- }
-
- void calculateViewLength() {
- if (_vertical) {
- _viewLength = node.offsetHeight;
- } else {
- _viewLength = node.offsetWidth;
- }
+ if (_viewLength != lastViewLength) {
+ if (_scrollbar != null) {
+ _scrollbar.refresh();
+ }
+ renderVisibleItems(true);
+ }
+ });
}
void enterDocument() {

Powered by Google App Engine
This is Rietveld 408576698