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

Side by Side Diff: samples/swipe/swipe.dart

Issue 11413071: Deprecating Element.elements for Element.children. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback. Created 8 years, 1 month 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) 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 break; 64 break;
65 } 65 }
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.children.length;
75 75
76 window.requestLayoutFrame(() { 76 window.requestLayoutFrame(() {
77 num width = query("#target").clientWidth; 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.children[i];
87 87
88 panel.classes.add("transformable"); 88 panel.classes.add("transformable");
89 89
90 panel.style.transform = 90 panel.style.transform =
91 "rotateY(${i * (360 / childCount)}deg) translateZ(${radius}px)"; 91 "rotateY(${i * (360 / childCount)}deg) translateZ(${radius}px)";
92 } 92 }
93 93
94 spinFigure(target, -1); 94 spinFigure(target, -1);
95 }); 95 });
96 } 96 }
97 97
98 void spinFigure(Element figure, int direction) { 98 void spinFigure(Element figure, int direction) {
99 num childCount = target.elements.length; 99 num childCount = target.children.length;
100 100
101 anglePos += (360.0 / childCount) * direction; 101 anglePos += (360.0 / childCount) * direction;
102 102
103 figure.style.transform = 103 figure.style.transform =
104 'translateZ(-${figureWidth}px) rotateY(${anglePos}deg)'; 104 'translateZ(-${figureWidth}px) rotateY(${anglePos}deg)';
105 } 105 }
106 106
107 /** 107 /**
108 * Start an indefinite spin in the given direction. 108 * Start an indefinite spin in the given direction.
109 */ 109 */
110 void startSpin(Element figure, int direction) { 110 void startSpin(Element figure, int direction) {
111 // If we're not already spinning - 111 // If we're not already spinning -
112 if (timeoutHandle == null) { 112 if (timeoutHandle == null) {
113 spinFigure(figure, direction); 113 spinFigure(figure, direction);
114 114
115 timeoutHandle = window.setInterval( 115 timeoutHandle = window.setInterval(
116 () => spinFigure(figure, direction), 100); 116 () => spinFigure(figure, direction), 100);
117 } 117 }
118 } 118 }
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 }
OLDNEW
« no previous file with comments | « samples/newissues/newissues.dart ('k') | samples/tests/samples/lib/layout/grid_layout_demo.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698