animation.rml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <rml>
  2. <head>
  3. <link type="text/template" href="../../../assets/window.rml"/>
  4. <title>Animation Sample</title>
  5. <style>
  6. body.window
  7. {
  8. max-width: 2000dp;
  9. max-height: 2000dp;
  10. left: 80dp;
  11. right: 80dp;
  12. top: 50dp;
  13. bottom: 50dp;
  14. perspective: 3000dp;
  15. /*opacity: 0;*/
  16. }
  17. section
  18. {
  19. display: block;
  20. position: absolute;
  21. width: 20%;
  22. height: 80%;
  23. }
  24. #fps
  25. {
  26. font-size: 0.85em;
  27. text-align: left;
  28. }
  29. button {
  30. margin-top: 50dp;
  31. }
  32. div#title_bar div#icon
  33. {
  34. display: none;
  35. }
  36. spacer
  37. {
  38. display: inline-block;
  39. width: 25dp;
  40. }
  41. #start_game
  42. {
  43. opacity: 0.8;
  44. transform: rotate(370deg) translateX(100dp) scale(1.2);
  45. transform-origin: 30% 80% 0;
  46. }
  47. #options {
  48. transform: scale(1.0);
  49. }
  50. #options:hover {
  51. animation: 1s spinner infinite;
  52. }
  53. @keyframes spinner {
  54. from { transform: scale(1.0) rotate(0deg); }
  55. 25% { transform: scale(1.2) rotate(90deg); }
  56. 50% { transform: scale(1.3) rotate(180deg); }
  57. 75% { transform: scale(1.2) rotate(270deg); }
  58. to { transform: scale(1.0) rotate(360deg); }
  59. }
  60. #high_scores {
  61. margin-left: -100dp;
  62. }
  63. @keyframes fadeout {
  64. from {
  65. opacity: 1;
  66. visibility: visible;
  67. }
  68. to {
  69. opacity: 0;
  70. visibility: hidden;
  71. }
  72. }
  73. @keyframes fadein {
  74. from {
  75. opacity: 0;
  76. visibility: hidden;
  77. }
  78. to {
  79. opacity: 1;
  80. visibility: visible;
  81. }
  82. }
  83. @keyframes textalign {
  84. 0%, 20% { text-align: left; }
  85. 50% { text-align: center; }
  86. 80%, 100% { text-align: right; }
  87. }
  88. .fadeout {
  89. animation: 1.2s cubic-in fadeout;
  90. visibility: hidden;
  91. }
  92. .fadein {
  93. animation: 1.2s cubic-out fadein;
  94. }
  95. .textalign {
  96. animation: 1.4s textalign;
  97. }
  98. #exit {
  99. transform: rotate(45deg);
  100. transform-origin: 50% 50% 0;
  101. }
  102. div.container
  103. {
  104. margin-top: 15dp;
  105. width: 100%;
  106. height: 200dp;
  107. background-color: #ae8484aa;
  108. }
  109. div.plain
  110. {
  111. font-size: 1.2em;
  112. padding: 10dp;
  113. margin: auto;
  114. width: 130dp;
  115. height: 70dp;
  116. background-color: #c66;
  117. }
  118. div.plain:hover { background-color: #ddb700; }
  119. /* -- TRANSFORM TESTS */
  120. #generic {
  121. /* Note the translateX vs translateY in animation target, and rotateZ vs rotate3d, scaleX vs scaleY.
  122. In order to match, they are converted to their generic forms, translate3d, rotate3d, and scale3d.
  123. For rotate3d to match another rotation, their rotation axes must align. */
  124. transform: translateX(100dp) rotateZ(70deg) scaleX(1.3);
  125. }
  126. #combine {
  127. transform: rotate(45deg);
  128. }
  129. #decomposition {
  130. /* To interpolate the rotate3d transforms, we need to decompose the matrix,
  131. see the element info in the debugger for the resulting matrix. */
  132. transform: translateX(100dp) rotate3d(1.0, 0, 1.0, 0deg);
  133. }
  134. /* -- MIXED UNITS TESTS */
  135. #abs_rel {
  136. margin: 0;
  137. margin-left: 50dp;
  138. }
  139. #abs_rel_transform {
  140. margin: 0;
  141. transform: translateX(100%);
  142. }
  143. #animation_event {
  144. position: relative;
  145. margin: 0;
  146. top: 50dp; left: 50dp;
  147. }
  148. /* -- TRANSITION TESTS */
  149. #transition_test {
  150. transition: all 1.6s elastic-out 0.0;
  151. }
  152. #transition_test:hover {
  153. /*transition: padding-left background-color transform 0.8s quadratic-out 1.0;*/
  154. padding-left: 60dp;
  155. transform: scale(1.5);
  156. }
  157. #transition_class {
  158. margin-left: 50dp;
  159. transition: all 0.5s cubic-out;
  160. cursor: pointer;
  161. }
  162. #transition_class.move_me {
  163. margin-left: -50dp;
  164. background-color: #dd3;
  165. }
  166. /* -- KEYFRAMES TESTS */
  167. @keyframes hello-world
  168. {
  169. 25% {
  170. transform: rotate(180deg);
  171. }
  172. 40% {
  173. transform: rotate(180deg) translateX(200dp);
  174. }
  175. 60% {
  176. transform: rotate(180deg) translateX(-200dp);
  177. }
  178. 75% {
  179. transform: rotate(180deg);
  180. }
  181. to {
  182. transform: rotate(360deg);
  183. }
  184. }
  185. #keyframes_test
  186. {
  187. transform: rotate(0);
  188. animation: 5s bounce-out infinite hello-world;
  189. transition: background-color 0.5s exponential-in-out;
  190. }
  191. @keyframes some-missing-keys
  192. {
  193. 0%, 30% {
  194. background-color: #d99;
  195. }
  196. 50% {
  197. background-color: #9d9;
  198. }
  199. to {
  200. background-color: #f9f;
  201. width: 100%;
  202. }
  203. }
  204. #keyframes_missing_keys
  205. {
  206. position: relative;
  207. margin: 0; padding: 0;
  208. top: 0; left: 0;
  209. width: 25dp; height: 25dp;
  210. animation: 2s cubic-in-out infinite alternate some-missing-keys;
  211. }
  212. #keyevent_response
  213. {
  214. position: relative;
  215. margin: 0; padding: 0;
  216. top: 110dp; left: 0;
  217. height: 55dp;
  218. }
  219. #performance
  220. {
  221. position: absolute;
  222. bottom: 0;
  223. height: 30%;
  224. width: 20%;
  225. left: -100dp;
  226. transform: scale(0.5) rotate(-90deg);
  227. }
  228. </style>
  229. </head>
  230. <body template="window">
  231. <section>
  232. <div id="fps"/>
  233. <button id="start_game">Start Game</button><br />
  234. <button id="high_scores" onkeydown="hello">High Scores</button><br />
  235. <button id="options">Options</button><br />
  236. <button id="help">Help</button><br />
  237. <button id="exit" onclick="exit">Exit</button>
  238. </section>
  239. <section id="performance"/>
  240. <section style="left: 28%;" id="transform_tests">
  241. <h1>Test transform animations</h1>
  242. <div class="container"><div class="plain" id="generic">Generic form conversion.</div></div>
  243. <div class="container"><div class="plain" id="combine">Match different transform primitive sizes</div></div>
  244. <div class="container"><div class="plain" id="decomposition">Force full matrix decomposition</div></div>
  245. </section>
  246. <section style="left: 52%;" id="mixed_units_tests">
  247. <h1>Mixed units tests</h1>
  248. <div class="container"><div class="plain" id="abs_rel">Pixel vs percentage.</div></div>
  249. <div class="container"><div class="plain" id="abs_rel_transform">Pixel vs percentage transform.</div></div>
  250. <div class="container"><div class="plain" id="animation_event">Animation event</div><div class="plain" id="keyevent_response">Events<br/><span style="font-size: 0.8em">(press arrow keys)</span></div></div>
  251. </section>
  252. <section style="left: 75%;" id="transition_tests">
  253. <h1>Transition tests</h1>
  254. <div class="container"><div class="plain" id="transition_test">Transition test (hover)</div></div>
  255. <div class="container"><div class="plain" id="transition_class" onclick="add_class">Transition class (click)</div></div>
  256. <div class="container"><div class="plain" id="keyframes_test">Keyframes test</div><div class="plain" id="keyframes_missing_keys"/></div>
  257. </section>
  258. </body>
  259. </rml>