· 5 years ago · Jan 15, 2021, 12:04 PM
1/*!
2 * Splide.js
3 * Version : 2.4.5
4 * License : MIT
5 * Copyright: 2020 Naotoshi Fujita
6 */
7(function webpackUniversalModuleDefinition(root, factory) {
8 if(typeof exports === 'object' && typeof module === 'object')
9 module.exports = factory();
10 else if(typeof define === 'function' && define.amd)
11 define([], factory);
12 else if(typeof exports === 'object')
13 exports["Splide"] = factory();
14 else
15 root["Splide"] = factory();
16})(window, function() {
17return /******/ (function(modules) { // webpackBootstrap
18/******/ // The module cache
19/******/ var installedModules = {};
20/******/
21/******/ // The require function
22/******/ function __webpack_require__(moduleId) {
23/******/
24/******/ // Check if module is in cache
25/******/ if(installedModules[moduleId]) {
26/******/ return installedModules[moduleId].exports;
27/******/ }
28/******/ // Create a new module (and put it into the cache)
29/******/ var module = installedModules[moduleId] = {
30/******/ i: moduleId,
31/******/ l: false,
32/******/ exports: {}
33/******/ };
34/******/
35/******/ // Execute the module function
36/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
37/******/
38/******/ // Flag the module as loaded
39/******/ module.l = true;
40/******/
41/******/ // Return the exports of the module
42/******/ return module.exports;
43/******/ }
44/******/
45/******/
46/******/ // expose the modules object (__webpack_modules__)
47/******/ __webpack_require__.m = modules;
48/******/
49/******/ // expose the module cache
50/******/ __webpack_require__.c = installedModules;
51/******/
52/******/ // define getter function for harmony exports
53/******/ __webpack_require__.d = function(exports, name, getter) {
54/******/ if(!__webpack_require__.o(exports, name)) {
55/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
56/******/ }
57/******/ };
58/******/
59/******/ // define __esModule on exports
60/******/ __webpack_require__.r = function(exports) {
61/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
62/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
63/******/ }
64/******/ Object.defineProperty(exports, '__esModule', { value: true });
65/******/ };
66/******/
67/******/ // create a fake namespace object
68/******/ // mode & 1: value is a module id, require it
69/******/ // mode & 2: merge all properties of value into the ns
70/******/ // mode & 4: return value when already ns object
71/******/ // mode & 8|1: behave like require
72/******/ __webpack_require__.t = function(value, mode) {
73/******/ if(mode & 1) value = __webpack_require__(value);
74/******/ if(mode & 8) return value;
75/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
76/******/ var ns = Object.create(null);
77/******/ __webpack_require__.r(ns);
78/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
79/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
80/******/ return ns;
81/******/ };
82/******/
83/******/ // getDefaultExport function for compatibility with non-harmony modules
84/******/ __webpack_require__.n = function(module) {
85/******/ var getter = module && module.__esModule ?
86/******/ function getDefault() { return module['default']; } :
87/******/ function getModuleExports() { return module; };
88/******/ __webpack_require__.d(getter, 'a', getter);
89/******/ return getter;
90/******/ };
91/******/
92/******/ // Object.prototype.hasOwnProperty.call
93/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
94/******/
95/******/ // __webpack_public_path__
96/******/ __webpack_require__.p = "";
97/******/
98/******/
99/******/ // Load entry module and return exports
100/******/ return __webpack_require__(__webpack_require__.s = 0);
101/******/ })
102/************************************************************************/
103/******/ ([
104/* 0 */
105/***/ (function(module, __webpack_exports__, __webpack_require__) {
106
107"use strict";
108// ESM COMPAT FLAG
109__webpack_require__.r(__webpack_exports__);
110
111// EXPORTS
112__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ module_Splide; });
113
114// NAMESPACE OBJECT: ./src/js/constants/states.js
115var states_namespaceObject = {};
116__webpack_require__.r(states_namespaceObject);
117__webpack_require__.d(states_namespaceObject, "CREATED", function() { return CREATED; });
118__webpack_require__.d(states_namespaceObject, "MOUNTED", function() { return MOUNTED; });
119__webpack_require__.d(states_namespaceObject, "IDLE", function() { return IDLE; });
120__webpack_require__.d(states_namespaceObject, "MOVING", function() { return MOVING; });
121__webpack_require__.d(states_namespaceObject, "DESTROYED", function() { return DESTROYED; });
122
123// CONCATENATED MODULE: ./src/js/core/event.js
124/**
125 * The function for providing an Event object simply managing events.
126 *
127 * @author Naotoshi Fujita
128 * @copyright Naotoshi Fujita. All rights reserved.
129 */
130
131/**
132 * The function for providing an Event object simply managing events.
133 */
134/* harmony default export */ var core_event = (function () {
135 /**
136 * Store all event data.
137 *
138 * @type {Array}
139 */
140 var data = [];
141 var Event = {
142 /**
143 * Subscribe the given event(s).
144 *
145 * @param {string} events - An event name. Use space to separate multiple events.
146 * Also, namespace is accepted by dot, such as 'resize.{namespace}'.
147 * @param {function} handler - A callback function.
148 * @param {Element} elm - Optional. Native event will be listened to when this arg is provided.
149 * @param {Object} options - Optional. Options for addEventListener.
150 */
151 on: function on(events, handler, elm, options) {
152 if (elm === void 0) {
153 elm = null;
154 }
155
156 if (options === void 0) {
157 options = {};
158 }
159
160 events.split(' ').forEach(function (event) {
161 if (elm) {
162 elm.addEventListener(event, handler, options);
163 }
164
165 data.push({
166 event: event,
167 handler: handler,
168 elm: elm,
169 options: options
170 });
171 });
172 },
173
174 /**
175 * Unsubscribe the given event(s).
176 *
177 * @param {string} events - A event name or names split by space.
178 * @param {Element} elm - Optional. removeEventListener() will be called when this arg is provided.
179 */
180 off: function off(events, elm) {
181 if (elm === void 0) {
182 elm = null;
183 }
184
185 events.split(' ').forEach(function (event) {
186 data = data.filter(function (item) {
187 if (item && item.event === event && item.elm === elm) {
188 unsubscribe(item);
189 return false;
190 }
191
192 return true;
193 });
194 });
195 },
196
197 /**
198 * Emit an event.
199 * This method is only for custom events.
200 *
201 * @param {string} event - An event name.
202 * @param {*} args - Any number of arguments passed to handlers.
203 */
204 emit: function emit(event) {
205 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
206 args[_key - 1] = arguments[_key];
207 }
208
209 data.forEach(function (item) {
210 if (!item.elm && item.event.split('.')[0] === event) {
211 item.handler.apply(item, args);
212 }
213 });
214 },
215
216 /**
217 * Clear event data.
218 */
219 destroy: function destroy() {
220 data.forEach(unsubscribe);
221 data = [];
222 }
223 };
224 /**
225 * Remove the registered event listener.
226 *
227 * @param {Object} item - An object containing event data.
228 */
229
230 function unsubscribe(item) {
231 if (item.elm) {
232 item.elm.removeEventListener(item.event, item.handler, item.options);
233 }
234 }
235
236 return Event;
237});
238// CONCATENATED MODULE: ./src/js/core/state.js
239/**
240 * The function providing a super simple state system.
241 *
242 * @author Naotoshi Fujita
243 * @copyright Naotoshi Fujita. All rights reserved.
244 */
245
246/**
247 * The function providing a super simple state system.
248 *
249 * @param {string|number} initialState - Provide the initial state value.
250 */
251/* harmony default export */ var state = (function (initialState) {
252 /**
253 * Store the current state.
254 *
255 * @type {string|number}
256 */
257 var curr = initialState;
258 return {
259 /**
260 * Change state.
261 *
262 * @param {string|number} state - A new state.
263 */
264 set: function set(state) {
265 curr = state;
266 },
267
268 /**
269 * Verify if the current state is given one or not.
270 *
271 * @param {string|number} state - A state name to be verified.
272 *
273 * @return {boolean} - True if the current state is the given one.
274 */
275 is: function is(state) {
276 return state === curr;
277 }
278 };
279});
280// CONCATENATED MODULE: ./src/js/utils/object.js
281function _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); }
282
283/**
284 * Some utility functions related with Object, supporting IE.
285 *
286 * @author Naotoshi Fujita
287 * @copyright Naotoshi Fujita. All rights reserved.
288 */
289var keys = Object.keys;
290/**
291 * Iterate an object like Array.forEach.
292 * IE doesn't support forEach of HTMLCollection.
293 *
294 * @param {Object} obj - An object.
295 * @param {function} callback - A function handling each value. Arguments are value, property and index.
296 */
297
298function each(obj, callback) {
299 keys(obj).some(function (key, index) {
300 return callback(obj[key], key, index);
301 });
302}
303/**
304 * Return values of the given object as an array.
305 * IE doesn't support Object.values.
306 *
307 * @param {Object} obj - An object.
308 *
309 * @return {Array} - An array containing all values of the given object.
310 */
311
312function values(obj) {
313 return keys(obj).map(function (key) {
314 return obj[key];
315 });
316}
317/**
318 * Check if the given subject is object or not.
319 *
320 * @param {*} subject - A subject to be verified.
321 *
322 * @return {boolean} - True if object, false otherwise.
323 */
324
325function isObject(subject) {
326 return typeof subject === 'object';
327}
328/**
329 * Merge two objects deeply.
330 *
331 * @param {Object} to - An object where "from" is merged.
332 * @param {Object} from - An object merged to "to".
333 *
334 * @return {Object} - A merged object.
335 */
336
337function merge(_ref, from) {
338 var to = _extends({}, _ref);
339
340 each(from, function (value, key) {
341 if (isObject(value)) {
342 if (!isObject(to[key])) {
343 to[key] = {};
344 }
345
346 to[key] = merge(to[key], value);
347 } else {
348 to[key] = value;
349 }
350 });
351 return to;
352}
353/**
354 * Assign all properties "from" to "to" object.
355 *
356 * @param {Object} to - An object where properties are assigned.
357 * @param {Object} from - An object whose properties are assigned to "to".
358 *
359 * @return {Object} - An assigned object.
360 */
361
362function object_assign(to, from) {
363 keys(from).forEach(function (key) {
364 if (!to[key]) {
365 Object.defineProperty(to, key, Object.getOwnPropertyDescriptor(from, key));
366 }
367 });
368 return to;
369}
370// CONCATENATED MODULE: ./src/js/utils/utils.js
371/**
372 * A package of some miscellaneous utility functions.
373 *
374 * @author Naotoshi Fujita
375 * @copyright Naotoshi Fujita. All rights reserved.
376 */
377
378/**
379 * Convert the given value to array.
380 *
381 * @param {*} value - Any value.
382 *
383 * @return {*[]} - Array containing the given value.
384 */
385
386function toArray(value) {
387 return Array.isArray(value) ? value : [value];
388}
389/**
390 * Check if the given value is between min and max.
391 * Min will be returned when the value is less than min or max will do when greater than max.
392 *
393 * @param {number} value - A number to be checked.
394 * @param {number} m1 - Minimum or maximum number.
395 * @param {number} m2 - Maximum or minimum number.
396 *
397 * @return {number} - A value itself, min or max.
398 */
399
400function between(value, m1, m2) {
401 return Math.min(Math.max(value, m1 > m2 ? m2 : m1), m1 > m2 ? m1 : m2);
402}
403/**
404 * The sprintf method with minimum functionality.
405 *
406 * @param {string} format - The string format.
407 * @param {string|Array} replacements - Replacements accepting multiple arguments.
408 *
409 * @returns {string} - Converted string.
410 */
411
412function sprintf(format, replacements) {
413 var i = 0;
414 return format.replace(/%s/g, function () {
415 return toArray(replacements)[i++];
416 });
417}
418/**
419 * Append px unit to the given subject if necessary.
420 *
421 * @param {number|string} value - A value that may not include an unit.
422 *
423 * @return {string} - If the value is string, return itself.
424 * If number, do value + "px". An empty string, otherwise.
425 */
426
427function unit(value) {
428 var type = typeof value;
429
430 if (type === 'number' && value > 0) {
431 return parseFloat(value) + 'px';
432 }
433
434 return type === 'string' ? value : '';
435}
436/**
437 * Pad start with 0.
438 *
439 * @param {number} number - A number to be filled with 0.
440 *
441 * @return {string|number} - Padded number.
442 */
443
444function pad(number) {
445 return number < 10 ? '0' + number : number;
446}
447/**
448 * Convert the given value to pixel.
449 *
450 * @param {Element} root - Root element where a dummy div is appended.
451 * @param {string|number} value - CSS value to be converted, such as 10rem.
452 *
453 * @return {number} - Pixel.
454 */
455
456function toPixel(root, value) {
457 if (typeof value === 'string') {
458 var div = create('div', {});
459 applyStyle(div, {
460 position: 'absolute',
461 width: value
462 });
463 append(root, div);
464 value = div.clientWidth;
465 dom_remove(div);
466 }
467
468 return +value || 0;
469}
470// CONCATENATED MODULE: ./src/js/utils/dom.js
471/**
472 * Some utility functions related with DOM.
473 *
474 * @author Naotoshi Fujita
475 * @copyright Naotoshi Fujita. All rights reserved.
476 */
477
478
479/**
480 * Find the first element matching the given selector.
481 * Be aware that all selectors after a space are ignored.
482 *
483 * @param {Element|Node} elm - An ancestor element.
484 * @param {string} selector - DOMString.
485 *
486 * @return {Element|null} - A found element or null.
487 */
488
489function find(elm, selector) {
490 return elm ? elm.querySelector(selector.split(' ')[0]) : null;
491}
492/**
493 * Find a first child having the given tag or class name.
494 *
495 * @param {Element} parent - A parent element.
496 * @param {string} tagOrClassName - A tag or class name.
497 *
498 * @return {Element|undefined} - A found element on success or undefined on failure.
499 */
500
501function child(parent, tagOrClassName) {
502 return children(parent, tagOrClassName)[0];
503}
504/**
505 * Return chile elements that matches the provided tag or class name.
506 *
507 * @param {Element} parent - A parent element.
508 * @param {string} tagOrClassName - A tag or class name.
509 *
510 * @return {Element[]} - Found elements.
511 */
512
513function children(parent, tagOrClassName) {
514 if (parent) {
515 return values(parent.children).filter(function (child) {
516 return hasClass(child, tagOrClassName.split(' ')[0]) || child.tagName === tagOrClassName;
517 });
518 }
519
520 return [];
521}
522/**
523 * Create an element with some optional attributes.
524 *
525 * @param {string} tag - A tag name.
526 * @param {Object} attrs - An object any attribute pairs of name and value.
527 *
528 * @return {Element} - A created element.
529 */
530
531function create(tag, attrs) {
532 var elm = document.createElement(tag);
533 each(attrs, function (value, key) {
534 return setAttribute(elm, key, value);
535 });
536 return elm;
537}
538/**
539 * Convert HTML string to DOM node.
540 *
541 * @param {string} html - HTML string.
542 *
543 * @return {Node} - A created node.
544 */
545
546function domify(html) {
547 var div = create('div', {});
548 div.innerHTML = html;
549 return div.firstChild;
550}
551/**
552 * Remove a given element from a DOM tree.
553 *
554 * @param {Element|Element[]} elms - Element(s) to be removed.
555 */
556
557function dom_remove(elms) {
558 toArray(elms).forEach(function (elm) {
559 if (elm) {
560 var parent = elm.parentElement;
561 parent && parent.removeChild(elm);
562 }
563 });
564}
565/**
566 * Append a child to a given element.
567 *
568 * @param {Element} parent - A parent element.
569 * @param {Element} child - An element to be appended.
570 */
571
572function append(parent, child) {
573 if (parent) {
574 parent.appendChild(child);
575 }
576}
577/**
578 * Insert an element before the reference element.
579 *
580 * @param {Element|Node} ref - A reference element.
581 * @param {Element} elm - An element to be inserted.
582 */
583
584function before(elm, ref) {
585 if (elm && ref) {
586 var parent = ref.parentElement;
587 parent && parent.insertBefore(elm, ref);
588 }
589}
590/**
591 * Apply styles to the given element.
592 *
593 * @param {Element} elm - An element where styles are applied.
594 * @param {Object} styles - Object containing styles.
595 */
596
597function applyStyle(elm, styles) {
598 if (elm) {
599 each(styles, function (value, prop) {
600 if (value !== null) {
601 elm.style[prop] = value;
602 }
603 });
604 }
605}
606/**
607 * Add or remove classes to/from the element.
608 * This function is for internal usage.
609 *
610 * @param {Element} elm - An element where classes are added.
611 * @param {string|string[]} classes - Class names being added.
612 * @param {boolean} remove - Whether to remove or add classes.
613 */
614
615function addOrRemoveClasses(elm, classes, remove) {
616 if (elm) {
617 toArray(classes).forEach(function (name) {
618 if (name) {
619 elm.classList[remove ? 'remove' : 'add'](name);
620 }
621 });
622 }
623}
624/**
625 * Add classes to the element.
626 *
627 * @param {Element} elm - An element where classes are added.
628 * @param {string|string[]} classes - Class names being added.
629 */
630
631
632function addClass(elm, classes) {
633 addOrRemoveClasses(elm, classes, false);
634}
635/**
636 * Remove a class from the element.
637 *
638 * @param {Element} elm - An element where classes are removed.
639 * @param {string|string[]} classes - A class name being removed.
640 */
641
642function removeClass(elm, classes) {
643 addOrRemoveClasses(elm, classes, true);
644}
645/**
646 * Verify if the provided element has the class or not.
647 *
648 * @param {Element} elm - An element.
649 * @param {string} className - A class name.
650 *
651 * @return {boolean} - True if the element has the class or false if not.
652 */
653
654function hasClass(elm, className) {
655 return !!elm && elm.classList.contains(className);
656}
657/**
658 * Set attribute to the given element.
659 *
660 * @param {Element} elm - An element where an attribute is assigned.
661 * @param {string} name - Attribute name.
662 * @param {string|number|boolean} value - Attribute value.
663 */
664
665function setAttribute(elm, name, value) {
666 if (elm) {
667 elm.setAttribute(name, value);
668 }
669}
670/**
671 * Get attribute from the given element.
672 *
673 * @param {Element} elm - An element where an attribute is assigned.
674 * @param {string} name - Attribute name.
675 *
676 * @return {string} - The value of the given attribute if available. An empty string if not.
677 */
678
679function getAttribute(elm, name) {
680 return elm ? elm.getAttribute(name) : '';
681}
682/**
683 * Remove attribute from the given element.
684 *
685 * @param {Element|Element[]} elms - An element where an attribute is removed.
686 * @param {string|string[]} names - Attribute name.
687 */
688
689function removeAttribute(elms, names) {
690 toArray(names).forEach(function (name) {
691 toArray(elms).forEach(function (elm) {
692 return elm && elm.removeAttribute(name);
693 });
694 });
695}
696/**
697 * Return the Rect object of the provided object.
698 *
699 * @param {Element} elm - An element.
700 *
701 * @return {ClientRect|DOMRect} - A rect object.
702 */
703
704function getRect(elm) {
705 return elm.getBoundingClientRect();
706}
707/**
708 * Trigger the given callback after all images contained by the element are loaded.
709 *
710 * @param {Element} elm - Element that may contain images.
711 * @param {Function} callback - Callback function fired right after all images are loaded.
712 */
713
714function dom_loaded(elm, callback) {
715 var images = elm.querySelectorAll('img');
716 var length = images.length;
717
718 if (length) {
719 var count = 0;
720 each(images, function (img) {
721 img.onload = img.onerror = function () {
722 if (++count === length) {
723 callback();
724 }
725 };
726 });
727 } else {
728 // Trigger the callback immediately if there is no image.
729 callback();
730 }
731}
732// CONCATENATED MODULE: ./src/js/constants/types.js
733/**
734 * Export slider types.
735 *
736 * @author Naotoshi Fujita
737 * @copyright Naotoshi Fujita. All rights reserved.
738 */
739
740/**
741 * Normal slider.
742 *
743 * @type {string}
744 */
745var SLIDE = 'slide';
746/**
747 * Loop after the last slide and before the first one.
748 *
749 * @type {string}
750 */
751
752var LOOP = 'loop';
753/**
754 * The track doesn't move.
755 *
756 * @type {string}
757 */
758
759var FADE = 'fade';
760// CONCATENATED MODULE: ./src/js/transitions/slide/index.js
761/**
762 * The component for general slide effect transition.
763 *
764 * @author Naotoshi Fujita
765 * @copyright Naotoshi Fujita. All rights reserved.
766 */
767
768
769/**
770 * The component for general slide effect transition.
771 *
772 * @param {Splide} Splide - A Splide instance.
773 * @param {Object} Components - An object containing components.
774 *
775 * @return {Object} - The component object.
776 */
777
778/* harmony default export */ var transitions_slide = (function (Splide, Components) {
779 /**
780 * Hold the list element.
781 *
782 * @type {Element}
783 */
784 var list;
785 /**
786 * Hold the onEnd callback function.
787 *
788 * @type {function}
789 */
790
791 var endCallback;
792 return {
793 /**
794 * Called when the component is mounted.
795 */
796 mount: function mount() {
797 list = Components.Elements.list;
798 Splide.on('transitionend', function (e) {
799 if (e.target === list && endCallback) {
800 endCallback();
801 }
802 }, list);
803 },
804
805 /**
806 * Start transition.
807 *
808 * @param {number} destIndex - Destination slide index that might be clone's.
809 * @param {number} newIndex - New index.
810 * @param {number} prevIndex - Previous index.
811 * @param {Object} coord - Destination coordinates.
812 * @param {function} done - Callback function must be invoked when transition is completed.
813 */
814 start: function start(destIndex, newIndex, prevIndex, coord, done) {
815 var options = Splide.options;
816 var edgeIndex = Components.Controller.edgeIndex;
817 var speed = options.speed;
818 endCallback = done;
819
820 if (Splide.is(SLIDE)) {
821 if (prevIndex === 0 && newIndex >= edgeIndex || prevIndex >= edgeIndex && newIndex === 0) {
822 speed = options.rewindSpeed || speed;
823 }
824 }
825
826 applyStyle(list, {
827 transition: "transform " + speed + "ms " + options.easing,
828 transform: "translate(" + coord.x + "px," + coord.y + "px)"
829 });
830 }
831 };
832});
833// CONCATENATED MODULE: ./src/js/transitions/fade/index.js
834/**
835 * The component for fade transition.
836 *
837 * @author Naotoshi Fujita
838 * @copyright Naotoshi Fujita. All rights reserved.
839 */
840
841
842/**
843 * The component for fade transition.
844 *
845 * @param {Splide} Splide - A Splide instance.
846 * @param {Object} Components - An object containing components.
847 *
848 * @return {Object} - The component object.
849 */
850
851/* harmony default export */ var fade = (function (Splide, Components) {
852 var Fade = {
853 /**
854 * Called when the component is mounted.
855 * Apply transition style to the first slide.
856 */
857 mount: function mount() {
858 apply(Splide.index);
859 },
860
861 /**
862 * Start transition.
863 *
864 * @param {number} destIndex - Destination slide index that might be clone's.
865 * @param {number} newIndex - New index.
866 * @param {number} prevIndex - Previous index.
867 * @param {Object} coord - Destination coordinates.
868 * @param {function} done - Callback function must be invoked when transition is completed.
869 */
870 start: function start(destIndex, newIndex, prevIndex, coord, done) {
871 var track = Components.Elements.track;
872 applyStyle(track, {
873 height: unit(track.clientHeight)
874 });
875 apply(newIndex);
876 done();
877 applyStyle(track, {
878 height: ''
879 });
880 }
881 };
882 /**
883 * Apply transition style to the slide specified by the given index.
884 *
885 * @param {number} index - A slide index.
886 */
887
888 function apply(index) {
889 var options = Splide.options;
890 applyStyle(Components.Elements.slides[index], {
891 transition: "opacity " + options.speed + "ms " + options.easing
892 });
893 }
894
895 return Fade;
896});
897// CONCATENATED MODULE: ./src/js/transitions/index.js
898/**
899 * Export transition components.
900 *
901 * @author Naotoshi Fujita
902 * @copyright Naotoshi Fujita. All rights reserved.
903 */
904
905
906// CONCATENATED MODULE: ./src/js/core/composer.js
907/**
908 * Provide a function for composing components.
909 *
910 * @author Naotoshi Fujita
911 * @copyright Naotoshi Fujita. All rights reserved.
912 */
913
914
915
916/**
917 * Compose components.
918 *
919 * @param {Splide} Splide - Splide instance.
920 * @param {Object} Components - Additional components.
921 * @param {function} Transition - Change component for transition.
922 *
923 * @return {Object} - An object containing all components.
924 */
925
926function compose(Splide, Components, Transition) {
927 var components = {};
928 each(Components, function (Component, name) {
929 components[name] = Component(Splide, components, name.toLowerCase());
930 });
931
932 if (!Transition) {
933 Transition = Splide.is(FADE) ? fade : transitions_slide;
934 }
935
936 components.Transition = Transition(Splide, components);
937 return components;
938}
939// CONCATENATED MODULE: ./src/js/utils/error.js
940/**
941 * Utility functions for outputting logs.
942 *
943 * @author Naotoshi Fujita
944 * @copyright Naotoshi Fujita. All rights reserved.
945 */
946
947/**
948 * Prefix of an error massage.
949 *
950 * @type {string}
951 */
952var MESSAGE_PREFIX = '[SPLIDE]';
953/**
954 * Display an error message on the browser console.
955 *
956 * @param {string} message - An error message.
957 */
958
959function error_error(message) {
960 console.error(MESSAGE_PREFIX + " " + message);
961}
962/**
963 * Check existence of the given object and throw an error if it doesn't.
964 *
965 * @throws {Error}
966 *
967 * @param {*} subject - A subject to be confirmed.
968 * @param {string} message - An error message.
969 */
970
971function exist(subject, message) {
972 if (!subject) {
973 throw new Error(message);
974 }
975}
976// CONCATENATED MODULE: ./src/js/constants/classes.js
977/**
978 * Export class names.
979 *
980 * @author Naotoshi Fujita
981 * @copyright Naotoshi Fujita. All rights reserved.
982 */
983
984/**
985 * A root class name.
986 *
987 * @type {string}
988 */
989var ROOT = 'mw-splide';
990/**
991 * The definition table of all classes for elements.
992 * They might be modified by options.
993 *
994 * @type {Object}
995 */
996
997var ELEMENT_CLASSES = {
998 root: ROOT,
999 slider: ROOT + "__slider",
1000 track: ROOT + "__track",
1001 list: ROOT + "__list",
1002 slide: ROOT + "__slide",
1003 container: ROOT + "__slide__container",
1004 arrows: ROOT + "__arrows",
1005 arrow: ROOT + "__arrow",
1006 prev: ROOT + "__arrow--prev",
1007 next: ROOT + "__arrow--next",
1008 pagination: ROOT + "__pagination",
1009 page: ROOT + "__pagination__page",
1010 clone: ROOT + "__slide--clone",
1011 progress: ROOT + "__progress",
1012 bar: ROOT + "__progress__bar",
1013 autoplay: ROOT + "__autoplay",
1014 play: ROOT + "__play",
1015 pause: ROOT + "__pause",
1016 spinner: ROOT + "__spinner",
1017 sr: ROOT + "__sr"
1018};
1019/**
1020 * Definitions of status classes.
1021 *
1022 * @type {Object}
1023 */
1024
1025var STATUS_CLASSES = {
1026 active: 'is-active',
1027 visible: 'is-visible',
1028 loading: 'is-loading'
1029};
1030// CONCATENATED MODULE: ./src/js/constants/i18n.js
1031/**
1032 * Export i18n texts as object.
1033 *
1034 * @author Naotoshi Fujita
1035 * @copyright Naotoshi Fujita. All rights reserved.
1036 */
1037
1038/**
1039 * Texts for i18n.
1040 *
1041 * @type {Object}
1042 */
1043var I18N = {
1044 prev: 'Previous slide',
1045 next: 'Next slide',
1046 first: 'Go to first slide',
1047 last: 'Go to last slide',
1048 slideX: 'Go to slide %s',
1049 pageX: 'Go to page %s',
1050 play: 'Start autoplay',
1051 pause: 'Pause autoplay'
1052};
1053// CONCATENATED MODULE: ./src/js/constants/defaults.js
1054/**
1055 * Export default options.
1056 *
1057 * @author Naotoshi Fujita
1058 * @copyright Naotoshi Fujita. All rights reserved.
1059 */
1060
1061
1062var DEFAULTS = {
1063 /**
1064 * Determine a slider type.
1065 * - 'slide': Regular slider.
1066 * - 'loop' : Carousel slider.
1067 * - 'fade' : Change slides with fade transition. perPage, drag options are ignored.
1068 *
1069 * @type {string}
1070 */
1071 type: 'slide',
1072
1073 /**
1074 * Whether to rewind a slider before the first slide or after the last one.
1075 * In "loop" mode, this option is ignored.
1076 *
1077 * @type {boolean}
1078 */
1079 rewind: false,
1080
1081 /**
1082 * Transition speed in milliseconds.
1083 *
1084 * @type {number}
1085 */
1086 speed: 400,
1087
1088 /**
1089 * Transition speed on rewind in milliseconds.
1090 *
1091 * @type {number}
1092 */
1093 rewindSpeed: 0,
1094
1095 /**
1096 * Whether to prevent any actions while a slider is transitioning.
1097 * If false, navigation, drag and swipe work while the slider is running.
1098 * Even so, it will be forced to wait for transition in some cases in the loop mode to shift a slider.
1099 *
1100 * @type {boolean}
1101 */
1102 waitForTransition: true,
1103
1104 /**
1105 * Define slider max width.
1106 *
1107 * @type {number}
1108 */
1109 width: 0,
1110
1111 /**
1112 * Define slider height.
1113 *
1114 * @type {number}
1115 */
1116 height: 0,
1117
1118 /**
1119 * Fix width of slides. CSS format is allowed such as 10em, 80% or 80vw.
1120 * perPage number will be ignored when this option is falsy.
1121 *
1122 * @type {number|string}
1123 */
1124 fixedWidth: 0,
1125
1126 /**
1127 * Fix height of slides. CSS format is allowed such as 10em, 80vh but % unit is not accepted.
1128 * heightRatio option will be ignored when this option is falsy.
1129 *
1130 * @type {number|string}
1131 */
1132 fixedHeight: 0,
1133
1134 /**
1135 * Determine height of slides by ratio to a slider width.
1136 * This will be ignored when the fixedHeight is provided.
1137 *
1138 * @type {number}
1139 */
1140 heightRatio: 0,
1141
1142 /**
1143 * If true, slide width will be determined by the element width itself.
1144 * - perPage/perMove should be 1.
1145 *
1146 * @type {boolean}
1147 */
1148 autoWidth: false,
1149
1150 /**
1151 * If true, slide height will be determined by the element width itself.
1152 * - perPage/perMove should be 1.
1153 *
1154 * @type {boolean}
1155 */
1156 autoHeight: false,
1157
1158 /**
1159 * Determine how many slides should be displayed per page.
1160 *
1161 * @type {number}
1162 */
1163 perPage: 1,
1164
1165 /**
1166 * Determine how many slides should be moved when a slider goes to next or perv.
1167 *
1168 * @type {number}
1169 */
1170 perMove: 0,
1171
1172 /**
1173 * Determine manually how many clones should be generated on the left and right side.
1174 * The total number of clones will be twice of this number.
1175 *
1176 * @type {number}
1177 */
1178 clones: 0,
1179
1180 /**
1181 * Start index.
1182 *
1183 * @type {number}
1184 */
1185 start: 0,
1186
1187 /**
1188 * Determine which slide should be focused if there are multiple slides in a page.
1189 * A string "center" is acceptable for centering slides.
1190 *
1191 * @type {boolean|number|string}
1192 */
1193 focus: false,
1194
1195 /**
1196 * Gap between slides. CSS format is allowed such as 1em.
1197 *
1198 * @type {number|string}
1199 */
1200 gap: 0,
1201
1202 /**
1203 * Set padding-left/right in horizontal mode or padding-top/bottom in vertical one.
1204 * Give a single value to set a same size for both sides or
1205 * do an object for different sizes.
1206 * Also, CSS format is allowed such as 1em.
1207 *
1208 * @example
1209 * - 10: Number
1210 * - '1em': CSS format.
1211 * - { left: 0, right: 20 }: Object for different sizes in horizontal mode.
1212 * - { top: 0, bottom: 20 }: Object for different sizes in vertical mode.
1213 *
1214 * @type {number|string|Object}
1215 */
1216 padding: 0,
1217
1218 /**
1219 * Whether to append arrows.
1220 *
1221 * @type {boolean}
1222 */
1223 arrows: true,
1224
1225 /**
1226 * Change the arrow SVG path like 'm7.61 0.807-2.12...'.
1227 *
1228 * @type {string}
1229 */
1230 arrowPath: '',
1231
1232 /**
1233 * Whether to append pagination(indicator dots) or not.
1234 *
1235 * @type {boolean}
1236 */
1237 pagination: true,
1238
1239 /**
1240 * Activate autoplay.
1241 *
1242 * @type {boolean}
1243 */
1244 autoplay: false,
1245
1246 /**
1247 * Autoplay interval in milliseconds.
1248 *
1249 * @type {number}
1250 */
1251 interval: 5000,
1252
1253 /**
1254 * Whether to stop autoplay when a slider is hovered.
1255 *
1256 * @type {boolean}
1257 */
1258 pauseOnHover: true,
1259
1260 /**
1261 * Whether to stop autoplay when a slider elements are focused.
1262 * True is recommended for accessibility.
1263 *
1264 * @type {boolean}
1265 */
1266 pauseOnFocus: true,
1267
1268 /**
1269 * Whether to reset progress of the autoplay timer when resumed.
1270 *
1271 * @type {boolean}
1272 */
1273 resetProgress: true,
1274
1275 /**
1276 * Loading images lazily.
1277 * Image src must be provided by a data-splide-lazy attribute.
1278 *
1279 * - false: Do nothing.
1280 * - 'nearby': Only images around an active slide will be loaded.
1281 * - 'sequential': All images will be sequentially loaded.
1282 *
1283 * @type {boolean|string}
1284 */
1285 lazyLoad: false,
1286
1287 /**
1288 * This option works only when a lazyLoad option is "nearby".
1289 * Determine how many pages(not slides) around an active slide should be loaded beforehand.
1290 *
1291 * @type {number}
1292 */
1293 preloadPages: 1,
1294
1295 /**
1296 * Easing for CSS transition. For example, linear, ease or cubic-bezier().
1297 *
1298 * @type {string}
1299 */
1300 easing: 'cubic-bezier(.42,.65,.27,.99)',
1301
1302 /**
1303 * Whether to enable keyboard shortcuts
1304 * - true or 'global': Listen to keydown event of the document.
1305 * - 'focused': Listen to the keydown event of the slider root element. tabindex="0" will be added to the element.
1306 * - false: Disable keyboard shortcuts.
1307 *
1308 * @type {boolean|string}
1309 */
1310 keyboard: 'global',
1311
1312 /**
1313 * Whether to allow mouse drag and touch swipe.
1314 *
1315 * @type {boolean}
1316 */
1317 drag: true,
1318
1319 /**
1320 * The angle threshold for drag.
1321 * The slider starts moving only when the drag angle is less than this threshold.
1322 *
1323 * @type {number}
1324 */
1325 dragAngleThreshold: 30,
1326
1327 /**
1328 * Distance threshold for determining if the action is "flick" or "swipe".
1329 * When a drag distance is over this value, the action will be treated as "swipe", not "flick".
1330 *
1331 * @type {number}
1332 */
1333 swipeDistanceThreshold: 150,
1334
1335 /**
1336 * Velocity threshold for determining if the action is "flick" or "swipe".
1337 * Around 0.5 is recommended.
1338 *
1339 * @type {number}
1340 */
1341 flickVelocityThreshold: .6,
1342
1343 /**
1344 * Determine power of flick. The larger number this is, the farther a slider runs by flick.
1345 * Around 500 is recommended.
1346 *
1347 * @type {number}
1348 */
1349 flickPower: 600,
1350
1351 /**
1352 * Limit a number of pages to move by flick.
1353 *
1354 * @type {number}
1355 */
1356 flickMaxPages: 1,
1357
1358 /**
1359 * Slider direction.
1360 * - 'ltr': Left to right.
1361 * - 'rtl': Right to left.
1362 * - 'ttb': Top to bottom.
1363 *
1364 * @type {string}
1365 */
1366 direction: 'ltr',
1367
1368 /**
1369 * Set img src to background-image of its parent element.
1370 * Images with various sizes can be displayed as same dimension without cropping work.
1371 * fixedHeight or heightRatio is required.
1372 *
1373 * @type {boolean}
1374 */
1375 cover: false,
1376
1377 /**
1378 * Whether to enable accessibility(aria and screen reader texts) or not.
1379 *
1380 * @type {boolean}
1381 */
1382 accessibility: true,
1383
1384 /**
1385 * Whether to add tabindex="0" to visible slides or not.
1386 *
1387 * @type {boolean}
1388 */
1389 slideFocus: true,
1390
1391 /**
1392 * Determine if a slider is navigation for another.
1393 * Use "sync" API to synchronize two sliders.
1394 *
1395 * @type {boolean}
1396 */
1397 isNavigation: false,
1398
1399 /**
1400 * Whether to trim spaces before the fist slide or after the last one when "focus" is not 0.
1401 *
1402 * @type {boolean}
1403 */
1404 trimSpace: true,
1405
1406 /**
1407 * The "is-active" class is added after transition as default.
1408 * If true, it will be added before move.
1409 *
1410 * @type {boolean}
1411 */
1412 updateOnMove: false,
1413
1414 /**
1415 * Throttle duration in milliseconds for the resize event.
1416 *
1417 * @type {number}
1418 */
1419 throttle: 100,
1420
1421 /**
1422 * Whether to destroy a slider or not.
1423 *
1424 * @type {boolean}
1425 */
1426 destroy: false,
1427
1428 /**
1429 * Options for specific breakpoints.
1430 *
1431 * @example
1432 * {
1433 * 1000: {
1434 * perPage: 3,
1435 * gap: 20
1436 * },
1437 * 600: {
1438 * perPage: 1,
1439 * gap: 5,
1440 * }
1441 * }
1442 *
1443 * @type {boolean|Object}
1444 */
1445 breakpoints: false,
1446
1447 /**
1448 * Collection of class names.
1449 *
1450 * @see ./classes.js
1451 *
1452 * @type {Object}
1453 */
1454 classes: ELEMENT_CLASSES,
1455
1456 /**
1457 * Collection of i18n texts.
1458 *
1459 * @see ./i18n.js
1460 *
1461 * @type {Object}
1462 */
1463 i18n: I18N
1464};
1465// CONCATENATED MODULE: ./src/js/constants/states.js
1466/**
1467 * Export state constants.
1468 *
1469 * @author Naotoshi Fujita
1470 * @copyright Naotoshi Fujita. All rights reserved.
1471 */
1472
1473/**
1474 * Splide has been just created.
1475 *
1476 * @type {number}
1477 */
1478var CREATED = 1;
1479/**
1480 * All components have been mounted and initialized.
1481 *
1482 * @type {number}
1483 */
1484
1485var MOUNTED = 2;
1486/**
1487 * Splide is ready for transition.
1488 *
1489 * @type {number}
1490 */
1491
1492var IDLE = 3;
1493/**
1494 * Splide is moving.
1495 *
1496 * @type {number}
1497 */
1498
1499var MOVING = 4;
1500/**
1501 * Splide is moving.
1502 *
1503 * @type {number}
1504 */
1505
1506var DESTROYED = 5;
1507// CONCATENATED MODULE: ./src/js/splide.js
1508function _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); } }
1509
1510function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
1511
1512/**
1513 * The main class for applying Splide to an element.
1514 *
1515 * @author Naotoshi Fujita
1516 * @copyright Naotoshi Fujita. All rights reserved.
1517 */
1518
1519
1520
1521
1522
1523
1524
1525
1526/**
1527 * The main class for applying Splide to an element,
1528 * providing some APIs to control the behavior.
1529 */
1530
1531var splide_Splide = /*#__PURE__*/function () {
1532 /**
1533 * Splide constructor.
1534 *
1535 * @throws {Error} When the given root element or selector is invalid.
1536 *
1537 * @param {Element|string} root - A selector for a root element or an element itself.
1538 * @param {Object} options - Optional. Options to change default behaviour.
1539 * @param {Object} Components - Optional. Components.
1540 */
1541 function Splide(root, options, Components) {
1542 if (options === void 0) {
1543 options = {};
1544 }
1545
1546 if (Components === void 0) {
1547 Components = {};
1548 }
1549
1550 this.root = root instanceof Element ? root : document.querySelector(root);
1551 exist(this.root, 'An invalid element/selector was given.');
1552 this.Components = null;
1553 this.Event = core_event();
1554 this.State = state(CREATED);
1555 this.STATES = states_namespaceObject;
1556 this._o = merge(DEFAULTS, options);
1557 this._i = 0;
1558 this._c = Components;
1559 this._e = {}; // Extensions
1560
1561 this._t = null; // Transition
1562 }
1563 /**
1564 * Compose and mount components.
1565 *
1566 * @param {Object} Extensions - Optional. Additional components.
1567 * @param {function} Transition - Optional. Set a custom transition component.
1568 *
1569 * @return {Splide|undefined} - This instance or undefined if an exception occurred.
1570 */
1571
1572
1573 var _proto = Splide.prototype;
1574
1575 _proto.mount = function mount(Extensions, Transition) {
1576 var _this = this;
1577
1578 if (Extensions === void 0) {
1579 Extensions = this._e;
1580 }
1581
1582 if (Transition === void 0) {
1583 Transition = this._t;
1584 }
1585
1586 this._e = Extensions;
1587 this._t = Transition;
1588 this.Components = compose(this, merge(this._c, Extensions), Transition);
1589
1590 try {
1591 each(this.Components, function (component, key) {
1592 var required = component.required;
1593
1594 if (required === undefined || required) {
1595 component.mount && component.mount();
1596 } else {
1597 delete _this.Components[key];
1598 }
1599 });
1600 } catch (e) {
1601 error_error(e.message);
1602 return;
1603 }
1604
1605 var State = this.State;
1606 State.set(MOUNTED);
1607 each(this.Components, function (component) {
1608 component.mounted && component.mounted();
1609 });
1610 this.emit('mounted');
1611 State.set(IDLE);
1612 this.emit('ready');
1613 applyStyle(this.root, {
1614 visibility: 'visible'
1615 });
1616 this.on('move drag', function () {
1617 return State.set(MOVING);
1618 }).on('moved dragged', function () {
1619 return State.set(IDLE);
1620 });
1621 return this;
1622 }
1623 /**
1624 * Set sync target.
1625 *
1626 * @param {Splide} splide - A Splide instance.
1627 *
1628 * @return {Splide} - This instance.
1629 */
1630 ;
1631
1632 _proto.sync = function sync(splide) {
1633 this.sibling = splide;
1634 return this;
1635 }
1636 /**
1637 * Register callback fired on the given event(s).
1638 *
1639 * @param {string} events - An event name. Use space to separate multiple events.
1640 * Also, namespace is accepted by dot, such as 'resize.{namespace}'.
1641 * @param {function} handler - A callback function.
1642 * @param {Element} elm - Optional. Native event will be listened to when this arg is provided.
1643 * @param {Object} options - Optional. Options for addEventListener.
1644 *
1645 * @return {Splide} - This instance.
1646 */
1647 ;
1648
1649 _proto.on = function on(events, handler, elm, options) {
1650 if (elm === void 0) {
1651 elm = null;
1652 }
1653
1654 if (options === void 0) {
1655 options = {};
1656 }
1657
1658 this.Event.on(events, handler, elm, options);
1659 return this;
1660 }
1661 /**
1662 * Unsubscribe the given event.
1663 *
1664 * @param {string} events - A event name.
1665 * @param {Element} elm - Optional. removeEventListener() will be called when this arg is provided.
1666 *
1667 * @return {Splide} - This instance.
1668 */
1669 ;
1670
1671 _proto.off = function off(events, elm) {
1672 if (elm === void 0) {
1673 elm = null;
1674 }
1675
1676 this.Event.off(events, elm);
1677 return this;
1678 }
1679 /**
1680 * Emit an event.
1681 *
1682 * @param {string} event - An event name.
1683 * @param {*} args - Any number of arguments passed to handlers.
1684 */
1685 ;
1686
1687 _proto.emit = function emit(event) {
1688 var _this$Event;
1689
1690 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1691 args[_key - 1] = arguments[_key];
1692 }
1693
1694 (_this$Event = this.Event).emit.apply(_this$Event, [event].concat(args));
1695
1696 return this;
1697 }
1698 /**
1699 * Go to the slide specified by the given control.
1700 *
1701 * @param {string|number} control - A control pattern.
1702 * @param {boolean} wait - Optional. Whether to wait for transition.
1703 */
1704 ;
1705
1706 _proto.go = function go(control, wait) {
1707 if (wait === void 0) {
1708 wait = this.options.waitForTransition;
1709 }
1710
1711 if (this.State.is(IDLE) || this.State.is(MOVING) && !wait) {
1712 this.Components.Controller.go(control, false);
1713 }
1714
1715 return this;
1716 }
1717 /**
1718 * Verify whether the slider type is the given one or not.
1719 *
1720 * @param {string} type - A slider type.
1721 *
1722 * @return {boolean} - True if the slider type is the provided type or false if not.
1723 */
1724 ;
1725
1726 _proto.is = function is(type) {
1727 return type === this._o.type;
1728 }
1729 /**
1730 * Insert a slide.
1731 *
1732 * @param {Element|string} slide - A slide element to be added.
1733 * @param {number} index - A slide will be added at the position.
1734 */
1735 ;
1736
1737 _proto.add = function add(slide, index) {
1738 if (index === void 0) {
1739 index = -1;
1740 }
1741
1742 this.Components.Elements.add(slide, index, this.refresh.bind(this));
1743 return this;
1744 }
1745 /**
1746 * Remove the slide designated by the index.
1747 *
1748 * @param {number} index - A slide index.
1749 */
1750 ;
1751
1752 _proto.remove = function remove(index) {
1753 this.Components.Elements.remove(index);
1754 this.refresh();
1755 return this;
1756 }
1757 /**
1758 * Destroy all Slide objects and clones and recreate them again.
1759 */
1760 ;
1761
1762 _proto.refresh = function refresh() {
1763 this.emit('refresh').emit('resize');
1764 return this;
1765 }
1766 /**
1767 * Destroy the Splide.
1768 * "Completely" boolean is mainly for breakpoints.
1769 *
1770 * @param {boolean} completely - Destroy completely.
1771 */
1772 ;
1773
1774 _proto.destroy = function destroy(completely) {
1775 var _this2 = this;
1776
1777 if (completely === void 0) {
1778 completely = true;
1779 }
1780
1781 // Postpone destroy because it should be done after mount.
1782 if (this.State.is(CREATED)) {
1783 this.on('ready', function () {
1784 return _this2.destroy(completely);
1785 });
1786 return;
1787 }
1788
1789 values(this.Components).reverse().forEach(function (component) {
1790 component.destroy && component.destroy(completely);
1791 });
1792 this.emit('destroy', completely); // Destroy all event handlers, including ones for native events.
1793
1794 this.Event.destroy();
1795 this.State.set(DESTROYED);
1796 return this;
1797 }
1798 /**
1799 * Return the current slide index.
1800 *
1801 * @return {number} - The current slide index.
1802 // */
1803 ;
1804
1805 _createClass(Splide, [{
1806 key: "index",
1807 get: function get() {
1808 return this._i;
1809 }
1810 /**
1811 * Set the current slide index.
1812 *
1813 * @param {number|string} index - A new index.
1814 */
1815 ,
1816 set: function set(index) {
1817 this._i = parseInt(index);
1818 }
1819 /**
1820 * Return length of slides.
1821 * This is an alias of Elements.length.
1822 *
1823 * @return {number} - A number of slides.
1824 */
1825
1826 }, {
1827 key: "length",
1828 get: function get() {
1829 return this.Components.Elements.length;
1830 }
1831 /**
1832 * Return options.
1833 *
1834 * @return {Object} - Options object.
1835 */
1836
1837 }, {
1838 key: "options",
1839 get: function get() {
1840 return this._o;
1841 }
1842 /**
1843 * Set options with merging the given object to the current one.
1844 *
1845 * @param {Object} options - New options.
1846 */
1847 ,
1848 set: function set(options) {
1849 var created = this.State.is(CREATED);
1850
1851 if (!created) {
1852 this.emit('update');
1853 }
1854
1855 this._o = merge(this._o, options);
1856
1857 if (!created) {
1858 this.emit('updated', this._o);
1859 }
1860 }
1861 /**
1862 * Return the class list.
1863 * This is an alias of Splide.options.classList.
1864 *
1865 * @return {Object} - An object containing all class list.
1866 */
1867
1868 }, {
1869 key: "classes",
1870 get: function get() {
1871 return this._o.classes;
1872 }
1873 /**
1874 * Return the i18n strings.
1875 * This is an alias of Splide.options.i18n.
1876 *
1877 * @return {Object} - An object containing all i18n strings.
1878 */
1879
1880 }, {
1881 key: "i18n",
1882 get: function get() {
1883 return this._o.i18n;
1884 }
1885 }]);
1886
1887 return Splide;
1888}();
1889
1890
1891// CONCATENATED MODULE: ./src/js/components/options/index.js
1892/**
1893 * The component for initializing options.
1894 *
1895 * @author Naotoshi Fujita
1896 * @copyright Naotoshi Fujita. All rights reserved.
1897 */
1898
1899
1900
1901/**
1902 * The component for initializing options.
1903 *
1904 * @param {Splide} Splide - A Splide instance.
1905 *
1906 * @return {Object} - The component object.
1907 */
1908
1909/* harmony default export */ var components_options = (function (Splide) {
1910 /**
1911 * Retrieve options from the data attribute.
1912 * Note that IE10 doesn't support dataset property.
1913 *
1914 * @type {string}
1915 */
1916 var options = getAttribute(Splide.root, 'data-splide');
1917
1918 if (options) {
1919 try {
1920 Splide.options = JSON.parse(options);
1921 } catch (e) {
1922 error_error(e.message);
1923 }
1924 }
1925
1926 return {
1927 /**
1928 * Called when the component is mounted.
1929 */
1930 mount: function mount() {
1931 if (Splide.State.is(CREATED)) {
1932 Splide.index = Splide.options.start;
1933 }
1934 }
1935 };
1936});
1937// CONCATENATED MODULE: ./src/js/constants/directions.js
1938/**
1939 * Export layout modes.
1940 *
1941 * @author Naotoshi Fujita
1942 * @copyright Naotoshi Fujita. All rights reserved.
1943 */
1944
1945/**
1946 * Enumerate slides from left to right.
1947 *
1948 * @type {string}
1949 */
1950var LTR = 'ltr';
1951/**
1952 * Enumerate slides from right to left.
1953 *
1954 * @type {string}
1955 */
1956
1957var RTL = 'rtl';
1958/**
1959 * Enumerate slides in a col.
1960 *
1961 * @type {string}
1962 */
1963
1964var TTB = 'ttb';
1965// CONCATENATED MODULE: ./src/js/components/elements/slide.js
1966/**
1967 * The sub component for handling each slide.
1968 *
1969 * @author Naotoshi Fujita
1970 * @copyright Naotoshi Fujita. All rights reserved.
1971 */
1972
1973
1974
1975
1976
1977
1978/**
1979 * Events for restoring original styles.
1980 *
1981 * @type {string}
1982 */
1983
1984var STYLE_RESTORE_EVENTS = 'update.slide';
1985/**
1986 * The sub component for handling each slide.
1987 *
1988 * @param {Splide} Splide - A Splide instance.
1989 * @param {number} index - An unique slide index.
1990 * @param {number} realIndex - Clones should pass a real slide index.
1991 * @param {Element} slide - A slide element.
1992 *
1993 * @return {Object} - The sub component object.
1994 */
1995
1996/* harmony default export */ var elements_slide = (function (Splide, index, realIndex, slide) {
1997 /**
1998 * Whether to update "is-active" class before or after transition.
1999 *
2000 * @type {boolean}
2001 */
2002 var updateOnMove = Splide.options.updateOnMove;
2003 /**
2004 * Events when the slide status is updated.
2005 * Append a namespace to remove listeners later.
2006 *
2007 * @type {string}
2008 */
2009
2010 var STATUS_UPDATE_EVENTS = 'ready.slide updated.slide resize.slide moved.slide' + (updateOnMove ? ' move.slide' : '');
2011 /**
2012 * Slide sub component object.
2013 *
2014 * @type {Object}
2015 */
2016
2017 var Slide = {
2018 /**
2019 * Slide element.
2020 *
2021 * @type {Element}
2022 */
2023 slide: slide,
2024
2025 /**
2026 * Slide index.
2027 *
2028 * @type {number}
2029 */
2030 index: index,
2031
2032 /**
2033 * Real index for clones.
2034 *
2035 * @type {number}
2036 */
2037 realIndex: realIndex,
2038
2039 /**
2040 * Container element if available.
2041 *
2042 * @type {Element|undefined}
2043 */
2044 container: child(slide, Splide.classes.container),
2045
2046 /**
2047 * Whether this is a cloned slide or not.
2048 *
2049 * @type {boolean}
2050 */
2051 isClone: realIndex > -1,
2052
2053 /**
2054 * Called when the component is mounted.
2055 */
2056 mount: function mount() {
2057 var _this = this;
2058
2059 if (!this.isClone) {
2060 slide.id = Splide.root.id + "-slide" + pad(index + 1);
2061 }
2062
2063 Splide.on(STATUS_UPDATE_EVENTS, function () {
2064 return _this.update();
2065 }).on(STYLE_RESTORE_EVENTS, restoreStyles).on('click', function () {
2066 return Splide.emit('click', _this);
2067 }, slide);
2068 /*
2069 * Add "is-active" class to a clone element temporarily
2070 * and it will be removed on "moved" event.
2071 */
2072
2073 if (updateOnMove) {
2074 Splide.on('move.slide', function (newIndex) {
2075 if (newIndex === realIndex) {
2076 _update(true, false);
2077 }
2078 });
2079 } // Make sure the slide is shown.
2080
2081
2082 applyStyle(slide, {
2083 display: ''
2084 }); // Hold the original styles.
2085
2086 this.styles = getAttribute(slide, 'style') || '';
2087 },
2088
2089 /**
2090 * Destroy.
2091 */
2092 destroy: function destroy() {
2093 Splide.off(STATUS_UPDATE_EVENTS).off(STYLE_RESTORE_EVENTS).off('click', slide);
2094 removeClass(slide, values(STATUS_CLASSES));
2095 restoreStyles();
2096 removeAttribute(this.container, 'style');
2097 },
2098
2099 /**
2100 * Update active and visible status.
2101 */
2102 update: function update() {
2103 _update(this.isActive(), false);
2104
2105 _update(this.isVisible(), true);
2106 },
2107
2108 /**
2109 * Check whether this slide is active or not.
2110 *
2111 * @return {boolean} - True if the slide is active or false if not.
2112 */
2113 isActive: function isActive() {
2114 return Splide.index === index;
2115 },
2116
2117 /**
2118 * Check whether this slide is visible in the viewport or not.
2119 *
2120 * @return {boolean} - True if the slide is visible or false if not.
2121 */
2122 isVisible: function isVisible() {
2123 var active = this.isActive();
2124
2125 if (Splide.is(FADE) || active) {
2126 return active;
2127 }
2128
2129 var trackRect = getRect(Splide.Components.Elements.track);
2130 var slideRect = getRect(slide);
2131
2132 if (Splide.options.direction === TTB) {
2133 return trackRect.top <= slideRect.top && slideRect.bottom <= trackRect.bottom;
2134 }
2135
2136 return trackRect.left <= slideRect.left && slideRect.right <= trackRect.right;
2137 },
2138
2139 /**
2140 * Calculate how far this slide is from another slide and
2141 * return true if the distance is within the given number.
2142 *
2143 * @param {number} from - Index of a target slide.
2144 * @param {number} within - True if the slide is within this number.
2145 *
2146 * @return {boolean} - True if the slide is within the number or false otherwise.
2147 */
2148 isWithin: function isWithin(from, within) {
2149 var diff = Math.abs(from - index);
2150
2151 if (!Splide.is(SLIDE) && !this.isClone) {
2152 diff = Math.min(diff, Splide.length - diff);
2153 }
2154
2155 return diff < within;
2156 }
2157 };
2158 /**
2159 * Update classes for activity or visibility.
2160 *
2161 * @param {boolean} active - Is active/visible or not.
2162 * @param {boolean} forVisibility - Toggle classes for activity or visibility.
2163 */
2164
2165 function _update(active, forVisibility) {
2166 var type = forVisibility ? 'visible' : 'active';
2167 var className = STATUS_CLASSES[type];
2168
2169 if (active) {
2170 addClass(slide, className);
2171 Splide.emit("" + type, Slide);
2172 } else {
2173 if (hasClass(slide, className)) {
2174 removeClass(slide, className);
2175 Splide.emit("" + (forVisibility ? 'hidden' : 'inactive'), Slide);
2176 }
2177 }
2178 }
2179 /**
2180 * Restore the original styles.
2181 */
2182
2183
2184 function restoreStyles() {
2185 setAttribute(slide, 'style', Slide.styles);
2186 }
2187
2188 return Slide;
2189});
2190// CONCATENATED MODULE: ./src/js/components/elements/index.js
2191/**
2192 * The component for main elements.
2193 *
2194 * @author Naotoshi Fujita
2195 * @copyright Naotoshi Fujita. All rights reserved.
2196 */
2197
2198
2199
2200
2201
2202/**
2203 * The property name for UID stored in a window object.
2204 *
2205 * @type {string}
2206 */
2207
2208var UID_NAME = 'uid';
2209/**
2210 * The component for main elements.
2211 *
2212 * @param {Splide} Splide - A Splide instance.
2213 * @param {Object} Components - An object containing components.
2214 *
2215 * @return {Object} - The component object.
2216 */
2217
2218/* harmony default export */ var components_elements = (function (Splide, Components) {
2219 /**
2220 * Hold the root element.
2221 *
2222 * @type {Element}
2223 */
2224 var root = Splide.root;
2225 /**
2226 * Hold the class list.
2227 *
2228 * @type {Object}
2229 */
2230
2231 var classes = Splide.classes;
2232 /**
2233 * Store Slide objects.
2234 *
2235 * @type {Array}
2236 */
2237
2238 var Slides = [];
2239 /*
2240 * Assign unique ID to the root element if it doesn't have the one.
2241 * Note that IE doesn't support padStart() to fill the uid by 0.
2242 */
2243
2244 if (!root.id) {
2245 window.splide = window.splide || {};
2246 var uid = window.splide[UID_NAME] || 0;
2247 window.splide[UID_NAME] = ++uid;
2248 root.id = "splide" + pad(uid);
2249 }
2250 /**
2251 * Elements component object.
2252 *
2253 * @type {Object}
2254 */
2255
2256
2257 var Elements = {
2258 /**
2259 * Called when the component is mounted.
2260 * Collect main elements and store them as member properties.
2261 */
2262 mount: function mount() {
2263 var _this = this;
2264
2265 collect();
2266 this.init();
2267 Splide.on('refresh', function () {
2268 _this.destroy();
2269
2270 _this.init();
2271 }).on('updated', function () {
2272 removeClass(root, getClasses());
2273 addClass(root, getClasses());
2274 });
2275 },
2276
2277 /**
2278 * Destroy.
2279 */
2280 destroy: function destroy() {
2281 Slides.forEach(function (Slide) {
2282 Slide.destroy();
2283 });
2284 Slides = [];
2285 removeClass(root, getClasses());
2286 },
2287
2288 /**
2289 * Initialization.
2290 */
2291 init: function init() {
2292 addClass(root, getClasses());
2293 Elements.slides.forEach(function (slide, index) {
2294 Elements.register(slide, index, -1);
2295 });
2296 },
2297
2298 /**
2299 * Register a slide to create a Slide object and handle its behavior.
2300 *
2301 * @param {Element} slide - A slide element.
2302 * @param {number} index - A unique index. This can be negative.
2303 * @param {number} realIndex - A real index for clones. Set -1 for real slides.
2304 */
2305 register: function register(slide, index, realIndex) {
2306 var SlideObject = elements_slide(Splide, index, realIndex, slide);
2307 SlideObject.mount();
2308 Slides.push(SlideObject);
2309 },
2310
2311 /**
2312 * Return the Slide object designated by the index.
2313 * Note that "find" is not supported by IE.
2314 *
2315 * @return {Object|undefined} - A Slide object if available. Undefined if not.
2316 */
2317 getSlide: function getSlide(index) {
2318 return Slides.filter(function (Slide) {
2319 return Slide.index === index;
2320 })[0];
2321 },
2322
2323 /**
2324 * Return all Slide objects.
2325 *
2326 * @param {boolean} includeClones - Whether to include cloned slides or not.
2327 *
2328 * @return {Object[]} - Slide objects.
2329 */
2330 getSlides: function getSlides(includeClones) {
2331 return includeClones ? Slides : Slides.filter(function (Slide) {
2332 return !Slide.isClone;
2333 });
2334 },
2335
2336 /**
2337 * Return Slide objects belonging to the given page.
2338 *
2339 * @param {number} page - A page number.
2340 *
2341 * @return {Object[]} - An array containing Slide objects.
2342 */
2343 getSlidesByPage: function getSlidesByPage(page) {
2344 var idx = Components.Controller.toIndex(page);
2345 var options = Splide.options;
2346 var max = options.focus !== false ? 1 : options.perPage;
2347 return Slides.filter(function (_ref) {
2348 var index = _ref.index;
2349 return idx <= index && index < idx + max;
2350 });
2351 },
2352
2353 /**
2354 * Insert a slide to a slider.
2355 * Need to refresh Splide after adding a slide.
2356 *
2357 * @param {Node|string} slide - A slide element to be added.
2358 * @param {number} index - A slide will be added at the position.
2359 * @param {Function} callback - Called right after the slide is added to the DOM tree.
2360 */
2361 add: function add(slide, index, callback) {
2362 if (typeof slide === 'string') {
2363 slide = domify(slide);
2364 }
2365
2366 if (slide instanceof Element) {
2367 var ref = this.slides[index]; // This will be removed in mount() of a Slide component.
2368
2369 applyStyle(slide, {
2370 display: 'none'
2371 });
2372
2373 if (ref) {
2374 before(slide, ref);
2375 this.slides.splice(index, 0, slide);
2376 } else {
2377 append(this.list, slide);
2378 this.slides.push(slide);
2379 }
2380
2381 dom_loaded(slide, function () {
2382 callback && callback(slide);
2383 });
2384 }
2385 },
2386
2387 /**
2388 * Remove a slide from a slider.
2389 * Need to refresh Splide after removing a slide.
2390 *
2391 * @param index - Slide index.
2392 */
2393 remove: function remove(index) {
2394 dom_remove(this.slides.splice(index, 1)[0]);
2395 },
2396
2397 /**
2398 * Trigger the provided callback for each Slide object.
2399 *
2400 * @param {Function} callback - A callback function. The first argument will be the Slide object.
2401 */
2402 each: function each(callback) {
2403 Slides.forEach(callback);
2404 },
2405
2406 /**
2407 * Return slides length without clones.
2408 *
2409 * @return {number} - Slide length.
2410 */
2411 get length() {
2412 return this.slides.length;
2413 },
2414
2415 /**
2416 * Return "SlideObjects" length including clones.
2417 *
2418 * @return {number} - Slide length including clones.
2419 */
2420 get total() {
2421 return Slides.length;
2422 }
2423
2424 };
2425 /**
2426 * Collect elements.
2427 */
2428
2429 function collect() {
2430 Elements.slider = child(root, classes.slider);
2431 Elements.track = find(root, "." + classes.track);
2432 Elements.list = child(Elements.track, classes.list);
2433 exist(Elements.track && Elements.list, 'Track or list was not found.');
2434 Elements.slides = children(Elements.list, classes.slide);
2435 var arrows = findParts(classes.arrows);
2436 Elements.arrows = {
2437 prev: find(arrows, "." + classes.prev),
2438 next: find(arrows, "." + classes.next)
2439 };
2440 var autoplay = findParts(classes.autoplay);
2441 Elements.bar = find(findParts(classes.progress), "." + classes.bar);
2442 Elements.play = find(autoplay, "." + classes.play);
2443 Elements.pause = find(autoplay, "." + classes.pause);
2444 Elements.track.id = Elements.track.id || root.id + "-track";
2445 Elements.list.id = Elements.list.id || root.id + "-list";
2446 }
2447 /**
2448 * Return class names for the root element.
2449 */
2450
2451
2452 function getClasses() {
2453 var rootClass = classes.root;
2454 var options = Splide.options;
2455 return [rootClass + "--" + options.type, rootClass + "--" + options.direction, options.drag ? rootClass + "--draggable" : '', options.isNavigation ? rootClass + "--nav" : '', STATUS_CLASSES.active];
2456 }
2457 /**
2458 * Find parts only from children of the root or track.
2459 *
2460 * @return {Element} - A found element or undefined.
2461 */
2462
2463
2464 function findParts(className) {
2465 return child(root, className) || child(Elements.slider, className);
2466 }
2467
2468 return Elements;
2469});
2470// CONCATENATED MODULE: ./src/js/components/controller/index.js
2471/**
2472 * The component for controlling the track.
2473 *
2474 * @author Naotoshi Fujita
2475 * @copyright Naotoshi Fujita. All rights reserved.
2476 */
2477
2478
2479
2480var floor = Math.floor;
2481/**
2482 * The component for controlling the track.
2483 *
2484 * @param {Splide} Splide - A Splide instance.
2485 * @param {Object} Components - An object containing components.
2486 *
2487 * @return {Object} - The component object.
2488 */
2489
2490/* harmony default export */ var controller = (function (Splide, Components) {
2491 /**
2492 * Store current options.
2493 *
2494 * @type {Object}
2495 */
2496 var options;
2497 /**
2498 * True if the slide is LOOP mode.
2499 *
2500 * @type {boolean}
2501 */
2502
2503 var isLoop;
2504 /**
2505 * Controller component object.
2506 *
2507 * @type {Object}
2508 */
2509
2510 var Controller = {
2511 /**
2512 * Called when the component is mounted.
2513 */
2514 mount: function mount() {
2515 options = Splide.options;
2516 isLoop = Splide.is(LOOP);
2517 bind();
2518 },
2519
2520 /**
2521 * Make track run by the given control.
2522 * - "+{i}" : Increment the slide index by i.
2523 * - "-{i}" : Decrement the slide index by i.
2524 * - "{i}" : Go to the slide whose index is i.
2525 * - ">" : Go to next page.
2526 * - "<" : Go to prev page.
2527 * - ">{i}" : Go to page i.
2528 *
2529 * @param {string|number} control - A control pattern.
2530 * @param {boolean} silently - Go to the destination without event emission.
2531 */
2532 go: function go(control, silently) {
2533 var destIndex = this.trim(this.parse(control));
2534 Components.Track.go(destIndex, this.rewind(destIndex), silently);
2535 },
2536
2537 /**
2538 * Parse the given control and return the destination index for the track.
2539 *
2540 * @param {string} control - A control target pattern.
2541 *
2542 * @return {number} - A parsed target.
2543 */
2544 parse: function parse(control) {
2545 var index = Splide.index;
2546 var matches = String(control).match(/([+\-<>]+)(\d+)?/);
2547 var indicator = matches ? matches[1] : '';
2548 var number = matches ? parseInt(matches[2]) : 0;
2549
2550 switch (indicator) {
2551 case '+':
2552 index += number || 1;
2553 break;
2554
2555 case '-':
2556 index -= number || 1;
2557 break;
2558
2559 case '>':
2560 case '<':
2561 index = parsePage(number, index, indicator === '<');
2562 break;
2563
2564 default:
2565 index = parseInt(control);
2566 }
2567
2568 return index;
2569 },
2570
2571 /**
2572 * Compute index from the given page number.
2573 *
2574 * @param {number} page - Page number.
2575 *
2576 * @return {number} - A computed page number.
2577 */
2578 toIndex: function toIndex(page) {
2579 if (hasFocus()) {
2580 return page;
2581 }
2582
2583 var length = Splide.length;
2584 var perPage = options.perPage;
2585 var index = page * perPage;
2586 index = index - (this.pageLength * perPage - length) * floor(index / length); // Adjustment for the last page.
2587
2588 if (length - perPage <= index && index < length) {
2589 index = length - perPage;
2590 }
2591
2592 return index;
2593 },
2594
2595 /**
2596 * Compute page number from the given slide index.
2597 *
2598 * @param {number} index - Slide index.
2599 *
2600 * @return {number} - A computed page number.
2601 */
2602 toPage: function toPage(index) {
2603 if (hasFocus()) {
2604 return index;
2605 }
2606
2607 var length = Splide.length;
2608 var perPage = options.perPage; // Make the last "perPage" number of slides belong to the last page.
2609
2610 if (length - perPage <= index && index < length) {
2611 return floor((length - 1) / perPage);
2612 }
2613
2614 return floor(index / perPage);
2615 },
2616
2617 /**
2618 * Trim the given index according to the current mode.
2619 * Index being returned could be less than 0 or greater than the length in Loop mode.
2620 *
2621 * @param {number} index - An index being trimmed.
2622 *
2623 * @return {number} - A trimmed index.
2624 */
2625 trim: function trim(index) {
2626 if (!isLoop) {
2627 index = options.rewind ? this.rewind(index) : between(index, 0, this.edgeIndex);
2628 }
2629
2630 return index;
2631 },
2632
2633 /**
2634 * Rewind the given index if it's out of range.
2635 *
2636 * @param {number} index - An index.
2637 *
2638 * @return {number} - A rewound index.
2639 */
2640 rewind: function rewind(index) {
2641 var edge = this.edgeIndex;
2642
2643 if (isLoop) {
2644 while (index > edge) {
2645 index -= edge + 1;
2646 }
2647
2648 while (index < 0) {
2649 index += edge + 1;
2650 }
2651 } else {
2652 if (index > edge) {
2653 index = 0;
2654 } else if (index < 0) {
2655 index = edge;
2656 }
2657 }
2658
2659 return index;
2660 },
2661
2662 /**
2663 * Check if the direction is "rtl" or not.
2664 *
2665 * @return {boolean} - True if "rtl" or false if not.
2666 */
2667 isRtl: function isRtl() {
2668 return options.direction === RTL;
2669 },
2670
2671 /**
2672 * Return the page length.
2673 *
2674 * @return {number} - Max page number.
2675 */
2676 get pageLength() {
2677 var length = Splide.length;
2678 return hasFocus() ? length : Math.ceil(length / options.perPage);
2679 },
2680
2681 /**
2682 * Return the edge index.
2683 *
2684 * @return {number} - Edge index.
2685 */
2686 get edgeIndex() {
2687 var length = Splide.length;
2688
2689 if (!length) {
2690 return 0;
2691 }
2692
2693 if (hasFocus() || options.isNavigation || isLoop) {
2694 return length - 1;
2695 }
2696
2697 return length - options.perPage;
2698 },
2699
2700 /**
2701 * Return the index of the previous slide.
2702 *
2703 * @return {number} - The index of the previous slide if available. -1 otherwise.
2704 */
2705 get prevIndex() {
2706 var prev = Splide.index - 1;
2707
2708 if (isLoop || options.rewind) {
2709 prev = this.rewind(prev);
2710 }
2711
2712 return prev > -1 ? prev : -1;
2713 },
2714
2715 /**
2716 * Return the index of the next slide.
2717 *
2718 * @return {number} - The index of the next slide if available. -1 otherwise.
2719 */
2720 get nextIndex() {
2721 var next = Splide.index + 1;
2722
2723 if (isLoop || options.rewind) {
2724 next = this.rewind(next);
2725 }
2726
2727 return Splide.index < next && next <= this.edgeIndex || next === 0 ? next : -1;
2728 }
2729
2730 };
2731 /**
2732 * Listen to some events.
2733 */
2734
2735 function bind() {
2736 Splide.on('move', function (newIndex) {
2737 Splide.index = newIndex;
2738 }).on('updated refresh', function (newOptions) {
2739 options = newOptions || options;
2740 Splide.index = between(Splide.index, 0, Controller.edgeIndex);
2741 });
2742 }
2743 /**
2744 * Verify if the focus option is available or not.
2745 *
2746 * @return {boolean} - True if a slider has the focus option.
2747 */
2748
2749
2750 function hasFocus() {
2751 return options.focus !== false;
2752 }
2753 /**
2754 * Return the next or previous page index computed by the page number and current index.
2755 *
2756 * @param {number} number - Specify the page number.
2757 * @param {number} index - Current index.
2758 * @param {boolean} prev - Prev or next.
2759 *
2760 * @return {number} - Slide index.
2761 */
2762
2763
2764 function parsePage(number, index, prev) {
2765 if (number > -1) {
2766 return Controller.toIndex(number);
2767 }
2768
2769 var perMove = options.perMove;
2770 var sign = prev ? -1 : 1;
2771
2772 if (perMove) {
2773 return index + perMove * sign;
2774 }
2775
2776 return Controller.toIndex(Controller.toPage(index) + sign);
2777 }
2778
2779 return Controller;
2780});
2781// CONCATENATED MODULE: ./src/js/components/track/index.js
2782/**
2783 * The component for moving list in the track.
2784 *
2785 * @author Naotoshi Fujita
2786 * @copyright Naotoshi Fujita. All rights reserved.
2787 */
2788
2789
2790
2791
2792
2793var abs = Math.abs;
2794/**
2795 * The component for moving list in the track.
2796 *
2797 * @param {Splide} Splide - A Splide instance.
2798 * @param {Object} Components - An object containing components.
2799 *
2800 * @return {Object} - The component object.
2801 */
2802
2803/* harmony default export */ var components_track = (function (Splide, Components) {
2804 /**
2805 * Hold the Layout component.
2806 *
2807 * @type {Object}
2808 */
2809 var Layout;
2810 /**
2811 * Hold the Layout component.
2812 *
2813 * @type {Object}
2814 */
2815
2816 var Elements;
2817 /**
2818 * Store the list element.
2819 *
2820 * @type {Element}
2821 */
2822
2823 var list;
2824 /**
2825 * Whether the current direction is vertical or not.
2826 *
2827 * @type {boolean}
2828 */
2829
2830 var isVertical = Splide.options.direction === TTB;
2831 /**
2832 * Whether the slider type is FADE or not.
2833 *
2834 * @type {boolean}
2835 */
2836
2837 var isFade = Splide.is(FADE);
2838 /**
2839 * This will be true while transitioning from the last index to the first one.
2840 *
2841 * @type {boolean}
2842 */
2843
2844 var isLoopPending = false;
2845 /**
2846 * Sign for the direction. Only RTL mode uses the positive sign.
2847 *
2848 * @type {number}
2849 */
2850
2851 var sign = Splide.options.direction === RTL ? 1 : -1;
2852 /**
2853 * Track component object.
2854 *
2855 * @type {Object}
2856 */
2857
2858 var Track = {
2859 /**
2860 * Make public the sign defined locally.
2861 *
2862 * @type {number}
2863 */
2864 sign: sign,
2865
2866 /**
2867 * Called when the component is mounted.
2868 */
2869 mount: function mount() {
2870 Elements = Components.Elements;
2871 Layout = Components.Layout;
2872 list = Elements.list;
2873 },
2874
2875 /**
2876 * Called after the component is mounted.
2877 * The resize event must be registered after the Layout's one is done.
2878 */
2879 mounted: function mounted() {
2880 var _this = this;
2881
2882 if (!isFade) {
2883 this.jump(0);
2884 Splide.on('mounted resize updated', function () {
2885 _this.jump(Splide.index);
2886 });
2887 }
2888 },
2889
2890 /**
2891 * Go to the given destination index.
2892 * After arriving there, the track is jump to the new index without animation, mainly for loop mode.
2893 *
2894 * @param {number} destIndex - A destination index.
2895 * This can be negative or greater than slides length for reaching clones.
2896 * @param {number} newIndex - An actual new index. They are always same in Slide and Rewind mode.
2897 * @param {boolean} silently - If true, suppress emitting events.
2898 */
2899 go: function go(destIndex, newIndex, silently) {
2900 var newPosition = getTrimmedPosition(destIndex);
2901 var prevIndex = Splide.index; // Prevent any actions while transitioning from the last index to the first one for jump.
2902
2903 if (Splide.State.is(MOVING) && isLoopPending) {
2904 return;
2905 }
2906
2907 isLoopPending = destIndex !== newIndex;
2908
2909 if (!silently) {
2910 Splide.emit('move', newIndex, prevIndex, destIndex);
2911 }
2912
2913 if (Math.abs(newPosition - this.position) >= 1 || isFade) {
2914 Components.Transition.start(destIndex, newIndex, prevIndex, this.toCoord(newPosition), function () {
2915 onTransitionEnd(destIndex, newIndex, prevIndex, silently);
2916 });
2917 } else {
2918 if (destIndex !== prevIndex && Splide.options.trimSpace === 'move') {
2919 Components.Controller.go(destIndex + destIndex - prevIndex, silently);
2920 } else {
2921 onTransitionEnd(destIndex, newIndex, prevIndex, silently);
2922 }
2923 }
2924 },
2925
2926 /**
2927 * Move the track to the specified index.
2928 *
2929 * @param {number} index - A destination index where the track jumps.
2930 */
2931 jump: function jump(index) {
2932 this.translate(getTrimmedPosition(index));
2933 },
2934
2935 /**
2936 * Set the list position by CSS translate property.
2937 *
2938 * @param {number} position - A new position value.
2939 */
2940 translate: function translate(position) {
2941 applyStyle(list, {
2942 transform: "translate" + (isVertical ? 'Y' : 'X') + "(" + position + "px)"
2943 });
2944 },
2945
2946 /**
2947 * Cancel the transition and set the list position.
2948 * Also, loop the slider if necessary.
2949 */
2950 cancel: function cancel() {
2951 if (Splide.is(LOOP)) {
2952 this.shift();
2953 } else {
2954 // Ensure the current position.
2955 this.translate(this.position);
2956 }
2957
2958 applyStyle(list, {
2959 transition: ''
2960 });
2961 },
2962
2963 /**
2964 * Shift the slider if it exceeds borders on the edge.
2965 */
2966 shift: function shift() {
2967 var position = abs(this.position);
2968 var left = abs(this.toPosition(0));
2969 var right = abs(this.toPosition(Splide.length));
2970 var innerSize = right - left;
2971
2972 if (position < left) {
2973 position += innerSize;
2974 } else if (position > right) {
2975 position -= innerSize;
2976 }
2977
2978 this.translate(sign * position);
2979 },
2980
2981 /**
2982 * Trim redundant spaces on the left or right edge if necessary.
2983 *
2984 * @param {number} position - Position value to be trimmed.
2985 *
2986 * @return {number} - Trimmed position.
2987 */
2988 trim: function trim(position) {
2989 if (!Splide.options.trimSpace || Splide.is(LOOP)) {
2990 return position;
2991 }
2992
2993 var edge = sign * (Layout.totalSize() - Layout.size - Layout.gap);
2994 return between(position, edge, 0);
2995 },
2996
2997 /**
2998 * Calculate the closest slide index from the given position.
2999 *
3000 * @param {number} position - A position converted to an slide index.
3001 *
3002 * @return {number} - The closest slide index.
3003 */
3004 toIndex: function toIndex(position) {
3005 var _this2 = this;
3006
3007 var index = 0;
3008 var minDistance = Infinity;
3009 Elements.getSlides(true).forEach(function (Slide) {
3010 var slideIndex = Slide.index;
3011 var distance = abs(_this2.toPosition(slideIndex) - position);
3012
3013 if (distance < minDistance) {
3014 minDistance = distance;
3015 index = slideIndex;
3016 }
3017 });
3018 return index;
3019 },
3020
3021 /**
3022 * Return coordinates object by the given position.
3023 *
3024 * @param {number} position - A position value.
3025 *
3026 * @return {Object} - A coordinates object.
3027 */
3028 toCoord: function toCoord(position) {
3029 return {
3030 x: isVertical ? 0 : position,
3031 y: isVertical ? position : 0
3032 };
3033 },
3034
3035 /**
3036 * Calculate the track position by a slide index.
3037 *
3038 * @param {number} index - Slide index.
3039 *
3040 * @return {Object} - Calculated position.
3041 */
3042 toPosition: function toPosition(index) {
3043 var position = Layout.totalSize(index) - Layout.slideSize(index) - Layout.gap;
3044 return sign * (position + this.offset(index));
3045 },
3046
3047 /**
3048 * Return the current offset value, considering direction.
3049 *
3050 * @return {number} - Offset amount.
3051 */
3052 offset: function offset(index) {
3053 var focus = Splide.options.focus;
3054 var slideSize = Layout.slideSize(index);
3055
3056 if (focus === 'center') {
3057 return -(Layout.size - slideSize) / 2;
3058 }
3059
3060 return -(parseInt(focus) || 0) * (slideSize + Layout.gap);
3061 },
3062
3063 /**
3064 * Return the current position.
3065 * This returns the correct position even while transitioning by CSS.
3066 *
3067 * @return {number} - Current position.
3068 */
3069 get position() {
3070 var prop = isVertical ? 'top' : 'left';
3071 return getRect(list)[prop] - getRect(Elements.track)[prop] - Layout.padding[prop];
3072 }
3073
3074 };
3075 /**
3076 * Called whenever slides arrive at a destination.
3077 *
3078 * @param {number} destIndex - A destination index.
3079 * @param {number} newIndex - A new index.
3080 * @param {number} prevIndex - A previous index.
3081 * @param {boolean} silently - If true, suppress emitting events.
3082 */
3083
3084 function onTransitionEnd(destIndex, newIndex, prevIndex, silently) {
3085 applyStyle(list, {
3086 transition: ''
3087 });
3088 isLoopPending = false;
3089
3090 if (!isFade) {
3091 Track.jump(newIndex);
3092 }
3093
3094 if (!silently) {
3095 Splide.emit('moved', newIndex, prevIndex, destIndex);
3096 }
3097 }
3098 /**
3099 * Convert index to the trimmed position.
3100 *
3101 * @return {number} - Trimmed position.
3102 */
3103
3104
3105 function getTrimmedPosition(index) {
3106 return Track.trim(Track.toPosition(index));
3107 }
3108
3109 return Track;
3110});
3111// CONCATENATED MODULE: ./src/js/components/clones/index.js
3112/**
3113 * The component for cloning some slides for "loop" mode of the track.
3114 *
3115 * @author Naotoshi Fujita
3116 * @copyright Naotoshi Fujita. All rights reserved.
3117 */
3118
3119
3120
3121/**
3122 * The component for cloning some slides for "loop" mode of the track.
3123 *
3124 * @param {Splide} Splide - A Splide instance.
3125 * @param {Object} Components - An object containing components.
3126 *
3127 * @return {Object} - The component object.
3128 */
3129
3130/* harmony default export */ var components_clones = (function (Splide, Components) {
3131 /**
3132 * Store information of all clones.
3133 *
3134 * @type {Array}
3135 */
3136 var clones = [];
3137 /**
3138 * Store the current clone count on one side.
3139 *
3140 * @type {number}
3141 */
3142
3143 var cloneCount = 0;
3144 /**
3145 * Keep Elements component.
3146 *
3147 * @type {Object}
3148 */
3149
3150 var Elements = Components.Elements;
3151 /**
3152 * Clones component object.
3153 *
3154 * @type {Object}
3155 */
3156
3157 var Clones = {
3158 /**
3159 * Called when the component is mounted.
3160 */
3161 mount: function mount() {
3162 if (Splide.is(LOOP)) {
3163 init();
3164 Splide.on('refresh', init).on('resize', function () {
3165 if (cloneCount !== getCloneCount()) {
3166 Splide.refresh();
3167 }
3168 });
3169 }
3170 },
3171
3172 /**
3173 * Destroy.
3174 */
3175 destroy: function destroy() {
3176 dom_remove(clones);
3177 clones = [];
3178 },
3179
3180 /**
3181 * Return all clones.
3182 *
3183 * @return {Element[]} - Cloned elements.
3184 */
3185 get clones() {
3186 return clones;
3187 },
3188
3189 /**
3190 * Return clone length.
3191 *
3192 * @return {number} - A length of clones.
3193 */
3194 get length() {
3195 return clones.length;
3196 }
3197
3198 };
3199 /**
3200 * Initialization.
3201 */
3202
3203 function init() {
3204 Clones.destroy();
3205 cloneCount = getCloneCount();
3206 generateClones(cloneCount);
3207 }
3208 /**
3209 * Generate and append/prepend clones.
3210 *
3211 * @param {number} count - The half number of clones.
3212 */
3213
3214
3215 function generateClones(count) {
3216 var length = Elements.length;
3217
3218 if (!length) {
3219 return;
3220 }
3221
3222 var slides = Elements.slides;
3223
3224 while (slides.length < count) {
3225 slides = slides.concat(slides);
3226 } // Clones after the last element.
3227
3228
3229 slides.slice(0, count).forEach(function (elm, index) {
3230 var clone = cloneDeeply(elm);
3231 append(Elements.list, clone);
3232 clones.push(clone);
3233 Elements.register(clone, index + length, index % length);
3234 }); // Clones before the first element.
3235
3236 slides.slice(-count).forEach(function (elm, index) {
3237 var clone = cloneDeeply(elm);
3238 before(clone, slides[0]);
3239 clones.push(clone);
3240 Elements.register(clone, index - count, (length + index - count % length) % length);
3241 });
3242 }
3243 /**
3244 * Return half count of clones to be generated.
3245 * Clone count is determined by:
3246 * - "clones" value in the options.
3247 * - Number of slides that can be placed in a view in "fixed" mode.
3248 * - Max pages a flick action can move.
3249 * - Whether the slide length is enough for perPage.
3250 *
3251 * @return {number} - Count for clones.
3252 */
3253
3254
3255 function getCloneCount() {
3256 var options = Splide.options;
3257
3258 if (options.clones) {
3259 return options.clones;
3260 } // Use the slide length in autoWidth mode because the number cannot be calculated.
3261
3262
3263 var baseCount = options.autoWidth || options.autoHeight ? Elements.length : options.perPage;
3264 var dimension = options.direction === TTB ? 'Height' : 'Width';
3265 var fixedSize = options["fixed" + dimension];
3266
3267 if (fixedSize) {
3268 // Roughly calculate the count. This needs not to be strict.
3269 baseCount = Math.ceil(Elements.track["client" + dimension] / fixedSize);
3270 }
3271
3272 return baseCount * (options.drag ? options.flickMaxPages + 1 : 1);
3273 }
3274 /**
3275 * Clone deeply the given element.
3276 *
3277 * @param {Element} elm - An element being duplicated.
3278 *
3279 * @return {Node} - A cloned node(element).
3280 */
3281
3282
3283 function cloneDeeply(elm) {
3284 var clone = elm.cloneNode(true);
3285 addClass(clone, Splide.classes.clone); // ID should not be duplicated.
3286
3287 removeAttribute(clone, 'id');
3288 return clone;
3289 }
3290
3291 return Clones;
3292});
3293// CONCATENATED MODULE: ./src/js/components/layout/directions/horizontal.js
3294/**
3295 * The resolver component for horizontal layout.
3296 *
3297 * @author Naotoshi Fujita
3298 * @copyright Naotoshi Fujita. All rights reserved.
3299 */
3300
3301
3302
3303/**
3304 * The resolver component for horizontal layout.
3305 *
3306 * @param {Splide} Splide - A Splide instance.
3307 * @param {Object} Components - An object containing components.
3308 *
3309 * @return {Object} - The resolver object.
3310 */
3311
3312/* harmony default export */ var horizontal = (function (Splide, Components) {
3313 /**
3314 * Keep the Elements component.
3315 *
3316 * @type {string}
3317 */
3318 var Elements = Components.Elements;
3319 /**
3320 * Keep the root element.
3321 *
3322 * @type {Element}
3323 */
3324
3325 var root = Splide.root;
3326 /**
3327 * Keep the track element.
3328 *
3329 * @type {Element}
3330 */
3331
3332 var track;
3333 /**
3334 * Keep the latest options.
3335 *
3336 * @type {Element}
3337 */
3338
3339 var options = Splide.options;
3340 return {
3341 /**
3342 * Margin property name.
3343 *
3344 * @type {string}
3345 */
3346 margin: 'margin' + (options.direction === RTL ? 'Left' : 'Right'),
3347
3348 /**
3349 * Always 0 because the height will be determined by inner contents.
3350 *
3351 * @type {number}
3352 */
3353 height: 0,
3354
3355 /**
3356 * Initialization.
3357 */
3358 init: function init() {
3359 options = Splide.options;
3360 track = Elements.track;
3361 this.gap = toPixel(root, options.gap);
3362 var padding = options.padding;
3363 var left = toPixel(root, padding.left || padding);
3364 var right = toPixel(root, padding.right || padding);
3365 this.padding = {
3366 left: left,
3367 right: right
3368 };
3369 applyStyle(track, {
3370 paddingLeft: unit(left),
3371 paddingRight: unit(right)
3372 });
3373 },
3374
3375 /**
3376 * Return total width from the left of the list to the right of the slide specified by the provided index.
3377 *
3378 * @param {number} index - Optional. A slide index. If undefined, total width of the slider will be returned.
3379 *
3380 * @return {number} - Total width to the right side of the specified slide, or 0 for an invalid index.
3381 */
3382 totalWidth: function totalWidth(index) {
3383 if (index === void 0) {
3384 index = Splide.length - 1;
3385 }
3386
3387 var Slide = Elements.getSlide(index);
3388 var width = 0;
3389
3390 if (Slide) {
3391 var slideRect = getRect(Slide.slide);
3392 var listRect = getRect(Elements.list);
3393
3394 if (options.direction === RTL) {
3395 width = listRect.right - slideRect.left;
3396 } else {
3397 width = slideRect.right - listRect.left;
3398 }
3399
3400 width += this.gap;
3401 }
3402
3403 return width;
3404 },
3405
3406 /**
3407 * Return the slide width in px.
3408 *
3409 * @param {number} index - Slide index.
3410 *
3411 * @return {number} - The slide width.
3412 */
3413 slideWidth: function slideWidth(index) {
3414 if (options.autoWidth) {
3415 var Slide = Elements.getSlide(index);
3416 return Slide ? Slide.slide.offsetWidth : 0;
3417 }
3418
3419 var width = options.fixedWidth || (this.width + this.gap) / options.perPage - this.gap;
3420 return toPixel(root, width);
3421 },
3422
3423 /**
3424 * Return the slide height in px.
3425 *
3426 * @return {number} - The slide height.
3427 */
3428 slideHeight: function slideHeight() {
3429 var height = options.height || options.fixedHeight || this.width * options.heightRatio;
3430 return toPixel(root, height);
3431 },
3432
3433 /**
3434 * Return slider width without padding.
3435 *
3436 * @return {number} - Current slider width.
3437 */
3438 get width() {
3439 return track.clientWidth - this.padding.left - this.padding.right;
3440 }
3441
3442 };
3443});
3444// CONCATENATED MODULE: ./src/js/components/layout/directions/vertical.js
3445/**
3446 * The resolver component for vertical layout.
3447 *
3448 * @author Naotoshi Fujita
3449 * @copyright Naotoshi Fujita. All rights reserved.
3450 */
3451
3452
3453
3454/**
3455 * The resolver component for vertical layout.
3456 *
3457 * @param {Splide} Splide - A Splide instance.
3458 * @param {Object} Components - An object containing components.
3459 *
3460 * @return {Object} - The resolver object.
3461 */
3462
3463/* harmony default export */ var vertical = (function (Splide, Components) {
3464 /**
3465 * Keep the Elements component.
3466 *
3467 * @type {string}
3468 */
3469 var Elements = Components.Elements;
3470 /**
3471 * Keep the root element.
3472 *
3473 * @type {Element}
3474 */
3475
3476 var root = Splide.root;
3477 /**
3478 * Keep the track element.
3479 *
3480 * @type {Element}
3481 */
3482
3483 var track;
3484 /**
3485 * Keep the latest options.
3486 *
3487 * @type {Element}
3488 */
3489
3490 var options;
3491 return {
3492 /**
3493 * Margin property name.
3494 *
3495 * @type {string}
3496 */
3497 margin: 'marginBottom',
3498
3499 /**
3500 * Init slider styles according to options.
3501 */
3502 init: function init() {
3503 options = Splide.options;
3504 track = Elements.track;
3505 this.gap = toPixel(root, options.gap);
3506 var padding = options.padding;
3507 var top = toPixel(root, padding.top || padding);
3508 var bottom = toPixel(root, padding.bottom || padding);
3509 this.padding = {
3510 top: top,
3511 bottom: bottom
3512 };
3513 applyStyle(track, {
3514 paddingTop: unit(top),
3515 paddingBottom: unit(bottom)
3516 });
3517 },
3518
3519 /**
3520 * Return total height from the top of the list to the bottom of the slide specified by the provided index.
3521 *
3522 * @param {number} index - Optional. A slide index. If undefined, total height of the slider will be returned.
3523 *
3524 * @return {number} - Total height to the bottom of the specified slide, or 0 for an invalid index.
3525 */
3526 totalHeight: function totalHeight(index) {
3527 if (index === void 0) {
3528 index = Splide.length - 1;
3529 }
3530
3531 var Slide = Elements.getSlide(index);
3532
3533 if (Slide) {
3534 return getRect(Slide.slide).bottom - getRect(Elements.list).top + this.gap;
3535 }
3536
3537 return 0;
3538 },
3539
3540 /**
3541 * Return the slide width in px.
3542 *
3543 * @return {number} - The slide width.
3544 */
3545 slideWidth: function slideWidth() {
3546 return toPixel(root, options.fixedWidth || this.width);
3547 },
3548
3549 /**
3550 * Return the slide height in px.
3551 *
3552 * @param {number} index - Slide index.
3553 *
3554 * @return {number} - The slide height.
3555 */
3556 slideHeight: function slideHeight(index) {
3557 if (options.autoHeight) {
3558 var Slide = Elements.getSlide(index);
3559 return Slide ? Slide.slide.offsetHeight : 0;
3560 }
3561
3562 var height = options.fixedHeight || (this.height + this.gap) / options.perPage - this.gap;
3563 return toPixel(root, height);
3564 },
3565
3566 /**
3567 * Return slider width without padding.
3568 *
3569 * @return {number} - Current slider width.
3570 */
3571 get width() {
3572 return track.clientWidth;
3573 },
3574
3575 /**
3576 * Return slide height without padding.
3577 *
3578 * @return {number} - Slider height.
3579 */
3580 get height() {
3581 var height = options.height || this.width * options.heightRatio;
3582 exist(height, '"height" or "heightRatio" is missing.');
3583 return toPixel(root, height) - this.padding.top - this.padding.bottom;
3584 }
3585
3586 };
3587});
3588// CONCATENATED MODULE: ./src/js/utils/time.js
3589/**
3590 * A package of utility functions related with time.
3591 *
3592 * @author Naotoshi Fujita
3593 * @copyright Naotoshi Fujita. All rights reserved.
3594 */
3595
3596/**
3597 * Simple throttle function that controls how often the given function is executed.
3598 *
3599 * @param {function} func - A function to be throttled.
3600 * @param {number} wait - Time in millisecond for interval of execution.
3601 *
3602 * @return {Function} - A debounced function.
3603 */
3604function throttle(func, wait) {
3605 var timeout; // Declare function by the "function" keyword to prevent "this" from being inherited.
3606
3607 return function () {
3608 if (!timeout) {
3609 timeout = setTimeout(function () {
3610 func();
3611 timeout = null;
3612 }, wait);
3613 }
3614 };
3615}
3616/**
3617 * Custom setInterval function that provides progress rate as callback.
3618 *
3619 * @param {function} callback - A callback function fired every time the interval time passes.
3620 * @param {number} interval - Interval duration in milliseconds.
3621 * @param {function} progress - A callback function fired whenever the progress goes.
3622 *
3623 * @return {Object} - An object containing play() and pause() functions.
3624 */
3625
3626function createInterval(callback, interval, progress) {
3627 var _window = window,
3628 requestAnimationFrame = _window.requestAnimationFrame;
3629 var start,
3630 elapse,
3631 rate,
3632 _pause = true;
3633
3634 var step = function step(timestamp) {
3635 if (!_pause) {
3636 if (!start) {
3637 start = timestamp;
3638
3639 if (rate && rate < 1) {
3640 start -= rate * interval;
3641 }
3642 }
3643
3644 elapse = timestamp - start;
3645 rate = elapse / interval;
3646
3647 if (elapse >= interval) {
3648 start = 0;
3649 rate = 1;
3650 callback();
3651 }
3652
3653 if (progress) {
3654 progress(rate);
3655 }
3656
3657 requestAnimationFrame(step);
3658 }
3659 };
3660
3661 return {
3662 pause: function pause() {
3663 _pause = true;
3664 start = 0;
3665 },
3666 play: function play(reset) {
3667 start = 0;
3668
3669 if (_pause) {
3670 _pause = false;
3671
3672 if (reset) {
3673 rate = 0;
3674 }
3675
3676 requestAnimationFrame(step);
3677 }
3678 }
3679 };
3680}
3681// CONCATENATED MODULE: ./src/js/components/layout/index.js
3682/**
3683 * The component for handing slide layouts and their sizes.
3684 *
3685 * @author Naotoshi Fujita
3686 * @copyright Naotoshi Fujita. All rights reserved.
3687 */
3688
3689
3690
3691
3692
3693
3694
3695/**
3696 * The component for handing slide layouts and their sizes.
3697 *
3698 * @param {Splide} Splide - A Splide instance.
3699 * @param {Object} Components - An object containing components.
3700 *
3701 * @return {Object} - The component object.
3702 */
3703
3704/* harmony default export */ var layout = (function (Splide, Components) {
3705 /**
3706 * Keep the Elements component.
3707 *
3708 * @type {string}
3709 */
3710 var Elements = Components.Elements;
3711 /**
3712 * Whether the slider is vertical or not.
3713 *
3714 * @type {boolean}
3715 */
3716
3717 var isVertical = Splide.options.direction === TTB;
3718 /**
3719 * Layout component object.
3720 *
3721 * @type {Object}
3722 */
3723
3724 var Layout = object_assign({
3725 /**
3726 * Called when the component is mounted.
3727 */
3728 mount: function mount() {
3729 bind();
3730 init(); // The word "size" means width for a horizontal slider and height for a vertical slider.
3731
3732 this.totalSize = isVertical ? this.totalHeight : this.totalWidth;
3733 this.slideSize = isVertical ? this.slideHeight : this.slideWidth;
3734 },
3735
3736 /**
3737 * Destroy the component.
3738 */
3739 destroy: function destroy() {
3740 removeAttribute([Elements.list, Elements.track], 'style');
3741 },
3742
3743 /**
3744 * Return the slider height on the vertical mode or width on the horizontal mode.
3745 *
3746 * @return {number}
3747 */
3748 get size() {
3749 return isVertical ? this.height : this.width;
3750 }
3751
3752 }, isVertical ? vertical(Splide, Components) : horizontal(Splide, Components));
3753 /**
3754 * Init slider styles according to options.
3755 */
3756
3757 function init() {
3758 Layout.init();
3759 applyStyle(Splide.root, {
3760 maxWidth: unit(Splide.options.width)
3761 });
3762 Elements.each(function (Slide) {
3763 Slide.slide.style[Layout.margin] = unit(Layout.gap);
3764 });
3765 resize();
3766 }
3767 /**
3768 * Listen the resize native event with throttle.
3769 * Initialize when the component is mounted or options are updated.
3770 */
3771
3772
3773 function bind() {
3774 Splide.on('resize load', throttle(function () {
3775 Splide.emit('resize');
3776 }, Splide.options.throttle), window).on('resize', resize).on('updated refresh', init);
3777 }
3778 /**
3779 * Resize the track and slide elements.
3780 */
3781
3782
3783 function resize() {
3784 var options = Splide.options;
3785 applyStyle(Elements.track, {
3786 height: unit(Layout.height)
3787 });
3788 var slideHeight = options.autoHeight ? null : unit(Layout.slideHeight());
3789 Elements.each(function (Slide) {
3790 applyStyle(Slide.container, {
3791 height: slideHeight
3792 });
3793 applyStyle(Slide.slide, {
3794 width: options.autoWidth ? null : unit(Layout.slideWidth(Slide.index)),
3795 height: Slide.container ? null : slideHeight
3796 });
3797 });
3798 }
3799
3800 return Layout;
3801});
3802// CONCATENATED MODULE: ./src/js/components/drag/index.js
3803/**
3804 * The component for supporting mouse drag and swipe.
3805 *
3806 * @author Naotoshi Fujita
3807 * @copyright Naotoshi Fujita. All rights reserved.
3808 */
3809
3810
3811
3812
3813
3814var drag_abs = Math.abs;
3815/**
3816 * If the absolute velocity is greater thant this value,
3817 * a slider always goes to a different slide after drag, not allowed to stay on a current slide.
3818 */
3819
3820var MIN_VELOCITY = 0.1;
3821/**
3822 * Adjust how much the track can be pulled on the first or last page.
3823 * The larger number this is, the farther the track moves.
3824 * This should be around 5 - 9.
3825 *
3826 * @type {number}
3827 */
3828
3829var FRICTION_REDUCER = 7;
3830/**
3831 * The component supporting mouse drag and swipe.
3832 *
3833 * @param {Splide} Splide - A Splide instance.
3834 * @param {Object} Components - An object containing components.
3835 *
3836 * @return {Object} - The component object.
3837 */
3838
3839/* harmony default export */ var drag = (function (Splide, Components) {
3840 /**
3841 * Store the Move component.
3842 *
3843 * @type {Object}
3844 */
3845 var Track = Components.Track;
3846 /**
3847 * Store the Controller component.
3848 *
3849 * @type {Object}
3850 */
3851
3852 var Controller = Components.Controller;
3853 /**
3854 * Coordinate of the track on starting drag.
3855 *
3856 * @type {Object}
3857 */
3858
3859 var startCoord;
3860 /**
3861 * Analyzed info on starting drag.
3862 *
3863 * @type {Object|null}
3864 */
3865
3866 var startInfo;
3867 /**
3868 * Analyzed info being updated while dragging/swiping.
3869 *
3870 * @type {Object}
3871 */
3872
3873 var currentInfo;
3874 /**
3875 * Determine whether slides are being dragged or not.
3876 *
3877 * @type {boolean}
3878 */
3879
3880 var isDragging;
3881 /**
3882 * Whether the slider direction is vertical or not.
3883 *
3884 * @type {boolean}
3885 */
3886
3887 var isVertical = Splide.options.direction === TTB;
3888 /**
3889 * Axis for the direction.
3890 *
3891 * @type {string}
3892 */
3893
3894 var axis = isVertical ? 'y' : 'x';
3895 /**
3896 * Drag component object.
3897 *
3898 * @type {Object}
3899 */
3900
3901 var Drag = {
3902 /**
3903 * Whether dragging is disabled or not.
3904 *
3905 * @type {boolean}
3906 */
3907 disabled: false,
3908
3909 /**
3910 * Called when the component is mounted.
3911 */
3912 mount: function mount() {
3913 var _this = this;
3914
3915 var Elements = Components.Elements;
3916 var track = Elements.track;
3917 Splide.on('touchstart mousedown', start, track).on('touchmove mousemove', move, track, {
3918 passive: false
3919 }).on('touchend touchcancel mouseleave mouseup dragend', end, track).on('mounted refresh', function () {
3920 // Prevent dragging an image or anchor itself.
3921 each(Elements.list.querySelectorAll('img, a'), function (elm) {
3922 Splide.off('dragstart', elm).on('dragstart', function (e) {
3923 e.preventDefault();
3924 }, elm, {
3925 passive: false
3926 });
3927 });
3928 }).on('mounted updated', function () {
3929 _this.disabled = !Splide.options.drag;
3930 });
3931 }
3932 };
3933 /**
3934 * Called when the track starts to be dragged.
3935 *
3936 * @param {TouchEvent|MouseEvent} e - TouchEvent or MouseEvent object.
3937 */
3938
3939 function start(e) {
3940 if (!Drag.disabled && !isDragging) {
3941 // These prams are used to evaluate whether the slider should start moving.
3942 init(e);
3943 }
3944 }
3945 /**
3946 * Initialize parameters.
3947 *
3948 * @param {TouchEvent|MouseEvent} e - TouchEvent or MouseEvent object.
3949 */
3950
3951
3952 function init(e) {
3953 startCoord = Track.toCoord(Track.position);
3954 startInfo = analyze(e, {});
3955 currentInfo = startInfo;
3956 }
3957 /**
3958 * Called while the track being dragged.
3959 *
3960 * @param {TouchEvent|MouseEvent} e - TouchEvent or MouseEvent object.
3961 */
3962
3963
3964 function move(e) {
3965 if (startInfo) {
3966 currentInfo = analyze(e, startInfo);
3967
3968 if (isDragging) {
3969 if (e.cancelable) {
3970 e.preventDefault();
3971 }
3972
3973 if (!Splide.is(FADE)) {
3974 var position = startCoord[axis] + currentInfo.offset[axis];
3975 Track.translate(resist(position));
3976 }
3977 } else {
3978 if (shouldMove(currentInfo)) {
3979 Splide.emit('drag', startInfo);
3980 isDragging = true;
3981 Track.cancel(); // These params are actual drag data.
3982
3983 init(e);
3984 }
3985 }
3986 }
3987 }
3988 /**
3989 * Determine whether to start moving the track or not by drag angle.
3990 *
3991 * @param {Object} info - An information object.
3992 *
3993 * @return {boolean} - True if the track should be moved or false if not.
3994 */
3995
3996
3997 function shouldMove(_ref) {
3998 var offset = _ref.offset;
3999
4000 if (Splide.State.is(MOVING) && Splide.options.waitForTransition) {
4001 return false;
4002 }
4003
4004 var angle = Math.atan(drag_abs(offset.y) / drag_abs(offset.x)) * 180 / Math.PI;
4005
4006 if (isVertical) {
4007 angle = 90 - angle;
4008 }
4009
4010 return angle < Splide.options.dragAngleThreshold;
4011 }
4012 /**
4013 * Resist dragging the track on the first/last page because there is no more.
4014 *
4015 * @param {number} position - A position being applied to the track.
4016 *
4017 * @return {Object} - Adjusted position.
4018 */
4019
4020
4021 function resist(position) {
4022 if (Splide.is(SLIDE)) {
4023 var sign = Track.sign;
4024
4025 var _start = sign * Track.trim(Track.toPosition(0));
4026
4027 var _end = sign * Track.trim(Track.toPosition(Controller.edgeIndex));
4028
4029 position *= sign;
4030
4031 if (position < _start) {
4032 position = _start - FRICTION_REDUCER * Math.log(_start - position);
4033 } else if (position > _end) {
4034 position = _end + FRICTION_REDUCER * Math.log(position - _end);
4035 }
4036
4037 position *= sign;
4038 }
4039
4040 return position;
4041 }
4042 /**
4043 * Called when dragging ends.
4044 */
4045
4046
4047 function end() {
4048 startInfo = null;
4049
4050 if (isDragging) {
4051 Splide.emit('dragged', currentInfo);
4052 go(currentInfo);
4053 isDragging = false;
4054 }
4055 }
4056 /**
4057 * Go to the slide determined by the analyzed data.
4058 *
4059 * @param {Object} info - An info object.
4060 */
4061
4062
4063 function go(info) {
4064 var velocity = info.velocity[axis];
4065 var absV = drag_abs(velocity);
4066
4067 if (absV > 0) {
4068 var options = Splide.options;
4069 var index = Splide.index;
4070 var sign = velocity < 0 ? -1 : 1;
4071 var destIndex = index;
4072
4073 if (!Splide.is(FADE)) {
4074 var destination = Track.position;
4075
4076 if (absV > options.flickVelocityThreshold && drag_abs(info.offset[axis]) < options.swipeDistanceThreshold) {
4077 destination += sign * Math.min(absV * options.flickPower, Components.Layout.size * (options.flickMaxPages || 1));
4078 }
4079
4080 destIndex = Track.toIndex(destination);
4081 }
4082 /*
4083 * Do not allow the track to go to a previous position if there is enough velocity.
4084 * Always use the adjacent index for the fade mode.
4085 */
4086
4087
4088 if (destIndex === index && absV > MIN_VELOCITY) {
4089 destIndex = index + sign * Track.sign;
4090 }
4091
4092 if (Splide.is(SLIDE)) {
4093 destIndex = between(destIndex, 0, Controller.edgeIndex);
4094 }
4095
4096 Controller.go(destIndex, options.isNavigation);
4097 }
4098 }
4099 /**
4100 * Analyze the given event object and return important information for handling swipe behavior.
4101 *
4102 * @param {Event} e - Touch or Mouse event object.
4103 * @param {Object} startInfo - Information analyzed on start for calculating difference from the current one.
4104 *
4105 * @return {Object} - An object containing analyzed information, such as offset, velocity, etc.
4106 */
4107
4108
4109 function analyze(e, startInfo) {
4110 var timeStamp = e.timeStamp,
4111 touches = e.touches;
4112
4113 var _ref2 = touches ? touches[0] : e,
4114 clientX = _ref2.clientX,
4115 clientY = _ref2.clientY;
4116
4117 var _ref3 = startInfo.to || {},
4118 _ref3$x = _ref3.x,
4119 fromX = _ref3$x === void 0 ? clientX : _ref3$x,
4120 _ref3$y = _ref3.y,
4121 fromY = _ref3$y === void 0 ? clientY : _ref3$y;
4122
4123 var startTime = startInfo.time || 0;
4124 var offset = {
4125 x: clientX - fromX,
4126 y: clientY - fromY
4127 };
4128 var duration = timeStamp - startTime;
4129 var velocity = {
4130 x: offset.x / duration,
4131 y: offset.y / duration
4132 };
4133 return {
4134 to: {
4135 x: clientX,
4136 y: clientY
4137 },
4138 offset: offset,
4139 time: timeStamp,
4140 velocity: velocity
4141 };
4142 }
4143
4144 return Drag;
4145});
4146// CONCATENATED MODULE: ./src/js/components/click/index.js
4147/**
4148 * The component for handling a click event.
4149 *
4150 * @author Naotoshi Fujita
4151 * @copyright Naotoshi Fujita. All rights reserved.
4152 */
4153
4154/**
4155 * The component for handling a click event.
4156 * Click should be disabled during drag/swipe.
4157 *
4158 * @param {Splide} Splide - A Splide instance.
4159 * @param {Object} Components - An object containing components.
4160 *
4161 * @return {Object} - The component object.
4162 */
4163
4164/* harmony default export */ var click = (function (Splide, Components) {
4165 /**
4166 * Whether click is disabled or not.
4167 *
4168 * @type {boolean}
4169 */
4170 var disabled = false;
4171 /**
4172 * Click component object.
4173 *
4174 * @type {Object}
4175 */
4176
4177 var Click = {
4178 /**
4179 * Mount only when the drag is activated and the slide type is not "fade".
4180 *
4181 * @type {boolean}
4182 */
4183 required: Splide.options.drag && !Splide.is(FADE),
4184
4185 /**
4186 * Called when the component is mounted.
4187 */
4188 mount: function mount() {
4189 Splide.on('click', onClick, Components.Elements.track, {
4190 capture: true
4191 }).on('drag', function () {
4192 disabled = true;
4193 }).on('moved', function () {
4194 disabled = false;
4195 });
4196 }
4197 };
4198 /**
4199 * Called when a track element is clicked.
4200 *
4201 * @param {Event} e - A click event.
4202 */
4203
4204 function onClick(e) {
4205 if (disabled) {
4206 e.preventDefault();
4207 e.stopPropagation();
4208 e.stopImmediatePropagation();
4209 }
4210 }
4211
4212 return Click;
4213});
4214// CONCATENATED MODULE: ./src/js/components/autoplay/index.js
4215/**
4216 * The component for playing slides automatically.
4217 *
4218 * @author Naotoshi Fujita
4219 * @copyright Naotoshi Fujita. All rights reserved.
4220 */
4221
4222
4223/**
4224 * Set of pause flags.
4225 */
4226
4227var PAUSE_FLAGS = {
4228 HOVER: 1,
4229 FOCUS: 2,
4230 MANUAL: 3
4231};
4232/**
4233 * The component for playing slides automatically.
4234 *
4235 * @param {Splide} Splide - A Splide instance.
4236 * @param {Object} Components - An object containing components.
4237 * @param {string} name - A component name as a lowercase string.
4238 *
4239 * @return {Object} - The component object.
4240 */
4241
4242/* harmony default export */ var components_autoplay = (function (Splide, Components, name) {
4243 /**
4244 * Store pause flags.
4245 *
4246 * @type {Array}
4247 */
4248 var flags = [];
4249 /**
4250 * Store an interval object.
4251 *
4252 * @type {Object};
4253 */
4254
4255 var interval;
4256 /**
4257 * Keep the Elements component.
4258 *
4259 * @type {string}
4260 */
4261
4262 var Elements = Components.Elements;
4263 /**
4264 * Autoplay component object.
4265 *
4266 * @type {Object}
4267 */
4268
4269 var Autoplay = {
4270 /**
4271 * Required only when the autoplay option is true.
4272 *
4273 * @type {boolean}
4274 */
4275 required: Splide.options.autoplay,
4276
4277 /**
4278 * Called when the component is mounted.
4279 * Note that autoplay starts only if there are slides over perPage number.
4280 */
4281 mount: function mount() {
4282 var options = Splide.options;
4283
4284 if (Elements.slides.length > options.perPage) {
4285 interval = createInterval(function () {
4286 Splide.go('>');
4287 }, options.interval, function (rate) {
4288 Splide.emit(name + ":playing", rate);
4289
4290 if (Elements.bar) {
4291 applyStyle(Elements.bar, {
4292 width: rate * 100 + "%"
4293 });
4294 }
4295 });
4296 bind();
4297 this.play();
4298 }
4299 },
4300
4301 /**
4302 * Start autoplay.
4303 *
4304 * @param {number} flag - A pause flag to be removed.
4305 */
4306 play: function play(flag) {
4307 if (flag === void 0) {
4308 flag = 0;
4309 }
4310
4311 flags = flags.filter(function (f) {
4312 return f !== flag;
4313 });
4314
4315 if (!flags.length) {
4316 Splide.emit(name + ":play");
4317 interval.play(Splide.options.resetProgress);
4318 }
4319 },
4320
4321 /**
4322 * Pause autoplay.
4323 * Note that Array.includes is not supported by IE.
4324 *
4325 * @param {number} flag - A pause flag to be added.
4326 */
4327 pause: function pause(flag) {
4328 if (flag === void 0) {
4329 flag = 0;
4330 }
4331
4332 interval.pause();
4333
4334 if (flags.indexOf(flag) === -1) {
4335 flags.push(flag);
4336 }
4337
4338 if (flags.length === 1) {
4339 Splide.emit(name + ":pause");
4340 }
4341 }
4342 };
4343 /**
4344 * Listen some events.
4345 */
4346
4347 function bind() {
4348 var options = Splide.options;
4349 var sibling = Splide.sibling;
4350 var elms = [Splide.root, sibling ? sibling.root : null];
4351
4352 if (options.pauseOnHover) {
4353 switchOn(elms, 'mouseleave', PAUSE_FLAGS.HOVER, true);
4354 switchOn(elms, 'mouseenter', PAUSE_FLAGS.HOVER, false);
4355 }
4356
4357 if (options.pauseOnFocus) {
4358 switchOn(elms, 'focusout', PAUSE_FLAGS.FOCUS, true);
4359 switchOn(elms, 'focusin', PAUSE_FLAGS.FOCUS, false);
4360 }
4361
4362 Splide.on('click', function () {
4363 // Need to be removed a focus flag at first.
4364 Autoplay.play(PAUSE_FLAGS.FOCUS);
4365 Autoplay.play(PAUSE_FLAGS.MANUAL);
4366 }, Elements.play).on('move refresh', function () {
4367 Autoplay.play();
4368 }) // Rewind the timer.
4369 .on('destroy', function () {
4370 Autoplay.pause();
4371 });
4372 switchOn([Elements.pause], 'click', PAUSE_FLAGS.MANUAL, false);
4373 }
4374 /**
4375 * Play or pause on the given event.
4376 *
4377 * @param {Element[]} elms - Elements.
4378 * @param {string} event - An event name or names.
4379 * @param {number} flag - A pause flag defined on the top.
4380 * @param {boolean} play - Determine whether to play or pause.
4381 */
4382
4383
4384 function switchOn(elms, event, flag, play) {
4385 elms.forEach(function (elm) {
4386 Splide.on(event, function () {
4387 Autoplay[play ? 'play' : 'pause'](flag);
4388 }, elm);
4389 });
4390 }
4391
4392 return Autoplay;
4393});
4394// CONCATENATED MODULE: ./src/js/components/cover/index.js
4395/**
4396 * The component for change an img element to background image of its wrapper.
4397 *
4398 * @author Naotoshi Fujita
4399 * @copyright Naotoshi Fujita. All rights reserved.
4400 */
4401
4402/**
4403 * The component for change an img element to background image of its wrapper.
4404 *
4405 * @param {Splide} Splide - A Splide instance.
4406 * @param {Object} Components - An object containing components.
4407 *
4408 * @return {Object} - The component object.
4409 */
4410
4411/* harmony default export */ var components_cover = (function (Splide, Components) {
4412 /**
4413 * Hold options.
4414 *
4415 * @type {Object}
4416 */
4417 var options = Splide.options;
4418 /**
4419 * Cover component object.
4420 *
4421 * @type {Object}
4422 */
4423
4424 var Cover = {
4425 /**
4426 * Required only when "cover" option is true.
4427 *
4428 * @type {boolean}
4429 */
4430 required: options.cover,
4431
4432 /**
4433 * Called when the component is mounted.
4434 */
4435 mount: function mount() {
4436 Splide.on('lazyload:loaded', function (img) {
4437 cover(img, false);
4438 });
4439 Splide.on('mounted updated refresh', function () {
4440 return apply(false);
4441 });
4442 },
4443
4444 /**
4445 * Destroy.
4446 */
4447 destroy: function destroy() {
4448 apply(true);
4449 }
4450 };
4451 /**
4452 * Apply "cover" to all slides.
4453 *
4454 * @param {boolean} uncover - If true, "cover" will be clear.
4455 */
4456
4457 function apply(uncover) {
4458 Components.Elements.each(function (Slide) {
4459 var img = child(Slide.slide, 'IMG') || child(Slide.container, 'IMG');
4460
4461 if (img && img.src) {
4462 cover(img, uncover);
4463 }
4464 });
4465 }
4466 /**
4467 * Set background image of the parent element, using source of the given image element.
4468 *
4469 * @param {Element} img - An image element.
4470 * @param {boolean} uncover - Reset "cover".
4471 */
4472
4473
4474 function cover(img, uncover) {
4475 applyStyle(img.parentElement, {
4476 background: uncover ? '' : "center/cover no-repeat url(\"" + img.src + "\")"
4477 });
4478 applyStyle(img, {
4479 display: uncover ? '' : 'none'
4480 });
4481 }
4482
4483 return Cover;
4484});
4485// CONCATENATED MODULE: ./src/js/components/arrows/path.js
4486/**
4487 * Export vector path for an arrow.
4488 *
4489 * @author Naotoshi Fujita
4490 * @copyright Naotoshi Fujita. All rights reserved.
4491 */
4492
4493/**
4494 * Namespace definition for SVG element.
4495 *
4496 * @type {string}
4497 */
4498var XML_NAME_SPACE = 'http://www.w3.org/2000/svg';
4499/**
4500 * The arrow vector path.
4501 *
4502 * @type {number}
4503 */
4504
4505var PATH = 'm15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z';
4506/**
4507 * SVG width and height.
4508 *
4509 * @type {number}
4510 */
4511
4512var SIZE = 40;
4513// CONCATENATED MODULE: ./src/js/components/arrows/index.js
4514/**
4515 * The component for appending prev/next arrows.
4516 *
4517 * @author Naotoshi Fujita
4518 * @copyright Naotoshi Fujita. All rights reserved.
4519 */
4520
4521
4522
4523/**
4524 * The component for appending prev/next arrows.
4525 *
4526 * @param {Splide} Splide - A Splide instance.
4527 * @param {Object} Components - An object containing components.
4528 * @param {string} name - A component name as a lowercase string.
4529 *
4530 * @return {Object} - The component object.
4531 */
4532
4533/* harmony default export */ var components_arrows = (function (Splide, Components, name) {
4534 /**
4535 * Previous arrow element.
4536 *
4537 * @type {Element|undefined}
4538 */
4539 var prev;
4540 /**
4541 * Next arrow element.
4542 *
4543 * @type {Element|undefined}
4544 */
4545
4546 var next;
4547 /**
4548 * Store the class list.
4549 *
4550 * @type {Object}
4551 */
4552
4553 var classes = Splide.classes;
4554 /**
4555 * Hold the root element.
4556 *
4557 * @type {Element}
4558 */
4559
4560 var root = Splide.root;
4561 /**
4562 * Whether arrows are created programmatically or not.
4563 *
4564 * @type {boolean}
4565 */
4566
4567 var created;
4568 /**
4569 * Hold the Elements component.
4570 *
4571 * @type {Object}
4572 */
4573
4574 var Elements = Components.Elements;
4575 /**
4576 * Arrows component object.
4577 *
4578 * @type {Object}
4579 */
4580
4581 var Arrows = {
4582 /**
4583 * Required when the arrows option is true.
4584 *
4585 * @type {boolean}
4586 */
4587 required: Splide.options.arrows,
4588
4589 /**
4590 * Called when the component is mounted.
4591 */
4592 mount: function mount() {
4593 // Attempt to get arrows from HTML source.
4594 prev = Elements.arrows.prev;
4595 next = Elements.arrows.next; // If arrows were not found in HTML, let's generate them.
4596
4597 if ((!prev || !next) && Splide.options.arrows) {
4598 prev = createArrow(true);
4599 next = createArrow(false);
4600 created = true;
4601 appendArrows();
4602 }
4603
4604 if (prev && next) {
4605 bind();
4606 }
4607
4608 this.arrows = {
4609 prev: prev,
4610 next: next
4611 };
4612 },
4613
4614 /**
4615 * Called after all components are mounted.
4616 */
4617 mounted: function mounted() {
4618 Splide.emit(name + ":mounted", prev, next);
4619 },
4620
4621 /**
4622 * Destroy.
4623 */
4624 destroy: function destroy() {
4625 removeAttribute([prev, next], 'disabled');
4626
4627 if (created) {
4628 dom_remove(prev.parentElement);
4629 }
4630 }
4631 };
4632 /**
4633 * Listen to native and custom events.
4634 */
4635
4636 function bind() {
4637 Splide.on('click', function () {
4638 Splide.go('<');
4639 }, prev).on('click', function () {
4640 Splide.go('>');
4641 }, next).on('mounted move updated refresh', updateDisabled);
4642 }
4643 /**
4644 * Update a disabled attribute.
4645 */
4646
4647
4648 function updateDisabled() {
4649 var _Components$Controlle = Components.Controller,
4650 prevIndex = _Components$Controlle.prevIndex,
4651 nextIndex = _Components$Controlle.nextIndex;
4652 var isEnough = Splide.length > Splide.options.perPage || Splide.is(LOOP);
4653 prev.disabled = prevIndex < 0 || !isEnough;
4654 next.disabled = nextIndex < 0 || !isEnough;
4655 Splide.emit(name + ":updated", prev, next, prevIndex, nextIndex);
4656 }
4657 /**
4658 * Create a wrapper element and append arrows.
4659 */
4660
4661
4662 function appendArrows() {
4663 var wrapper = create('div', {
4664 "class": classes.arrows
4665 });
4666 append(wrapper, prev);
4667 append(wrapper, next);
4668 var slider = Elements.slider;
4669 var parent = Splide.options.arrows === 'slider' && slider ? slider : root;
4670 before(wrapper, parent.firstElementChild);
4671 }
4672 /**
4673 * Create an arrow element.
4674 *
4675 * @param {boolean} prev - Determine to create a prev arrow or next arrow.
4676 *
4677 * @return {Element} - A created arrow element.
4678 */
4679
4680
4681 function createArrow(prev) {
4682 var arrow = "<div class=\"" + classes.arrow + " " + (prev ? classes.prev : classes.next) + "\" role=\"button\" tabindex=\"0\">" + ("<svg xmlns=\"" + XML_NAME_SPACE + "\"\tviewBox=\"0 0 " + SIZE + " " + SIZE + "\"\twidth=\"" + SIZE + "\"\theight=\"" + SIZE + "\">") + ("<path d=\"" + (Splide.options.arrowPath || PATH) + "\" />");
4683 return domify(arrow);
4684 }
4685
4686 return Arrows;
4687});
4688// CONCATENATED MODULE: ./src/js/components/pagination/index.js
4689/**
4690 * The component for handling pagination
4691 *
4692 * @author Naotoshi Fujita
4693 * @copyright Naotoshi Fujita. All rights reserved.
4694 */
4695
4696
4697/**
4698 * The event name for updating some attributes of pagination nodes.
4699 *
4700 * @type {string}
4701 */
4702
4703var ATTRIBUTES_UPDATE_EVENT = 'move.page';
4704/**
4705 * The event name for recreating pagination.
4706 *
4707 * @type {string}
4708 */
4709
4710var UPDATE_EVENT = 'updated.page refresh.page';
4711/**
4712 * The component for handling pagination
4713 *
4714 * @param {Splide} Splide - A Splide instance.
4715 * @param {Object} Components - An object containing components.
4716 * @param {string} name - A component name as a lowercase string.
4717 *
4718 * @return {Object} - The component object.
4719 */
4720
4721/* harmony default export */ var components_pagination = (function (Splide, Components, name) {
4722 /**
4723 * Store all data for pagination.
4724 * - list: A list element.
4725 * - items: An array that contains objects(li, button, index, page).
4726 *
4727 * @type {Object}
4728 */
4729 var data = {};
4730 /**
4731 * Hold the Elements component.
4732 *
4733 * @type {Object}
4734 */
4735
4736 var Elements = Components.Elements;
4737 /**
4738 * Pagination component object.
4739 *
4740 * @type {Object}
4741 */
4742
4743 var Pagination = {
4744 /**
4745 * Called when the component is mounted.
4746 */
4747 mount: function mount() {
4748 var pagination = Splide.options.pagination;
4749
4750 if (pagination) {
4751 data = createPagination();
4752 var slider = Elements.slider;
4753 var parent = pagination === 'slider' && slider ? slider : Splide.root;
4754 append(parent, data.list);
4755 Splide.on(ATTRIBUTES_UPDATE_EVENT, updateAttributes);
4756 }
4757
4758 Splide.off(UPDATE_EVENT).on(UPDATE_EVENT, function () {
4759 Pagination.destroy();
4760
4761 if (Splide.options.pagination) {
4762 Pagination.mount();
4763 Pagination.mounted();
4764 }
4765 });
4766 },
4767
4768 /**
4769 * Called after all components are mounted.
4770 */
4771 mounted: function mounted() {
4772 if (Splide.options.pagination) {
4773 var index = Splide.index;
4774 Splide.emit(name + ":mounted", data, this.getItem(index));
4775 updateAttributes(index, -1);
4776 }
4777 },
4778
4779 /**
4780 * Destroy the pagination.
4781 * Be aware that node.remove() is not supported by IE.
4782 */
4783 destroy: function destroy() {
4784 dom_remove(data.list);
4785
4786 if (data.items) {
4787 data.items.forEach(function (item) {
4788 Splide.off('click', item.button);
4789 });
4790 } // Do not remove UPDATE_EVENT to recreate pagination if needed.
4791
4792
4793 Splide.off(ATTRIBUTES_UPDATE_EVENT);
4794 data = {};
4795 },
4796
4797 /**
4798 * Return an item by index.
4799 *
4800 * @param {number} index - A slide index.
4801 *
4802 * @return {Object|undefined} - An item object on success or undefined on failure.
4803 */
4804 getItem: function getItem(index) {
4805 return data.items[Components.Controller.toPage(index)];
4806 },
4807
4808 /**
4809 * Return object containing pagination data.
4810 *
4811 * @return {Object} - Pagination data including list and items.
4812 */
4813 get data() {
4814 return data;
4815 }
4816
4817 };
4818 /**
4819 * Update attributes.
4820 *
4821 * @param {number} index - Active index.
4822 * @param {number} prevIndex - Prev index.
4823 */
4824
4825 function updateAttributes(index, prevIndex) {
4826 var prev = Pagination.getItem(prevIndex);
4827 var curr = Pagination.getItem(index);
4828 var active = STATUS_CLASSES.active;
4829
4830 if (prev) {
4831 removeClass(prev.button, active);
4832 }
4833
4834 if (curr) {
4835 addClass(curr.button, active);
4836 }
4837
4838 Splide.emit(name + ":updated", data, prev, curr);
4839 }
4840 /**
4841 * Create a wrapper and button elements.
4842 *
4843 * @return {Object} - An object contains all data.
4844 */
4845
4846
4847 function createPagination() {
4848 var options = Splide.options;
4849 var classes = Splide.classes;
4850 var list = create('ul', {
4851 "class": classes.pagination
4852 });
4853 var items = Elements.getSlides(false).filter(function (Slide) {
4854 return options.focus !== false || Slide.index % options.perPage === 0;
4855 }).map(function (Slide, page) {
4856 var li = create('li', {});
4857 var button = create('button', {
4858 "class": classes.page,
4859 type: 'button'
4860 });
4861 append(li, button);
4862 append(list, li);
4863 Splide.on('click', function () {
4864 Splide.go(">" + page);
4865 }, button);
4866 return {
4867 li: li,
4868 button: button,
4869 page: page,
4870 Slides: Elements.getSlidesByPage(page)
4871 };
4872 });
4873 return {
4874 list: list,
4875 items: items
4876 };
4877 }
4878
4879 return Pagination;
4880});
4881// CONCATENATED MODULE: ./src/js/components/lazyload/index.js
4882/**
4883 * The component for loading slider images lazily.
4884 *
4885 * @author Naotoshi Fujita
4886 * @copyright Naotoshi Fujita. All rights reserved.
4887 */
4888
4889
4890
4891/**
4892 * The name for a data attribute.
4893 *
4894 * @type {string}
4895 */
4896
4897var SRC_DATA_NAME = 'data-splide-lazy';
4898/**
4899 * The component for loading slider images lazily.
4900 *
4901 * @param {Splide} Splide - A Splide instance.
4902 * @param {Object} Components - An object containing components.
4903 * @param {string} name - A component name as a lowercase string.
4904 *
4905 * @return {Object} - The component object.
4906 */
4907
4908/* harmony default export */ var lazyload = (function (Splide, Components, name) {
4909 /**
4910 * Next index for sequential loading.
4911 *
4912 * @type {number}
4913 */
4914 var nextIndex;
4915 /**
4916 * Store objects containing an img element and a Slide object.
4917 *
4918 * @type {Object[]}
4919 */
4920
4921 var images;
4922 /**
4923 * Store the options.
4924 *
4925 * @type {Object}
4926 */
4927
4928 var options = Splide.options;
4929 /**
4930 * Whether to load images sequentially or not.
4931 *
4932 * @type {boolean}
4933 */
4934
4935 var isSequential = options.lazyLoad === 'sequential';
4936 /**
4937 * Lazyload component object.
4938 *
4939 * @type {Object}
4940 */
4941
4942 var Lazyload = {
4943 /**
4944 * Mount only when the lazyload option is provided.
4945 *
4946 * @type {boolean}
4947 */
4948 required: options.lazyLoad,
4949
4950 /**
4951 * Called when the component is mounted.
4952 */
4953 mount: function mount() {
4954 Splide.on('mounted refresh', function () {
4955 init();
4956 Components.Elements.each(function (Slide) {
4957 each(Slide.slide.querySelectorAll("[" + SRC_DATA_NAME + "]"), function (img) {
4958 if (!img.src) {
4959 images.push({
4960 img: img,
4961 Slide: Slide
4962 });
4963 applyStyle(img, {
4964 display: 'none'
4965 });
4966 }
4967 });
4968 });
4969
4970 if (isSequential) {
4971 loadNext();
4972 }
4973 });
4974
4975 if (!isSequential) {
4976 Splide.on("mounted refresh moved." + name, check);
4977 }
4978 },
4979
4980 /**
4981 * Destroy.
4982 */
4983 destroy: init
4984 };
4985 /**
4986 * Initialize parameters.
4987 */
4988
4989 function init() {
4990 images = [];
4991 nextIndex = 0;
4992 }
4993 /**
4994 * Check how close each image is from the active slide and
4995 * determine whether to start loading or not, according to the distance.
4996 *
4997 * @param {number} index - Current index.
4998 */
4999
5000
5001 function check(index) {
5002 index = isNaN(index) ? Splide.index : index;
5003 images = images.filter(function (image) {
5004 if (image.Slide.isWithin(index, options.perPage * (options.preloadPages + 1))) {
5005 load(image.img, image.Slide);
5006 return false;
5007 }
5008
5009 return true;
5010 }); // Unbind if all images are loaded.
5011
5012 if (!images[0]) {
5013 Splide.off("moved." + name);
5014 }
5015 }
5016 /**
5017 * Start loading an image.
5018 * Creating a clone of the image element since setting src attribute directly to it
5019 * often occurs 'hitch', blocking some other processes of a browser.
5020 *
5021 * @param {Element} img - An image element.
5022 * @param {Object} Slide - A Slide object.
5023 */
5024
5025
5026 function load(img, Slide) {
5027 addClass(Slide.slide, STATUS_CLASSES.loading);
5028 var spinner = create('span', {
5029 "class": Splide.classes.spinner
5030 });
5031 append(img.parentElement, spinner);
5032
5033 img.onload = function () {
5034 loaded(img, spinner, Slide, false);
5035 };
5036
5037 img.onerror = function () {
5038 loaded(img, spinner, Slide, true);
5039 };
5040
5041 setAttribute(img, 'src', getAttribute(img, SRC_DATA_NAME));
5042 }
5043 /**
5044 * Start loading a next image in images array.
5045 */
5046
5047
5048 function loadNext() {
5049 if (nextIndex < images.length) {
5050 var image = images[nextIndex];
5051 load(image.img, image.Slide);
5052 }
5053
5054 nextIndex++;
5055 }
5056 /**
5057 * Called just after the image was loaded or loading was aborted by some error.
5058 *
5059 * @param {Element} img - An image element.
5060 * @param {Element} spinner - A spinner element.
5061 * @param {Object} Slide - A Slide object.
5062 * @param {boolean} error - True if the image was loaded successfully or false on error.
5063 */
5064
5065
5066 function loaded(img, spinner, Slide, error) {
5067 removeClass(Slide.slide, STATUS_CLASSES.loading);
5068
5069 if (!error) {
5070 dom_remove(spinner);
5071 applyStyle(img, {
5072 display: ''
5073 });
5074 Splide.emit(name + ":loaded", img).emit('resize');
5075 }
5076
5077 if (isSequential) {
5078 loadNext();
5079 }
5080 }
5081
5082 return Lazyload;
5083});
5084// CONCATENATED MODULE: ./src/js/constants/a11y.js
5085/**
5086 * Export aria attribute names.
5087 *
5088 * @author Naotoshi Fujita
5089 * @copyright Naotoshi Fujita. All rights reserved.
5090 */
5091
5092/**
5093 * Attribute name for aria-current.
5094 *
5095 * @type {string}
5096 */
5097var ARIA_CURRENRT = 'aria-current';
5098/**
5099 * Attribute name for aria-control.
5100 *
5101 * @type {string}
5102 */
5103
5104var ARIA_CONTROLS = 'aria-controls';
5105/**
5106 * Attribute name for aria-control.
5107 *
5108 * @type {string}
5109 */
5110
5111var ARIA_LABEL = 'aria-label';
5112/**
5113 * Attribute name for aria-labelledby.
5114 *
5115 * @type {string}
5116 */
5117
5118var ARIA_LABELLEDBY = 'aria-labelledby';
5119/**
5120 * Attribute name for aria-hidden.
5121 *
5122 * @type {string}
5123 */
5124
5125var ARIA_HIDDEN = 'aria-hidden';
5126/**
5127 * Attribute name for tab-index.
5128 *
5129 * @type {string}
5130 */
5131
5132var TAB_INDEX = 'tabindex';
5133// CONCATENATED MODULE: ./src/js/components/keyboard/index.js
5134/**
5135 * The component for controlling slides via keyboard.
5136 *
5137 * @author Naotoshi Fujita
5138 * @copyright Naotoshi Fujita. All rights reserved.
5139 */
5140
5141
5142/**
5143 * Map a key to a slide control.
5144 *
5145 * @type {Object}
5146 */
5147
5148var KEY_MAP = {
5149 ltr: {
5150 ArrowLeft: '<',
5151 ArrowRight: '>',
5152 // For IE.
5153 Left: '<',
5154 Right: '>'
5155 },
5156 rtl: {
5157 ArrowLeft: '>',
5158 ArrowRight: '<',
5159 // For IE.
5160 Left: '>',
5161 Right: '<'
5162 },
5163 ttb: {
5164 ArrowUp: '<',
5165 ArrowDown: '>',
5166 // For IE.
5167 Up: '<',
5168 Down: '>'
5169 }
5170};
5171/**
5172 * The component for controlling slides via keyboard.
5173 *
5174 * @param {Splide} Splide - A Splide instance.
5175 *
5176 * @return {Object} - The component object.
5177 */
5178
5179/* harmony default export */ var components_keyboard = (function (Splide) {
5180 /**
5181 * Hold the target element.
5182 *
5183 * @type {Element|Document|undefined}
5184 */
5185 var target;
5186 return {
5187 /**
5188 * Called when the component is mounted.
5189 */
5190 mount: function mount() {
5191 Splide.on('mounted updated', function () {
5192 var options = Splide.options;
5193 var root = Splide.root;
5194 var map = KEY_MAP[options.direction];
5195 var keyboard = options.keyboard;
5196
5197 if (target) {
5198 Splide.off('keydown', target);
5199 removeAttribute(root, TAB_INDEX);
5200 }
5201
5202 if (keyboard) {
5203 if (keyboard === 'focused') {
5204 target = root;
5205 setAttribute(root, TAB_INDEX, 0);
5206 } else {
5207 target = document;
5208 }
5209
5210 Splide.on('keydown', function (e) {
5211 if (map[e.key]) {
5212 Splide.go(map[e.key]);
5213 }
5214 }, target);
5215 }
5216 });
5217 }
5218 };
5219});
5220// CONCATENATED MODULE: ./src/js/components/a11y/index.js
5221/**
5222 * The component for enhancing accessibility.
5223 *
5224 * @author Naotoshi Fujita
5225 * @copyright Naotoshi Fujita. All rights reserved.
5226 */
5227
5228
5229
5230/**
5231 * The component for enhancing accessibility.
5232 *
5233 * @param {Splide} Splide - A Splide instance.
5234 * @param {Object} Components - An object containing components.
5235 *
5236 * @return {Object} - The component object.
5237 */
5238
5239/* harmony default export */ var a11y = (function (Splide, Components) {
5240 /**
5241 * Hold a i18n object.
5242 *
5243 * @type {Object}
5244 */
5245 var i18n = Splide.i18n;
5246 /**
5247 * Hold the Elements component.
5248 *
5249 * @type {Object}
5250 */
5251
5252 var Elements = Components.Elements;
5253 /**
5254 * All attributes related with A11y.
5255 *
5256 * @type {string[]}
5257 */
5258
5259 var allAttributes = [ARIA_HIDDEN, TAB_INDEX, ARIA_CONTROLS, ARIA_LABEL, ARIA_CURRENRT, 'role'];
5260 /**
5261 * A11y component object.
5262 *
5263 * @type {Object}
5264 */
5265
5266 var A11y = {
5267 /**
5268 * Required only when the accessibility option is true.
5269 *
5270 * @type {boolean}
5271 */
5272 required: Splide.options.accessibility,
5273
5274 /**
5275 * Called when the component is mounted.
5276 */
5277 mount: function mount() {
5278 Splide.on('visible', function (Slide) {
5279 updateSlide(Slide.slide, true);
5280 }).on('hidden', function (Slide) {
5281 updateSlide(Slide.slide, false);
5282 }).on('arrows:mounted', initArrows).on('arrows:updated', updateArrows).on('pagination:mounted', initPagination).on('pagination:updated', updatePagination).on('refresh', function () {
5283 removeAttribute(Components.Clones.clones, allAttributes);
5284 });
5285
5286 if (Splide.options.isNavigation) {
5287 Splide.on('navigation:mounted', initNavigation).on('active', function (Slide) {
5288 updateNavigation(Slide, true);
5289 }).on('inactive', function (Slide) {
5290 updateNavigation(Slide, false);
5291 });
5292 }
5293
5294 initAutoplay();
5295 },
5296
5297 /**
5298 * Destroy.
5299 */
5300 destroy: function destroy() {
5301 var Arrows = Components.Arrows;
5302 var arrows = Arrows ? Arrows.arrows : {};
5303 removeAttribute(Elements.slides.concat([arrows.prev, arrows.next, Elements.play, Elements.pause]), allAttributes);
5304 }
5305 };
5306 /**
5307 * Update slide attributes when it gets visible or hidden.
5308 *
5309 * @param {Element} slide - A slide element.
5310 * @param {Boolean} visible - True when the slide gets visible, or false when hidden.
5311 */
5312
5313 function updateSlide(slide, visible) {
5314 setAttribute(slide, ARIA_HIDDEN, !visible);
5315 if (Splide.options.slideFocus) {
5316 setAttribute(slide, TAB_INDEX, visible ? 0 : -1);
5317 }
5318 }
5319 /**
5320 * Initialize arrows if they are available.
5321 * Append screen reader elements and add aria-controls attribute.
5322 *
5323 * @param {Element} prev - Previous arrow element.
5324 * @param {Element} next - Next arrow element.
5325 */
5326
5327
5328 function initArrows(prev, next) {
5329 var controls = Elements.track.id;
5330 setAttribute(prev, ARIA_CONTROLS, controls);
5331 setAttribute(next, ARIA_CONTROLS, controls);
5332 }
5333 /**
5334 * Update arrow attributes.
5335 *
5336 * @param {Element} prev - Previous arrow element.
5337 * @param {Element} next - Next arrow element.
5338 * @param {number} prevIndex - Previous slide index or -1 when there is no precede slide.
5339 * @param {number} nextIndex - Next slide index or -1 when there is no next slide.
5340 */
5341
5342
5343 function updateArrows(prev, next, prevIndex, nextIndex) {
5344 var index = Splide.index;
5345 var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
5346 var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
5347 setAttribute(prev, ARIA_LABEL, prevLabel);
5348 setAttribute(next, ARIA_LABEL, nextLabel);
5349 }
5350 /**
5351 * Initialize pagination if it's available.
5352 * Append a screen reader element and add aria-controls/label attribute to each item.
5353 *
5354 * @param {Object} data - Data object containing all items.
5355 * @param {Object} activeItem - An initial active item.
5356 */
5357
5358
5359 function initPagination(data, activeItem) {
5360 if (activeItem) {
5361 setAttribute(activeItem.button, ARIA_CURRENRT, true);
5362 }
5363
5364 data.items.forEach(function (item) {
5365 var options = Splide.options;
5366 var text = options.focus === false && options.perPage > 1 ? i18n.pageX : i18n.slideX;
5367 var label = sprintf(text, item.page + 1);
5368 var button = item.button;
5369 var controls = item.Slides.map(function (Slide) {
5370 return Slide.slide.id;
5371 });
5372 setAttribute(button, ARIA_CONTROLS, controls.join(' '));
5373 setAttribute(button, ARIA_LABEL, label);
5374 });
5375 }
5376 /**
5377 * Update pagination attributes.
5378 *
5379 * @param {Object} data - Data object containing all items.
5380 * @param {Element} prev - A previous active element.
5381 * @param {Element} curr - A current active element.
5382 */
5383
5384
5385 function updatePagination(data, prev, curr) {
5386 if (prev) {
5387 removeAttribute(prev.button, ARIA_CURRENRT);
5388 }
5389
5390 if (curr) {
5391 setAttribute(curr.button, ARIA_CURRENRT, true);
5392 }
5393 }
5394 /**
5395 * Initialize autoplay buttons.
5396 */
5397
5398
5399 function initAutoplay() {
5400 ['play', 'pause'].forEach(function (name) {
5401 var elm = Elements[name];
5402
5403 if (elm) {
5404 if (!isButton(elm)) {
5405 setAttribute(elm, 'role', 'button');
5406 }
5407
5408 setAttribute(elm, ARIA_CONTROLS, Elements.track.id);
5409 setAttribute(elm, ARIA_LABEL, i18n[name]);
5410 }
5411 });
5412 }
5413 /**
5414 * Initialize navigation slider.
5415 * Add button role, aria-label, aria-controls to slide elements and append screen reader text to them.
5416 *
5417 * @param {Splide} main - A main Splide instance.
5418 */
5419
5420
5421 function initNavigation(main) {
5422 Elements.each(function (Slide) {
5423 var slide = Slide.slide;
5424 var realIndex = Slide.realIndex;
5425
5426 if (!isButton(slide)) {
5427 setAttribute(slide, 'role', 'button');
5428 }
5429
5430 var slideIndex = realIndex > -1 ? realIndex : Slide.index;
5431 var label = sprintf(i18n.slideX, slideIndex + 1);
5432 var mainSlide = main.Components.Elements.getSlide(slideIndex);
5433 setAttribute(slide, ARIA_LABEL, label);
5434
5435 if (mainSlide) {
5436 setAttribute(slide, ARIA_CONTROLS, mainSlide.slide.id);
5437 }
5438 });
5439 }
5440 /**
5441 * Update navigation attributes.
5442 *
5443 * @param {Object} Slide - A target Slide object.
5444 * @param {boolean} active - True if the slide is active or false if inactive.
5445 */
5446
5447
5448 function updateNavigation(_ref, active) {
5449 var slide = _ref.slide;
5450
5451 if (active) {
5452 setAttribute(slide, ARIA_CURRENRT, true);
5453 } else {
5454 removeAttribute(slide, ARIA_CURRENRT);
5455 }
5456 }
5457 /**
5458 * Check if the given element is button or not.
5459 *
5460 * @param {Element} elm - An element to be checked.
5461 *
5462 * @return {boolean} - True if the given element is button.
5463 */
5464
5465
5466 function isButton(elm) {
5467 return elm.tagName === 'BUTTON';
5468 }
5469
5470 return A11y;
5471});
5472// CONCATENATED MODULE: ./src/js/components/sync/index.js
5473/**
5474 * The component for synchronizing a slider with another.
5475 *
5476 * @author Naotoshi Fujita
5477 * @copyright Naotoshi Fujita. All rights reserved.
5478 */
5479
5480
5481/**
5482 * The event name for sync.
5483 *
5484 * @type {string}
5485 */
5486
5487var SYNC_EVENT = 'move.sync';
5488/**
5489 * The keys for triggering the navigation button.
5490 *
5491 * @type {String[]}
5492 */
5493
5494var TRIGGER_KEYS = [' ', 'Enter', 'Spacebar'];
5495/**
5496 * The component for synchronizing a slider with another.
5497 *
5498 * @param {Splide} Splide - A Splide instance.
5499 *
5500 * @return {Object} - The component object.
5501 */
5502
5503/* harmony default export */ var sync = (function (Splide) {
5504 /**
5505 * Keep the sibling Splide instance.
5506 *
5507 * @type {Splide}
5508 */
5509 var sibling = Splide.sibling;
5510 /**
5511 * Whether the sibling slider is navigation or not.
5512 *
5513 * @type {Splide|boolean}
5514 */
5515
5516 var isNavigation = sibling && sibling.options.isNavigation;
5517 /**
5518 * Layout component object.
5519 *
5520 * @type {Object}
5521 */
5522
5523 var Sync = {
5524 /**
5525 * Required only when the sub slider is available.
5526 *
5527 * @type {boolean}
5528 */
5529 required: !!sibling,
5530
5531 /**
5532 * Called when the component is mounted.
5533 */
5534 mount: function mount() {
5535 syncMain();
5536 syncSibling();
5537
5538 if (isNavigation) {
5539 bind();
5540 }
5541 },
5542
5543 /**
5544 * Called after all components are mounted.
5545 */
5546 mounted: function mounted() {
5547 if (isNavigation) {
5548 sibling.emit('navigation:mounted', Splide);
5549 }
5550 }
5551 };
5552 /**
5553 * Listen the primary slider event to move secondary one.
5554 * Must unbind a handler at first to avoid infinite loop.
5555 */
5556
5557 function syncMain() {
5558 Splide.on(SYNC_EVENT, function (newIndex, prevIndex, destIndex) {
5559 sibling.off(SYNC_EVENT).go(sibling.is(LOOP) ? destIndex : newIndex, false);
5560 syncSibling();
5561 });
5562 }
5563 /**
5564 * Listen the secondary slider event to move primary one.
5565 * Must unbind a handler at first to avoid infinite loop.
5566 */
5567
5568
5569 function syncSibling() {
5570 sibling.on(SYNC_EVENT, function (newIndex, prevIndex, destIndex) {
5571 Splide.off(SYNC_EVENT).go(Splide.is(LOOP) ? destIndex : newIndex, false);
5572 syncMain();
5573 });
5574 }
5575 /**
5576 * Listen some events on each slide.
5577 */
5578
5579
5580 function bind() {
5581 sibling.Components.Elements.each(function (_ref) {
5582 var slide = _ref.slide,
5583 index = _ref.index;
5584
5585 /*
5586 * Listen mouseup and touchend events to handle click.
5587 */
5588 Splide.on('mouseup touchend', function (e) {
5589 // Ignore a middle or right click.
5590 if (!e.button || e.button === 0) {
5591 moveSibling(index);
5592 }
5593 }, slide);
5594 /*
5595 * Subscribe keyup to handle Enter and Space key.
5596 * Note that Array.includes is not supported by IE.
5597 */
5598
5599 Splide.on('keyup', function (e) {
5600 if (TRIGGER_KEYS.indexOf(e.key) > -1) {
5601 e.preventDefault();
5602 moveSibling(index);
5603 }
5604 }, slide, {
5605 passive: false
5606 });
5607 });
5608 }
5609 /**
5610 * Move the sibling to the given index.
5611 * Need to check "IDLE" status because slides can be moving by Drag component.
5612 *
5613 * @param {number} index - Target index.
5614 */
5615
5616
5617 function moveSibling(index) {
5618 if (Splide.State.is(IDLE)) {
5619 sibling.go(index);
5620 }
5621 }
5622
5623 return Sync;
5624});
5625// CONCATENATED MODULE: ./src/js/components/breakpoints/index.js
5626/**
5627 * The component for updating options according to a current window width.
5628 *
5629 * @author Naotoshi Fujita
5630 * @copyright Naotoshi Fujita. All rights reserved.
5631 */
5632
5633
5634/**
5635 * Interval time for throttle.
5636 *
5637 * @type {number}
5638 */
5639
5640var THROTTLE = 50;
5641/**
5642 * The component for updating options according to a current window width.
5643 *
5644 * @param {Splide} Splide - A Splide instance.
5645 *
5646 * @return {Object} - The component object.
5647 */
5648
5649/* harmony default export */ var components_breakpoints = (function (Splide) {
5650 /**
5651 * Store breakpoints.
5652 *
5653 * @type {Object|boolean}
5654 */
5655 var breakpoints = Splide.options.breakpoints;
5656 /**
5657 * The check function whose frequency of call is reduced.
5658 *
5659 * @type {Function}
5660 */
5661
5662 var throttledCheck = throttle(check, THROTTLE);
5663 /**
5664 * Keep initial options.
5665 *
5666 * @type {Object}
5667 */
5668
5669 var initialOptions;
5670 /**
5671 * An array containing objects of point and MediaQueryList.
5672 *
5673 * @type {Object[]}
5674 */
5675
5676 var map = [];
5677 /**
5678 * Hold the previous breakpoint.
5679 *
5680 * @type {number|undefined}
5681 */
5682
5683 var prevPoint;
5684 /**
5685 * Breakpoints component object.
5686 *
5687 * @type {Object}
5688 */
5689
5690 var Breakpoints = {
5691 /**
5692 * Required only when the breakpoints definition is provided and browser supports matchMedia.
5693 *
5694 * @type {boolean}
5695 */
5696 required: breakpoints && matchMedia,
5697
5698 /**
5699 * Called when the component is mounted.
5700 */
5701 mount: function mount() {
5702 map = Object.keys(breakpoints).sort(function (n, m) {
5703 return +n - +m;
5704 }).map(function (point) {
5705 return {
5706 point: point,
5707 mql: matchMedia("(max-width:" + point + "px)")
5708 };
5709 });
5710 /*
5711 * To keep monitoring resize event after destruction without "completely",
5712 * use native addEventListener instead of Splide.on.
5713 */
5714
5715 this.destroy(true);
5716 addEventListener('resize', throttledCheck); // Keep initial options to apply them when no breakpoint matches.
5717
5718 initialOptions = Splide.options;
5719 check();
5720 },
5721
5722 /**
5723 * Destroy.
5724 *
5725 * @param {boolean} completely - Whether to destroy Splide completely.
5726 */
5727 destroy: function destroy(completely) {
5728 if (completely) {
5729 removeEventListener('resize', throttledCheck);
5730 }
5731 }
5732 };
5733 /**
5734 * Check the breakpoint.
5735 */
5736
5737 function check() {
5738 var point = getPoint();
5739
5740 if (point !== prevPoint) {
5741 prevPoint = point;
5742 var State = Splide.State;
5743 var options = breakpoints[point] || initialOptions;
5744 var destroy = options.destroy;
5745
5746 if (destroy) {
5747 Splide.options = initialOptions;
5748 Splide.destroy(destroy === 'completely');
5749 } else {
5750 if (State.is(DESTROYED)) {
5751 State.set(CREATED);
5752 Splide.mount();
5753 }
5754
5755 Splide.options = options;
5756 }
5757 }
5758 }
5759 /**
5760 * Return the breakpoint matching current window width.
5761 * Note that Array.prototype.find is not supported by IE.
5762 *
5763 * @return {number|string} - A breakpoint as number or string. -1 if no point matches.
5764 */
5765
5766
5767 function getPoint() {
5768 var item = map.filter(function (item) {
5769 return item.mql.matches;
5770 })[0];
5771 return item ? item.point : -1;
5772 }
5773
5774 return Breakpoints;
5775});
5776// CONCATENATED MODULE: ./src/js/components/index.js
5777/**
5778 * Export components.
5779 *
5780 * @author Naotoshi Fujita
5781 * @copyright Naotoshi Fujita. All rights reserved.
5782 */
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800var COMPLETE = {
5801 Options: components_options,
5802 Breakpoints: components_breakpoints,
5803 Controller: controller,
5804 Elements: components_elements,
5805 Track: components_track,
5806 Clones: components_clones,
5807 Layout: layout,
5808 Drag: drag,
5809 Click: click,
5810 Autoplay: components_autoplay,
5811 Cover: components_cover,
5812 Arrows: components_arrows,
5813 Pagination: components_pagination,
5814 LazyLoad: lazyload,
5815 Keyboard: components_keyboard,
5816 Sync: sync,
5817 A11y: a11y
5818};
5819var LIGHT = {
5820 Options: components_options,
5821 Controller: controller,
5822 Elements: components_elements,
5823 Track: components_track,
5824 Clones: components_clones,
5825 Layout: layout,
5826 Drag: drag,
5827 Click: click,
5828 Arrows: components_arrows,
5829 Pagination: components_pagination,
5830 A11y: a11y
5831};
5832// CONCATENATED MODULE: ./build/module/module.js
5833function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
5834
5835/**
5836 * Export Splide class for import.
5837 *
5838 * @author Naotoshi Fujita
5839 * @copyright Naotoshi Fujita. All rights reserved.
5840 */
5841
5842
5843/**
5844 * Export Splide class for import from other projects.
5845 */
5846
5847var module_Splide = /*#__PURE__*/function (_Core) {
5848 _inheritsLoose(Splide, _Core);
5849
5850 function Splide(root, options) {
5851 return _Core.call(this, root, options, COMPLETE) || this;
5852 }
5853
5854 return Splide;
5855}(splide_Splide);
5856
5857
5858
5859/***/ })
5860/******/ ]);
5861});