OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // This file contains View framework classes. | 5 // This file contains View framework classes. |
6 // As it grows, it may need to be split into multiple files. | 6 // As it grows, it may need to be split into multiple files. |
7 | 7 |
8 /** A factory that creates a view from a data model. */ | 8 /** A factory that creates a view from a data model. */ |
9 interface ViewFactory<D> { | 9 interface ViewFactory<D> { |
10 View newView(D item); | 10 View newView(D item); |
11 | 11 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 if (height != null) { | 281 if (height != null) { |
282 style.height = '${height}px'; | 282 style.height = '${height}px'; |
283 } | 283 } |
284 // TODO(jacobr): this should be specified by the default CSS for a | 284 // TODO(jacobr): this should be specified by the default CSS for a |
285 // GenericListView. | 285 // GenericListView. |
286 style.overflow = 'hidden'; | 286 style.overflow = 'hidden'; |
287 } | 287 } |
288 | 288 |
289 | 289 |
290 void onResize() { | 290 void onResize() { |
291 int lastViewLength = _viewLength; | 291 window.requestMeasurementFrame(() { |
292 node.rect.then((ElementRect rect) { | 292 int lastViewLength = _viewLength; |
293 _viewLength = _vertical ? rect.offset.height : rect.offset.width; | 293 final offset = node.rect.offset; |
| 294 _viewLength = _vertical ? offset.height : offset.width; |
294 if (_viewLength != lastViewLength) { | 295 if (_viewLength != lastViewLength) { |
295 if (_scrollbar != null) { | 296 return () { |
296 _scrollbar.refresh(); | 297 if (_scrollbar != null) { |
297 } | 298 _scrollbar.refresh(); |
298 renderVisibleItems(true); | 299 } |
| 300 renderVisibleItems(true); |
| 301 }; |
299 } | 302 } |
300 }); | 303 }); |
301 } | 304 } |
302 | 305 |
303 void enterDocument() { | 306 void enterDocument() { |
304 if (scroller != null) { | 307 if (scroller != null) { |
305 onResize(); | |
306 | |
307 if (_scrollbar != null) { | 308 if (_scrollbar != null) { |
308 _scrollbar.initialize(); | 309 _scrollbar.initialize(); |
309 } | 310 } |
| 311 onResize(); |
310 } | 312 } |
311 } | 313 } |
312 | 314 |
313 int getNextIndex(int index, bool forward) { | 315 int getNextIndex(int index, bool forward) { |
314 int delta = forward ? 1 : -1; | 316 int delta = forward ? 1 : -1; |
315 if (_paginate) { | 317 if (_paginate) { |
316 int newPage = Math.max(0, _layout.getPage(index, _viewLength) + delta); | 318 int newPage = Math.max(0, _layout.getPage(index, _viewLength) + delta); |
317 index = _layout.getPageStartIndex(newPage, _viewLength); | 319 index = _layout.getPageStartIndex(newPage, _viewLength); |
318 } else { | 320 } else { |
319 index += delta; | 321 index += delta; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 978 |
977 container = node.query('.dialog-body'); | 979 container = node.query('.dialog-body'); |
978 container.nodes.add(_content.node); | 980 container.nodes.add(_content.node); |
979 | 981 |
980 return node; | 982 return node; |
981 } | 983 } |
982 | 984 |
983 /** Override to handle dialog done. */ | 985 /** Override to handle dialog done. */ |
984 void onDone() { } | 986 void onDone() { } |
985 } | 987 } |
OLD | NEW |