v2-sizzle.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width" />
  6. <title>v2 sizzle</title>
  7. <link rel="stylesheet" href="../css/flickity.css" media="screen" />
  8. <style>
  9. body { font-family: Texta; }
  10. * { box-sizing: border-box; }
  11. .parallax-container {
  12. position: relative;
  13. width: 360px;
  14. height: 400px;
  15. overflow: hidden;
  16. margin: 40px auto;
  17. }
  18. .carousel {
  19. width: 100%;
  20. }
  21. .flickity-viewport {
  22. transition: height 0.2s;
  23. }
  24. .cell {
  25. width: 360px;
  26. height: 200px;
  27. margin-right: 10px;
  28. background: #8C8;
  29. border-radius: 8px;
  30. }
  31. .cell--half-width {
  32. width: 175px;
  33. }
  34. .cell--third-width {
  35. width: calc((360px - 20px) / 3);
  36. }
  37. .cell--height1 {
  38. height: 300px;
  39. }
  40. .cell--height2 {
  41. height: 250px;
  42. }
  43. .cell__word {
  44. color: white;
  45. font-size: 54px;
  46. line-height: 1.0;
  47. display: block;
  48. padding: 20px;
  49. width: 100%;
  50. position: absolute;
  51. top: 50%;
  52. left: 0;
  53. transform: translateY(-50%);
  54. text-align: center;
  55. }
  56. .cell--half-width .cell__word {
  57. font-size: 40px;
  58. }
  59. .cell__word--group { text-align: right; }
  60. .cell__word--cells { text-align: left; }
  61. .cell--parallax { opacity: 0.6; }
  62. .flickity-prev-next-button {
  63. width: 36px;
  64. height: 36px;
  65. }
  66. .parallax-layer {
  67. position: absolute;
  68. left: 0;
  69. top: 0;
  70. pointer-events: none;
  71. }
  72. .parallax-layer--bg {
  73. width: calc((100% + 10px)* 0.7);
  74. }
  75. .parallax-bg-cell {
  76. width: 252px;
  77. height: 140px;
  78. background: #19F;
  79. position: absolute;
  80. top: 30px;
  81. border-radius: 6px;
  82. opacity: 0.6;
  83. }
  84. /* .parallax-bg-cell:nth-child(1) { left: 0px; }
  85. .parallax-bg-cell:nth-child(2) { left: 296px; }
  86. .parallax-bg-cell:nth-child(3) { left: 592px; }
  87. .parallax-bg-cell:nth-child(4) { left: 888px; }*/
  88. .parallax-bg-cell:nth-child(1) { left: 1036px; }
  89. .parallax-bg-cell:nth-child(2) { left: 1295px; }
  90. .parallax-layer--fg {
  91. width: calc((100% + 10px)* 1.5);
  92. }
  93. .parallax-fg-cell {
  94. width: 100%;
  95. position: absolute;
  96. top: 0;
  97. font-size: 54px;
  98. line-height: 200px;
  99. text-align: center;
  100. color: white;
  101. }
  102. .parallax-fg-cell:nth-child(1) { left: 400%; }
  103. .parallax-fg-cell:nth-child(2) { left: 500%; }
  104. .parallax-fg-cell:nth-child(3) { left: 600%; }
  105. </style>
  106. </head>
  107. <body>
  108. <div class="parallax-container">
  109. <div class="parallax-layer parallax-layer--bg">
  110. <!-- <div class="parallax-bg-cell"></div>
  111. <div class="parallax-bg-cell"></div>
  112. <div class="parallax-bg-cell"></div>
  113. <div class="parallax-bg-cell"></div> -->
  114. <div class="parallax-bg-cell"></div>
  115. <div class="parallax-bg-cell"></div>
  116. </div>
  117. <div class="carousel">
  118. <div class="cell cell--half-width">
  119. <span class="cell__word cell__word--group">Group</span>
  120. </div>
  121. <div class="cell cell--half-width">
  122. <span class="cell__word cell__word--cells">cells</span>
  123. </div>
  124. <div class="cell cell--third-width"></div>
  125. <div class="cell cell--third-width"></div>
  126. <div class="cell cell--third-width"></div>
  127. <div class="cell cell--height1">
  128. <span class="cell__word">Adaptive height</span>
  129. </div>
  130. <div class="cell">
  131. </div>
  132. <div class="cell cell--parallax"></div>
  133. <div class="cell cell--parallax"></div>
  134. <div class="cell"></div>
  135. </div>
  136. <div class="parallax-layer parallax-layer--fg">
  137. <div class="parallax-fg-cell">Parallax</div>
  138. <div class="parallax-fg-cell">whoa</div>
  139. <div class="parallax-fg-cell">Flickity v2</div>
  140. </div>
  141. </div>
  142. <script src="../bower_components/get-size/get-size.js"></script>
  143. <script src="../bower_components/desandro-matches-selector/matches-selector.js"></script>
  144. <script src="../bower_components/ev-emitter/ev-emitter.js"></script>
  145. <script src="../bower_components/unipointer/unipointer.js"></script>
  146. <script src="../bower_components/unidragger/unidragger.js"></script>
  147. <script src="../bower_components/fizzy-ui-utils/utils.js"></script>
  148. <script src="../js/cell.js"></script>
  149. <script src="../js/slide.js"></script>
  150. <script src="../js/animate.js"></script>
  151. <script src="../js/flickity.js"></script>
  152. <script src="../js/drag.js"></script>
  153. <script src="../js/prev-next-button.js"></script>
  154. <script src="../js/page-dots.js"></script>
  155. <script src="../js/player.js"></script>
  156. <script src="../js/add-remove-cell.js"></script>
  157. <script>
  158. var flkty = new Flickity( '.carousel', {
  159. groupCells: true,
  160. adaptiveHeight: true,
  161. wrapAround: true,
  162. });
  163. var paraBg = document.querySelector('.parallax-layer--bg');
  164. var paraFg = document.querySelector('.parallax-layer--fg');
  165. var count = flkty.slides.length - 1;
  166. flkty.on( 'scroll', function( progress ) {
  167. paraBg.style.left = ( 0.5 - ( 0.5 + progress * count ) * 0.7 ) * (37/36) * 100 + '%';
  168. paraFg.style.left = ( 0.5 - ( 0.5 + progress * count ) *1.5 ) * (37/36) * 100 + '%';
  169. });
  170. flkty.reposition();
  171. </script>
  172. </body>
  173. </html>