intia-theme 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/hero.html +5 -3
  3. data/_includes/introduction.html +1 -1
  4. data/_includes/story-slider.html +1 -1
  5. data/_layouts/404.html +7 -0
  6. data/_sass/_layout.scss +40 -11
  7. data/_sass/_main.scss +32 -11
  8. data/assets/img/404.png +0 -0
  9. data/assets/img/arrow-down.png +0 -0
  10. data/assets/img/arrow-left.png +0 -0
  11. data/assets/js/main.js +4 -1
  12. data/favicon.png +0 -0
  13. data/node_modules/bulma/CHANGELOG.md +1558 -0
  14. data/node_modules/bulma/LICENSE +21 -0
  15. data/node_modules/bulma/README.md +134 -0
  16. data/node_modules/bulma/bulma.sass +10 -0
  17. data/node_modules/bulma/css/bulma-rtl.css +11811 -0
  18. data/node_modules/bulma/css/bulma-rtl.css.map +1 -0
  19. data/node_modules/bulma/css/bulma-rtl.min.css +1 -0
  20. data/node_modules/bulma/css/bulma.css +11811 -0
  21. data/node_modules/bulma/css/bulma.css.map +1 -0
  22. data/node_modules/bulma/css/bulma.min.css +1 -0
  23. data/node_modules/bulma/package.json +82 -0
  24. data/node_modules/bulma/sass/base/_all.sass +6 -0
  25. data/node_modules/bulma/sass/base/animations.sass +5 -0
  26. data/node_modules/bulma/sass/base/generic.sass +145 -0
  27. data/node_modules/bulma/sass/base/helpers.sass +1 -0
  28. data/node_modules/bulma/sass/base/minireset.sass +79 -0
  29. data/node_modules/bulma/sass/components/_all.sass +15 -0
  30. data/node_modules/bulma/sass/components/breadcrumb.sass +77 -0
  31. data/node_modules/bulma/sass/components/card.sass +103 -0
  32. data/node_modules/bulma/sass/components/dropdown.sass +83 -0
  33. data/node_modules/bulma/sass/components/level.sass +79 -0
  34. data/node_modules/bulma/sass/components/media.sass +59 -0
  35. data/node_modules/bulma/sass/components/menu.sass +59 -0
  36. data/node_modules/bulma/sass/components/message.sass +101 -0
  37. data/node_modules/bulma/sass/components/modal.sass +117 -0
  38. data/node_modules/bulma/sass/components/navbar.sass +446 -0
  39. data/node_modules/bulma/sass/components/pagination.sass +166 -0
  40. data/node_modules/bulma/sass/components/panel.sass +121 -0
  41. data/node_modules/bulma/sass/components/tabs.sass +176 -0
  42. data/node_modules/bulma/sass/elements/_all.sass +16 -0
  43. data/node_modules/bulma/sass/elements/box.sass +26 -0
  44. data/node_modules/bulma/sass/elements/button.sass +345 -0
  45. data/node_modules/bulma/sass/elements/container.sass +29 -0
  46. data/node_modules/bulma/sass/elements/content.sass +159 -0
  47. data/node_modules/bulma/sass/elements/form.sass +1 -0
  48. data/node_modules/bulma/sass/elements/icon.sass +46 -0
  49. data/node_modules/bulma/sass/elements/image.sass +73 -0
  50. data/node_modules/bulma/sass/elements/notification.sass +52 -0
  51. data/node_modules/bulma/sass/elements/other.sass +31 -0
  52. data/node_modules/bulma/sass/elements/progress.sass +73 -0
  53. data/node_modules/bulma/sass/elements/table.sass +133 -0
  54. data/node_modules/bulma/sass/elements/tag.sass +140 -0
  55. data/node_modules/bulma/sass/elements/title.sass +70 -0
  56. data/node_modules/bulma/sass/form/_all.sass +9 -0
  57. data/node_modules/bulma/sass/form/checkbox-radio.sass +22 -0
  58. data/node_modules/bulma/sass/form/file.sass +184 -0
  59. data/node_modules/bulma/sass/form/input-textarea.sass +66 -0
  60. data/node_modules/bulma/sass/form/select.sass +87 -0
  61. data/node_modules/bulma/sass/form/shared.sass +60 -0
  62. data/node_modules/bulma/sass/form/tools.sass +215 -0
  63. data/node_modules/bulma/sass/grid/_all.sass +5 -0
  64. data/node_modules/bulma/sass/grid/columns.sass +513 -0
  65. data/node_modules/bulma/sass/grid/tiles.sass +36 -0
  66. data/node_modules/bulma/sass/helpers/_all.sass +12 -0
  67. data/node_modules/bulma/sass/helpers/color.sass +39 -0
  68. data/node_modules/bulma/sass/helpers/flexbox.sass +35 -0
  69. data/node_modules/bulma/sass/helpers/float.sass +10 -0
  70. data/node_modules/bulma/sass/helpers/other.sass +14 -0
  71. data/node_modules/bulma/sass/helpers/overflow.sass +2 -0
  72. data/node_modules/bulma/sass/helpers/position.sass +7 -0
  73. data/node_modules/bulma/sass/helpers/spacing.sass +31 -0
  74. data/node_modules/bulma/sass/helpers/typography.sass +103 -0
  75. data/node_modules/bulma/sass/helpers/visibility.sass +122 -0
  76. data/node_modules/bulma/sass/layout/_all.sass +6 -0
  77. data/node_modules/bulma/sass/layout/footer.sass +11 -0
  78. data/node_modules/bulma/sass/layout/hero.sass +153 -0
  79. data/node_modules/bulma/sass/layout/section.sass +17 -0
  80. data/node_modules/bulma/sass/utilities/_all.sass +9 -0
  81. data/node_modules/bulma/sass/utilities/animations.sass +1 -0
  82. data/node_modules/bulma/sass/utilities/controls.sass +49 -0
  83. data/node_modules/bulma/sass/utilities/derived-variables.sass +114 -0
  84. data/node_modules/bulma/sass/utilities/extends.sass +25 -0
  85. data/node_modules/bulma/sass/utilities/functions.sass +136 -0
  86. data/node_modules/bulma/sass/utilities/initial-variables.sass +78 -0
  87. data/node_modules/bulma/sass/utilities/mixins.sass +280 -0
  88. data/node_modules/bulma-block-list/LICENSE.txt +21 -0
  89. data/node_modules/bulma-block-list/README.md +32 -0
  90. data/node_modules/bulma-block-list/node_modules/bulma/CHANGELOG.md +1390 -0
  91. data/node_modules/bulma-block-list/node_modules/bulma/LICENSE +21 -0
  92. data/node_modules/bulma-block-list/node_modules/bulma/README.md +130 -0
  93. data/node_modules/bulma-block-list/node_modules/bulma/bulma.sass +9 -0
  94. data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.css +10855 -0
  95. data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.css.map +1 -0
  96. data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.min.css +1 -0
  97. data/node_modules/bulma-block-list/node_modules/bulma/package.json +80 -0
  98. data/node_modules/bulma-block-list/node_modules/bulma/sass/base/_all.sass +5 -0
  99. data/node_modules/bulma-block-list/node_modules/bulma/sass/base/generic.sass +142 -0
  100. data/node_modules/bulma-block-list/node_modules/bulma/sass/base/helpers.sass +281 -0
  101. data/node_modules/bulma-block-list/node_modules/bulma/sass/base/minireset.sass +79 -0
  102. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/_all.sass +15 -0
  103. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/breadcrumb.sass +75 -0
  104. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/card.sass +79 -0
  105. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/dropdown.sass +81 -0
  106. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/level.sass +77 -0
  107. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/list.sass +39 -0
  108. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/media.sass +50 -0
  109. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/menu.sass +57 -0
  110. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/message.sass +99 -0
  111. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/modal.sass +113 -0
  112. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/navbar.sass +441 -0
  113. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/pagination.sass +150 -0
  114. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/panel.sass +119 -0
  115. data/node_modules/bulma-block-list/node_modules/bulma/sass/components/tabs.sass +151 -0
  116. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/_all.sass +15 -0
  117. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/box.sass +24 -0
  118. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/button.sass +323 -0
  119. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/container.sass +24 -0
  120. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/content.sass +155 -0
  121. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/form.sass +1 -0
  122. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/icon.sass +21 -0
  123. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/image.sass +71 -0
  124. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/notification.sass +43 -0
  125. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/other.sass +39 -0
  126. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/progress.sass +67 -0
  127. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/table.sass +127 -0
  128. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/tag.sass +128 -0
  129. data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/title.sass +70 -0
  130. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/_all.sass +8 -0
  131. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/checkbox-radio.sass +21 -0
  132. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/file.sass +180 -0
  133. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/input-textarea.sass +64 -0
  134. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/select.sass +85 -0
  135. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/shared.sass +55 -0
  136. data/node_modules/bulma-block-list/node_modules/bulma/sass/form/tools.sass +205 -0
  137. data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/_all.sass +4 -0
  138. data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/columns.sass +504 -0
  139. data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/tiles.sass +34 -0
  140. data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/_all.sass +5 -0
  141. data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/footer.sass +9 -0
  142. data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/hero.sass +145 -0
  143. data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/section.sass +13 -0
  144. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/_all.sass +8 -0
  145. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/animations.sass +5 -0
  146. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/controls.sass +50 -0
  147. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/derived-variables.sass +106 -0
  148. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/functions.sass +110 -0
  149. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/initial-variables.sass +77 -0
  150. data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/mixins.sass +261 -0
  151. data/node_modules/bulma-block-list/package.json +59 -0
  152. data/node_modules/bulma-block-list/src/block-list.scss +109 -0
  153. data/node_modules/bulma-block-list/src/demo.scss +3 -0
  154. data/node_modules/bulma-carousel/CHANGELOG.md +307 -0
  155. data/node_modules/bulma-carousel/LICENSE +21 -0
  156. data/node_modules/bulma-carousel/README.md +13 -0
  157. data/node_modules/bulma-carousel/dist/css/bulma-carousel.min.css +1 -0
  158. data/node_modules/bulma-carousel/dist/js/bulma-carousel.js +2371 -0
  159. data/node_modules/bulma-carousel/package.json +108 -0
  160. data/node_modules/bulma-carousel/src/demo/_data/events.yml +15 -0
  161. data/node_modules/bulma-carousel/src/demo/_data/getters.yml +26 -0
  162. data/node_modules/bulma-carousel/src/demo/_data/menu.yml +26 -0
  163. data/node_modules/bulma-carousel/src/demo/_data/methods.yml +57 -0
  164. data/node_modules/bulma-carousel/src/demo/_data/options.yml +79 -0
  165. data/node_modules/bulma-carousel/src/demo/_data/setters.yml +0 -0
  166. data/node_modules/bulma-carousel/src/demo/_data/tree.yml +30 -0
  167. data/node_modules/bulma-carousel/src/demo/_includes/anchor.html +3 -0
  168. data/node_modules/bulma-carousel/src/demo/_includes/breadcrumb.html +5 -0
  169. data/node_modules/bulma-carousel/src/demo/_includes/events.html +33 -0
  170. data/node_modules/bulma-carousel/src/demo/_includes/getters.html +28 -0
  171. data/node_modules/bulma-carousel/src/demo/_includes/head.html +22 -0
  172. data/node_modules/bulma-carousel/src/demo/_includes/menu.html +22 -0
  173. data/node_modules/bulma-carousel/src/demo/_includes/methods.html +49 -0
  174. data/node_modules/bulma-carousel/src/demo/_includes/options.html +33 -0
  175. data/node_modules/bulma-carousel/src/demo/_includes/setters.html +28 -0
  176. data/node_modules/bulma-carousel/src/demo/_includes/tree.html +25 -0
  177. data/node_modules/bulma-carousel/src/demo/_includes/variables.html +28 -0
  178. data/node_modules/bulma-carousel/src/demo/_layouts/default.html +47 -0
  179. data/node_modules/bulma-carousel/src/demo/assets/css/bulma-carousel.min.css +1 -0
  180. data/node_modules/bulma-carousel/src/demo/assets/css/documentation.min.css +1 -0
  181. data/node_modules/bulma-carousel/src/demo/assets/css/highlight.css +78 -0
  182. data/node_modules/bulma-carousel/src/demo/assets/images/1.jpg +0 -0
  183. data/node_modules/bulma-carousel/src/demo/assets/images/2.jpg +0 -0
  184. data/node_modules/bulma-carousel/src/demo/assets/images/3.jpg +0 -0
  185. data/node_modules/bulma-carousel/src/demo/assets/images/4.jpg +0 -0
  186. data/node_modules/bulma-carousel/src/demo/assets/images/5.jpg +0 -0
  187. data/node_modules/bulma-carousel/src/demo/assets/images/6.jpg +0 -0
  188. data/node_modules/bulma-carousel/src/demo/assets/images/left.svg +3 -0
  189. data/node_modules/bulma-carousel/src/demo/assets/images/right.svg +3 -0
  190. data/node_modules/bulma-carousel/src/demo/assets/js/bulma-carousel.min.js +1 -0
  191. data/node_modules/bulma-carousel/src/demo/assets/js/doc.js +111 -0
  192. data/node_modules/bulma-carousel/src/demo/assets/js/main.js +23 -0
  193. data/node_modules/bulma-carousel/src/demo/changelog.html +17 -0
  194. data/node_modules/bulma-carousel/src/demo/customization.html +78 -0
  195. data/node_modules/bulma-carousel/src/demo/demonstration/index.html +402 -0
  196. data/node_modules/bulma-carousel/src/demo/index.html +396 -0
  197. data/node_modules/bulma-carousel/src/js/components/Media.js +129 -0
  198. data/node_modules/bulma-carousel/src/js/components/autoplay.js +111 -0
  199. data/node_modules/bulma-carousel/src/js/components/breakpoint.js +91 -0
  200. data/node_modules/bulma-carousel/src/js/components/infinite.js +60 -0
  201. data/node_modules/bulma-carousel/src/js/components/loop.js +35 -0
  202. data/node_modules/bulma-carousel/src/js/components/navigation.js +107 -0
  203. data/node_modules/bulma-carousel/src/js/components/pagination.js +103 -0
  204. data/node_modules/bulma-carousel/src/js/components/swipe.js +106 -0
  205. data/node_modules/bulma-carousel/src/js/components/transitioner.js +74 -0
  206. data/node_modules/bulma-carousel/src/js/components/transitions/fade.js +90 -0
  207. data/node_modules/bulma-carousel/src/js/components/transitions/translate.js +98 -0
  208. data/node_modules/bulma-carousel/src/js/defaultOptions.js +50 -0
  209. data/node_modules/bulma-carousel/src/js/index.js +428 -0
  210. data/node_modules/bulma-carousel/src/js/templates/index.js +5 -0
  211. data/node_modules/bulma-carousel/src/js/templates/item.js +3 -0
  212. data/node_modules/bulma-carousel/src/js/templates/navigation.js +4 -0
  213. data/node_modules/bulma-carousel/src/js/templates/pagination-page.js +3 -0
  214. data/node_modules/bulma-carousel/src/js/templates/pagination.js +3 -0
  215. data/node_modules/bulma-carousel/src/js/utils/coordinate.js +98 -0
  216. data/node_modules/bulma-carousel/src/js/utils/css.js +84 -0
  217. data/node_modules/bulma-carousel/src/js/utils/detect-prefixes.js +50 -0
  218. data/node_modules/bulma-carousel/src/js/utils/detect-supportsPassive.js +16 -0
  219. data/node_modules/bulma-carousel/src/js/utils/device.js +17 -0
  220. data/node_modules/bulma-carousel/src/js/utils/dom.js +10 -0
  221. data/node_modules/bulma-carousel/src/js/utils/eventEmitter.js +19 -0
  222. data/node_modules/bulma-carousel/src/js/utils/events.js +65 -0
  223. data/node_modules/bulma-carousel/src/js/utils/index.js +16 -0
  224. data/node_modules/bulma-carousel/src/js/utils/type.js +21 -0
  225. data/node_modules/bulma-carousel/src/sass/index.sass +145 -0
  226. data/package-lock.json +32 -0
  227. data/package.json +10 -0
  228. metadata +222 -4
  229. data/_config.yml +0 -72
  230. data/assets/img/arrow.png +0 -0
