1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959 |
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- /*!
- * Splide.js
- * Version : 3.2.2
- * License : MIT
- * Copyright: 2021 Naotoshi Fujita
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Splide = factory());
- })(this, function () {
- 'use strict';
- var PROJECT_CODE = "splide";
- var DATA_ATTRIBUTE = "data-" + PROJECT_CODE;
- var CREATED = 1;
- var MOUNTED = 2;
- var IDLE = 3;
- var MOVING = 4;
- var DESTROYED = 5;
- var STATES = {
- CREATED: CREATED,
- MOUNTED: MOUNTED,
- IDLE: IDLE,
- MOVING: MOVING,
- DESTROYED: DESTROYED
- };
- var DEFAULT_EVENT_PRIORITY = 10;
- var DEFAULT_USER_EVENT_PRIORITY = 20;
- function empty(array) {
- array.length = 0;
- }
- function isObject(subject) {
- return !isNull(subject) && typeof subject === "object";
- }
- function isArray(subject) {
- return Array.isArray(subject);
- }
- function isFunction(subject) {
- return typeof subject === "function";
- }
- function isString(subject) {
- return typeof subject === "string";
- }
- function isUndefined(subject) {
- return typeof subject === "undefined";
- }
- function isNull(subject) {
- return subject === null;
- }
- function isHTMLElement(subject) {
- return subject instanceof HTMLElement;
- }
- function toArray(value) {
- return isArray(value) ? value : [value];
- }
- function forEach(values, iteratee) {
- toArray(values).forEach(iteratee);
- }
- function includes(array, value) {
- return array.indexOf(value) > -1;
- }
- function push(array, items) {
- array.push.apply(array, toArray(items));
- return array;
- }
- var arrayProto = Array.prototype;
- function slice(arrayLike, start, end) {
- return arrayProto.slice.call(arrayLike, start, end);
- }
- function find(arrayLike, predicate) {
- return slice(arrayLike).filter(predicate)[0];
- }
- function toggleClass(elm, classes, add) {
- if (elm) {
- forEach(classes, function (name) {
- if (name) {
- elm.classList[add ? "add" : "remove"](name);
- }
- });
- }
- }
- function addClass(elm, classes) {
- toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true);
- }
- function append(parent, children) {
- forEach(children, parent.appendChild.bind(parent));
- }
- function before(nodes, ref) {
- forEach(nodes, function (node) {
- var parent = ref.parentNode;
- if (parent) {
- parent.insertBefore(node, ref);
- }
- });
- }
- function matches(elm, selector) {
- return (elm["msMatchesSelector"] || elm.matches).call(elm, selector);
- }
- function children(parent, selector) {
- return parent ? slice(parent.children).filter(function (child) {
- return matches(child, selector);
- }) : [];
- }
- function child(parent, selector) {
- return selector ? children(parent, selector)[0] : parent.firstElementChild;
- }
- function forOwn(object, iteratee, right) {
- if (object) {
- var keys = Object.keys(object);
- keys = right ? keys.reverse() : keys;
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- if (key !== "__proto__") {
- if (iteratee(object[key], key) === false) {
- break;
- }
- }
- }
- }
- return object;
- }
- function assign(object) {
- slice(arguments, 1).forEach(function (source) {
- forOwn(source, function (value, key) {
- object[key] = source[key];
- });
- });
- return object;
- }
- function merge(object, source) {
- forOwn(source, function (value, key) {
- if (isArray(value)) {
- object[key] = value.slice();
- } else if (isObject(value)) {
- object[key] = merge(isObject(object[key]) ? object[key] : {}, value);
- } else {
- object[key] = value;
- }
- });
- return object;
- }
- function removeAttribute(elm, attrs) {
- if (elm) {
- forEach(attrs, function (attr) {
- elm.removeAttribute(attr);
- });
- }
- }
- function setAttribute(elm, attrs, value) {
- if (isObject(attrs)) {
- forOwn(attrs, function (value2, name) {
- setAttribute(elm, name, value2);
- });
- } else {
- isNull(value) ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value));
- }
- }
- function create(tag, attrs, parent) {
- var elm = document.createElement(tag);
- if (attrs) {
- isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs);
- }
- parent && append(parent, elm);
- return elm;
- }
- function style(elm, prop, value) {
- if (isUndefined(value)) {
- return getComputedStyle(elm)[prop];
- }
- if (!isNull(value)) {
- var style2 = elm.style;
- value = "" + value;
- if (style2[prop] !== value) {
- style2[prop] = value;
- }
- }
- }
- function display(elm, display2) {
- style(elm, "display", display2);
- }
- function focus(elm) {
- elm["setActive"] && elm["setActive"]() || elm.focus({
- preventScroll: true
- });
- }
- function getAttribute(elm, attr) {
- return elm.getAttribute(attr);
- }
- function hasClass(elm, className) {
- return elm && elm.classList.contains(className);
- }
- function rect(target) {
- return target.getBoundingClientRect();
- }
- function remove(nodes) {
- forEach(nodes, function (node) {
- if (node && node.parentNode) {
- node.parentNode.removeChild(node);
- }
- });
- }
- function measure(parent, value) {
- if (isString(value)) {
- var div = create("div", {
- style: "width: " + value + "; position: absolute;"
- }, parent);
- value = rect(div).width;
- remove(div);
- }
- return value;
- }
- function parseHtml(html) {
- return child(new DOMParser().parseFromString(html, "text/html").body);
- }
- function prevent(e, stopPropagation) {
- e.preventDefault();
- if (stopPropagation) {
- e.stopPropagation();
- e.stopImmediatePropagation();
- }
- }
- function query(parent, selector) {
- return parent && parent.querySelector(selector);
- }
- function queryAll(parent, selector) {
- return slice(parent.querySelectorAll(selector));
- }
- function removeClass(elm, classes) {
- toggleClass(elm, classes, false);
- }
- function unit(value) {
- return isString(value) ? value : value ? value + "px" : "";
- }
- function assert(condition, message) {
- if (message === void 0) {
- message = "";
- }
- if (!condition) {
- throw new Error("[" + PROJECT_CODE + "] " + message);
- }
- }
- function nextTick(callback) {
- setTimeout(callback);
- }
- var noop = function noop() {};
- function raf(func) {
- return requestAnimationFrame(func);
- }
- var min = Math.min,
- max = Math.max,
- floor = Math.floor,
- ceil = Math.ceil,
- abs = Math.abs;
- function approximatelyEqual(x, y, epsilon) {
- return abs(x - y) < epsilon;
- }
- function between(number, minOrMax, maxOrMin, exclusive) {
- var minimum = min(minOrMax, maxOrMin);
- var maximum = max(minOrMax, maxOrMin);
- return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum;
- }
- function clamp(number, x, y) {
- var minimum = min(x, y);
- var maximum = max(x, y);
- return min(max(minimum, number), maximum);
- }
- function sign(x) {
- return +(x > 0) - +(x < 0);
- }
- function format(string, replacements) {
- forEach(replacements, function (replacement) {
- string = string.replace("%s", "" + replacement);
- });
- return string;
- }
- function pad(number) {
- return number < 10 ? "0" + number : "" + number;
- }
- var ids = {};
- function uniqueId(prefix) {
- return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1);
- }
- function EventBus() {
- var handlers = {};
- function on(events, callback, key, priority) {
- if (priority === void 0) {
- priority = DEFAULT_EVENT_PRIORITY;
- }
- forEachEvent(events, function (event, namespace) {
- handlers[event] = handlers[event] || [];
- push(handlers[event], {
- _event: event,
- _callback: callback,
- _namespace: namespace,
- _priority: priority,
- _key: key
- }).sort(function (handler1, handler2) {
- return handler1._priority - handler2._priority;
- });
- });
- }
- function off(events, key) {
- forEachEvent(events, function (event, namespace) {
- var eventHandlers = handlers[event];
- handlers[event] = eventHandlers && eventHandlers.filter(function (handler) {
- return handler._key ? handler._key !== key : key || handler._namespace !== namespace;
- });
- });
- }
- function offBy(key) {
- forOwn(handlers, function (eventHandlers, event) {
- off(event, key);
- });
- }
- function emit(event) {
- var _arguments = arguments;
- (handlers[event] || []).forEach(function (handler) {
- handler._callback.apply(handler, slice(_arguments, 1));
- });
- }
- function destroy() {
- handlers = {};
- }
- function forEachEvent(events, iteratee) {
- toArray(events).join(" ").split(" ").forEach(function (eventNS) {
- var fragments = eventNS.split(".");
- iteratee(fragments[0], fragments[1]);
- });
- }
- return {
- on: on,
- off: off,
- offBy: offBy,
- emit: emit,
- destroy: destroy
- };
- }
- var EVENT_MOUNTED = "mounted";
- var EVENT_READY = "ready";
- var EVENT_MOVE = "move";
- var EVENT_MOVED = "moved";
- var EVENT_CLICK = "click";
- var EVENT_ACTIVE = "active";
- var EVENT_INACTIVE = "inactive";
- var EVENT_VISIBLE = "visible";
- var EVENT_HIDDEN = "hidden";
- var EVENT_SLIDE_KEYDOWN = "slide:keydown";
- var EVENT_REFRESH = "refresh";
- var EVENT_UPDATED = "updated";
- var EVENT_RESIZE = "resize";
- var EVENT_RESIZED = "resized";
- var EVENT_REPOSITIONED = "repositioned";
- var EVENT_DRAG = "drag";
- var EVENT_DRAGGING = "dragging";
- var EVENT_DRAGGED = "dragged";
- var EVENT_SCROLL = "scroll";
- var EVENT_SCROLLED = "scrolled";
- var EVENT_DESTROY = "destroy";
- var EVENT_ARROWS_MOUNTED = "arrows:mounted";
- var EVENT_ARROWS_UPDATED = "arrows:updated";
- var EVENT_PAGINATION_MOUNTED = "pagination:mounted";
- var EVENT_PAGINATION_UPDATED = "pagination:updated";
- var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
- var EVENT_AUTOPLAY_PLAY = "autoplay:play";
- var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
- var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
- var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
- function EventInterface(Splide2) {
- var event = Splide2.event;
- var key = {};
- var listeners = [];
- function on(events, callback, priority) {
- event.on(events, callback, key, priority);
- }
- function off(events) {
- event.off(events, key);
- }
- function bind(targets, events, callback, options) {
- forEachEvent(targets, events, function (target, event2) {
- listeners.push([target, event2, callback, options]);
- target.addEventListener(event2, callback, options);
- });
- }
- function unbind(targets, events, callback) {
- forEachEvent(targets, events, function (target, event2) {
- listeners = listeners.filter(function (listener) {
- if (listener[0] === target && listener[1] === event2 && (!callback || listener[2] === callback)) {
- target.removeEventListener(event2, listener[2], listener[3]);
- return false;
- }
- return true;
- });
- });
- }
- function forEachEvent(targets, events, iteratee) {
- forEach(targets, function (target) {
- if (target) {
- events.split(" ").forEach(iteratee.bind(null, target));
- }
- });
- }
- function destroy() {
- listeners = listeners.filter(function (data) {
- return unbind(data[0], data[1]);
- });
- event.offBy(key);
- }
- event.on(EVENT_DESTROY, destroy, key);
- return {
- on: on,
- off: off,
- emit: event.emit,
- bind: bind,
- unbind: unbind,
- destroy: destroy
- };
- }
- function RequestInterval(interval, onInterval, onUpdate, limit) {
- var now = Date.now;
- var startTime;
- var rate = 0;
- var id;
- var paused = true;
- var count = 0;
- function update() {
- if (!paused) {
- var elapsed = now() - startTime;
- if (elapsed >= interval) {
- rate = 1;
- startTime = now();
- } else {
- rate = elapsed / interval;
- }
- if (onUpdate) {
- onUpdate(rate);
- }
- if (rate === 1) {
- onInterval();
- if (limit && ++count >= limit) {
- return pause();
- }
- }
- raf(update);
- }
- }
- function start(resume) {
- !resume && cancel();
- startTime = now() - (resume ? rate * interval : 0);
- paused = false;
- raf(update);
- }
- function pause() {
- paused = true;
- }
- function rewind() {
- startTime = now();
- rate = 0;
- if (onUpdate) {
- onUpdate(rate);
- }
- }
- function cancel() {
- cancelAnimationFrame(id);
- rate = 0;
- id = 0;
- paused = true;
- }
- function isPaused() {
- return paused;
- }
- return {
- start: start,
- rewind: rewind,
- pause: pause,
- cancel: cancel,
- isPaused: isPaused
- };
- }
- function State(initialState) {
- var state = initialState;
- function set(value) {
- state = value;
- }
- function is(states) {
- return includes(toArray(states), state);
- }
- return {
- set: set,
- is: is
- };
- }
- function Throttle(func, duration) {
- var interval;
- function throttled() {
- var _arguments2 = arguments,
- _this = this;
- if (!interval) {
- interval = RequestInterval(duration || 0, function () {
- func.apply(_this, _arguments2);
- interval = null;
- }, null, 1);
- interval.start();
- }
- }
- return throttled;
- }
- function Options(Splide2, Components2, options) {
- var throttledObserve = Throttle(observe);
- var initialOptions;
- var points;
- var currPoint;
- function setup() {
- try {
- merge(options, JSON.parse(getAttribute(Splide2.root, DATA_ATTRIBUTE)));
- } catch (e) {
- assert(false, e.message);
- }
- initialOptions = merge({}, options);
- var breakpoints = options.breakpoints;
- if (breakpoints) {
- var isMin = options.mediaQuery === "min";
- points = Object.keys(breakpoints).sort(function (n, m) {
- return isMin ? +m - +n : +n - +m;
- }).map(function (point) {
- return [point, matchMedia("(" + (isMin ? "min" : "max") + "-width:" + point + "px)")];
- });
- observe();
- }
- }
- function mount() {
- if (points) {
- addEventListener("resize", throttledObserve);
- }
- }
- function destroy(completely) {
- if (completely) {
- removeEventListener("resize", throttledObserve);
- }
- }
- function observe() {
- var item = find(points, function (item2) {
- return item2[1].matches;
- }) || [];
- if (item[0] !== currPoint) {
- onMatch(currPoint = item[0]);
- }
- }
- function onMatch(point) {
- var newOptions = options.breakpoints[point] || initialOptions;
- if (newOptions.destroy) {
- Splide2.options = initialOptions;
- Splide2.destroy(newOptions.destroy === "completely");
- } else {
- if (Splide2.state.is(DESTROYED)) {
- destroy(true);
- Splide2.mount();
- }
- Splide2.options = newOptions;
- }
- }
- return {
- setup: setup,
- mount: mount,
- destroy: destroy
- };
- }
- var RTL = "rtl";
- var TTB = "ttb";
- var ORIENTATION_MAP = {
- marginRight: ["marginBottom", "marginLeft"],
- autoWidth: ["autoHeight"],
- fixedWidth: ["fixedHeight"],
- paddingLeft: ["paddingTop", "paddingRight"],
- paddingRight: ["paddingBottom", "paddingLeft"],
- width: ["height"],
- left: ["top", "right"],
- right: ["bottom", "left"],
- x: ["y"],
- X: ["Y"],
- Y: ["X"],
- ArrowLeft: ["ArrowUp", "ArrowRight"],
- ArrowRight: ["ArrowDown", "ArrowLeft"]
- };
- function Direction(Splide2, Components2, options) {
- function resolve(prop, axisOnly) {
- var direction = options.direction;
- var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
- return ORIENTATION_MAP[prop][index] || prop;
- }
- function orient(value) {
- return value * (options.direction === RTL ? 1 : -1);
- }
- return {
- resolve: resolve,
- orient: orient
- };
- }
- var CLASS_ROOT = PROJECT_CODE;
- var CLASS_SLIDER = PROJECT_CODE + "__slider";
- var CLASS_TRACK = PROJECT_CODE + "__track";
- var CLASS_LIST = PROJECT_CODE + "__list";
- var CLASS_SLIDE = PROJECT_CODE + "__slide";
- var CLASS_CLONE = CLASS_SLIDE + "--clone";
- var CLASS_CONTAINER = CLASS_SLIDE + "__container";
- var CLASS_ARROWS = PROJECT_CODE + "__arrows";
- var CLASS_ARROW = PROJECT_CODE + "__arrow";
- var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
- var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
- var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
- var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
- var CLASS_PROGRESS = PROJECT_CODE + "__progress";
- var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
- var CLASS_AUTOPLAY = PROJECT_CODE + "__autoplay";
- var CLASS_PLAY = PROJECT_CODE + "__play";
- var CLASS_PAUSE = PROJECT_CODE + "__pause";
- var CLASS_SPINNER = PROJECT_CODE + "__spinner";
- var CLASS_INITIALIZED = "is-initialized";
- var CLASS_ACTIVE = "is-active";
- var CLASS_PREV = "is-prev";
- var CLASS_NEXT = "is-next";
- var CLASS_VISIBLE = "is-visible";
- var CLASS_LOADING = "is-loading";
- var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING];
- var CLASSES = {
- slide: CLASS_SLIDE,
- clone: CLASS_CLONE,
- arrows: CLASS_ARROWS,
- arrow: CLASS_ARROW,
- prev: CLASS_ARROW_PREV,
- next: CLASS_ARROW_NEXT,
- pagination: CLASS_PAGINATION,
- page: CLASS_PAGINATION_PAGE,
- spinner: CLASS_SPINNER
- };
- function Elements(Splide2, Components2, options) {
- var _EventInterface = EventInterface(Splide2),
- on = _EventInterface.on;
- var root = Splide2.root;
- var elements = {};
- var slides = [];
- var classes;
- var slider;
- var track;
- var list;
- function setup() {
- collect();
- identify();
- addClass(root, classes = getClasses());
- }
- function mount() {
- on(EVENT_REFRESH, refresh, DEFAULT_EVENT_PRIORITY - 2);
- on(EVENT_UPDATED, update);
- }
- function destroy() {
- [root, track, list].forEach(function (elm) {
- removeAttribute(elm, "style");
- });
- empty(slides);
- removeClass(root, classes);
- }
- function refresh() {
- destroy();
- setup();
- }
- function update() {
- removeClass(root, classes);
- addClass(root, classes = getClasses());
- }
- function collect() {
- slider = child(root, "." + CLASS_SLIDER);
- track = query(root, "." + CLASS_TRACK);
- list = child(track, "." + CLASS_LIST);
- assert(track && list, "A track/list element is missing.");
- push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
- var autoplay = find("." + CLASS_AUTOPLAY);
- var arrows = find("." + CLASS_ARROWS);
- assign(elements, {
- root: root,
- slider: slider,
- track: track,
- list: list,
- slides: slides,
- arrows: arrows,
- autoplay: autoplay,
- prev: query(arrows, "." + CLASS_ARROW_PREV),
- next: query(arrows, "." + CLASS_ARROW_NEXT),
- bar: query(find("." + CLASS_PROGRESS), "." + CLASS_PROGRESS_BAR),
- play: query(autoplay, "." + CLASS_PLAY),
- pause: query(autoplay, "." + CLASS_PAUSE)
- });
- }
- function identify() {
- var id = root.id || uniqueId(PROJECT_CODE);
- root.id = id;
- track.id = track.id || id + "-track";
- list.id = list.id || id + "-list";
- }
- function find(selector) {
- return child(root, selector) || child(slider, selector);
- }
- function getClasses() {
- return [CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE];
- }
- return assign(elements, {
- setup: setup,
- mount: mount,
- destroy: destroy
- });
- }
- var ROLE = "role";
- var ARIA_CONTROLS = "aria-controls";
- var ARIA_CURRENT = "aria-current";
- var ARIA_LABEL = "aria-label";
- var ARIA_HIDDEN = "aria-hidden";
- var TAB_INDEX = "tabindex";
- var DISABLED = "disabled";
- var ARIA_ORIENTATION = "aria-orientation";
- var ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, ARIA_ORIENTATION, TAB_INDEX, DISABLED];
- var SLIDE = "slide";
- var LOOP = "loop";
- var FADE = "fade";
- function Slide$1(Splide2, index, slideIndex, slide) {
- var _EventInterface2 = EventInterface(Splide2),
- on = _EventInterface2.on,
- emit = _EventInterface2.emit,
- bind = _EventInterface2.bind,
- destroyEvents = _EventInterface2.destroy;
- var Components = Splide2.Components,
- root = Splide2.root,
- options = Splide2.options;
- var isNavigation = options.isNavigation,
- updateOnMove = options.updateOnMove;
- var resolve = Components.Direction.resolve;
- var styles = getAttribute(slide, "style");
- var isClone = slideIndex > -1;
- var container = child(slide, "." + CLASS_CONTAINER);
- var focusableNodes = options.focusableNodes && queryAll(slide, options.focusableNodes);
- var destroyed;
- function mount() {
- var _this2 = this;
- init();
- bind(slide, "click keydown", function (e) {
- emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
- });
- on([EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], update.bind(this));
- if (updateOnMove) {
- on(EVENT_MOVE, onMove.bind(this));
- }
- }
- function init() {
- if (!isClone) {
- slide.id = root.id + "-slide" + pad(index + 1);
- }
- if (isNavigation) {
- var idx = isClone ? slideIndex : index;
- var label = format(options.i18n.slideX, idx + 1);
- var controls = Splide2.splides.map(function (splide) {
- return splide.root.id;
- }).join(" ");
- setAttribute(slide, ARIA_LABEL, label);
- setAttribute(slide, ARIA_CONTROLS, controls);
- setAttribute(slide, ROLE, "menuitem");
- }
- }
- function destroy() {
- destroyed = true;
- destroyEvents();
- removeClass(slide, STATUS_CLASSES);
- removeAttribute(slide, ALL_ATTRIBUTES);
- setAttribute(slide, "style", styles);
- }
- function onMove(next, prev, dest) {
- if (!destroyed) {
- update.call(this);
- if (dest === index) {
- updateActivity.call(this, true);
- }
- }
- }
- function update() {
- if (!destroyed) {
- var currIndex = Splide2.index;
- updateActivity.call(this, isActive());
- updateVisibility.call(this, isVisible());
- toggleClass(slide, CLASS_PREV, index === currIndex - 1);
- toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
- }
- }
- function updateActivity(active) {
- if (active !== hasClass(slide, CLASS_ACTIVE)) {
- toggleClass(slide, CLASS_ACTIVE, active);
- if (isNavigation) {
- setAttribute(slide, ARIA_CURRENT, active || null);
- }
- emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
- }
- }
- function updateVisibility(visible) {
- var ariaHidden = !visible && !isActive();
- setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
- setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
- if (focusableNodes) {
- focusableNodes.forEach(function (node) {
- setAttribute(node, TAB_INDEX, ariaHidden ? -1 : null);
- });
- }
- if (visible !== hasClass(slide, CLASS_VISIBLE)) {
- toggleClass(slide, CLASS_VISIBLE, visible);
- emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
- }
- }
- function style$1(prop, value, useContainer) {
- style(useContainer && container || slide, prop, value);
- }
- function isActive() {
- return Splide2.index === index;
- }
- function isVisible() {
- if (Splide2.is(FADE)) {
- return isActive();
- }
- var trackRect = rect(Components.Elements.track);
- var slideRect = rect(slide);
- var left = resolve("left");
- var right = resolve("right");
- return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
- }
- function isWithin(from, distance) {
- var diff = abs(from - index);
- if (!isClone && (options.rewind || Splide2.is(LOOP))) {
- diff = min(diff, Splide2.length - diff);
- }
- return diff <= distance;
- }
- return {
- index: index,
- slideIndex: slideIndex,
- slide: slide,
- container: container,
- isClone: isClone,
- mount: mount,
- destroy: destroy,
- style: style$1,
- isWithin: isWithin
- };
- }
- function Slides(Splide2, Components2, options) {
- var _EventInterface3 = EventInterface(Splide2),
- on = _EventInterface3.on,
- emit = _EventInterface3.emit,
- bind = _EventInterface3.bind;
- var _Components2$Elements = Components2.Elements,
- slides = _Components2$Elements.slides,
- list = _Components2$Elements.list;
- var Slides2 = [];
- function mount() {
- init();
- on(EVENT_REFRESH, refresh);
- on([EVENT_MOUNTED, EVENT_REFRESH], function () {
- Slides2.sort(function (Slide1, Slide2) {
- return Slide1.index - Slide2.index;
- });
- });
- }
- function init() {
- slides.forEach(function (slide, index) {
- register(slide, index, -1);
- });
- }
- function destroy() {
- forEach$1(function (Slide2) {
- Slide2.destroy();
- });
- empty(Slides2);
- }
- function refresh() {
- destroy();
- init();
- }
- function register(slide, index, slideIndex) {
- var object = Slide$1(Splide2, index, slideIndex, slide);
- object.mount();
- Slides2.push(object);
- }
- function get(excludeClones) {
- return excludeClones ? filter(function (Slide2) {
- return !Slide2.isClone;
- }) : Slides2;
- }
- function getIn(page) {
- var Controller = Components2.Controller;
- var index = Controller.toIndex(page);
- var max = Controller.hasFocus() ? 1 : options.perPage;
- return filter(function (Slide2) {
- return between(Slide2.index, index, index + max - 1);
- });
- }
- function getAt(index) {
- return filter(index)[0];
- }
- function add(items, index) {
- forEach(items, function (slide) {
- if (isString(slide)) {
- slide = parseHtml(slide);
- }
- if (isHTMLElement(slide)) {
- var ref = slides[index];
- ref ? before(slide, ref) : append(list, slide);
- addClass(slide, options.classes.slide);
- observeImages(slide, emit.bind(null, EVENT_RESIZE));
- }
- });
- emit(EVENT_REFRESH);
- }
- function remove$1(matcher) {
- remove(filter(matcher).map(function (Slide2) {
- return Slide2.slide;
- }));
- emit(EVENT_REFRESH);
- }
- function forEach$1(iteratee, excludeClones) {
- get(excludeClones).forEach(iteratee);
- }
- function filter(matcher) {
- return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
- return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
- });
- }
- function style(prop, value, useContainer) {
- forEach$1(function (Slide2) {
- Slide2.style(prop, value, useContainer);
- });
- }
- function observeImages(elm, callback) {
- var images = queryAll(elm, "img");
- var length = images.length;
- if (length) {
- images.forEach(function (img) {
- bind(img, "load error", function () {
- if (! --length) {
- callback();
- }
- });
- });
- } else {
- callback();
- }
- }
- function getLength(excludeClones) {
- return excludeClones ? slides.length : Slides2.length;
- }
- function isEnough() {
- return Slides2.length > options.perPage;
- }
- return {
- mount: mount,
- destroy: destroy,
- register: register,
- get: get,
- getIn: getIn,
- getAt: getAt,
- add: add,
- remove: remove$1,
- forEach: forEach$1,
- filter: filter,
- style: style,
- getLength: getLength,
- isEnough: isEnough
- };
- }
- function Layout(Splide2, Components2, options) {
- var _EventInterface4 = EventInterface(Splide2),
- on = _EventInterface4.on,
- bind = _EventInterface4.bind,
- emit = _EventInterface4.emit;
- var Slides = Components2.Slides;
- var resolve = Components2.Direction.resolve;
- var _Components2$Elements2 = Components2.Elements,
- track = _Components2$Elements2.track,
- list = _Components2$Elements2.list;
- var getAt = Slides.getAt;
- var vertical;
- function mount() {
- init();
- bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
- on([EVENT_UPDATED, EVENT_REFRESH], init);
- on(EVENT_RESIZE, resize);
- }
- function init() {
- vertical = options.direction === TTB;
- style(Splide2.root, "maxWidth", unit(options.width));
- style(track, resolve("paddingLeft"), cssPadding(false));
- style(track, resolve("paddingRight"), cssPadding(true));
- resize();
- }
- function resize() {
- style(track, "height", cssTrackHeight());
- Slides.style(resolve("marginRight"), unit(options.gap));
- Slides.style("width", cssSlideWidth() || null);
- setSlidesHeight();
- emit(EVENT_RESIZED);
- }
- function setSlidesHeight() {
- Slides.style("height", cssSlideHeight() || null, true);
- }
- function cssPadding(right) {
- var padding = options.padding;
- var prop = resolve(right ? "right" : "left");
- return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
- }
- function cssTrackHeight() {
- var height = "";
- if (vertical) {
- height = cssHeight();
- assert(height, "height or heightRatio is missing.");
- height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")";
- }
- return height;
- }
- function cssHeight() {
- return unit(options.height || rect(list).width * options.heightRatio);
- }
- function cssSlideWidth() {
- return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
- }
- function cssSlideHeight() {
- return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
- }
- function cssSlideSize() {
- var gap = unit(options.gap);
- return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
- }
- function listSize() {
- return rect(list)[resolve("width")];
- }
- function slideSize(index, withoutGap) {
- var Slide = getAt(index || 0);
- return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
- }
- function totalSize(index, withoutGap) {
- var Slide = getAt(index);
- if (Slide) {
- var right = rect(Slide.slide)[resolve("right")];
- var left = rect(list)[resolve("left")];
- return abs(right - left) + (withoutGap ? 0 : getGap());
- }
- return 0;
- }
- function sliderSize() {
- return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
- }
- function getGap() {
- var Slide = getAt(0);
- return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
- }
- function getPadding(right) {
- return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0;
- }
- return {
- mount: mount,
- listSize: listSize,
- slideSize: slideSize,
- sliderSize: sliderSize,
- totalSize: totalSize,
- getPadding: getPadding
- };
- }
- function Clones(Splide2, Components2, options) {
- var _EventInterface5 = EventInterface(Splide2),
- on = _EventInterface5.on,
- emit = _EventInterface5.emit;
- var Elements = Components2.Elements,
- Slides = Components2.Slides;
- var resolve = Components2.Direction.resolve;
- var clones = [];
- var cloneCount;
- function mount() {
- init();
- on(EVENT_REFRESH, refresh);
- on([EVENT_UPDATED, EVENT_RESIZE], observe);
- }
- function init() {
- if (cloneCount = computeCloneCount()) {
- generate(cloneCount);
- emit(EVENT_RESIZE);
- }
- }
- function destroy() {
- remove(clones);
- empty(clones);
- }
- function refresh() {
- destroy();
- init();
- }
- function observe() {
- if (cloneCount < computeCloneCount()) {
- emit(EVENT_REFRESH);
- }
- }
- function generate(count) {
- var slides = Slides.get().slice();
- var length = slides.length;
- if (length) {
- while (slides.length < count) {
- push(slides, slides);
- }
- push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
- var isHead = index < count;
- var clone = cloneDeep(Slide.slide, index);
- isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
- push(clones, clone);
- Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
- });
- }
- }
- function cloneDeep(elm, index) {
- var clone = elm.cloneNode(true);
- addClass(clone, options.classes.clone);
- clone.id = Splide2.root.id + "-clone" + pad(index + 1);
- return clone;
- }
- function computeCloneCount() {
- var clones2 = options.clones;
- if (!Splide2.is(LOOP)) {
- clones2 = 0;
- } else if (!clones2) {
- var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
- var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
- var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
- clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
- }
- return clones2;
- }
- return {
- mount: mount,
- destroy: destroy
- };
- }
- function Move(Splide2, Components2, options) {
- var _EventInterface6 = EventInterface(Splide2),
- on = _EventInterface6.on,
- emit = _EventInterface6.emit;
- var _Components2$Layout = Components2.Layout,
- slideSize = _Components2$Layout.slideSize,
- getPadding = _Components2$Layout.getPadding,
- totalSize = _Components2$Layout.totalSize,
- listSize = _Components2$Layout.listSize,
- sliderSize = _Components2$Layout.sliderSize;
- var _Components2$Directio = Components2.Direction,
- resolve = _Components2$Directio.resolve,
- orient = _Components2$Directio.orient;
- var _Components2$Elements3 = Components2.Elements,
- list = _Components2$Elements3.list,
- track = _Components2$Elements3.track;
- var waiting;
- function mount() {
- on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
- }
- function destroy() {
- removeAttribute(list, "style");
- }
- function reposition() {
- if (!isBusy() && !Components2.Drag.isDragging()) {
- Components2.Scroll.cancel();
- jump(Splide2.index);
- emit(EVENT_REPOSITIONED);
- }
- }
- function move(dest, index, prev, callback) {
- if (!isBusy()) {
- var set = Splide2.state.set;
- var position = getPosition();
- var looping = dest !== index;
- waiting = looping || options.waitForTransition;
- set(MOVING);
- emit(EVENT_MOVE, index, prev, dest);
- Components2.Transition.start(dest, function () {
- looping && jump(index);
- waiting = false;
- set(IDLE);
- emit(EVENT_MOVED, index, prev, dest);
- if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
- Components2.Controller.go(dest > prev ? ">" : "<", false, callback);
- } else {
- callback && callback();
- }
- });
- }
- }
- function jump(index) {
- translate(toPosition(index, true));
- }
- function translate(position, preventLoop) {
- if (!Splide2.is(FADE)) {
- list.style.transform = "translate" + resolve("X") + "(" + (preventLoop ? position : loop(position)) + "px)";
- }
- }
- function loop(position) {
- if (!waiting && Splide2.is(LOOP)) {
- var diff = orient(position - getPosition());
- var exceededMin = exceededLimit(false, position) && diff < 0;
- var exceededMax = exceededLimit(true, position) && diff > 0;
- if (exceededMin || exceededMax) {
- position = shift(position, exceededMax);
- }
- }
- return position;
- }
- function shift(position, backwards) {
- var excess = position - getLimit(backwards);
- var size = sliderSize();
- position -= sign(excess) * size * ceil(abs(excess) / size);
- return position;
- }
- function cancel() {
- waiting = false;
- translate(getPosition());
- Components2.Transition.cancel();
- }
- function toIndex(position) {
- var Slides = Components2.Slides.get();
- var index = 0;
- var minDistance = Infinity;
- for (var i = 0; i < Slides.length; i++) {
- var slideIndex = Slides[i].index;
- var distance = abs(toPosition(slideIndex, true) - position);
- if (distance <= minDistance) {
- minDistance = distance;
- index = slideIndex;
- } else {
- break;
- }
- }
- return index;
- }
- function toPosition(index, trimming) {
- var position = orient(totalSize(index - 1) - offset(index));
- return trimming ? trim(position) : position;
- }
- function getPosition() {
- var left = resolve("left");
- return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
- }
- function trim(position) {
- if (options.trimSpace && Splide2.is(SLIDE)) {
- position = clamp(position, 0, orient(sliderSize() - listSize()));
- }
- return position;
- }
- function offset(index) {
- var focus = options.focus;
- return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
- }
- function getLimit(max) {
- return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
- }
- function isBusy() {
- return !!waiting;
- }
- function exceededLimit(max, position) {
- position = isUndefined(position) ? getPosition() : position;
- var exceededMin = max !== true && orient(position) < orient(getLimit(false));
- var exceededMax = max !== false && orient(position) > orient(getLimit(true));
- return exceededMin || exceededMax;
- }
- return {
- mount: mount,
- destroy: destroy,
- move: move,
- jump: jump,
- translate: translate,
- shift: shift,
- cancel: cancel,
- toIndex: toIndex,
- toPosition: toPosition,
- getPosition: getPosition,
- getLimit: getLimit,
- isBusy: isBusy,
- exceededLimit: exceededLimit
- };
- }
- function Controller(Splide2, Components2, options) {
- var _EventInterface7 = EventInterface(Splide2),
- on = _EventInterface7.on;
- var Move = Components2.Move;
- var getPosition = Move.getPosition,
- getLimit = Move.getLimit;
- var _Components2$Slides = Components2.Slides,
- isEnough = _Components2$Slides.isEnough,
- getLength = _Components2$Slides.getLength;
- var isLoop = Splide2.is(LOOP);
- var isSlide = Splide2.is(SLIDE);
- var currIndex = options.start || 0;
- var prevIndex = currIndex;
- var slideCount;
- var perMove;
- var perPage;
- function mount() {
- init();
- on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 1);
- }
- function init() {
- slideCount = getLength(true);
- perMove = options.perMove;
- perPage = options.perPage;
- currIndex = clamp(currIndex, 0, slideCount - 1);
- }
- function go(control, allowSameIndex, callback) {
- var dest = parse(control);
- if (options.useScroll) {
- scroll(dest, true, true, options.speed, callback);
- } else {
- var index = loop(dest);
- if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
- setIndex(index);
- Move.move(dest, index, prevIndex, callback);
- }
- }
- }
- function scroll(destination, useIndex, snap, duration, callback) {
- var dest = useIndex ? destination : toDest(destination);
- Components2.Scroll.scroll(useIndex || snap ? Move.toPosition(dest, true) : destination, duration, function () {
- setIndex(Move.toIndex(Move.getPosition()));
- callback && callback();
- });
- }
- function parse(control) {
- var index = currIndex;
- if (isString(control)) {
- var _ref = control.match(/([+\-<>])(\d+)?/) || [],
- indicator = _ref[1],
- number = _ref[2];
- if (indicator === "+" || indicator === "-") {
- index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
- } else if (indicator === ">") {
- index = number ? toIndex(+number) : getNext(true);
- } else if (indicator === "<") {
- index = getPrev(true);
- }
- } else {
- if (isLoop) {
- index = clamp(control, -perPage, slideCount + perPage - 1);
- } else {
- index = clamp(control, 0, getEnd());
- }
- }
- return index;
- }
- function getNext(destination) {
- return getAdjacent(false, destination);
- }
- function getPrev(destination) {
- return getAdjacent(true, destination);
- }
- function getAdjacent(prev, destination) {
- var number = perMove || (hasFocus() ? 1 : perPage);
- var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
- if (dest === -1 && isSlide) {
- if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
- return prev ? 0 : getEnd();
- }
- }
- return destination ? dest : loop(dest);
- }
- function computeDestIndex(dest, from, incremental) {
- if (isEnough()) {
- var end = getEnd();
- if (dest < 0 || dest > end) {
- if (between(0, dest, from, true) || between(end, from, dest, true)) {
- dest = toIndex(toPage(dest));
- } else {
- if (isLoop) {
- dest = perMove ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount;
- } else if (options.rewind) {
- dest = dest < 0 ? end : 0;
- } else {
- dest = -1;
- }
- }
- } else {
- if (!isLoop && !incremental && dest !== from) {
- dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
- }
- }
- } else {
- dest = -1;
- }
- return dest;
- }
- function getEnd() {
- var end = slideCount - perPage;
- if (hasFocus() || isLoop && perMove) {
- end = slideCount - 1;
- }
- return max(end, 0);
- }
- function loop(index) {
- if (isLoop) {
- return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1;
- }
- return index;
- }
- function toIndex(page) {
- return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
- }
- function toPage(index) {
- if (!hasFocus()) {
- index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index;
- index = floor(index / perPage);
- }
- return index;
- }
- function toDest(destination) {
- var closest = Move.toIndex(destination);
- return isSlide ? clamp(closest, 0, getEnd()) : closest;
- }
- function setIndex(index) {
- if (index !== currIndex) {
- prevIndex = currIndex;
- currIndex = index;
- }
- }
- function getIndex(prev) {
- return prev ? prevIndex : currIndex;
- }
- function hasFocus() {
- return !isUndefined(options.focus) || options.isNavigation;
- }
- return {
- mount: mount,
- go: go,
- scroll: scroll,
- getNext: getNext,
- getPrev: getPrev,
- getEnd: getEnd,
- setIndex: setIndex,
- getIndex: getIndex,
- toIndex: toIndex,
- toPage: toPage,
- toDest: toDest,
- hasFocus: hasFocus
- };
- }
- var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
- var 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";
- var SIZE = 40;
- function Arrows(Splide2, Components2, options) {
- var _EventInterface8 = EventInterface(Splide2),
- on = _EventInterface8.on,
- bind = _EventInterface8.bind,
- emit = _EventInterface8.emit;
- var classes = options.classes,
- i18n = options.i18n;
- var Elements = Components2.Elements,
- Controller = Components2.Controller;
- var wrapper = Elements.arrows;
- var prev = Elements.prev;
- var next = Elements.next;
- var created;
- var arrows = {};
- function mount() {
- init();
- on(EVENT_UPDATED, init);
- }
- function init() {
- if (options.arrows) {
- if (!prev || !next) {
- createArrows();
- }
- }
- if (prev && next) {
- if (!arrows.prev) {
- var id = Elements.track.id;
- setAttribute(prev, ARIA_CONTROLS, id);
- setAttribute(next, ARIA_CONTROLS, id);
- arrows.prev = prev;
- arrows.next = next;
- listen();
- emit(EVENT_ARROWS_MOUNTED, prev, next);
- } else {
- display(wrapper, options.arrows === false ? "none" : "");
- }
- }
- }
- function destroy() {
- if (created) {
- remove(wrapper);
- } else {
- removeAttribute(prev, ALL_ATTRIBUTES);
- removeAttribute(next, ALL_ATTRIBUTES);
- }
- }
- function listen() {
- var go = Controller.go;
- on([EVENT_MOUNTED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
- bind(next, "click", function () {
- go(">", true);
- });
- bind(prev, "click", function () {
- go("<", true);
- });
- }
- function createArrows() {
- wrapper = create("div", classes.arrows);
- prev = createArrow(true);
- next = createArrow(false);
- created = true;
- append(wrapper, [prev, next]);
- before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root));
- }
- function createArrow(prev2) {
- var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\"><path d=\"" + (options.arrowPath || PATH) + "\" />";
- return parseHtml(arrow);
- }
- function update() {
- var index = Splide2.index;
- var prevIndex = Controller.getPrev();
- var nextIndex = Controller.getNext();
- var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
- var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
- prev.disabled = prevIndex < 0;
- next.disabled = nextIndex < 0;
- setAttribute(prev, ARIA_LABEL, prevLabel);
- setAttribute(next, ARIA_LABEL, nextLabel);
- emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
- }
- return {
- arrows: arrows,
- mount: mount,
- destroy: destroy
- };
- }
- function Autoplay(Splide2, Components2, options) {
- var _EventInterface9 = EventInterface(Splide2),
- on = _EventInterface9.on,
- bind = _EventInterface9.bind,
- emit = _EventInterface9.emit;
- var Elements = Components2.Elements;
- var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), update);
- var isPaused = interval.isPaused;
- var hovered;
- var focused;
- var paused;
- function mount() {
- var autoplay = options.autoplay;
- if (autoplay) {
- initButton(true);
- initButton(false);
- listen();
- if (autoplay !== "pause") {
- play();
- }
- }
- }
- function initButton(forPause) {
- var prop = forPause ? "pause" : "play";
- var button = Elements[prop];
- if (button) {
- setAttribute(button, ARIA_CONTROLS, Elements.track.id);
- setAttribute(button, ARIA_LABEL, options.i18n[prop]);
- bind(button, "click", forPause ? pause : play);
- }
- }
- function listen() {
- var root = Elements.root;
- if (options.pauseOnHover) {
- bind(root, "mouseenter mouseleave", function (e) {
- hovered = e.type === "mouseenter";
- autoToggle();
- });
- }
- if (options.pauseOnFocus) {
- bind(root, "focusin focusout", function (e) {
- focused = e.type === "focusin";
- autoToggle();
- });
- }
- on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
- }
- function play() {
- if (isPaused() && Components2.Slides.isEnough()) {
- interval.start(!options.resetProgress);
- focused = hovered = paused = false;
- emit(EVENT_AUTOPLAY_PLAY);
- }
- }
- function pause(manual) {
- if (manual === void 0) {
- manual = true;
- }
- if (!isPaused()) {
- interval.pause();
- emit(EVENT_AUTOPLAY_PAUSE);
- }
- paused = manual;
- }
- function autoToggle() {
- if (!paused) {
- if (!hovered && !focused) {
- play();
- } else {
- pause(false);
- }
- }
- }
- function update(rate) {
- var bar = Elements.bar;
- if (bar) {
- style(bar, "width", rate * 100 + "%");
- }
- emit(EVENT_AUTOPLAY_PLAYING, rate);
- }
- return {
- mount: mount,
- destroy: interval.cancel,
- play: play,
- pause: pause,
- isPaused: isPaused
- };
- }
- function Cover(Splide2, Components2, options) {
- var _EventInterface10 = EventInterface(Splide2),
- on = _EventInterface10.on;
- function mount() {
- if (options.cover) {
- on(EVENT_LAZYLOAD_LOADED, function (img, Slide) {
- toggle(true, img, Slide);
- });
- on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply.bind(null, true));
- }
- }
- function destroy() {
- apply(false);
- }
- function apply(cover) {
- Components2.Slides.forEach(function (Slide) {
- var img = child(Slide.container || Slide.slide, "img");
- if (img && img.src) {
- toggle(cover, img, Slide);
- }
- });
- }
- function toggle(cover, img, Slide) {
- Slide.style("background", cover ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
- display(img, cover ? "none" : "");
- }
- return {
- mount: mount,
- destroy: destroy
- };
- }
- var BOUNCE_DIFF_THRESHOLD = 10;
- var BOUNCE_DURATION = 600;
- var FRICTION_FACTOR = 0.6;
- var BASE_VELOCITY = 1.5;
- var MIN_DURATION = 800;
- function Scroll(Splide2, Components2, options) {
- var _EventInterface11 = EventInterface(Splide2),
- on = _EventInterface11.on,
- emit = _EventInterface11.emit;
- var Move = Components2.Move;
- var getPosition = Move.getPosition,
- getLimit = Move.getLimit,
- exceededLimit = Move.exceededLimit;
- var interval;
- var scrollCallback;
- function mount() {
- on(EVENT_MOVE, clear);
- on([EVENT_UPDATED, EVENT_REFRESH], cancel);
- }
- function scroll(destination, duration, callback, suppressConstraint) {
- var start = getPosition();
- var friction = 1;
- duration = duration || computeDuration(abs(destination - start));
- scrollCallback = callback;
- clear();
- interval = RequestInterval(duration, onScrolled, function (rate) {
- var position = getPosition();
- var target = start + (destination - start) * easing(rate);
- var diff = (target - getPosition()) * friction;
- Move.translate(position + diff);
- if (Splide2.is(SLIDE) && !suppressConstraint && exceededLimit()) {
- friction *= FRICTION_FACTOR;
- if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
- bounce(exceededLimit(false));
- }
- }
- }, 1);
- emit(EVENT_SCROLL);
- interval.start();
- }
- function bounce(backwards) {
- scroll(getLimit(!backwards), BOUNCE_DURATION, null, true);
- }
- function onScrolled() {
- var position = getPosition();
- var index = Move.toIndex(position);
- if (!between(index, 0, Splide2.length - 1)) {
- Move.translate(Move.shift(position, index > 0), true);
- }
- scrollCallback && scrollCallback();
- emit(EVENT_SCROLLED);
- }
- function computeDuration(distance) {
- return max(distance / BASE_VELOCITY, MIN_DURATION);
- }
- function clear() {
- if (interval) {
- interval.cancel();
- }
- }
- function cancel() {
- if (interval && !interval.isPaused()) {
- clear();
- onScrolled();
- }
- }
- function easing(t) {
- var easingFunc = options.easingFunc;
- return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
- }
- return {
- mount: mount,
- destroy: clear,
- scroll: scroll,
- cancel: cancel
- };
- }
- var FRICTION = 5;
- var LOG_INTERVAL = 200;
- var POINTER_DOWN_EVENTS = "touchstart mousedown";
- var POINTER_MOVE_EVENTS = "touchmove mousemove";
- var POINTER_UP_EVENTS = "touchend touchcancel mouseup";
- function Drag(Splide2, Components2, options) {
- var _EventInterface12 = EventInterface(Splide2),
- on = _EventInterface12.on,
- emit = _EventInterface12.emit,
- bind = _EventInterface12.bind,
- unbind = _EventInterface12.unbind;
- var Move = Components2.Move,
- Scroll = Components2.Scroll,
- Controller = Components2.Controller;
- var track = Components2.Elements.track;
- var _Components2$Directio2 = Components2.Direction,
- resolve = _Components2$Directio2.resolve,
- orient = _Components2$Directio2.orient;
- var getPosition = Move.getPosition,
- exceededLimit = Move.exceededLimit;
- var listenerOptions = {
- passive: false,
- capture: true
- };
- var basePosition;
- var baseEvent;
- var prevBaseEvent;
- var lastEvent;
- var isFree;
- var dragging;
- var hasExceeded = false;
- var clickPrevented;
- var disabled;
- var target;
- function mount() {
- bind(track, POINTER_MOVE_EVENTS, noop, listenerOptions);
- bind(track, POINTER_UP_EVENTS, noop, listenerOptions);
- bind(track, POINTER_DOWN_EVENTS, onPointerDown, listenerOptions);
- bind(track, "click", onClick, {
- capture: true
- });
- bind(track, "dragstart", prevent);
- on([EVENT_MOUNTED, EVENT_UPDATED], init);
- }
- function init() {
- var drag = options.drag;
- disable(!drag);
- isFree = drag === "free";
- }
- function onPointerDown(e) {
- if (!disabled) {
- var noDrag = options.noDrag;
- var isTouch = isTouchEvent(e);
- var isDraggable = !noDrag || isHTMLElement(e.target) && !matches(e.target, noDrag);
- if (isDraggable && (isTouch || !e.button)) {
- if (!Move.isBusy()) {
- target = isTouch ? track : window;
- prevBaseEvent = null;
- lastEvent = null;
- clickPrevented = false;
- bind(target, POINTER_MOVE_EVENTS, onPointerMove, listenerOptions);
- bind(target, POINTER_UP_EVENTS, onPointerUp, listenerOptions);
- Move.cancel();
- Scroll.cancel();
- save(e);
- } else {
- prevent(e, true);
- }
- }
- }
- }
- function onPointerMove(e) {
- if (!lastEvent) {
- emit(EVENT_DRAG);
- }
- lastEvent = e;
- if (e.cancelable) {
- if (dragging) {
- var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
- var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
- if (expired || exceeded) {
- save(e);
- }
- Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
- emit(EVENT_DRAGGING);
- clickPrevented = true;
- prevent(e);
- } else {
- var diff = abs(coordOf(e) - coordOf(baseEvent));
- var thresholds = options.dragMinThreshold;
- thresholds = isObject(thresholds) ? thresholds : {
- mouse: 0,
- touch: +thresholds || 10
- };
- dragging = diff > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
- if (isSliderDirection()) {
- prevent(e);
- }
- }
- }
- }
- function onPointerUp(e) {
- unbind(target, POINTER_MOVE_EVENTS, onPointerMove);
- unbind(target, POINTER_UP_EVENTS, onPointerUp);
- if (lastEvent) {
- if (dragging || e.cancelable && isSliderDirection()) {
- var velocity = computeVelocity(e);
- var destination = computeDestination(velocity);
- if (isFree) {
- Controller.scroll(destination);
- } else if (Splide2.is(FADE)) {
- Controller.go(Splide2.index + orient(sign(velocity)));
- } else {
- Controller.go(Controller.toDest(destination), true);
- }
- prevent(e);
- }
- emit(EVENT_DRAGGED);
- }
- dragging = false;
- }
- function save(e) {
- prevBaseEvent = baseEvent;
- baseEvent = e;
- basePosition = getPosition();
- }
- function onClick(e) {
- if (!disabled && clickPrevented) {
- prevent(e, true);
- }
- }
- function isSliderDirection() {
- var diffX = abs(coordOf(lastEvent) - coordOf(baseEvent));
- var diffY = abs(coordOf(lastEvent, true) - coordOf(baseEvent, true));
- return diffX > diffY;
- }
- function computeVelocity(e) {
- if (Splide2.is(LOOP) || !hasExceeded) {
- var base = baseEvent === lastEvent && prevBaseEvent || baseEvent;
- var diffCoord = coordOf(lastEvent) - coordOf(base);
- var diffTime = timeOf(e) - timeOf(base);
- var isFlick = timeOf(e) - timeOf(lastEvent) < LOG_INTERVAL;
- if (diffTime && isFlick) {
- return diffCoord / diffTime;
- }
- }
- return 0;
- }
- function computeDestination(velocity) {
- return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
- }
- function coordOf(e, orthogonal) {
- return (isTouchEvent(e) ? e.touches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")];
- }
- function timeOf(e) {
- return e.timeStamp;
- }
- function constrain(diff) {
- return diff / (hasExceeded && Splide2.is(SLIDE) ? FRICTION : 1);
- }
- function isTouchEvent(e) {
- return typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
- }
- function isDragging() {
- return dragging;
- }
- function disable(value) {
- disabled = value;
- }
- return {
- mount: mount,
- disable: disable,
- isDragging: isDragging
- };
- }
- var IE_ARROW_KEYS = ["Left", "Right", "Up", "Down"];
- function Keyboard(Splide2, Components2, options) {
- var _EventInterface13 = EventInterface(Splide2),
- on = _EventInterface13.on,
- bind = _EventInterface13.bind,
- unbind = _EventInterface13.unbind;
- var root = Components2.Elements.root;
- var resolve = Components2.Direction.resolve;
- var target;
- function mount() {
- init();
- on(EVENT_UPDATED, function () {
- destroy();
- init();
- });
- }
- function init() {
- var _options$keyboard = options.keyboard,
- keyboard = _options$keyboard === void 0 ? "global" : _options$keyboard;
- if (keyboard) {
- if (keyboard === "focused") {
- target = root;
- setAttribute(root, TAB_INDEX, 0);
- } else {
- target = window;
- }
- bind(target, "keydown", onKeydown);
- }
- }
- function destroy() {
- unbind(target, "keydown");
- if (isHTMLElement(target)) {
- removeAttribute(target, TAB_INDEX);
- }
- }
- function onKeydown(e) {
- var key = e.key;
- var normalizedKey = includes(IE_ARROW_KEYS, key) ? "Arrow" + key : key;
- if (normalizedKey === resolve("ArrowLeft")) {
- Splide2.go("<");
- } else if (normalizedKey === resolve("ArrowRight")) {
- Splide2.go(">");
- }
- }
- return {
- mount: mount,
- destroy: destroy
- };
- }
- var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
- var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
- var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
- function LazyLoad(Splide2, Components2, options) {
- var _EventInterface14 = EventInterface(Splide2),
- on = _EventInterface14.on,
- off = _EventInterface14.off,
- bind = _EventInterface14.bind,
- emit = _EventInterface14.emit;
- var isSequential = options.lazyLoad === "sequential";
- var images = [];
- var index = 0;
- function mount() {
- if (options.lazyLoad) {
- on([EVENT_MOUNTED, EVENT_REFRESH], function () {
- destroy();
- init();
- });
- if (!isSequential) {
- on([EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED], observe);
- }
- }
- }
- function init() {
- Components2.Slides.forEach(function (_Slide) {
- queryAll(_Slide.slide, IMAGE_SELECTOR).forEach(function (_img) {
- var src = getAttribute(_img, SRC_DATA_ATTRIBUTE);
- var srcset = getAttribute(_img, SRCSET_DATA_ATTRIBUTE);
- if (src !== _img.src || srcset !== _img.srcset) {
- var _spinner = create("span", options.classes.spinner, _img.parentElement);
- setAttribute(_spinner, ROLE, "presentation");
- images.push({
- _img: _img,
- _Slide: _Slide,
- src: src,
- srcset: srcset,
- _spinner: _spinner
- });
- !_img.src && display(_img, "none");
- }
- });
- });
- if (isSequential) {
- loadNext();
- }
- }
- function destroy() {
- index = 0;
- images = [];
- }
- function observe() {
- images = images.filter(function (data) {
- var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
- if (data._Slide.isWithin(Splide2.index, distance)) {
- return load(data);
- }
- return true;
- });
- if (!images.length) {
- off(EVENT_MOVED);
- }
- }
- function load(data) {
- var _img = data._img;
- addClass(data._Slide.slide, CLASS_LOADING);
- bind(_img, "load error", function (e) {
- onLoad(data, e.type === "error");
- });
- ["src", "srcset"].forEach(function (name) {
- if (data[name]) {
- setAttribute(_img, name, data[name]);
- removeAttribute(_img, name === "src" ? SRC_DATA_ATTRIBUTE : SRCSET_DATA_ATTRIBUTE);
- }
- });
- }
- function onLoad(data, error) {
- var _Slide = data._Slide;
- removeClass(_Slide.slide, CLASS_LOADING);
- if (!error) {
- remove(data._spinner);
- display(data._img, "");
- emit(EVENT_LAZYLOAD_LOADED, data._img, _Slide);
- emit(EVENT_RESIZE);
- }
- if (isSequential) {
- loadNext();
- }
- }
- function loadNext() {
- if (index < images.length) {
- load(images[index++]);
- }
- }
- return {
- mount: mount,
- destroy: destroy
- };
- }
- function Pagination(Splide2, Components2, options) {
- var _EventInterface15 = EventInterface(Splide2),
- on = _EventInterface15.on,
- emit = _EventInterface15.emit,
- bind = _EventInterface15.bind,
- unbind = _EventInterface15.unbind;
- var Slides = Components2.Slides,
- Elements = Components2.Elements,
- Controller = Components2.Controller;
- var hasFocus = Controller.hasFocus,
- getIndex = Controller.getIndex;
- var items = [];
- var list;
- function mount() {
- init();
- on([EVENT_UPDATED, EVENT_REFRESH], init);
- on([EVENT_MOVE, EVENT_SCROLLED], update);
- }
- function init() {
- destroy();
- if (options.pagination && Slides.isEnough()) {
- createPagination();
- emit(EVENT_PAGINATION_MOUNTED, {
- list: list,
- items: items
- }, getAt(Splide2.index));
- update();
- }
- }
- function destroy() {
- if (list) {
- remove(list);
- items.forEach(function (item) {
- unbind(item.button, "click");
- });
- empty(items);
- list = null;
- }
- }
- function createPagination() {
- var length = Splide2.length;
- var classes = options.classes,
- i18n = options.i18n,
- perPage = options.perPage;
- var parent = options.pagination === "slider" && Elements.slider || Elements.root;
- var max = hasFocus() ? length : ceil(length / perPage);
- list = create("ul", classes.pagination, parent);
- for (var i = 0; i < max; i++) {
- var li = create("li", null, list);
- var button = create("button", {
- class: classes.page,
- type: "button"
- }, li);
- var controls = Slides.getIn(i).map(function (Slide) {
- return Slide.slide.id;
- });
- var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
- bind(button, "click", onClick.bind(null, i));
- setAttribute(button, ARIA_CONTROLS, controls.join(" "));
- setAttribute(button, ARIA_LABEL, format(text, i + 1));
- items.push({
- li: li,
- button: button,
- page: i
- });
- }
- }
- function onClick(page) {
- Controller.go(">" + page, true, function () {
- var Slide = Slides.getAt(Controller.toIndex(page));
- Slide && focus(Slide.slide);
- });
- }
- function getAt(index) {
- return items[Controller.toPage(index)];
- }
- function update() {
- var prev = getAt(getIndex(true));
- var curr = getAt(getIndex());
- if (prev) {
- removeClass(prev.button, CLASS_ACTIVE);
- removeAttribute(prev.button, ARIA_CURRENT);
- }
- if (curr) {
- addClass(curr.button, CLASS_ACTIVE);
- setAttribute(curr.button, ARIA_CURRENT, true);
- }
- emit(EVENT_PAGINATION_UPDATED, {
- list: list,
- items: items
- }, prev, curr);
- }
- return {
- items: items,
- mount: mount,
- destroy: destroy,
- getAt: getAt
- };
- }
- var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
- function Sync(Splide2, Components2, options) {
- var splides = Splide2.splides;
- var list = Components2.Elements.list;
- function mount() {
- if (options.isNavigation) {
- navigate();
- } else {
- sync();
- }
- }
- function destroy() {
- removeAttribute(list, ALL_ATTRIBUTES);
- }
- function sync() {
- var processed = [];
- splides.concat(Splide2).forEach(function (splide, index, instances) {
- EventInterface(splide).on(EVENT_MOVE, function (index2, prev, dest) {
- instances.forEach(function (instance) {
- if (instance !== splide && !includes(processed, splide)) {
- processed.push(instance);
- instance.go(instance.is(LOOP) ? dest : index2);
- }
- });
- empty(processed);
- });
- });
- }
- function navigate() {
- var _EventInterface16 = EventInterface(Splide2),
- on = _EventInterface16.on,
- emit = _EventInterface16.emit;
- on(EVENT_CLICK, onClick);
- on(EVENT_SLIDE_KEYDOWN, onKeydown);
- on([EVENT_MOUNTED, EVENT_UPDATED], update);
- setAttribute(list, ROLE, "menu");
- emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
- }
- function update() {
- setAttribute(list, ARIA_ORIENTATION, options.direction !== TTB ? "horizontal" : null);
- }
- function onClick(Slide) {
- Splide2.go(Slide.index);
- }
- function onKeydown(Slide, e) {
- if (includes(TRIGGER_KEYS, e.key)) {
- onClick(Slide);
- prevent(e);
- }
- }
- return {
- mount: mount,
- destroy: destroy
- };
- }
- function Wheel(Splide2, Components2, options) {
- var _EventInterface17 = EventInterface(Splide2),
- bind = _EventInterface17.bind;
- function mount() {
- if (options.wheel) {
- bind(Components2.Elements.track, "wheel", onWheel, {
- passive: false,
- capture: true
- });
- }
- }
- function onWheel(e) {
- var deltaY = e.deltaY;
- if (deltaY) {
- Splide2.go(deltaY < 0 ? "<" : ">");
- prevent(e);
- }
- }
- return {
- mount: mount
- };
- }
- var ComponentConstructors = /*#__PURE__*/Object.freeze({
- __proto__: null,
- Options: Options,
- Direction: Direction,
- Elements: Elements,
- Slides: Slides,
- Layout: Layout,
- Clones: Clones,
- Move: Move,
- Controller: Controller,
- Arrows: Arrows,
- Autoplay: Autoplay,
- Cover: Cover,
- Scroll: Scroll,
- Drag: Drag,
- Keyboard: Keyboard,
- LazyLoad: LazyLoad,
- Pagination: Pagination,
- Sync: Sync,
- Wheel: Wheel
- });
- var I18N = {
- prev: "Previous slide",
- next: "Next slide",
- first: "Go to first slide",
- last: "Go to last slide",
- slideX: "Go to slide %s",
- pageX: "Go to page %s",
- play: "Start autoplay",
- pause: "Pause autoplay"
- };
- var DEFAULTS = {
- type: "slide",
- speed: 400,
- waitForTransition: true,
- perPage: 1,
- arrows: true,
- pagination: true,
- interval: 5e3,
- pauseOnHover: true,
- pauseOnFocus: true,
- resetProgress: true,
- easing: "cubic-bezier(0.25, 1, 0.5, 1)",
- drag: true,
- direction: "ltr",
- slideFocus: true,
- trimSpace: true,
- focusableNodes: "a, button, textarea, input, select, iframe",
- classes: CLASSES,
- i18n: I18N
- };
- function Fade(Splide2, Components2, options) {
- var _EventInterface18 = EventInterface(Splide2),
- on = _EventInterface18.on;
- function mount() {
- on([EVENT_MOUNTED, EVENT_REFRESH], function () {
- nextTick(function () {
- Components2.Slides.style("transition", "opacity " + options.speed + "ms " + options.easing);
- });
- });
- }
- function start(index, done) {
- var track = Components2.Elements.track;
- style(track, "height", unit(rect(track).height));
- nextTick(function () {
- done();
- style(track, "height", "");
- });
- }
- return {
- mount: mount,
- start: start,
- cancel: noop
- };
- }
- function Slide(Splide2, Components2, options) {
- var _EventInterface19 = EventInterface(Splide2),
- bind = _EventInterface19.bind;
- var Move = Components2.Move,
- Controller = Components2.Controller;
- var list = Components2.Elements.list;
- var endCallback;
- function mount() {
- bind(list, "transitionend", function (e) {
- if (e.target === list && endCallback) {
- cancel();
- endCallback();
- }
- });
- }
- function start(index, done) {
- var destination = Move.toPosition(index, true);
- var position = Move.getPosition();
- var speed = getSpeed(index);
- if (abs(destination - position) >= 1 && speed >= 1) {
- apply("transform " + speed + "ms " + options.easing);
- Move.translate(destination, true);
- endCallback = done;
- } else {
- Move.jump(index);
- done();
- }
- }
- function cancel() {
- apply("");
- }
- function getSpeed(index) {
- var rewindSpeed = options.rewindSpeed;
- if (Splide2.is(SLIDE) && rewindSpeed) {
- var prev = Controller.getIndex(true);
- var end = Controller.getEnd();
- if (prev === 0 && index >= end || prev >= end && index === 0) {
- return rewindSpeed;
- }
- }
- return options.speed;
- }
- function apply(transition) {
- style(list, "transition", transition);
- }
- return {
- mount: mount,
- start: start,
- cancel: cancel
- };
- }
- var _Splide = /*#__PURE__*/function () {
- function _Splide(target, options) {
- this.event = EventBus();
- this.Components = {};
- this.state = State(CREATED);
- this.splides = [];
- this._options = {};
- this._Extensions = {};
- var root = isString(target) ? query(document, target) : target;
- assert(root, root + " is invalid.");
- this.root = root;
- merge(DEFAULTS, _Splide.defaults);
- merge(merge(this._options, DEFAULTS), options || {});
- }
- var _proto = _Splide.prototype;
- _proto.mount = function mount(Extensions, Transition) {
- var _this3 = this;
- var state = this.state,
- Components2 = this.Components;
- assert(state.is([CREATED, DESTROYED]), "Already mounted!");
- state.set(CREATED);
- this._Components = Components2;
- this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
- this._Extensions = Extensions || this._Extensions;
- var Constructors = assign({}, ComponentConstructors, this._Extensions, {
- Transition: this._Transition
- });
- forOwn(Constructors, function (Component, key) {
- var component = Component(_this3, Components2, _this3._options);
- Components2[key] = component;
- component.setup && component.setup();
- });
- forOwn(Components2, function (component) {
- component.mount && component.mount();
- });
- this.emit(EVENT_MOUNTED);
- addClass(this.root, CLASS_INITIALIZED);
- state.set(IDLE);
- this.emit(EVENT_READY);
- return this;
- };
- _proto.sync = function sync(splide) {
- this.splides.push(splide);
- splide.splides.push(this);
- return this;
- };
- _proto.go = function go(control) {
- this._Components.Controller.go(control);
- return this;
- };
- _proto.on = function on(events, callback) {
- this.event.on(events, callback, null, DEFAULT_USER_EVENT_PRIORITY);
- return this;
- };
- _proto.off = function off(events) {
- this.event.off(events);
- return this;
- };
- _proto.emit = function emit(event) {
- var _this$event;
- (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1)));
- return this;
- };
- _proto.add = function add(slides, index) {
- this._Components.Slides.add(slides, index);
- return this;
- };
- _proto.remove = function remove(matcher) {
- this._Components.Slides.remove(matcher);
- return this;
- };
- _proto.is = function is(type) {
- return this._options.type === type;
- };
- _proto.refresh = function refresh() {
- this.emit(EVENT_REFRESH);
- return this;
- };
- _proto.destroy = function destroy(completely) {
- if (completely === void 0) {
- completely = true;
- }
- var event = this.event,
- state = this.state;
- if (state.is(CREATED)) {
- event.on(EVENT_READY, this.destroy.bind(this, completely), this);
- } else {
- forOwn(this._Components, function (component) {
- component.destroy && component.destroy(completely);
- }, true);
- event.emit(EVENT_DESTROY);
- event.destroy();
- completely && empty(this.splides);
- state.set(DESTROYED);
- }
- return this;
- };
- _createClass(_Splide, [{
- key: "options",
- get: function get() {
- return this._options;
- },
- set: function set(options) {
- var _options = this._options;
- merge(_options, options);
- if (!this.state.is(CREATED)) {
- this.emit(EVENT_UPDATED, _options);
- }
- }
- }, {
- key: "length",
- get: function get() {
- return this._Components.Slides.getLength(true);
- }
- }, {
- key: "index",
- get: function get() {
- return this._Components.Controller.getIndex();
- }
- }]);
- return _Splide;
- }();
- var Splide = _Splide;
- Splide.defaults = {};
- Splide.STATES = STATES;
- return Splide;
- });
- //# sourceMappingURL=splide.js.map
|