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

Side by Side Diff: dart/samples/swarm/swarm_ui_lib/view/PagedViews.dart

Issue 66253002: Version 0.8.10.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of view; 5 part of view;
6 6
7 class PageState { 7 class PageState {
8 final ObservableValue<int> current; 8 final ObservableValue<int> current;
9 final ObservableValue<int> target; 9 final ObservableValue<int> target;
10 final ObservableValue<int> length; 10 final ObservableValue<int> length;
(...skipping 28 matching lines...) Expand all
39 // TODO(jmesserly): this was supposed to use the somewhat flatter unicode 39 // TODO(jmesserly): this was supposed to use the somewhat flatter unicode
40 // glyphs that Chrome uses on the new tab page, but the text is getting 40 // glyphs that Chrome uses on the new tab page, but the text is getting
41 // corrupted. 41 // corrupted.
42 final node = new Element.html(''' 42 final node = new Element.html('''
43 <div class="page-number"> 43 <div class="page-number">
44 <div class="page-number-left">&lsaquo;</div> 44 <div class="page-number-left">&lsaquo;</div>
45 <div class="page-number-label"></div> 45 <div class="page-number-label"></div>
46 <div class="page-number-right">&rsaquo;</div> 46 <div class="page-number-right">&rsaquo;</div>
47 </div> 47 </div>
48 '''); 48 ''');
49 _left = node.query('.page-number-left'); 49 _left = node.querySelector('.page-number-left');
50 _label = node.query('.page-number-label'); 50 _label = node.querySelector('.page-number-label');
51 _right = node.query('.page-number-right'); 51 _right = node.querySelector('.page-number-right');
52 return node; 52 return node;
53 } 53 }
54 54
55 void enterDocument() { 55 void enterDocument() {
56 watch(pages.current, (s) => _update()); 56 watch(pages.current, (s) => _update());
57 watch(pages.length, (s) => _update()); 57 watch(pages.length, (s) => _update());
58 58
59 _left.onClick.listen((e) { 59 _left.onClick.listen((e) {
60 if (pages.current.value > 0) { 60 if (pages.current.value > 0) {
61 pages.target.value = pages.current.value - 1; 61 pages.target.value = pages.current.value - 1;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int _viewportSize; 96 int _viewportSize;
97 Scroller scroller; 97 Scroller scroller;
98 98
99 PagedColumnView(this.pages, this.contentView) : super(); 99 PagedColumnView(this.pages, this.contentView) : super();
100 100
101 Element render() { 101 Element render() {
102 final node = new Element.html(''' 102 final node = new Element.html('''
103 <div class="paged-column"> 103 <div class="paged-column">
104 <div class="paged-column-container"></div> 104 <div class="paged-column-container"></div>
105 </div>'''); 105 </div>''');
106 _container = node.query('.paged-column-container'); 106 _container = node.querySelector('.paged-column-container');
107 _container.nodes.add(contentView.node); 107 _container.nodes.add(contentView.node);
108 108
109 // TODO(jmesserly): if we end up with empty columns on the last page, 109 // TODO(jmesserly): if we end up with empty columns on the last page,
110 // this causes the last page to end up right justified. But it seems to 110 // this causes the last page to end up right justified. But it seems to
111 // work reasonably well for both clicking and throwing. So for now, leave 111 // work reasonably well for both clicking and throwing. So for now, leave
112 // the scroller configured the default way. 112 // the scroller configured the default way.
113 113
114 // TODO(jacobr): use named arguments when available. 114 // TODO(jacobr): use named arguments when available.
115 scroller = new Scroller( 115 scroller = new Scroller(
116 _container, 116 _container,
(...skipping 19 matching lines...) Expand all
136 // But we need computedStyle to read our CSS properties. 136 // But we need computedStyle to read our CSS properties.
137 void enterDocument() { 137 void enterDocument() {
138 scheduleMicrotask(() { 138 scheduleMicrotask(() {
139 var style = contentView.node.getComputedStyle(); 139 var style = contentView.node.getComputedStyle();
140 _computeColumnGap(style); 140 _computeColumnGap(style);
141 141
142 // Trigger a fake resize event so we measure our height. 142 // Trigger a fake resize event so we measure our height.
143 windowResized(); 143 windowResized();
144 144
145 // Hook img onload events, so we find out about changes in content size 145 // Hook img onload events, so we find out about changes in content size
146 for (ImageElement img in contentView.node.queryAll("img")) { 146 for (ImageElement img in contentView.node.querySelectorAll("img")) {
147 if (!img.complete) { 147 if (!img.complete) {
148 img.onLoad.listen((e) { 148 img.onLoad.listen((e) {
149 _updatePageCount(null); 149 _updatePageCount(null);
150 }); 150 });
151 } 151 }
152 } 152 }
153 153
154 // If the selected page changes, animate to it. 154 // If the selected page changes, animate to it.
155 watch(pages.target, (s) => _onPageSelected()); 155 watch(pages.target, (s) => _onPageSelected());
156 watch(pages.length, (s) => _onPageSelected()); 156 watch(pages.length, (s) => _onPageSelected());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return perPage * (columnSize + _columnGap); 276 return perPage * (columnSize + _columnGap);
277 } 277 }
278 278
279 void _onPageSelected() { 279 void _onPageSelected() {
280 scheduleMicrotask(() { 280 scheduleMicrotask(() {
281 int translate = -pages.target.value * _computePageSize(_container); 281 int translate = -pages.target.value * _computePageSize(_container);
282 scroller.throwTo(translate, 0); 282 scroller.throwTo(translate, 0);
283 }); 283 });
284 } 284 }
285 } 285 }
OLDNEW
« no previous file with comments | « dart/samples/swarm/swarm_ui_lib/touch/EventUtil.dart ('k') | dart/samples/swarm/swarm_ui_lib/view/SliderMenu.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698