destroy.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <title></title>
  8. <style>
  9. html, body{
  10. color: #223;
  11. font-size: 21pt;
  12. margin: 0; padding: 0;
  13. }
  14. nav{
  15. font-size: 21pt;
  16. line-height: 1.5em;
  17. position: fixed;
  18. bottom: 0; left: 0;
  19. }
  20. nav a{ color: inherit; }
  21. .col{
  22. text-align: center;
  23. width: 50%;
  24. float: left;
  25. box-sizing: border-box;
  26. }
  27. h4{ text-align: center;}
  28. .container{
  29. display: flex;
  30. align-items: center;
  31. outline: 1px solid #eed;
  32. font-size: 42pt;
  33. /*padding: 37.5vh 12.5vw;*/
  34. padding: 0 12.5vw;
  35. height: 200vh;
  36. }
  37. .block{
  38. background: #223;
  39. color: #eed;
  40. line-height: 25vh;
  41. text-align: right;
  42. /*padding: 0 42pt;*/
  43. margin-top: 20vh;
  44. height: 200px;
  45. width: 400px;
  46. position: relative;
  47. }
  48. span{
  49. background: #eed;
  50. color: #223;
  51. line-height: 25vh;
  52. text-align: left;
  53. padding: 0 42pt;
  54. display: block;
  55. width: 50%;
  56. position: absolute;
  57. top: 0; left: 0;
  58. box-sizing: border-box;
  59. }
  60. button {
  61. position: fixed;
  62. left: 50%;
  63. transform: translateX(-50%);
  64. }
  65. </style>
  66. </head>
  67. <body>
  68. <h4>cancelAnimation upon destroy <br><small>(check performance panel)</small></h4>
  69. <button id="destroy">destroy</button>
  70. <section>
  71. <div class="col">
  72. <br>With Percentage (0.5) <br><br>
  73. <div id="21" class="container"><div class="block">#1<span class="rellax" data-rellax-percentage="0.5">#1</span></div></div>
  74. <div id="22" class="container"><div class="block">#2<span class="rellax" data-rellax-percentage="0.5">#2</span></div></div>
  75. <div id="23" class="container"><div class="block">#3<span class="rellax" data-rellax-percentage="0.5">#3</span></div></div>
  76. <div id="24" class="container"><div class="block">#4<span class="rellax" data-rellax-percentage="0.5" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#4</span></div></div>
  77. <div id="25" class="container"><div class="block">#5<span class="rellax" data-rellax-percentage="0.5" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#5</span></div></div>
  78. <div id="26" class="container"><div class="block">#6<span class="rellax" data-rellax-percentage="0.5" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#6</span></div></div>
  79. </div>
  80. <div class="col">
  81. <br>Without Percentage <br><br>
  82. <div id="21" class="container"><div class="block">#1<span class="rellax" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#1</span></div></div>
  83. <div id="22" class="container"><div class="block">#2<span class="rellax" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#2</span></div></div>
  84. <div id="23" class="container"><div class="block">#3<span class="rellax" style="transition: transform 10s cubic-bezier(0,1,.5,1);">#3</span></div></div>
  85. <div id="24" class="container"><div class="block">#4<span class="rellax">#4</span></div></div>
  86. <div id="25" class="container"><div class="block">#5<span class="rellax">#5</span></div></div>
  87. <div id="26" class="container"><div class="block">#6<span class="rellax">#6</span></div></div>
  88. </div>
  89. </section>
  90. <!-- Scripts -->
  91. <script src="../rellax.js"></script>
  92. <script>
  93. var rellax = new Rellax('.rellax', {
  94. center: true,
  95. callback: function(positions) {
  96. // callback every position change
  97. console.log(positions);
  98. }
  99. });
  100. // test cancaelAnimation on Rellax destroy
  101. document.querySelector('#destroy').addEventListener('click', function() {
  102. rellax.destroy();
  103. }, false);
  104. </script>
  105. </body>
  106. </html>