index.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>jQuery Transit tests</title>
  6. <script>
  7. /*
  8. * Dynamic script loading
  9. */
  10. (function() {
  11. var m = location.search.match(/jquery=([^&$]*)/);
  12. var jQueryVersion = m ? m[1] : "1.8.1";
  13. function addScript(src) {
  14. document.write("<scr"+"ipt src='"+src+"'></scr"+"ipt>");
  15. }
  16. // Dynamically load jQuery depending on what's passed on get params.
  17. if (jQueryVersion === "1.9.0b1") {
  18. addScript("http://code.jquery.com/jquery-1.9.0b1.js");
  19. addScript("http://code.jquery.com/jquery-migrate-1.0.0b1.js");
  20. } else {
  21. addScript("http://ajax.googleapis.com/ajax/libs/jquery/"+jQueryVersion+"/jquery.min.js");
  22. }
  23. addScript("../jquery.transit.js");
  24. })();
  25. </script>
  26. <script src="test.js"></script>
  27. <link href="style.css" rel="stylesheet" />
  28. </head>
  29. <body>
  30. <div class='use'>
  31. Use:
  32. <a href='index.html?jquery=2.0.3'>jQ 2.0.3</a>
  33. <a href='index.html?jquery=1.9.0b1'>jQ 1.9.0b1</a>
  34. <a href='index.html?jquery=1.8.1'>jQ 1.8</a>
  35. <a href='index.html?jquery=1.7.0'>jQ 1.7</a>
  36. <a href='index.html?jquery=1.6.0'>jQ 1.6</a>
  37. <a href='index.html?jquery=1.5.0'>jQ 1.5</a>
  38. <button class='play-all'>Play all</button>
  39. </div>
  40. <div class='description'>
  41. <h1>jQuery transit tests</h1>
  42. <p class='version' id='jquery-version'></p>
  43. <p>Since there's no reliable programmatic way to test for transitions, this
  44. is a simple page set up so you can visually inspect effects
  45. conveniently.</p>
  46. </div>
  47. <div class='tests'></div>
  48. <script>
  49. group('Transformations');
  50. test('Translation', function($box) { $box.transition({ x: 20, y: 20 }); });
  51. test('Rotate', function($box) { $box.transition({ rotate: 45 }); });
  52. test('Rotate via string', function($box) { $box.transition({ rotate: '45deg' }); });
  53. test('Skew X', function($box) { $box.transition({ skewX: 30 }); });
  54. test('Skew Y', function($box) { $box.transition({ skewY: 30 }); });
  55. test('Skew XY', function($box) { $box.transition({ skewY: 30, skewX: 30 }); });
  56. test('Scale up', function($box) { $box.transition({ scale: 2 }); });
  57. test('Scale down', function($box) { $box.transition({ scale: 0.5 }); });
  58. group('3D transformations');
  59. test('Rotate X', function($box) {
  60. $box.transition({
  61. perspective: '500px',
  62. rotateX: 180
  63. });
  64. });
  65. test('Rotate Y', function($box) {
  66. $box.transition({
  67. perspective: '500px',
  68. rotateY: 180
  69. });
  70. });
  71. test('Rotate X/Y', function($box) {
  72. $box.transition({
  73. perspective: '500px',
  74. rotateX: 180,
  75. rotateY: 180
  76. });
  77. });
  78. group('Params');
  79. test('Delay', function($box) {
  80. $box.transition({ rotate: 45, delay: 150 });
  81. });
  82. test('Delay zero', function($box) {
  83. $box
  84. .transition({ x: 50, delay: 0 })
  85. .transition({ x: 0 });
  86. });
  87. test('Ease (should be snappy)', function($box) {
  88. $box.transition(
  89. { x: 100 }, 500,
  90. 'cubic-bezier(0,0.9,0.3,1)');
  91. });
  92. group('Chaining');
  93. test('Queueing', function($box) {
  94. $box
  95. .transition({ x: 50 })
  96. .transition({ x: 0 })
  97. .transition({ y: 50 })
  98. .transition({ y: 0 });
  99. });
  100. test('Duration 0 (should not flicker)', function($box) {
  101. $box
  102. .transition({ x: 50 }, 0)
  103. .transition({ x: 0 }, 0)
  104. .transition({ y: 50 }, 0);
  105. });
  106. group('Callbacks');
  107. test('2nd param', function($box) {
  108. $box.transition(
  109. { rotate: 45 },
  110. function() { $box.html('OK'); });
  111. });
  112. test('3rd param', function($box) {
  113. $box.transition(
  114. { rotate: 45 },
  115. 500,
  116. function() { $box.html('OK'); });
  117. });
  118. test('as "complete"', function($box) {
  119. $box.transition({
  120. rotate: 45,
  121. complete: function() { $box.html('OK'); }
  122. });
  123. });
  124. group('Misc');
  125. test('CSS with Transition', function($box) {
  126. $box
  127. .css({ x: -50 })
  128. .transition({ x: 50 });
  129. });
  130. test('Opacity', function($box) {
  131. $box
  132. .transition({ opacity: 0 });
  133. });
  134. test('Transition of transform (no jump first time)', function($box) {
  135. $box
  136. .transition({ transform: "translateX(80px)" });
  137. });
  138. </script>
  139. </body>
  140. </html>