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:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:math'; | 9 import 'dart:math'; |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 }); | 67 }); |
68 | 68 |
69 document.onKeyUp.listen((event) => stopSpin()); | 69 document.onKeyUp.listen((event) => stopSpin()); |
70 } | 70 } |
71 | 71 |
72 void initialize3D() { | 72 void initialize3D() { |
73 target.classes.add("transformable"); | 73 target.classes.add("transformable"); |
74 | 74 |
75 num childCount = target.children.length; | 75 num childCount = target.children.length; |
76 | 76 |
77 window.setImmediate(() { | 77 scheduleMicrotask(() { |
78 num width = query("#target").client.width; | 78 num width = query("#target").client.width; |
79 figureWidth = (width / 2) ~/ tan(PI / childCount); | 79 figureWidth = (width / 2) ~/ tan(PI / childCount); |
80 | 80 |
81 target.style.transform = "translateZ(-${figureWidth}px)"; | 81 target.style.transform = "translateZ(-${figureWidth}px)"; |
82 | 82 |
83 num radius = (figureWidth * 1.2).round(); | 83 num radius = (figureWidth * 1.2).round(); |
84 query('#container2').style.width = "${radius}px"; | 84 query('#container2').style.width = "${radius}px"; |
85 | 85 |
86 for (int i = 0; i < childCount; i++) { | 86 for (int i = 0; i < childCount; i++) { |
87 var panel = target.children[i]; | 87 var panel = target.children[i]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 /** | 121 /** |
122 * Stop any spin that may be in progress. | 122 * Stop any spin that may be in progress. |
123 */ | 123 */ |
124 void stopSpin() { | 124 void stopSpin() { |
125 if (timer != null) { | 125 if (timer != null) { |
126 timer.cancel(); | 126 timer.cancel(); |
127 timer = null; | 127 timer = null; |
128 } | 128 } |
129 } | 129 } |
OLD | NEW |