OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 7 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
8 import 'package:observatory/src/elements/helpers/tag.dart'; | 8 import 'package:observatory/src/elements/helpers/tag.dart'; |
9 | 9 |
10 typedef HtmlElement VirtualCollectionCreateCallback(); | 10 typedef HtmlElement VirtualCollectionCreateCallback(); |
11 typedef void VirtualCollectionUpdateCallback(HtmlElement el, dynamic item, | 11 typedef void VirtualCollectionUpdateCallback(HtmlElement el, dynamic item, |
12 int index); | 12 int index); |
13 | 13 |
14 class VirtualCollectionElement extends HtmlElement implements Renderable { | 14 class VirtualCollectionElement extends HtmlElement implements Renderable { |
15 static const tag = | 15 static const tag = |
16 const Tag<VirtualCollectionElement>('virtual-collection'); | 16 const Tag<VirtualCollectionElement>('virtual-collection'); |
17 | 17 |
18 RenderingScheduler<VirtualCollectionElement> _r; | 18 RenderingScheduler<VirtualCollectionElement> _r; |
19 | 19 |
20 Stream<RenderedEvent<VirtualCollectionElement>> get onRendered => | 20 Stream<RenderedEvent<VirtualCollectionElement>> get onRendered => |
21 _r.onRendered; | 21 _r.onRendered; |
22 | 22 |
23 VirtualCollectionCreateCallback _create; | 23 VirtualCollectionCreateCallback _create; |
24 VirtualCollectionUpdateCallback _update; | 24 VirtualCollectionUpdateCallback _update; |
25 double _itemHeight; | 25 double _itemHeight; |
26 int _top; | 26 int _top; |
27 int _height; | 27 double _height; |
28 List _items; | 28 List _items; |
29 StreamSubscription _onScrollSubscription; | 29 StreamSubscription _onScrollSubscription; |
30 StreamSubscription _onResizeSubscription; | 30 StreamSubscription _onResizeSubscription; |
31 | 31 |
32 List get items => _items; | 32 List get items => _items; |
33 | 33 |
34 set items(Iterable value) { | 34 set items(Iterable value) { |
35 _items = new List.unmodifiable(value); | 35 _items = new List.unmodifiable(value); |
36 _r.dirty(); | 36 _r.dirty(); |
37 } | 37 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 _shifter.children.length * _inverse_preload * _itemHeight) { | 149 _shifter.children.length * _inverse_preload * _itemHeight) { |
150 _r.dirty(); | 150 _r.dirty(); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void _onResize(_) { | 154 void _onResize(_) { |
155 _height = getBoundingClientRect().height; | 155 _height = getBoundingClientRect().height; |
156 _r.dirty(); | 156 _r.dirty(); |
157 } | 157 } |
158 } | 158 } |
OLD | NEW |