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