@@ -0,0 +1,98 @@
1
+ import Coordinate from '../../utils/coordinate';
2
+ import {
3
+ height,
4
+ width
5
+ } from '../../utils/css';
6
+
7
+ export default class Translate {
8
+ constructor(transitioner, slider, options = {}) {
9
+ this.transitioner = transitioner;
10
+ this.slider = slider;
11
+ this.options = {
12
+ ...options
13
+ };
14
+
15
+ this.onTransitionEnd = this.onTransitionEnd.bind(this);
16
+ }
17
+
18
+ init() {
19
+ this._position = new Coordinate(this.slider.container.offsetLeft, this.slider.container.offsetTop);
20
+ this._bindEvents();
21
+ return this;
22
+ }
23
+
24
+ destroy() {
25
+ this._unbindEvents();
26
+ }
27
+
28
+ _bindEvents() {
29
+ this.slider.container.addEventListener('transitionend', this.onTransitionEnd);
30
+ }
31
+
32
+ _unbindEvents() {
33
+ this.slider.container.removeEventListener('transitionend', this.onTransitionEnd);
34
+ }
35
+
36
+ enable() {
37
+ this.slider.container.style.transition = `${this.options.duration}ms ${this.options.timing}`;
38
+ }
39
+
40
+ disable() {
41
+ this.slider.container.style.transition = 'none';
42
+ }
43
+
44
+ apply() {
45
+ let maxOffset;
46
+ if (this.options.effect === 'translate') {
47
+ const slide = this.slider.slides.filter(slide => slide.dataset.sliderIndex == this.slider.state.next)[0];
48
+ const slideOffset = new Coordinate(slide.offsetLeft, slide.offsetTop);
49
+ if (this.options.centerMode) {
50
+ maxOffset = new Coordinate(Math.round(width(this.slider.container)), Math.round(height(this.slider.container)));
51
+ } else {
52
+ maxOffset = new Coordinate(Math.round(width(this.slider.container) - width(this.slider.wrapper)), Math.round(height(this.slider.container) - height(this.slider.wrapper)));
53
+ }
54
+ const nextOffset = new Coordinate(Math.min(Math.max(slideOffset.x * -1, maxOffset.x * -1), 0), Math.min(Math.max(slideOffset.y * -1, maxOffset.y * -1), 0));
55
+ if (this.options.loop) {
56
+ if (!this.options.vertical && Math.abs(this._position.x) > maxOffset.x) {
57
+ nextOffset.x = 0;
58
+ this.slider.state.next = 0;
59
+ } else if (this.options.vertical && Math.abs(this._position.y) > maxOffset.y) {
60
+ nextOffset.y = 0;
61
+ this.slider.state.next = 0;
62
+ }
63
+ }
64
+
65
+ this._position.x = nextOffset.x;
66
+ this._position.y = nextOffset.y;
67
+ if (this.options.centerMode) {
68
+ this._position.x = this._position.x + (this.slider.wrapperWidth / 2) - (width(slide) / 2);
69
+ }
70
+
71
+ if (this.slider.direction === 'rtl') {
72
+ this._position.x = -this._position.x;
73
+ this._position.y = -this._position.y;
74
+ }
75
+ this.slider.container.style.transform = `translate3d(${this._position.x}px, ${this._position.y}px, 0)`;
76
+
77
+ /**
78
+ * update the index with the nextIndex only if
79
+ * the offset of the nextIndex is in the range of the maxOffset
80
+ */
81
+ if (slideOffset.x > maxOffset.x) {
82
+ this.slider.transitioner.end();
83
+ }
84
+ }
85
+ }
86
+
87
+ onTransitionEnd(e) {
88
+ if (this.options.effect === 'translate') {
89
+
90
+ if (this.transitioner.isAnimating() && e.target == this.slider.container) {
91
+ if (this.options.infinite) {
92
+ this.slider._infinite.onTransitionEnd(e);
93
+ }
94
+ }
95
+ this.transitioner.end();
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,50 @@
1
+ const defaultOptions = {
2
+ initialSlide: 0,
3
+ slidesToScroll: 1,
4
+ slidesToShow: 1,
5
+
6
+ navigation: true,
7
+ navigationKeys: true,
8
+ navigationSwipe: true,
9
+
10
+ pagination: true,
11
+
12
+ loop: false,
13
+ infinite: false,
14
+
15
+ effect: 'translate',
16
+ duration: 300,
17
+ timing: 'ease',
18
+
19
+ autoplay: false,
20
+ autoplaySpeed: 3000,
21
+ pauseOnHover: true,
22
+ breakpoints: [{
23
+ changePoint: 480,
24
+ slidesToShow: 1,
25
+ slidesToScroll: 1
26
+ },
27
+ {
28
+ changePoint: 640,
29
+ slidesToShow: 2,
30
+ slidesToScroll: 2
31
+ },
32
+ {
33
+ changePoint: 768,
34
+ slidesToShow: 3,
35
+ slidesToScroll: 3
36
+ }
37
+ ],
38
+
39
+ onReady: null,
40
+ icons: {
41
+ 'previous': `<svg viewBox="0 0 50 80" xml:space="preserve">
42
+ <polyline fill="currentColor" stroke-width=".5em" stroke-linecap="round" stroke-linejoin="round" points="45.63,75.8 0.375,38.087 45.63,0.375 "/>
43
+ </svg>`,
44
+ 'next': `<svg viewBox="0 0 50 80" xml:space="preserve">
45
+ <polyline fill="currentColor" stroke-width=".5em" stroke-linecap="round" stroke-linejoin="round" points="0.375,0.375 45.63,38.087 0.375,75.8 "/>
46
+ </svg>`
47
+ }
48
+ };
49
+
50
+ export default defaultOptions;
@@ -0,0 +1,428 @@
1
+ import {
2
+ uuid
3
+ } from './utils/index';
4
+ import {
5
+ removeClasses,
6
+ height,
7
+ width,
8
+ outerHeight
9
+ } from './utils/css';
10
+ import {
11
+ isString,
12
+ isFunction
13
+ } from './utils/type';
14
+ import EventEmitter from './utils/eventEmitter';
15
+
16
+ import Autoplay from './components/autoplay';
17
+ import Breakpoint from './components/breakpoint';
18
+ import Infinite from './components/infinite';
19
+ import Loop from './components/loop';
20
+ import Navigation from './components/navigation';
21
+ import Pagination from './components/pagination';
22
+ import Swipe from './components/swipe';
23
+ import Transitioner from './components/transitioner';
24
+
25
+ import defaultOptions from './defaultOptions';
26
+ import template from './templates';
27
+ import templateItem from './templates/item';
28
+
29
+ export default class bulmaCarousel extends EventEmitter {
30
+ constructor(selector, options = {}) {
31
+ super();
32
+
33
+ this.element = isString(selector) ? document.querySelector(selector) : selector;
34
+ // An invalid selector or non-DOM node has been provided.
35
+ if (!this.element) {
36
+ throw new Error('An invalid selector or non-DOM node has been provided.');
37
+ }
38
+ this._clickEvents = ['click', 'touch'];
39
+
40
+ // Use Element dataset values to override options
41
+ const elementConfig = this.element.dataset ? Object.keys(this.element.dataset)
42
+ .filter(key => Object.keys(defaultOptions).includes(key))
43
+ .reduce((obj, key) => {
44
+ return {
45
+ ...obj,
46
+ [key]: this.element.dataset[key]
47
+ };
48
+ }, {}) : {};
49
+ // Set default options - dataset attributes are master
50
+ this.options = {
51
+ ...defaultOptions,
52
+ ...options,
53
+ ...elementConfig
54
+ };
55
+
56
+ this._id = uuid('slider');
57
+
58
+ this.onShow = this.onShow.bind(this);
59
+
60
+ // Initiate plugin
61
+ this._init();
62
+ }
63
+
64
+ /**
65
+ * Initiate all DOM element containing datePicker class
66
+ * @method
67
+ * @return {Array} Array of all datePicker instances
68
+ */
69
+ static attach(selector = '.slider', options = {}) {
70
+ let instances = new Array();
71
+
72
+ const elements = isString(selector) ? document.querySelectorAll(selector) : Array.isArray(selector) ? selector : [selector];
73
+ [].forEach.call(elements, element => {
74
+ if (typeof element[this.constructor.name] === 'undefined') {
75
+ const instance = new bulmaCarousel(element, options);
76
+ element[this.constructor.name] = instance;
77
+ instances.push(instance);
78
+ } else {
79
+ instances.push(element[this.constructor.name]);
80
+ }
81
+ });
82
+
83
+ return instances;
84
+ }
85
+
86
+ /****************************************************
87
+ * *
88
+ * PRIVATE FUNCTIONS *
89
+ * *
90
+ ****************************************************/
91
+ /**
92
+ * Initiate plugin instance
93
+ * @method _init
94
+ * @return {Slider} Current plugin instance
95
+ */
96
+ _init() {
97
+ this._items = Array.from(this.element.children);
98
+
99
+ // Load plugins
100
+ this._breakpoint = new Breakpoint(this);
101
+ this._autoplay = new Autoplay(this);
102
+ this._navigation = new Navigation(this);
103
+ this._pagination = new Pagination(this);
104
+ this._infinite = new Infinite(this);
105
+ this._loop = new Loop(this);
106
+ this._swipe = new Swipe(this);
107
+
108
+ this._build();
109
+
110
+ if (isFunction(this.options.onReady)) {
111
+ this.options.onReady(this);
112
+ }
113
+
114
+ return this;
115
+ }
116
+
117
+ /**
118
+ * Build Slider HTML component and append it to the DOM
119
+ * @method _build
120
+ */
121
+ _build() {
122
+ // Generate HTML Fragment of template
123
+ this.node = document.createRange().createContextualFragment(template(this.id));
124
+ // Save pointers to template parts
125
+ this._ui = {
126
+ wrapper: this.node.firstChild,
127
+ container: this.node.querySelector('.slider-container')
128
+ }
129
+
130
+ // Add slider to DOM
131
+ this.element.appendChild(this.node);
132
+ this._ui.wrapper.classList.add('is-loading');
133
+ this._ui.container.style.opacity = 0;
134
+
135
+ this._transitioner = new Transitioner(this);
136
+
137
+ // Wrap all items by slide element
138
+ this._slides = this._items.map((item, index) => {
139
+ return this._createSlide(item, index);
140
+ });
141
+
142
+ this.reset();
143
+
144
+ this._bindEvents();
145
+
146
+ this._ui.container.style.opacity = 1;
147
+ this._ui.wrapper.classList.remove('is-loading');
148
+ }
149
+
150
+ /**
151
+ * Bind all events
152
+ * @method _bindEvents
153
+ * @return {void}
154
+ */
155
+ _bindEvents() {
156
+ this.on('show', this.onShow);
157
+ }
158
+
159
+ _unbindEvents() {
160
+ this.off('show', this.onShow);
161
+ }
162
+
163
+ _createSlide(item, index) {
164
+ const slide = document.createRange().createContextualFragment(templateItem()).firstChild;
165
+ slide.dataset.sliderIndex = index;
166
+ slide.appendChild(item);
167
+ return slide;
168
+ }
169
+
170
+ /**
171
+ * Calculate slider dimensions
172
+ */
173
+ _setDimensions() {
174
+ if (!this.options.vertical) {
175
+ if (this.options.centerMode) {
176
+ this._ui.wrapper.style.padding = '0px ' + this.options.centerPadding;
177
+ }
178
+ } else {
179
+ this._ui.wrapper.style.height = outerHeight(this._slides[0]) * this.slidesToShow;
180
+ if (this.options.centerMode) {
181
+ this._ui.wrapper.style.padding = this.options.centerPadding + ' 0px';
182
+ }
183
+ }
184
+
185
+ this._wrapperWidth = width(this._ui.wrapper);
186
+ this._wrapperHeight = outerHeight(this._ui.wrapper);
187
+
188
+ if (!this.options.vertical) {
189
+ this._slideWidth = Math.ceil(this._wrapperWidth / this.slidesToShow);
190
+ this._containerWidth = Math.ceil(this._slideWidth * this._slides.length);
191
+ this._ui.container.style.width = this._containerWidth + 'px';
192
+ } else {
193
+ this._slideWidth = Math.ceil(this._wrapperWidth);
194
+ this._containerHeight = Math.ceil((outerHeight(this._slides[0]) * this._slides.length));
195
+ this._ui.container.style.height = this._containerHeight + 'px';
196
+ }
197
+
198
+ this._slides.forEach(slide => {
199
+ slide.style.width = this._slideWidth + 'px';
200
+ });
201
+ }
202
+
203
+ _setHeight() {
204
+ if (this.options.effect !== 'translate') {
205
+ this._ui.container.style.height = outerHeight(this._slides[this.state.index]) + 'px';
206
+ }
207
+ }
208
+
209
+ // Update slides classes
210
+ _setClasses() {
211
+ this._slides.forEach(slide => {
212
+ removeClasses(slide, 'is-active is-current is-slide-previous is-slide-next');
213
+ if (Math.abs((this.state.index - 1) % this.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
214
+ slide.classList.add('is-slide-previous');
215
+ }
216
+ if (Math.abs(this.state.index % this.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
217
+ slide.classList.add('is-current');
218
+ }
219
+ if (Math.abs((this.state.index + 1) % this.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
220
+ slide.classList.add('is-slide-next');
221
+ }
222
+ });
223
+ }
224
+
225
+ /****************************************************
226
+ * *
227
+ * GETTERS and SETTERS *
228
+ * *
229
+ ****************************************************/
230
+
231
+ /**
232
+ * Get id of current datePicker
233
+ */
234
+ get id() {
235
+ return this._id;
236
+ }
237
+
238
+ set index(index) {
239
+ this._index = index;
240
+ }
241
+
242
+ get index() {
243
+ return this._index;
244
+ }
245
+
246
+ set length(length) {
247
+ this._length = length;
248
+ }
249
+
250
+ get length() {
251
+ return this._length;
252
+ }
253
+
254
+ get slides() {
255
+ return this._slides;
256
+ }
257
+
258
+ set slides(slides) {
259
+ this._slides = slides;
260
+ }
261
+
262
+ get slidesToScroll() {
263
+ return this.options.effect === 'translate' ? this._breakpoint.getSlidesToScroll() : 1;
264
+ }
265
+
266
+ get slidesToShow() {
267
+ return this.options.effect === 'translate' ? this._breakpoint.getSlidesToShow() : 1;
268
+ }
269
+
270
+ get direction() {
271
+ return (this.element.dir.toLowerCase() === 'rtl' || this.element.style.direction === 'rtl') ? 'rtl' : 'ltr';
272
+ }
273
+
274
+ get wrapper() {
275
+ return this._ui.wrapper;
276
+ }
277
+
278
+ get wrapperWidth() {
279
+ return this._wrapperWidth || 0;
280
+ }
281
+
282
+ get container() {
283
+ return this._ui.container;
284
+ }
285
+
286
+ get containerWidth() {
287
+ return this._containerWidth || 0;
288
+ }
289
+
290
+ get slideWidth() {
291
+ return this._slideWidth || 0;
292
+ }
293
+
294
+ get transitioner() {
295
+ return this._transitioner;
296
+ }
297
+
298
+
299
+ /****************************************************
300
+ * *
301
+ * EVENTS FUNCTIONS *
302
+ * *
303
+ ****************************************************/
304
+ onShow(e) {
305
+ this._navigation.refresh();
306
+ this._pagination.refresh();
307
+ this._setClasses();
308
+ }
309
+
310
+ /****************************************************
311
+ * *
312
+ * PUBLIC FUNCTIONS *
313
+ * *
314
+ ****************************************************/
315
+ next() {
316
+ if (!this.options.loop && !this.options.infinite && this.state.index + this.slidesToScroll > this.state.length - this.slidesToShow && !this.options.centerMode) {
317
+ this.state.next = this.state.index;
318
+ } else {
319
+ this.state.next = this.state.index + this.slidesToScroll;
320
+ }
321
+ this.show();
322
+ }
323
+
324
+ previous() {
325
+ if (!this.options.loop && !this.options.infinite && this.state.index === 0) {
326
+ this.state.next = this.state.index;
327
+ } else {
328
+ this.state.next = this.state.index - this.slidesToScroll;
329
+ }
330
+ this.show();
331
+ }
332
+
333
+ start() {
334
+ this._autoplay.start();
335
+ }
336
+
337
+ pause() {
338
+ this._autoplay.pause();
339
+ }
340
+
341
+ stop() {
342
+ this._autoplay.stop();
343
+ }
344
+
345
+ show(index, force = false) {
346
+ // If all slides are already visible then return
347
+ if (!this.state.length || this.state.length <= this.slidesToShow) {
348
+ return;
349
+ }
350
+
351
+ if (typeof index === 'number') {
352
+ this.state.next = index;
353
+ }
354
+
355
+ if (this.options.loop) {
356
+ this._loop.apply();
357
+ }
358
+ if (this.options.infinite) {
359
+ this._infinite.apply();
360
+ }
361
+
362
+ // If new slide is already the current one then return
363
+ if (this.state.index === this.state.next) {
364
+ return;
365
+ }
366
+
367
+ this.emit('before:show', this.state);
368
+ this._transitioner.apply(force, this._setHeight.bind(this));
369
+ this.emit('after:show', this.state);
370
+
371
+ this.emit('show', this);
372
+ }
373
+
374
+ reset() {
375
+ this.state = {
376
+ length: this._items.length,
377
+ index: Math.abs(this.options.initialSlide),
378
+ next: Math.abs(this.options.initialSlide),
379
+ prev: undefined
380
+ };
381
+
382
+ // Fix options
383
+ if (this.options.loop && this.options.infinite) {
384
+ this.options.loop = false;
385
+ }
386
+ if (this.options.slidesToScroll > this.options.slidesToShow) {
387
+ this.options.slidesToScroll = this.slidesToShow;
388
+ }
389
+ this._breakpoint.init();
390
+
391
+ if (this.state.index >= this.state.length && this.state.index !== 0) {
392
+ this.state.index = this.state.index - this.slidesToScroll;
393
+ }
394
+ if (this.state.length <= this.slidesToShow) {
395
+ this.state.index = 0;
396
+ }
397
+
398
+ this._ui.wrapper.appendChild(this._navigation.init().render());
399
+ this._ui.wrapper.appendChild(this._pagination.init().render());
400
+
401
+ if (this.options.navigationSwipe) {
402
+ this._swipe.bindEvents();
403
+ } else {
404
+ this._swipe._bindEvents();
405
+ }
406
+
407
+ this._breakpoint.apply();
408
+ // Move all created slides into slider
409
+ this._slides.forEach(slide => this._ui.container.appendChild(slide));
410
+ this._transitioner.init().apply(true, this._setHeight.bind(this));
411
+
412
+ if (this.options.autoplay) {
413
+ this._autoplay.init().start();
414
+ }
415
+ }
416
+
417
+ /**
418
+ * Destroy Slider
419
+ * @method destroy
420
+ */
421
+ destroy() {
422
+ this._unbindEvents();
423
+ this._items.forEach(item => {
424
+ this.element.appendChild(item);
425
+ });
426
+ this.node.remove();
427
+ }
428
+ }
@@ -0,0 +1,5 @@
1
+ export default (id) => {
2
+ return `<div id="${id}" class="slider" tabindex="0">
3
+ <div class="slider-container"></div>
4
+ </div>`;
5
+ };
@@ -0,0 +1,3 @@
1
+ export default () => {
2
+ return `<div class="slider-item"></div>`;
3
+ };
@@ -0,0 +1,4 @@
1
+ export default (icons) => {
2
+ return `<div class="slider-navigation-previous">${icons.previous}</div>
3
+ <div class="slider-navigation-next">${icons.next}</div>`;
4
+ };
@@ -0,0 +1,3 @@
1
+ export default () => {
2
+ return `<div class="slider-page"></div>`;
3
+ };
@@ -0,0 +1,3 @@
1
+ export default () => {
2
+ return `<div class="slider-pagination"></div>`;
3
+ };
@@ -0,0 +1,98 @@
1
+ export default class Coordinate {
2
+ constructor(x = 0, y = 0) {
3
+ this._x = x;
4
+ this._y = y;
5
+ }
6
+
7
+ get x() {
8
+ return this._x;
9
+ }
10
+
11
+ set x(value = 0) {
12
+ this._x = value;
13
+ return this;
14
+ }
15
+
16
+ get y() {
17
+ return this._y;
18
+ }
19
+
20
+ set y(value = 0) {
21
+ this._y = value;
22
+ return this;
23
+ }
24
+
25
+ add(coord) {
26
+ return new Coordinate(this._x + coord._x, this._y + coord._y);
27
+ }
28
+
29
+ sub(coord) {
30
+ return new Coordinate(this._x - coord._x, this._y - coord._y);
31
+ }
32
+
33
+ distance(coord) {
34
+ let deltaX = this._x - coord._x;
35
+ let deltaY = this._y - coord._y;
36
+
37
+ return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
38
+ }
39
+
40
+ max(coord) {
41
+ let x = Math.max(this._x, coord._x);
42
+ let y = Math.max(this._y, coord._y);
43
+
44
+ return new Coordinate(x, y);
45
+ }
46
+
47
+ equals(coord) {
48
+ if (this == coord) {
49
+ return true;
50
+ }
51
+ if (!coord || coord == null) {
52
+ return false;
53
+ }
54
+ return this._x == coord._x && this._y == coord._y;
55
+ }
56
+
57
+ inside(northwest, southeast) {
58
+ if ((this._x >= northwest._x) && (this._x <= southeast._x) &&
59
+ (this._y >= northwest._y) && (this._y <= southeast._y)) {
60
+
61
+ return true;
62
+ }
63
+ return false;
64
+ }
65
+
66
+ constrain(min, max) {
67
+ if (min._x > max._x || min._y > max._y) {
68
+ return this;
69
+ }
70
+
71
+ let x = this._x,
72
+ y = this._y;
73
+
74
+ if (min._x !== null) {
75
+ x = Math.max(x, min._x);
76
+ }
77
+ if (max._x !== null) {
78
+ x = Math.min(x, max._x);
79
+ }
80
+ if (min._y !== null) {
81
+ y = Math.max(y, min._y);
82
+ }
83
+ if (max._y !== null) {
84
+ y = Math.min(y, max._y);
85
+ }
86
+
87
+ return new Coordinate(x, y);
88
+ }
89
+
90
+ reposition(element) {
91
+ element.style['top'] = this._y + 'px';
92
+ element.style['left'] = this._x + 'px';
93
+ }
94
+
95
+ toString() {
96
+ return '(' + this._x + ',' + this._y + ')';
97
+ }
98
+ }