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