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 part of view; | 5 part of view; |
6 | 6 |
7 typedef void SelectHandler(String menuText); | 7 typedef void SelectHandler(String menuText); |
8 | 8 |
9 /** | 9 /** |
10 * This implements a horizontal menu bar with a sliding triangle arrow | 10 * This implements a horizontal menu bar with a sliding triangle arrow |
(...skipping 18 matching lines...) Expand all Loading... |
29 SelectHandler onSelect; | 29 SelectHandler onSelect; |
30 | 30 |
31 List<String> _menuItems; | 31 List<String> _menuItems; |
32 | 32 |
33 SliderMenu(this._menuItems, this.onSelect) : super() {} | 33 SliderMenu(this._menuItems, this.onSelect) : super() {} |
34 | 34 |
35 Element render() { | 35 Element render() { |
36 // Create a div for each menu item. | 36 // Create a div for each menu item. |
37 final items = new StringBuffer(); | 37 final items = new StringBuffer(); |
38 for (final item in _menuItems) { | 38 for (final item in _menuItems) { |
39 items.add('<div class="sm-item">$item</div>'); | 39 items.write('<div class="sm-item">$item</div>'); |
40 } | 40 } |
41 | 41 |
42 // Create a root node to hold this view. | 42 // Create a root node to hold this view. |
43 return new Element.html(''' | 43 return new Element.html(''' |
44 <div class="sm-root"> | 44 <div class="sm-root"> |
45 <div class="sm-item-box"> | 45 <div class="sm-item-box"> |
46 <div class="sm-item-filler"></div> | 46 <div class="sm-item-filler"></div> |
47 $items | 47 $items |
48 <div class="sm-item-filler"></div> | 48 <div class="sm-item-filler"></div> |
49 </div> | 49 </div> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 void _moveIndicator(num x, bool animate) { | 170 void _moveIndicator(num x, bool animate) { |
171 // find the slider filler (the div element to the left of the | 171 // find the slider filler (the div element to the left of the |
172 // triangle) set its width the push the triangle to where we want it. | 172 // triangle) set its width the push the triangle to where we want it. |
173 String duration = animate ? '.3s' : '0s'; | 173 String duration = animate ? '.3s' : '0s'; |
174 final triangle = node.query('.sm-triangle'); | 174 final triangle = node.query('.sm-triangle'); |
175 triangle.style.transitionDuration = duration; | 175 triangle.style.transitionDuration = duration; |
176 FxUtil.setWebkitTransform(triangle, x, 0); | 176 FxUtil.setWebkitTransform(triangle, x, 0); |
177 } | 177 } |
178 } | 178 } |
OLD | NEW |