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.
- checksums.yaml +4 -4
- data/_includes/hero.html +5 -3
- data/_includes/introduction.html +1 -1
- data/_includes/story-slider.html +1 -1
- data/_layouts/404.html +7 -0
- data/_sass/_layout.scss +40 -11
- data/_sass/_main.scss +32 -11
- data/assets/img/404.png +0 -0
- data/assets/img/arrow-down.png +0 -0
- data/assets/img/arrow-left.png +0 -0
- data/assets/js/main.js +4 -1
- data/favicon.png +0 -0
- data/node_modules/bulma/CHANGELOG.md +1558 -0
- data/node_modules/bulma/LICENSE +21 -0
- data/node_modules/bulma/README.md +134 -0
- data/node_modules/bulma/bulma.sass +10 -0
- data/node_modules/bulma/css/bulma-rtl.css +11811 -0
- data/node_modules/bulma/css/bulma-rtl.css.map +1 -0
- data/node_modules/bulma/css/bulma-rtl.min.css +1 -0
- data/node_modules/bulma/css/bulma.css +11811 -0
- data/node_modules/bulma/css/bulma.css.map +1 -0
- data/node_modules/bulma/css/bulma.min.css +1 -0
- data/node_modules/bulma/package.json +82 -0
- data/node_modules/bulma/sass/base/_all.sass +6 -0
- data/node_modules/bulma/sass/base/animations.sass +5 -0
- data/node_modules/bulma/sass/base/generic.sass +145 -0
- data/node_modules/bulma/sass/base/helpers.sass +1 -0
- data/node_modules/bulma/sass/base/minireset.sass +79 -0
- data/node_modules/bulma/sass/components/_all.sass +15 -0
- data/node_modules/bulma/sass/components/breadcrumb.sass +77 -0
- data/node_modules/bulma/sass/components/card.sass +103 -0
- data/node_modules/bulma/sass/components/dropdown.sass +83 -0
- data/node_modules/bulma/sass/components/level.sass +79 -0
- data/node_modules/bulma/sass/components/media.sass +59 -0
- data/node_modules/bulma/sass/components/menu.sass +59 -0
- data/node_modules/bulma/sass/components/message.sass +101 -0
- data/node_modules/bulma/sass/components/modal.sass +117 -0
- data/node_modules/bulma/sass/components/navbar.sass +446 -0
- data/node_modules/bulma/sass/components/pagination.sass +166 -0
- data/node_modules/bulma/sass/components/panel.sass +121 -0
- data/node_modules/bulma/sass/components/tabs.sass +176 -0
- data/node_modules/bulma/sass/elements/_all.sass +16 -0
- data/node_modules/bulma/sass/elements/box.sass +26 -0
- data/node_modules/bulma/sass/elements/button.sass +345 -0
- data/node_modules/bulma/sass/elements/container.sass +29 -0
- data/node_modules/bulma/sass/elements/content.sass +159 -0
- data/node_modules/bulma/sass/elements/form.sass +1 -0
- data/node_modules/bulma/sass/elements/icon.sass +46 -0
- data/node_modules/bulma/sass/elements/image.sass +73 -0
- data/node_modules/bulma/sass/elements/notification.sass +52 -0
- data/node_modules/bulma/sass/elements/other.sass +31 -0
- data/node_modules/bulma/sass/elements/progress.sass +73 -0
- data/node_modules/bulma/sass/elements/table.sass +133 -0
- data/node_modules/bulma/sass/elements/tag.sass +140 -0
- data/node_modules/bulma/sass/elements/title.sass +70 -0
- data/node_modules/bulma/sass/form/_all.sass +9 -0
- data/node_modules/bulma/sass/form/checkbox-radio.sass +22 -0
- data/node_modules/bulma/sass/form/file.sass +184 -0
- data/node_modules/bulma/sass/form/input-textarea.sass +66 -0
- data/node_modules/bulma/sass/form/select.sass +87 -0
- data/node_modules/bulma/sass/form/shared.sass +60 -0
- data/node_modules/bulma/sass/form/tools.sass +215 -0
- data/node_modules/bulma/sass/grid/_all.sass +5 -0
- data/node_modules/bulma/sass/grid/columns.sass +513 -0
- data/node_modules/bulma/sass/grid/tiles.sass +36 -0
- data/node_modules/bulma/sass/helpers/_all.sass +12 -0
- data/node_modules/bulma/sass/helpers/color.sass +39 -0
- data/node_modules/bulma/sass/helpers/flexbox.sass +35 -0
- data/node_modules/bulma/sass/helpers/float.sass +10 -0
- data/node_modules/bulma/sass/helpers/other.sass +14 -0
- data/node_modules/bulma/sass/helpers/overflow.sass +2 -0
- data/node_modules/bulma/sass/helpers/position.sass +7 -0
- data/node_modules/bulma/sass/helpers/spacing.sass +31 -0
- data/node_modules/bulma/sass/helpers/typography.sass +103 -0
- data/node_modules/bulma/sass/helpers/visibility.sass +122 -0
- data/node_modules/bulma/sass/layout/_all.sass +6 -0
- data/node_modules/bulma/sass/layout/footer.sass +11 -0
- data/node_modules/bulma/sass/layout/hero.sass +153 -0
- data/node_modules/bulma/sass/layout/section.sass +17 -0
- data/node_modules/bulma/sass/utilities/_all.sass +9 -0
- data/node_modules/bulma/sass/utilities/animations.sass +1 -0
- data/node_modules/bulma/sass/utilities/controls.sass +49 -0
- data/node_modules/bulma/sass/utilities/derived-variables.sass +114 -0
- data/node_modules/bulma/sass/utilities/extends.sass +25 -0
- data/node_modules/bulma/sass/utilities/functions.sass +136 -0
- data/node_modules/bulma/sass/utilities/initial-variables.sass +78 -0
- data/node_modules/bulma/sass/utilities/mixins.sass +280 -0
- data/node_modules/bulma-block-list/LICENSE.txt +21 -0
- data/node_modules/bulma-block-list/README.md +32 -0
- data/node_modules/bulma-block-list/node_modules/bulma/CHANGELOG.md +1390 -0
- data/node_modules/bulma-block-list/node_modules/bulma/LICENSE +21 -0
- data/node_modules/bulma-block-list/node_modules/bulma/README.md +130 -0
- data/node_modules/bulma-block-list/node_modules/bulma/bulma.sass +9 -0
- data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.css +10855 -0
- data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.css.map +1 -0
- data/node_modules/bulma-block-list/node_modules/bulma/css/bulma.min.css +1 -0
- data/node_modules/bulma-block-list/node_modules/bulma/package.json +80 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/base/_all.sass +5 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/base/generic.sass +142 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/base/helpers.sass +281 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/base/minireset.sass +79 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/_all.sass +15 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/breadcrumb.sass +75 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/card.sass +79 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/dropdown.sass +81 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/level.sass +77 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/list.sass +39 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/media.sass +50 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/menu.sass +57 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/message.sass +99 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/modal.sass +113 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/navbar.sass +441 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/pagination.sass +150 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/panel.sass +119 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/components/tabs.sass +151 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/_all.sass +15 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/box.sass +24 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/button.sass +323 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/container.sass +24 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/content.sass +155 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/form.sass +1 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/icon.sass +21 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/image.sass +71 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/notification.sass +43 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/other.sass +39 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/progress.sass +67 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/table.sass +127 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/tag.sass +128 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/elements/title.sass +70 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/_all.sass +8 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/checkbox-radio.sass +21 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/file.sass +180 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/input-textarea.sass +64 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/select.sass +85 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/shared.sass +55 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/form/tools.sass +205 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/_all.sass +4 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/columns.sass +504 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/grid/tiles.sass +34 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/_all.sass +5 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/footer.sass +9 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/hero.sass +145 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/layout/section.sass +13 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/_all.sass +8 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/animations.sass +5 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/controls.sass +50 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/derived-variables.sass +106 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/functions.sass +110 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/initial-variables.sass +77 -0
- data/node_modules/bulma-block-list/node_modules/bulma/sass/utilities/mixins.sass +261 -0
- data/node_modules/bulma-block-list/package.json +59 -0
- data/node_modules/bulma-block-list/src/block-list.scss +109 -0
- data/node_modules/bulma-block-list/src/demo.scss +3 -0
- data/node_modules/bulma-carousel/CHANGELOG.md +307 -0
- data/node_modules/bulma-carousel/LICENSE +21 -0
- data/node_modules/bulma-carousel/README.md +13 -0
- data/node_modules/bulma-carousel/dist/css/bulma-carousel.min.css +1 -0
- data/node_modules/bulma-carousel/dist/js/bulma-carousel.js +2371 -0
- data/node_modules/bulma-carousel/package.json +108 -0
- data/node_modules/bulma-carousel/src/demo/_data/events.yml +15 -0
- data/node_modules/bulma-carousel/src/demo/_data/getters.yml +26 -0
- data/node_modules/bulma-carousel/src/demo/_data/menu.yml +26 -0
- data/node_modules/bulma-carousel/src/demo/_data/methods.yml +57 -0
- data/node_modules/bulma-carousel/src/demo/_data/options.yml +79 -0
- data/node_modules/bulma-carousel/src/demo/_data/setters.yml +0 -0
- data/node_modules/bulma-carousel/src/demo/_data/tree.yml +30 -0
- data/node_modules/bulma-carousel/src/demo/_includes/anchor.html +3 -0
- data/node_modules/bulma-carousel/src/demo/_includes/breadcrumb.html +5 -0
- data/node_modules/bulma-carousel/src/demo/_includes/events.html +33 -0
- data/node_modules/bulma-carousel/src/demo/_includes/getters.html +28 -0
- data/node_modules/bulma-carousel/src/demo/_includes/head.html +22 -0
- data/node_modules/bulma-carousel/src/demo/_includes/menu.html +22 -0
- data/node_modules/bulma-carousel/src/demo/_includes/methods.html +49 -0
- data/node_modules/bulma-carousel/src/demo/_includes/options.html +33 -0
- data/node_modules/bulma-carousel/src/demo/_includes/setters.html +28 -0
- data/node_modules/bulma-carousel/src/demo/_includes/tree.html +25 -0
- data/node_modules/bulma-carousel/src/demo/_includes/variables.html +28 -0
- data/node_modules/bulma-carousel/src/demo/_layouts/default.html +47 -0
- data/node_modules/bulma-carousel/src/demo/assets/css/bulma-carousel.min.css +1 -0
- data/node_modules/bulma-carousel/src/demo/assets/css/documentation.min.css +1 -0
- data/node_modules/bulma-carousel/src/demo/assets/css/highlight.css +78 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/1.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/2.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/3.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/4.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/5.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/6.jpg +0 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/left.svg +3 -0
- data/node_modules/bulma-carousel/src/demo/assets/images/right.svg +3 -0
- data/node_modules/bulma-carousel/src/demo/assets/js/bulma-carousel.min.js +1 -0
- data/node_modules/bulma-carousel/src/demo/assets/js/doc.js +111 -0
- data/node_modules/bulma-carousel/src/demo/assets/js/main.js +23 -0
- data/node_modules/bulma-carousel/src/demo/changelog.html +17 -0
- data/node_modules/bulma-carousel/src/demo/customization.html +78 -0
- data/node_modules/bulma-carousel/src/demo/demonstration/index.html +402 -0
- data/node_modules/bulma-carousel/src/demo/index.html +396 -0
- data/node_modules/bulma-carousel/src/js/components/Media.js +129 -0
- data/node_modules/bulma-carousel/src/js/components/autoplay.js +111 -0
- data/node_modules/bulma-carousel/src/js/components/breakpoint.js +91 -0
- data/node_modules/bulma-carousel/src/js/components/infinite.js +60 -0
- data/node_modules/bulma-carousel/src/js/components/loop.js +35 -0
- data/node_modules/bulma-carousel/src/js/components/navigation.js +107 -0
- data/node_modules/bulma-carousel/src/js/components/pagination.js +103 -0
- data/node_modules/bulma-carousel/src/js/components/swipe.js +106 -0
- data/node_modules/bulma-carousel/src/js/components/transitioner.js +74 -0
- data/node_modules/bulma-carousel/src/js/components/transitions/fade.js +90 -0
- data/node_modules/bulma-carousel/src/js/components/transitions/translate.js +98 -0
- data/node_modules/bulma-carousel/src/js/defaultOptions.js +50 -0
- data/node_modules/bulma-carousel/src/js/index.js +428 -0
- data/node_modules/bulma-carousel/src/js/templates/index.js +5 -0
- data/node_modules/bulma-carousel/src/js/templates/item.js +3 -0
- data/node_modules/bulma-carousel/src/js/templates/navigation.js +4 -0
- data/node_modules/bulma-carousel/src/js/templates/pagination-page.js +3 -0
- data/node_modules/bulma-carousel/src/js/templates/pagination.js +3 -0
- data/node_modules/bulma-carousel/src/js/utils/coordinate.js +98 -0
- data/node_modules/bulma-carousel/src/js/utils/css.js +84 -0
- data/node_modules/bulma-carousel/src/js/utils/detect-prefixes.js +50 -0
- data/node_modules/bulma-carousel/src/js/utils/detect-supportsPassive.js +16 -0
- data/node_modules/bulma-carousel/src/js/utils/device.js +17 -0
- data/node_modules/bulma-carousel/src/js/utils/dom.js +10 -0
- data/node_modules/bulma-carousel/src/js/utils/eventEmitter.js +19 -0
- data/node_modules/bulma-carousel/src/js/utils/events.js +65 -0
- data/node_modules/bulma-carousel/src/js/utils/index.js +16 -0
- data/node_modules/bulma-carousel/src/js/utils/type.js +21 -0
- data/node_modules/bulma-carousel/src/sass/index.sass +145 -0
- data/package-lock.json +32 -0
- data/package.json +10 -0
- metadata +222 -4
- data/_config.yml +0 -72
- 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,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
|
+
}
|