| 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 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 */ |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.requestLayoutFrame(() { |
| 159 num x = rect.offset.left + | 159 num x = selectedItem.offsetLeft + |
| 160 rect.offset.width / 2 - TRIANGLE_WIDTH / 2; | 160 selectedItem.offsetWidth / 2 - TRIANGLE_WIDTH / 2; |
| 161 _moveIndicator(x, animate); | 161 _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 } |
| OLD | NEW |