Chromium Code Reviews| 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) { |
|
nweiz
2011/10/28 03:58:38
I feel like ?: would read much better here.
Jacob
2011/10/31 22:09:50
Done.
|
| + _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() { |