test-auto-animate.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Test Auto-Animate</title>
  6. <link rel="stylesheet" href="../css/reveal.css">
  7. <link rel="stylesheet" href="qunit-2.5.0.css">
  8. </head>
  9. <body style="overflow: auto;">
  10. <div id="qunit"></div>
  11. <div id="qunit-fixture"></div>
  12. <div class="reveal">
  13. <div class="slides">
  14. <section data-auto-animate>
  15. <h1>h1</h1>
  16. <h2>h2</h2>
  17. <h3 style="position: absolute; left: 0;">h3</h2>
  18. </section>
  19. <section data-auto-animate>
  20. <h1 data-auto-animate-duration="0.3">h1</h1>
  21. <h2 style="opacity: 0;">h2</h2>
  22. <h3 style="position: absolute; left: 100px;">h3</h2>
  23. </section>
  24. <section data-auto-animate data-auto-animate-duration="0.3">
  25. <h1>h1</h1>
  26. <h2>h2</h2>
  27. <h3>h3</h2>
  28. </section>
  29. </div>
  30. </div>
  31. <script src="../js/reveal.js"></script>
  32. <script src="qunit-2.5.0.js"></script>
  33. <script>
  34. window.externalScriptSequence = '';
  35. Reveal.addEventListener( 'ready', () => {
  36. QUnit.module( 'Auto-Animate' );
  37. const slides = [].slice.call( document.querySelectorAll( '.slides section' ) ).map( slide => {
  38. return {
  39. h1: slide.querySelector( 'h1' ),
  40. h2: slide.querySelector( 'h2' ),
  41. h3: slide.querySelector( 'h3' )
  42. };
  43. } );
  44. QUnit.test( 'Adds data-auto-animate-target', assert => {
  45. Reveal.slide(1);
  46. assert.strictEqual( slides[0].h1.getAttribute( 'data-auto-animate-target' ), '', 'From elements have blank data-auto-animate-target' );
  47. assert.ok( slides[1].h1.getAttribute( 'data-auto-animate-target' ).length > 0, 'To elements have a data-auto-animate-target value' );
  48. });
  49. QUnit.test( 'Ends on correct target styles', assert => {
  50. Reveal.slide(1);
  51. assert.strictEqual( slides[1].h2.style.opacity, "0" );
  52. assert.strictEqual( slides[1].h3.offsetLeft, 100 );
  53. });
  54. QUnit.test( 'Slide specific data-auto-animate-duration', assert => {
  55. assert.timeout( 350 );
  56. var done = assert.async();
  57. Reveal.slide(2);
  58. slides[2].h3.addEventListener( 'transitionend', function() {
  59. assert.ok( true, 'Transition ended within time window' );
  60. done();
  61. } );
  62. });
  63. QUnit.test( 'Element specific data-auto-animate-duration', assert => {
  64. assert.timeout( 350 );
  65. var done = assert.async();
  66. Reveal.slide(1);
  67. slides[1].h1.addEventListener( 'transitionend', function() {
  68. assert.ok( true, 'Transition ended within time window' );
  69. done();
  70. } );
  71. });
  72. } );
  73. Reveal.initialize();
  74. </script>
  75. </body>
  76. </html>