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

Side by Side Diff: client/view/PagedViews.dart

Issue 8360025: Move the individual property definitions from client/base/Css to CSSStyleDeclaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 9 years, 2 months 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
« no previous file with comments | « client/view/ConveyorView.dart ('k') | client/view/SliderMenu.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class PageState { 5 class PageState {
6 final ObservableValue<int> current; 6 final ObservableValue<int> current;
7 final ObservableValue<int> target; 7 final ObservableValue<int> target;
8 final ObservableValue<int> length; 8 final ObservableValue<int> length;
9 PageState() : 9 PageState() :
10 current = new ObservableValue<int>(0), 10 current = new ObservableValue<int>(0),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 // If the selected page changes, animate to it. 146 // If the selected page changes, animate to it.
147 watch(pages.target, (s) => _onPageSelected()); 147 watch(pages.target, (s) => _onPageSelected());
148 watch(pages.length, (s) => _onPageSelected()); 148 watch(pages.length, (s) => _onPageSelected());
149 } 149 }
150 150
151 /** Read the column-gap setting so we know how far to translate the child. */ 151 /** Read the column-gap setting so we know how far to translate the child. */
152 void _computeColumnGap() { 152 void _computeColumnGap() {
153 final style = window.getComputedStyle(contentView.node, ''); 153 final style = window.getComputedStyle(contentView.node, '');
154 String gap = Css.getColumnGap(style); 154 String gap = style.columnGap;
155 if (gap == 'normal') { 155 if (gap == 'normal') {
156 gap = Css.getFontSize(style); 156 gap = style.fontSize;
157 } 157 }
158 _columnGap = _toPixels(gap, 'column-gap or font-size'); 158 _columnGap = _toPixels(gap, 'column-gap or font-size');
159 _columnWidth = _toPixels(Css.getColumnWidth(style), 'column-width'); 159 _columnWidth = _toPixels(style.columnWidth, 'column-width');
160 } 160 }
161 161
162 static int _toPixels(String value, String message) { 162 static int _toPixels(String value, String message) {
163 // TODO(jmesserly): Safari 4 has a bug where this property does not end 163 // TODO(jmesserly): Safari 4 has a bug where this property does not end
164 // in "px" like it should, but the value is correct. Handle that gracefully. 164 // in "px" like it should, but the value is correct. Handle that gracefully.
165 if (value.endsWith('px')) { 165 if (value.endsWith('px')) {
166 value = value.substring(0, value.length - 2); 166 value = value.substring(0, value.length - 2);
167 } 167 }
168 return Math.parseDouble(value).round().toInt(); 168 return Math.parseDouble(value).round().toInt();
169 } 169 }
170 170
171 /** Watch for resize and update page count. */ 171 /** Watch for resize and update page count. */
172 void windowResized() { 172 void windowResized() {
173 // TODO(jmesserly): verify we aren't triggering unnecessary layouts. 173 // TODO(jmesserly): verify we aren't triggering unnecessary layouts.
174 174
175 // The content needs to have its height explicitly set, or columns don't 175 // The content needs to have its height explicitly set, or columns don't
176 // flow to the right correctly. So we copy our own height and set the height 176 // flow to the right correctly. So we copy our own height and set the height
177 // of the content. 177 // of the content.
178 Css.setHeight(contentView.node.style, '${node.offsetHeight}px'); 178 contentView.node.style.height = '${node.offsetHeight}px';
179 179
180 _updatePageCount(); 180 _updatePageCount();
181 scroller.reconfigure(); 181 scroller.reconfigure();
182 // TODO(jacobr): calling snapToPage here is overkill. 182 // TODO(jacobr): calling snapToPage here is overkill.
183 _snapToPage(null); 183 _snapToPage(null);
184 } 184 }
185 185
186 bool _updatePageCount() { 186 bool _updatePageCount() {
187 int pageLength = 1; 187 int pageLength = 1;
188 if (_container.scrollWidth > _container.offsetWidth) { 188 if (_container.scrollWidth > _container.offsetWidth) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Finally, compute how big each page is, and how far to translate. 259 // Finally, compute how big each page is, and how far to translate.
260 return perPage * (columnSize + _columnGap); 260 return perPage * (columnSize + _columnGap);
261 } 261 }
262 262
263 void _onPageSelected() { 263 void _onPageSelected() {
264 int translate = -pages.target.value * _computePageSize(); 264 int translate = -pages.target.value * _computePageSize();
265 scroller.reconfigure(); 265 scroller.reconfigure();
266 scroller.throwTo(translate, 0); 266 scroller.throwTo(translate, 0);
267 } 267 }
268 } 268 }
OLDNEW
« no previous file with comments | « client/view/ConveyorView.dart ('k') | client/view/SliderMenu.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698