| OLD | NEW |
| 1 // Copyright (c) 2012, 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 library swipe; | 5 library swipe; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'dart:math'; | 8 import 'dart:math'; |
| 9 | 9 |
| 10 Element target; | 10 Element target; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 }); | 66 }); |
| 67 | 67 |
| 68 document.on.keyUp.add((event) => stopSpin()); | 68 document.on.keyUp.add((event) => stopSpin()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void initialize3D() { | 71 void initialize3D() { |
| 72 target.classes.add("transformable"); | 72 target.classes.add("transformable"); |
| 73 | 73 |
| 74 num childCount = target.elements.length; | 74 num childCount = target.elements.length; |
| 75 | 75 |
| 76 query("#target").rect.then((ElementRect r) { | 76 window.requestLayoutFrame(() { |
| 77 num width = r.client.width; | 77 num width = query("#target").clientWidth; |
| 78 figureWidth = (width / 2) ~/ tan(PI / childCount); | 78 figureWidth = (width / 2) ~/ tan(PI / childCount); |
| 79 | 79 |
| 80 target.style.transform = "translateZ(-${figureWidth}px)"; | 80 target.style.transform = "translateZ(-${figureWidth}px)"; |
| 81 | 81 |
| 82 num radius = (figureWidth * 1.2).round(); | 82 num radius = (figureWidth * 1.2).round(); |
| 83 query('#container2').style.width = "${radius}px"; | 83 query('#container2').style.width = "${radius}px"; |
| 84 | 84 |
| 85 for (int i = 0; i < childCount; i++) { | 85 for (int i = 0; i < childCount; i++) { |
| 86 var panel = target.elements[i]; | 86 var panel = target.elements[i]; |
| 87 | 87 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * Stop any spin that may be in progress. | 121 * Stop any spin that may be in progress. |
| 122 */ | 122 */ |
| 123 void stopSpin() { | 123 void stopSpin() { |
| 124 if (timeoutHandle != null) { | 124 if (timeoutHandle != null) { |
| 125 window.clearInterval(timeoutHandle); | 125 window.clearInterval(timeoutHandle); |
| 126 timeoutHandle = null; | 126 timeoutHandle = null; |
| 127 } | 127 } |
| 128 } | 128 } |
| OLD | NEW |