| OLD | NEW |
| 1 #!mojo mojo:sky_viewer | 1 #!mojo mojo:sky_viewer |
| 2 <sky> | 2 <sky> |
| 3 <import src="fps-counter.sky" /> | |
| 4 <style> | 3 <style> |
| 5 square { | 4 square { |
| 6 margin: 50px; | 5 margin: 50px; |
| 7 height: 100px; | 6 height: 100px; |
| 8 width: 100px; | 7 width: 100px; |
| 9 background-color: green; | 8 background-color: green; |
| 10 } | 9 } |
| 11 </style> | 10 </style> |
| 12 <square /> | 11 <square /> |
| 13 <fps-counter showHistory="true" /> | |
| 14 <script> | 12 <script> |
| 15 var square = document.querySelector('square'); | 13 import "dart:sky"; |
| 16 var timeBase = 0; | |
| 17 | 14 |
| 18 function animate(time) { | 15 void main() { |
| 19 if (!timeBase) | 16 Element square = document.querySelector('square'); |
| 20 timeBase = time; | 17 double timeBase = null; |
| 21 var delta = time - timeBase; | 18 |
| 22 var rotation = Math.floor(delta / 10); | 19 void animate(double time) { |
| 23 square.style.transform = 'rotate(' + rotation + 'deg)'; | 20 if (timeBase == null) |
| 24 requestAnimationFrame(animate); | 21 timeBase = time; |
| 22 double delta = time - timeBase; |
| 23 int rotation = (delta / 10).floor(); |
| 24 square.style.setProperty("transform", 'rotate(${rotation}deg)'); |
| 25 window.requestAnimationFrame(animate); |
| 26 } |
| 27 |
| 28 window.requestAnimationFrame(animate); |
| 25 } | 29 } |
| 26 | |
| 27 requestAnimationFrame(animate); | |
| 28 </script> | 30 </script> |
| 29 </sky> | 31 </sky> |
| OLD | NEW |