-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulma-carousel.js
2371 lines (2006 loc) · 80.9 KB
/
bulma-carousel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["bulmaCarousel"] = factory();
else
root["bulmaCarousel"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export addClasses */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return removeClasses; });
/* unused harmony export show */
/* unused harmony export hide */
/* unused harmony export offset */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return width; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return height; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return outerHeight; });
/* unused harmony export outerWidth */
/* unused harmony export position */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return css; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__type__ = __webpack_require__(2);
var addClasses = function addClasses(element, classes) {
classes = Array.isArray(classes) ? classes : classes.split(' ');
classes.forEach(function (cls) {
element.classList.add(cls);
});
};
var removeClasses = function removeClasses(element, classes) {
classes = Array.isArray(classes) ? classes : classes.split(' ');
classes.forEach(function (cls) {
element.classList.remove(cls);
});
};
var show = function show(elements) {
elements = Array.isArray(elements) ? elements : [elements];
elements.forEach(function (element) {
element.style.display = '';
});
};
var hide = function hide(elements) {
elements = Array.isArray(elements) ? elements : [elements];
elements.forEach(function (element) {
element.style.display = 'none';
});
};
var offset = function offset(element) {
var rect = element.getBoundingClientRect();
return {
top: rect.top + document.body.scrollTop,
left: rect.left + document.body.scrollLeft
};
};
// returns an element's width
var width = function width(element) {
return element.getBoundingClientRect().width || element.offsetWidth;
};
// returns an element's height
var height = function height(element) {
return element.getBoundingClientRect().height || element.offsetHeight;
};
var outerHeight = function outerHeight(element) {
var withMargin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var height = element.offsetHeight;
if (withMargin) {
var style = window.getComputedStyle(element);
height += parseInt(style.marginTop) + parseInt(style.marginBottom);
}
return height;
};
var outerWidth = function outerWidth(element) {
var withMargin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var width = element.offsetWidth;
if (withMargin) {
var style = window.getComputedStyle(element);
width += parseInt(style.marginLeft) + parseInt(style.marginRight);
}
return width;
};
var position = function position(element) {
return {
left: element.offsetLeft,
top: element.offsetTop
};
};
var css = function css(element, obj) {
if (!obj) {
return window.getComputedStyle(element);
}
if (Object(__WEBPACK_IMPORTED_MODULE_0__type__["b" /* isObject */])(obj)) {
var style = '';
Object.keys(obj).forEach(function (key) {
style += key + ': ' + obj[key] + ';';
});
element.style.cssText += style;
}
};
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = detectSupportsPassive;
function detectSupportsPassive() {
var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});
window.addEventListener('testPassive', null, opts);
window.removeEventListener('testPassive', null, opts);
} catch (e) {}
return supportsPassive;
}
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isFunction; });
/* unused harmony export isNumber */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isString; });
/* unused harmony export isDate */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isObject; });
/* unused harmony export isEmptyObject */
/* unused harmony export isNode */
/* unused harmony export isVideo */
/* unused harmony export isHTML5 */
/* unused harmony export isIFrame */
/* unused harmony export isYoutube */
/* unused harmony export isVimeo */
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var isFunction = function isFunction(unknown) {
return typeof unknown === 'function';
};
var isNumber = function isNumber(unknown) {
return typeof unknown === "number";
};
var isString = function isString(unknown) {
return typeof unknown === 'string' || !!unknown && (typeof unknown === 'undefined' ? 'undefined' : _typeof(unknown)) === 'object' && Object.prototype.toString.call(unknown) === '[object String]';
};
var isDate = function isDate(unknown) {
return (Object.prototype.toString.call(unknown) === '[object Date]' || unknown instanceof Date) && !isNaN(unknown.valueOf());
};
var isObject = function isObject(unknown) {
return (typeof unknown === 'function' || (typeof unknown === 'undefined' ? 'undefined' : _typeof(unknown)) === 'object' && !!unknown) && !Array.isArray(unknown);
};
var isEmptyObject = function isEmptyObject(unknown) {
for (var name in unknown) {
if (unknown.hasOwnProperty(name)) {
return false;
}
}
return true;
};
var isNode = function isNode(unknown) {
return !!(unknown && unknown.nodeType === HTMLElement | SVGElement);
};
var isVideo = function isVideo(unknown) {
return isYoutube(unknown) || isVimeo(unknown) || isHTML5(unknown);
};
var isHTML5 = function isHTML5(unknown) {
return isNode(unknown) && unknown.tagName === 'VIDEO';
};
var isIFrame = function isIFrame(unknown) {
return isNode(unknown) && unknown.tagName === 'IFRAME';
};
var isYoutube = function isYoutube(unknown) {
return isIFrame(unknown) && !!unknown.src.match(/\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/);
};
var isVimeo = function isVimeo(unknown) {
return isIFrame(unknown) && !!unknown.src.match(/vimeo\.com\/video\/.*/);
};
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var EventEmitter = function () {
function EventEmitter() {
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, EventEmitter);
this.events = new Map(events);
}
_createClass(EventEmitter, [{
key: "on",
value: function on(name, cb) {
var _this = this;
this.events.set(name, [].concat(_toConsumableArray(this.events.has(name) ? this.events.get(name) : []), [cb]));
return function () {
return _this.events.set(name, _this.events.get(name).filter(function (fn) {
return fn !== cb;
}));
};
}
}, {
key: "emit",
value: function emit(name) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return this.events.has(name) && this.events.get(name).map(function (fn) {
return fn.apply(undefined, args);
});
}
}]);
return EventEmitter;
}();
/* harmony default export */ __webpack_exports__["a"] = (EventEmitter);
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Coordinate = function () {
function Coordinate() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
_classCallCheck(this, Coordinate);
this._x = x;
this._y = y;
}
_createClass(Coordinate, [{
key: 'add',
value: function add(coord) {
return new Coordinate(this._x + coord._x, this._y + coord._y);
}
}, {
key: 'sub',
value: function sub(coord) {
return new Coordinate(this._x - coord._x, this._y - coord._y);
}
}, {
key: 'distance',
value: function distance(coord) {
var deltaX = this._x - coord._x;
var deltaY = this._y - coord._y;
return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
}
}, {
key: 'max',
value: function max(coord) {
var x = Math.max(this._x, coord._x);
var y = Math.max(this._y, coord._y);
return new Coordinate(x, y);
}
}, {
key: 'equals',
value: function equals(coord) {
if (this == coord) {
return true;
}
if (!coord || coord == null) {
return false;
}
return this._x == coord._x && this._y == coord._y;
}
}, {
key: 'inside',
value: function inside(northwest, southeast) {
if (this._x >= northwest._x && this._x <= southeast._x && this._y >= northwest._y && this._y <= southeast._y) {
return true;
}
return false;
}
}, {
key: 'constrain',
value: function constrain(min, max) {
if (min._x > max._x || min._y > max._y) {
return this;
}
var x = this._x,
y = this._y;
if (min._x !== null) {
x = Math.max(x, min._x);
}
if (max._x !== null) {
x = Math.min(x, max._x);
}
if (min._y !== null) {
y = Math.max(y, min._y);
}
if (max._y !== null) {
y = Math.min(y, max._y);
}
return new Coordinate(x, y);
}
}, {
key: 'reposition',
value: function reposition(element) {
element.style['top'] = this._y + 'px';
element.style['left'] = this._x + 'px';
}
}, {
key: 'toString',
value: function toString() {
return '(' + this._x + ',' + this._y + ')';
}
}, {
key: 'x',
get: function get() {
return this._x;
},
set: function set() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this._x = value;
return this;
}
}, {
key: 'y',
get: function get() {
return this._y;
},
set: function set() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this._y = value;
return this;
}
}]);
return Coordinate;
}();
/* harmony default export */ __webpack_exports__["a"] = (Coordinate);
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_index__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_css__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_type__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_eventEmitter__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_autoplay__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_breakpoint__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_infinite__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__components_loop__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_navigation__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_pagination__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_swipe__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_transitioner__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__defaultOptions__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__templates__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__templates_item__ = __webpack_require__(24);
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var bulmaCarousel = function (_EventEmitter) {
_inherits(bulmaCarousel, _EventEmitter);
function bulmaCarousel(selector) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, bulmaCarousel);
var _this = _possibleConstructorReturn(this, (bulmaCarousel.__proto__ || Object.getPrototypeOf(bulmaCarousel)).call(this));
_this.element = Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["c" /* isString */])(selector) ? document.querySelector(selector) : selector;
// An invalid selector or non-DOM node has been provided.
if (!_this.element) {
throw new Error('An invalid selector or non-DOM node has been provided.');
}
_this._clickEvents = ['click', 'touch'];
// Use Element dataset values to override options
var elementConfig = _this.element.dataset ? Object.keys(_this.element.dataset).filter(function (key) {
return Object.keys(__WEBPACK_IMPORTED_MODULE_12__defaultOptions__["a" /* default */]).includes(key);
}).reduce(function (obj, key) {
return _extends({}, obj, _defineProperty({}, key, _this.element.dataset[key]));
}, {}) : {};
// Set default options - dataset attributes are master
_this.options = _extends({}, __WEBPACK_IMPORTED_MODULE_12__defaultOptions__["a" /* default */], options, elementConfig);
_this._id = Object(__WEBPACK_IMPORTED_MODULE_0__utils_index__["a" /* uuid */])('slider');
_this.onShow = _this.onShow.bind(_this);
// Initiate plugin
_this._init();
return _this;
}
/**
* Initiate all DOM element containing datePicker class
* @method
* @return {Array} Array of all datePicker instances
*/
_createClass(bulmaCarousel, [{
key: '_init',
/****************************************************
* *
* PRIVATE FUNCTIONS *
* *
****************************************************/
/**
* Initiate plugin instance
* @method _init
* @return {Slider} Current plugin instance
*/
value: function _init() {
this._items = Array.from(this.element.children);
// Load plugins
this._breakpoint = new __WEBPACK_IMPORTED_MODULE_5__components_breakpoint__["a" /* default */](this);
this._autoplay = new __WEBPACK_IMPORTED_MODULE_4__components_autoplay__["a" /* default */](this);
this._navigation = new __WEBPACK_IMPORTED_MODULE_8__components_navigation__["a" /* default */](this);
this._pagination = new __WEBPACK_IMPORTED_MODULE_9__components_pagination__["a" /* default */](this);
this._infinite = new __WEBPACK_IMPORTED_MODULE_6__components_infinite__["a" /* default */](this);
this._loop = new __WEBPACK_IMPORTED_MODULE_7__components_loop__["a" /* default */](this);
this._swipe = new __WEBPACK_IMPORTED_MODULE_10__components_swipe__["a" /* default */](this);
this._build();
if (Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["a" /* isFunction */])(this.options.onReady)) {
this.options.onReady(this);
}
return this;
}
/**
* Build Slider HTML component and append it to the DOM
* @method _build
*/
}, {
key: '_build',
value: function _build() {
var _this2 = this;
// Generate HTML Fragment of template
this.node = document.createRange().createContextualFragment(Object(__WEBPACK_IMPORTED_MODULE_13__templates__["a" /* default */])(this.id));
// Save pointers to template parts
this._ui = {
wrapper: this.node.firstChild,
container: this.node.querySelector('.slider-container')
// Add slider to DOM
};this.element.appendChild(this.node);
this._ui.wrapper.classList.add('is-loading');
this._ui.container.style.opacity = 0;
this._transitioner = new __WEBPACK_IMPORTED_MODULE_11__components_transitioner__["a" /* default */](this);
// Wrap all items by slide element
this._slides = this._items.map(function (item, index) {
return _this2._createSlide(item, index);
});
this.reset();
this._bindEvents();
this._ui.container.style.opacity = 1;
this._ui.wrapper.classList.remove('is-loading');
}
/**
* Bind all events
* @method _bindEvents
* @return {void}
*/
}, {
key: '_bindEvents',
value: function _bindEvents() {
this.on('show', this.onShow);
}
}, {
key: '_unbindEvents',
value: function _unbindEvents() {
this.off('show', this.onShow);
}
}, {
key: '_createSlide',
value: function _createSlide(item, index) {
var slide = document.createRange().createContextualFragment(Object(__WEBPACK_IMPORTED_MODULE_14__templates_item__["a" /* default */])()).firstChild;
slide.dataset.sliderIndex = index;
slide.appendChild(item);
return slide;
}
/**
* Calculate slider dimensions
*/
}, {
key: '_setDimensions',
value: function _setDimensions() {
var _this3 = this;
if (!this.options.vertical) {
if (this.options.centerMode) {
this._ui.wrapper.style.padding = '0px ' + this.options.centerPadding;
}
} else {
this._ui.wrapper.style.height = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[0]) * this.slidesToShow;
if (this.options.centerMode) {
this._ui.wrapper.style.padding = this.options.centerPadding + ' 0px';
}
}
this._wrapperWidth = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["e" /* width */])(this._ui.wrapper);
this._wrapperHeight = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._ui.wrapper);
if (!this.options.vertical) {
this._slideWidth = Math.ceil(this._wrapperWidth / this.slidesToShow);
this._containerWidth = Math.ceil(this._slideWidth * this._slides.length);
this._ui.container.style.width = this._containerWidth + 'px';
} else {
this._slideWidth = Math.ceil(this._wrapperWidth);
this._containerHeight = Math.ceil(Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[0]) * this._slides.length);
this._ui.container.style.height = this._containerHeight + 'px';
}
this._slides.forEach(function (slide) {
slide.style.width = _this3._slideWidth + 'px';
});
}
}, {
key: '_setHeight',
value: function _setHeight() {
if (this.options.effect !== 'translate') {
this._ui.container.style.height = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[this.state.index]) + 'px';
}
}
// Update slides classes
}, {
key: '_setClasses',
value: function _setClasses() {
var _this4 = this;
this._slides.forEach(function (slide) {
Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["d" /* removeClasses */])(slide, 'is-active is-current is-slide-previous is-slide-next');
if (Math.abs((_this4.state.index - 1) % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-slide-previous');
}
if (Math.abs(_this4.state.index % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-current');
}
if (Math.abs((_this4.state.index + 1) % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-slide-next');
}
});
}
/****************************************************
* *
* GETTERS and SETTERS *
* *
****************************************************/
/**
* Get id of current datePicker
*/
}, {
key: 'onShow',
/****************************************************
* *
* EVENTS FUNCTIONS *
* *
****************************************************/
value: function onShow(e) {
this._navigation.refresh();
this._pagination.refresh();
this._setClasses();
}
/****************************************************
* *
* PUBLIC FUNCTIONS *
* *
****************************************************/
}, {
key: 'next',
value: function next() {
if (!this.options.loop && !this.options.infinite && this.state.index + this.slidesToScroll > this.state.length - this.slidesToShow && !this.options.centerMode) {
this.state.next = this.state.index;
} else {
this.state.next = this.state.index + this.slidesToScroll;
}
this.show();
}
}, {
key: 'previous',
value: function previous() {
if (!this.options.loop && !this.options.infinite && this.state.index === 0) {
this.state.next = this.state.index;
} else {
this.state.next = this.state.index - this.slidesToScroll;
}
this.show();
}
}, {
key: 'start',
value: function start() {
this._autoplay.start();
}
}, {
key: 'pause',
value: function pause() {
this._autoplay.pause();
}
}, {
key: 'stop',
value: function stop() {
this._autoplay.stop();
}
}, {
key: 'show',
value: function show(index) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// If all slides are already visible then return
if (!this.state.length || this.state.length <= this.slidesToShow) {
return;
}
if (typeof index === 'Number') {
this.state.next = index;
}
if (this.options.loop) {
this._loop.apply();
}
if (this.options.infinite) {
this._infinite.apply();
}
// If new slide is already the current one then return
if (this.state.index === this.state.next) {
return;
}
this.emit('before:show', this.state);
this._transitioner.apply(force, this._setHeight.bind(this));
this.emit('after:show', this.state);
this.emit('show', this);
}
}, {
key: 'reset',
value: function reset() {
var _this5 = this;
this.state = {
length: this._items.length,
index: Math.abs(this.options.initialSlide),
next: Math.abs(this.options.initialSlide),
prev: undefined
};
// Fix options
if (this.options.loop && this.options.infinite) {
this.options.loop = false;
}
if (this.options.slidesToScroll > this.options.slidesToShow) {
this.options.slidesToScroll = this.slidesToShow;
}
this._breakpoint.init();
if (this.state.index >= this.state.length && this.state.index !== 0) {
this.state.index = this.state.index - this.slidesToScroll;
}
if (this.state.length <= this.slidesToShow) {
this.state.index = 0;
}
this._ui.wrapper.appendChild(this._navigation.init().render());
this._ui.wrapper.appendChild(this._pagination.init().render());
if (this.options.navigationSwipe) {
this._swipe.bindEvents();
} else {
this._swipe._bindEvents();
}
this._breakpoint.apply();
// Move all created slides into slider
this._slides.forEach(function (slide) {
return _this5._ui.container.appendChild(slide);
});
this._transitioner.init().apply(true, this._setHeight.bind(this));
if (this.options.autoplay) {
this._autoplay.init().start();
}
}
/**
* Destroy Slider
* @method destroy
*/
}, {
key: 'destroy',
value: function destroy() {
var _this6 = this;
this._unbindEvents();
this._items.forEach(function (item) {
_this6.element.appendChild(item);
});
this.node.remove();
}
}, {
key: 'id',
get: function get() {
return this._id;
}
}, {
key: 'index',
set: function set(index) {
this._index = index;
},
get: function get() {
return this._index;
}
}, {
key: 'length',
set: function set(length) {
this._length = length;
},
get: function get() {
return this._length;
}
}, {
key: 'slides',
get: function get() {
return this._slides;
},
set: function set(slides) {
this._slides = slides;
}
}, {
key: 'slidesToScroll',
get: function get() {
return this.options.effect === 'translate' ? this._breakpoint.getSlidesToScroll() : 1;
}
}, {
key: 'slidesToShow',
get: function get() {
return this.options.effect === 'translate' ? this._breakpoint.getSlidesToShow() : 1;
}
}, {
key: 'direction',
get: function get() {
return this.element.dir.toLowerCase() === 'rtl' || this.element.style.direction === 'rtl' ? 'rtl' : 'ltr';
}
}, {
key: 'wrapper',
get: function get() {
return this._ui.wrapper;
}
}, {
key: 'wrapperWidth',
get: function get() {
return this._wrapperWidth || 0;
}
}, {
key: 'container',
get: function get() {
return this._ui.container;
}
}, {
key: 'containerWidth',
get: function get() {
return this._containerWidth || 0;
}
}, {
key: 'slideWidth',
get: function get() {
return this._slideWidth || 0;
}
}, {
key: 'transitioner',
get: function get() {
return this._transitioner;
}
}], [{
key: 'attach',
value: function attach() {
var _this7 = this;
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.slider';
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var instances = new Array();
var elements = Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["c" /* isString */])(selector) ? document.querySelectorAll(selector) : Array.isArray(selector) ? selector : [selector];
[].forEach.call(elements, function (element) {
if (typeof element[_this7.constructor.name] === 'undefined') {
var instance = new bulmaCarousel(element, options);
element[_this7.constructor.name] = instance;
instances.push(instance);
} else {
instances.push(element[_this7.constructor.name]);
}
});
return instances;
}
}]);
return bulmaCarousel;
}(__WEBPACK_IMPORTED_MODULE_3__utils_eventEmitter__["a" /* default */]);
/* harmony default export */ __webpack_exports__["default"] = (bulmaCarousel);
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return uuid; });
/* unused harmony export isRtl */
/* unused harmony export defer */
/* unused harmony export getNodeIndex */
/* unused harmony export camelize */
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var uuid = function uuid() {
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return prefix + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
});
};
var isRtl = function isRtl() {
return document.documentElement.getAttribute('dir') === 'rtl';
};
var defer = function defer() {
this.promise = new Promise(function (resolve, reject) {
this.resolve = resolve;
this.reject = reject;
}.bind(this));