OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 abstract class ViewFactory<D> { | 9 abstract class ViewFactory<D> { |
10 View newView(D item); | 10 View newView(D item); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 scroller = new Scroller( | 213 scroller = new Scroller( |
214 _containerElem, | 214 _containerElem, |
215 _vertical /* verticalScrollEnabled */, | 215 _vertical /* verticalScrollEnabled */, |
216 !_vertical /* horizontalScrollEnabled */, | 216 !_vertical /* horizontalScrollEnabled */, |
217 true /* momentumEnabled */, | 217 true /* momentumEnabled */, |
218 () { | 218 () { |
219 num width = _layout.getWidth(_viewLength); | 219 num width = _layout.getWidth(_viewLength); |
220 num height = _layout.getHeight(_viewLength); | 220 num height = _layout.getHeight(_viewLength); |
221 width = width != null ? width : 0; | 221 width = width != null ? width : 0; |
222 height = height != null ? height : 0; | 222 height = height != null ? height : 0; |
223 final completer = new Completer<Size>(); | 223 return new Size(width, height); |
224 completer.complete(new Size(width, height)); | |
225 return completer.future; | |
226 }, | 224 }, |
227 _paginate && _snapToItems ? | 225 _paginate && _snapToItems ? |
228 Scroller.FAST_SNAP_DECELERATION_FACTOR : 1); | 226 Scroller.FAST_SNAP_DECELERATION_FACTOR : 1); |
229 scroller.onContentMoved.add((e) => renderVisibleItems(false)); | 227 scroller.onContentMoved.add((e) => renderVisibleItems(false)); |
230 if (_pages != null) { | 228 if (_pages != null) { |
231 watch(_pages.target, (s) => _onPageSelected()); | 229 watch(_pages.target, (s) => _onPageSelected()); |
232 } | 230 } |
233 | 231 |
234 if (_snapToItems) { | 232 if (_snapToItems) { |
235 scroller.onDecelStart.add((e) => _decelStart()); | 233 scroller.onDecelStart.add((e) => _decelStart()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 style.height = '${height}px'; | 280 style.height = '${height}px'; |
283 } | 281 } |
284 // TODO(jacobr): this should be specified by the default CSS for a | 282 // TODO(jacobr): this should be specified by the default CSS for a |
285 // GenericListView. | 283 // GenericListView. |
286 style.overflow = 'hidden'; | 284 style.overflow = 'hidden'; |
287 } | 285 } |
288 | 286 |
289 | 287 |
290 void onResize() { | 288 void onResize() { |
291 int lastViewLength = _viewLength; | 289 int lastViewLength = _viewLength; |
292 node.rect.then((ElementRect rect) { | 290 window.requestLayoutFrame(() { |
293 _viewLength = _vertical ? rect.offset.height : rect.offset.width; | 291 _viewLength = _vertical ? node.offsetHeight : node.offsetWidth; |
294 if (_viewLength != lastViewLength) { | 292 if (_viewLength != lastViewLength) { |
295 if (_scrollbar != null) { | 293 if (_scrollbar != null) { |
296 _scrollbar.refresh(); | 294 _scrollbar.refresh(); |
297 } | 295 } |
298 renderVisibleItems(true); | 296 renderVisibleItems(true); |
299 } | 297 } |
300 }); | 298 }); |
301 } | 299 } |
302 | 300 |
303 void enterDocument() { | 301 void enterDocument() { |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 | 974 |
977 container = node.query('.dialog-body'); | 975 container = node.query('.dialog-body'); |
978 container.nodes.add(_content.node); | 976 container.nodes.add(_content.node); |
979 | 977 |
980 return node; | 978 return node; |
981 } | 979 } |
982 | 980 |
983 /** Override to handle dialog done. */ | 981 /** Override to handle dialog done. */ |
984 void onDone() { } | 982 void onDone() { } |
985 } | 983 } |
OLD | NEW |