/
splide.js
5859 lines (5072 loc) · 135 KB
/
splide.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
/*!
* Splide.js
* Version : 2.4.20
* License : MIT
* Copyright: 2020 Naotoshi Fujita
*/
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ }();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
// UNUSED EXPORTS: Splide
// NAMESPACE OBJECT: ./src/js/constants/states.js
var states_namespaceObject = {};
__webpack_require__.r(states_namespaceObject);
__webpack_require__.d(states_namespaceObject, {
"CREATED": function() { return CREATED; },
"DESTROYED": function() { return DESTROYED; },
"IDLE": function() { return IDLE; },
"MOUNTED": function() { return MOUNTED; },
"MOVING": function() { return MOVING; }
});
;// CONCATENATED MODULE: ./src/js/core/event.js
/**
* The function for providing an Event object simply managing events.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* The function for providing an Event object simply managing events.
*/
/* harmony default export */ var core_event = (function () {
/**
* Store all event data.
*
* @type {Array}
*/
var data = [];
var Event = {
/**
* Subscribe the given event(s).
*
* @param {string} events - An event name. Use space to separate multiple events.
* Also, namespace is accepted by dot, such as 'resize.{namespace}'.
* @param {function} handler - A callback function.
* @param {Element} elm - Optional. Native event will be listened to when this arg is provided.
* @param {Object} options - Optional. Options for addEventListener.
*/
on: function on(events, handler, elm, options) {
if (elm === void 0) {
elm = null;
}
if (options === void 0) {
options = {};
}
events.split(' ').forEach(function (event) {
if (elm) {
elm.addEventListener(event, handler, options);
}
data.push({
event: event,
handler: handler,
elm: elm,
options: options
});
});
},
/**
* Unsubscribe the given event(s).
*
* @param {string} events - A event name or names split by space.
* @param {Element} elm - Optional. removeEventListener() will be called when this arg is provided.
*/
off: function off(events, elm) {
if (elm === void 0) {
elm = null;
}
events.split(' ').forEach(function (event) {
data = data.filter(function (item) {
if (item && item.event === event && item.elm === elm) {
unsubscribe(item);
return false;
}
return true;
});
});
},
/**
* Emit an event.
* This method is only for custom events.
*
* @param {string} event - An event name.
* @param {*} args - Any number of arguments passed to handlers.
*/
emit: function emit(event) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
data.forEach(function (item) {
if (!item.elm && item.event.split('.')[0] === event) {
item.handler.apply(item, args);
}
});
},
/**
* Clear event data.
*/
destroy: function destroy() {
data.forEach(unsubscribe);
data = [];
}
};
/**
* Remove the registered event listener.
*
* @param {Object} item - An object containing event data.
*/
function unsubscribe(item) {
if (item.elm) {
item.elm.removeEventListener(item.event, item.handler, item.options);
}
}
return Event;
});
;// CONCATENATED MODULE: ./src/js/core/state.js
/**
* The function providing a super simple state system.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* The function providing a super simple state system.
*
* @param {string|number} initialState - Provide the initial state value.
*/
/* harmony default export */ var state = (function (initialState) {
/**
* Store the current state.
*
* @type {string|number}
*/
var curr = initialState;
return {
/**
* Change state.
*
* @param {string|number} state - A new state.
*/
set: function set(state) {
curr = state;
},
/**
* Verify if the current state is given one or not.
*
* @param {string|number} state - A state name to be verified.
*
* @return {boolean} - True if the current state is the given one.
*/
is: function is(state) {
return state === curr;
}
};
});
;// CONCATENATED MODULE: ./src/js/utils/object.js
function _extends() { _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; }; return _extends.apply(this, arguments); }
/**
* Some utility functions related with Object, supporting IE.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
var keys = Object.keys;
/**
* Iterate an object like Array.forEach.
* IE doesn't support forEach of HTMLCollection.
*
* @param {Object} obj - An object.
* @param {function} callback - A function handling each value. Arguments are value, property and index.
*/
function each(obj, callback) {
keys(obj).some(function (key, index) {
return callback(obj[key], key, index);
});
}
/**
* Return values of the given object as an array.
* IE doesn't support Object.values.
*
* @param {Object} obj - An object.
*
* @return {Array} - An array containing all values of the given object.
*/
function values(obj) {
return keys(obj).map(function (key) {
return obj[key];
});
}
/**
* Check if the given subject is object or not.
*
* @param {*} subject - A subject to be verified.
*
* @return {boolean} - True if object, false otherwise.
*/
function isObject(subject) {
return typeof subject === 'object';
}
/**
* Merge two objects deeply.
*
* @param {Object} to - An object where "from" is merged.
* @param {Object} from - An object merged to "to".
*
* @return {Object} - A merged object.
*/
function merge(_ref, from) {
var to = _extends({}, _ref);
each(from, function (value, key) {
if (isObject(value)) {
if (!isObject(to[key])) {
to[key] = {};
}
to[key] = merge(to[key], value);
} else {
to[key] = value;
}
});
return to;
}
/**
* Assign all properties "from" to "to" object.
*
* @param {Object} to - An object where properties are assigned.
* @param {Object} from - An object whose properties are assigned to "to".
*
* @return {Object} - An assigned object.
*/
function object_assign(to, from) {
keys(from).forEach(function (key) {
if (!to[key]) {
Object.defineProperty(to, key, Object.getOwnPropertyDescriptor(from, key));
}
});
return to;
}
;// CONCATENATED MODULE: ./src/js/utils/utils.js
/**
* A package of some miscellaneous utility functions.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Convert the given value to array.
*
* @param {*} value - Any value.
*
* @return {*[]} - Array containing the given value.
*/
function toArray(value) {
return Array.isArray(value) ? value : [value];
}
/**
* Check if the given value is between min and max.
* Min will be returned when the value is less than min or max will do when greater than max.
*
* @param {number} value - A number to be checked.
* @param {number} m1 - Minimum or maximum number.
* @param {number} m2 - Maximum or minimum number.
*
* @return {number} - A value itself, min or max.
*/
function between(value, m1, m2) {
return Math.min(Math.max(value, m1 > m2 ? m2 : m1), m1 > m2 ? m1 : m2);
}
/**
* The sprintf method with minimum functionality.
*
* @param {string} format - The string format.
* @param {string|Array} replacements - Replacements accepting multiple arguments.
*
* @returns {string} - Converted string.
*/
function sprintf(format, replacements) {
var i = 0;
return format.replace(/%s/g, function () {
return toArray(replacements)[i++];
});
}
/**
* Append px unit to the given subject if necessary.
*
* @param {number|string} value - A value that may not include an unit.
*
* @return {string} - If the value is string, return itself.
* If number, do value + "px". An empty string, otherwise.
*/
function unit(value) {
var type = typeof value;
if (type === 'number' && value > 0) {
return parseFloat(value) + 'px';
}
return type === 'string' ? value : '';
}
/**
* Pad start with 0.
*
* @param {number} number - A number to be filled with 0.
*
* @return {string|number} - Padded number.
*/
function pad(number) {
return number < 10 ? '0' + number : number;
}
/**
* Convert the given value to pixel.
*
* @param {Element} root - Root element where a dummy div is appended.
* @param {string|number} value - CSS value to be converted, such as 10rem.
*
* @return {number} - Pixel.
*/
function toPixel(root, value) {
if (typeof value === 'string') {
var div = create('div', {});
applyStyle(div, {
position: 'absolute',
width: value
});
append(root, div);
value = div.clientWidth;
dom_remove(div);
}
return +value || 0;
}
;// CONCATENATED MODULE: ./src/js/utils/dom.js
/**
* Some utility functions related with DOM.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Find the first element matching the given selector.
* Be aware that all selectors after a space are ignored.
*
* @param {Element|Node} elm - An ancestor element.
* @param {string} selector - DOMString.
*
* @return {Element|null} - A found element or null.
*/
function find(elm, selector) {
return elm ? elm.querySelector(selector.split(' ')[0]) : null;
}
/**
* Find a first child having the given tag or class name.
*
* @param {Element} parent - A parent element.
* @param {string} tagOrClassName - A tag or class name.
*
* @return {Element|undefined} - A found element on success or undefined on failure.
*/
function child(parent, tagOrClassName) {
return children(parent, tagOrClassName)[0];
}
/**
* Return chile elements that matches the provided tag or class name.
*
* @param {Element} parent - A parent element.
* @param {string} tagOrClassName - A tag or class name.
*
* @return {Element[]} - Found elements.
*/
function children(parent, tagOrClassName) {
if (parent) {
return values(parent.children).filter(function (child) {
return hasClass(child, tagOrClassName.split(' ')[0]) || child.tagName === tagOrClassName;
});
}
return [];
}
/**
* Create an element with some optional attributes.
*
* @param {string} tag - A tag name.
* @param {Object} attrs - An object any attribute pairs of name and value.
*
* @return {Element} - A created element.
*/
function create(tag, attrs) {
var elm = document.createElement(tag);
each(attrs, function (value, key) {
return setAttribute(elm, key, value);
});
return elm;
}
/**
* Convert HTML string to DOM node.
*
* @param {string} html - HTML string.
*
* @return {Node} - A created node.
*/
function domify(html) {
var div = create('div', {});
div.innerHTML = html;
return div.firstChild;
}
/**
* Remove a given element from a DOM tree.
*
* @param {Element|Element[]} elms - Element(s) to be removed.
*/
function dom_remove(elms) {
toArray(elms).forEach(function (elm) {
if (elm) {
var parent = elm.parentElement;
parent && parent.removeChild(elm);
}
});
}
/**
* Append a child to a given element.
*
* @param {Element} parent - A parent element.
* @param {Element} child - An element to be appended.
*/
function append(parent, child) {
if (parent) {
parent.appendChild(child);
}
}
/**
* Insert an element before the reference element.
*
* @param {Element|Node} ref - A reference element.
* @param {Element} elm - An element to be inserted.
*/
function before(elm, ref) {
if (elm && ref) {
var parent = ref.parentElement;
parent && parent.insertBefore(elm, ref);
}
}
/**
* Apply styles to the given element.
*
* @param {Element} elm - An element where styles are applied.
* @param {Object} styles - Object containing styles.
*/
function applyStyle(elm, styles) {
if (elm) {
each(styles, function (value, prop) {
if (value !== null) {
elm.style[prop] = value;
}
});
}
}
/**
* Add or remove classes to/from the element.
* This function is for internal usage.
*
* @param {Element} elm - An element where classes are added.
* @param {string|string[]} classes - Class names being added.
* @param {boolean} remove - Whether to remove or add classes.
*/
function addOrRemoveClasses(elm, classes, remove) {
if (elm) {
toArray(classes).forEach(function (name) {
if (name) {
elm.classList[remove ? 'remove' : 'add'](name);
}
});
}
}
/**
* Add classes to the element.
*
* @param {Element} elm - An element where classes are added.
* @param {string|string[]} classes - Class names being added.
*/
function addClass(elm, classes) {
addOrRemoveClasses(elm, classes, false);
}
/**
* Remove a class from the element.
*
* @param {Element} elm - An element where classes are removed.
* @param {string|string[]} classes - A class name being removed.
*/
function removeClass(elm, classes) {
addOrRemoveClasses(elm, classes, true);
}
/**
* Verify if the provided element has the class or not.
*
* @param {Element} elm - An element.
* @param {string} className - A class name.
*
* @return {boolean} - True if the element has the class or false if not.
*/
function hasClass(elm, className) {
return !!elm && elm.classList.contains(className);
}
/**
* Set attribute to the given element.
*
* @param {Element} elm - An element where an attribute is assigned.
* @param {string} name - Attribute name.
* @param {string|number|boolean} value - Attribute value.
*/
function setAttribute(elm, name, value) {
if (elm) {
elm.setAttribute(name, value);
}
}
/**
* Get attribute from the given element.
*
* @param {Element} elm - An element where an attribute is assigned.
* @param {string} name - Attribute name.
*
* @return {string} - The value of the given attribute if available. An empty string if not.
*/
function getAttribute(elm, name) {
return elm ? elm.getAttribute(name) : '';
}
/**
* Remove attribute from the given element.
*
* @param {Element|Element[]} elms - An element where an attribute is removed.
* @param {string|string[]} names - Attribute name.
*/
function removeAttribute(elms, names) {
toArray(names).forEach(function (name) {
toArray(elms).forEach(function (elm) {
return elm && elm.removeAttribute(name);
});
});
}
/**
* Return the Rect object of the provided object.
*
* @param {Element} elm - An element.
*
* @return {ClientRect|DOMRect} - A rect object.
*/
function getRect(elm) {
return elm.getBoundingClientRect();
}
/**
* Trigger the given callback after all images contained by the element are loaded.
*
* @param {Element} elm - Element that may contain images.
* @param {Function} callback - Callback function fired right after all images are loaded.
*/
function loaded(elm, callback) {
var images = elm.querySelectorAll('img');
var length = images.length;
if (length) {
var count = 0;
each(images, function (img) {
img.onload = img.onerror = function () {
if (++count === length) {
callback();
}
};
});
} else {
// Trigger the callback immediately if there is no image.
callback();
}
}
;// CONCATENATED MODULE: ./src/js/constants/types.js
/**
* Export slider types.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Normal slider.
*
* @type {string}
*/
var SLIDE = 'slide';
/**
* Loop after the last slide and before the first one.
*
* @type {string}
*/
var LOOP = 'loop';
/**
* The track doesn't move.
*
* @type {string}
*/
var FADE = 'fade';
;// CONCATENATED MODULE: ./src/js/transitions/slide/index.js
/**
* The component for general slide effect transition.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* The component for general slide effect transition.
*
* @param {Splide} Splide - A Splide instance.
* @param {Object} Components - An object containing components.
*
* @return {Object} - The component object.
*/
/* harmony default export */ var slide = (function (Splide, Components) {
/**
* Hold the list element.
*
* @type {Element}
*/
var list;
/**
* Hold the onEnd callback function.
*
* @type {function}
*/
var endCallback;
return {
/**
* Called when the component is mounted.
*/
mount: function mount() {
list = Components.Elements.list;
Splide.on('transitionend', function (e) {
if (e.target === list && endCallback) {
endCallback();
}
}, list);
},
/**
* Start transition.
*
* @param {number} destIndex - Destination slide index that might be clone's.
* @param {number} newIndex - New index.
* @param {number} prevIndex - Previous index.
* @param {Object} coord - Destination coordinates.
* @param {function} done - Callback function must be invoked when transition is completed.
*/
start: function start(destIndex, newIndex, prevIndex, coord, done) {
var options = Splide.options;
var edgeIndex = Components.Controller.edgeIndex;
var speed = options.speed;
endCallback = done;
if (Splide.is(SLIDE)) {
if (prevIndex === 0 && newIndex >= edgeIndex || prevIndex >= edgeIndex && newIndex === 0) {
speed = options.rewindSpeed || speed;
}
}
applyStyle(list, {
transition: "transform " + speed + "ms " + options.easing,
transform: "translate(" + coord.x + "px," + coord.y + "px)"
});
}
};
});
;// CONCATENATED MODULE: ./src/js/transitions/fade/index.js
/**
* The component for fade transition.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* The component for fade transition.
*
* @param {Splide} Splide - A Splide instance.
* @param {Object} Components - An object containing components.
*
* @return {Object} - The component object.
*/
/* harmony default export */ var fade = (function (Splide, Components) {
var Fade = {
/**
* Called when the component is mounted.
* Apply transition style to the first slide.
*/
mount: function mount() {
apply(Splide.index);
},
/**
* Start transition.
*
* @param {number} destIndex - Destination slide index that might be clone's.
* @param {number} newIndex - New index.
* @param {number} prevIndex - Previous index.
* @param {Object} coord - Destination coordinates.
* @param {function} done - Callback function must be invoked when transition is completed.
*/
start: function start(destIndex, newIndex, prevIndex, coord, done) {
var track = Components.Elements.track;
applyStyle(track, {
height: unit(track.clientHeight)
});
apply(newIndex);
setTimeout(function () {
done();
applyStyle(track, {
height: ''
});
});
}
};
/**
* Apply transition style to the slide specified by the given index.
*
* @param {number} index - A slide index.
*/
function apply(index) {
var options = Splide.options;
applyStyle(Components.Elements.slides[index], {
transition: "opacity " + options.speed + "ms " + options.easing
});
}
return Fade;
});
;// CONCATENATED MODULE: ./src/js/transitions/index.js
/**
* Export transition components.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
;// CONCATENATED MODULE: ./src/js/core/composer.js
/**
* Provide a function for composing components.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Compose components.
*
* @param {Splide} Splide - Splide instance.
* @param {Object} Components - Additional components.
* @param {function} Transition - Change component for transition.
*
* @return {Object} - An object containing all components.
*/
function compose(Splide, Components, Transition) {
var components = {};
each(Components, function (Component, name) {
components[name] = Component(Splide, components, name.toLowerCase());
});
if (!Transition) {
Transition = Splide.is(FADE) ? fade : slide;
}
components.Transition = Transition(Splide, components);
return components;
}
;// CONCATENATED MODULE: ./src/js/utils/error.js
/**
* Utility functions for outputting logs.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Prefix of an error massage.
*
* @type {string}
*/
var MESSAGE_PREFIX = '[SPLIDE]';
/**
* Display an error message on the browser console.
*
* @param {string} message - An error message.
*/
function error(message) {
console.error(MESSAGE_PREFIX + " " + message);
}
/**
* Check existence of the given object and throw an error if it doesn't.
*
* @throws {Error}
*
* @param {*} subject - A subject to be confirmed.
* @param {string} message - An error message.
*/
function exist(subject, message) {
if (!subject) {
throw new Error(message);
}
}
;// CONCATENATED MODULE: ./src/js/constants/classes.js
/**
* Export class names.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* A root class name.
*
* @type {string}
*/
var ROOT = 'splide';
/**
* The definition table of all classes for elements.
* They might be modified by options.
*
* @type {Object}
*/
var ELEMENT_CLASSES = {
root: ROOT,
slider: ROOT + "__slider",
track: ROOT + "__track",
list: ROOT + "__list",
slide: ROOT + "__slide",
container: ROOT + "__slide__container",
arrows: ROOT + "__arrows",
arrow: ROOT + "__arrow",
prev: ROOT + "__arrow--prev",
next: ROOT + "__arrow--next",
pagination: ROOT + "__pagination",
page: ROOT + "__pagination__page",
clone: ROOT + "__slide--clone",
progress: ROOT + "__progress",
bar: ROOT + "__progress__bar",
autoplay: ROOT + "__autoplay",
play: ROOT + "__play",
pause: ROOT + "__pause",
spinner: ROOT + "__spinner",
sr: ROOT + "__sr"
};
/**
* Definitions of status classes.
*
* @type {Object}
*/
var STATUS_CLASSES = {
active: 'is-active',
visible: 'is-visible',
loading: 'is-loading'
};
;// CONCATENATED MODULE: ./src/js/constants/i18n.js
/**
* Export i18n texts as object.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
/**
* Texts for i18n.
*
* @type {Object}
*/
var I18N = {
prev: 'Previous slide',
next: 'Next slide',
first: 'Go to first slide',
last: 'Go to last slide',
slideX: 'Go to slide %s',
pageX: 'Go to page %s',
play: 'Start autoplay',
pause: 'Pause autoplay'
};
;// CONCATENATED MODULE: ./src/js/constants/defaults.js
/**
* Export default options.
*
* @author Naotoshi Fujita
* @copyright Naotoshi Fujita. All rights reserved.
*/
var DEFAULTS = {
/**
* Determine a slider type.
* - 'slide': Regular slider.