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

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

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version Created 8 years, 11 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
OLDNEW
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 typedef void SelectHandler(String menuText); 5 typedef void SelectHandler(String menuText);
6 6
7 /** 7 /**
8 * This implements a horizontal menu bar with a sliding triangle arrow 8 * This implements a horizontal menu bar with a sliding triangle arrow
9 * that points at the currently selected item. 9 * that points at the currently selected item.
10 */ 10 */
11 class SliderMenu extends View { 11 class SliderMenu extends View {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 selectItem(result, animate); 148 selectItem(result, animate);
149 } 149 }
150 } 150 }
151 151
152 /** 152 /**
153 * animate - if true, then animate the movement of the triangle slider 153 * animate - if true, then animate the movement of the triangle slider
154 */ 154 */
155 void updateIndicator(bool animate) { 155 void updateIndicator(bool animate) {
156 if (selectedItem != null) { 156 if (selectedItem != null) {
157 // calculate where we want to put the triangle 157 // calculate where we want to put the triangle
158 selectedItem.rect.then((ElementRect rect) { 158 window.requestMeasurementFrame(() {
159 num x = rect.offset.left + 159 final offsetRect = selectedItem.rect.offset;
160 rect.offset.width / 2 - TRIANGLE_WIDTH / 2; 160 num x = offsetRect.left + offsetRect.width / 2 - TRIANGLE_WIDTH / 2;
161 _moveIndicator(x, animate); 161 return () { _moveIndicator(x, animate); };
162 }); 162 });
163 } else { 163 } else {
164 _moveIndicator(0, animate); 164 _moveIndicator(0, animate);
165 } 165 }
166 } 166 }
167 167
168 void _moveIndicator(num x, bool animate) { 168 void _moveIndicator(num x, bool animate) {
169 // find the slider filler (the div element to the left of the 169 // find the slider filler (the div element to the left of the
170 // triangle) set its width the push the triangle to where we want it. 170 // triangle) set its width the push the triangle to where we want it.
171 String duration = animate ? '.3s' : '0s'; 171 String duration = animate ? '.3s' : '0s';
172 final triangle = node.query('.sm-triangle'); 172 final triangle = node.query('.sm-triangle');
173 triangle.style.transitionDuration = duration; 173 triangle.style.transitionDuration = duration;
174 FxUtil.setWebkitTransform(triangle, x, 0); 174 FxUtil.setWebkitTransform(triangle, x, 0);
175 } 175 }
176 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698