splide.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958
  1. 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); } }
  2. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3. /*!
  4. * Splide.js
  5. * Version : 3.0.0
  6. * License : MIT
  7. * Copyright: 2021 Naotoshi Fujita
  8. */
  9. (function (global, factory) {
  10. 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());
  11. })(this, function () {
  12. 'use strict';
  13. var PROJECT_CODE = "splide";
  14. var DATA_ATTRIBUTE = "data-" + PROJECT_CODE;
  15. var CREATED = 1;
  16. var MOUNTED = 2;
  17. var IDLE = 3;
  18. var MOVING = 4;
  19. var DESTROYED = 5;
  20. var STATES = {
  21. CREATED: CREATED,
  22. MOUNTED: MOUNTED,
  23. IDLE: IDLE,
  24. MOVING: MOVING,
  25. DESTROYED: DESTROYED
  26. };
  27. var DEFAULT_EVENT_PRIORITY = 10;
  28. var DEFAULT_USER_EVENT_PRIORITY = 20;
  29. function empty(array) {
  30. array.length = 0;
  31. }
  32. function isObject(subject) {
  33. return !isNull(subject) && typeof subject === "object";
  34. }
  35. function isArray(subject) {
  36. return Array.isArray(subject);
  37. }
  38. function isFunction(subject) {
  39. return typeof subject === "function";
  40. }
  41. function isString(subject) {
  42. return typeof subject === "string";
  43. }
  44. function isUndefined(subject) {
  45. return typeof subject === "undefined";
  46. }
  47. function isNull(subject) {
  48. return subject === null;
  49. }
  50. function isHTMLElement(subject) {
  51. return subject instanceof HTMLElement;
  52. }
  53. function isHTMLButtonElement(subject) {
  54. return subject instanceof HTMLButtonElement;
  55. }
  56. function toArray(value) {
  57. return isArray(value) ? value : [value];
  58. }
  59. function forEach(values, iteratee) {
  60. toArray(values).forEach(iteratee);
  61. }
  62. function includes(array, value) {
  63. return array.indexOf(value) > -1;
  64. }
  65. function push(array, items) {
  66. array.push.apply(array, toArray(items));
  67. return array;
  68. }
  69. var arrayProto = Array.prototype;
  70. function slice(arrayLike, start, end) {
  71. return arrayProto.slice.call(arrayLike, start, end);
  72. }
  73. function find(arrayLike, predicate) {
  74. return slice(arrayLike).filter(predicate)[0];
  75. }
  76. function toggleClass(elm, classes, add) {
  77. if (elm) {
  78. forEach(classes, function (name) {
  79. if (name) {
  80. elm.classList[add ? "add" : "remove"](name);
  81. }
  82. });
  83. }
  84. }
  85. function addClass(elm, classes) {
  86. toggleClass(elm, classes, true);
  87. }
  88. function append(parent, children) {
  89. forEach(children, parent.appendChild.bind(parent));
  90. }
  91. function before(nodes, ref) {
  92. forEach(nodes, function (node) {
  93. var parent = ref.parentNode;
  94. if (parent) {
  95. parent.insertBefore(node, ref);
  96. }
  97. });
  98. }
  99. function matches(elm, selector) {
  100. return (elm["msMatchesSelector"] || elm.matches).call(elm, selector);
  101. }
  102. function children(parent, selector) {
  103. return parent ? slice(parent.children).filter(function (child) {
  104. return matches(child, selector);
  105. }) : [];
  106. }
  107. function child(parent, selector) {
  108. return selector ? children(parent, selector)[0] : parent.firstElementChild;
  109. }
  110. function forOwn(object, iteratee) {
  111. if (object) {
  112. var keys = Object.keys(object);
  113. for (var i = 0; i < keys.length; i++) {
  114. var key = keys[i];
  115. if (key !== "__proto__") {
  116. if (iteratee(object[key], key) === false) {
  117. break;
  118. }
  119. }
  120. }
  121. }
  122. return object;
  123. }
  124. function assign(object) {
  125. for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  126. sources[_key - 1] = arguments[_key];
  127. }
  128. sources.forEach(function (source) {
  129. forOwn(source, function (value, key) {
  130. object[key] = source[key];
  131. });
  132. });
  133. return object;
  134. }
  135. function merge(object, source) {
  136. forOwn(source, function (value, key) {
  137. if (isArray(value)) {
  138. object[key] = value.slice();
  139. } else if (isObject(value)) {
  140. object[key] = merge(isObject(object[key]) ? object[key] : {}, value);
  141. } else {
  142. object[key] = value;
  143. }
  144. });
  145. return object;
  146. }
  147. function removeAttribute(elm, attrs) {
  148. if (elm) {
  149. forEach(attrs, function (attr) {
  150. elm.removeAttribute(attr);
  151. });
  152. }
  153. }
  154. function setAttribute(elm, attrs, value) {
  155. if (isObject(attrs)) {
  156. forOwn(attrs, function (value2, name) {
  157. setAttribute(elm, name, value2);
  158. });
  159. } else {
  160. isNull(value) ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value));
  161. }
  162. }
  163. function create(tag, attrs, parent) {
  164. var elm = document.createElement(tag);
  165. if (attrs) {
  166. if (isString(attrs) || isArray(attrs)) {
  167. addClass(elm, attrs);
  168. } else {
  169. setAttribute(elm, attrs);
  170. }
  171. }
  172. if (parent) {
  173. append(parent, elm);
  174. }
  175. return elm;
  176. }
  177. function style(elms, styles) {
  178. if (isString(styles)) {
  179. return isArray(elms) ? null : getComputedStyle(elms)[styles];
  180. }
  181. forOwn(styles, function (value, key) {
  182. if (!isNull(value)) {
  183. forEach(elms, function (elm) {
  184. if (elm) {
  185. elm.style[key] = "" + value;
  186. }
  187. });
  188. }
  189. });
  190. }
  191. function display(elm, display2) {
  192. style(elm, {
  193. display: display2
  194. });
  195. }
  196. function getAttribute(elm, attr) {
  197. return elm.getAttribute(attr);
  198. }
  199. function hasClass(elm, className) {
  200. return elm && elm.classList.contains(className);
  201. }
  202. function parseHtml(html) {
  203. return child(new DOMParser().parseFromString(html, "text/html").body);
  204. }
  205. function prevent(e, stopPropagation) {
  206. e.preventDefault();
  207. if (stopPropagation) {
  208. e.stopPropagation();
  209. e.stopImmediatePropagation();
  210. }
  211. }
  212. function query(parent, selector) {
  213. return parent && parent.querySelector(selector);
  214. }
  215. function queryAll(parent, selector) {
  216. return slice(parent.querySelectorAll(selector));
  217. }
  218. function rect(target) {
  219. return target.getBoundingClientRect();
  220. }
  221. function remove(nodes) {
  222. forEach(nodes, function (node) {
  223. if (node && node.parentNode) {
  224. node.parentNode.removeChild(node);
  225. }
  226. });
  227. }
  228. function removeClass(elm, classes) {
  229. toggleClass(elm, classes, false);
  230. }
  231. function unit(value) {
  232. return isString(value) ? value : value ? value + "px" : "";
  233. }
  234. function assert(condition, message) {
  235. if (message === void 0) {
  236. message = "";
  237. }
  238. if (!condition) {
  239. throw new Error("[" + PROJECT_CODE + "] " + message);
  240. }
  241. }
  242. function nextTick(callback) {
  243. setTimeout(callback);
  244. }
  245. var noop = function noop() {};
  246. function raf(func) {
  247. return requestAnimationFrame(func);
  248. }
  249. function approximatelyEqual(x, y, epsilon) {
  250. return Math.abs(x - y) < epsilon;
  251. }
  252. function between(number, minOrMax, maxOrMin, exclusive) {
  253. var min = Math.min(minOrMax, maxOrMin);
  254. var max = Math.max(minOrMax, maxOrMin);
  255. return exclusive ? min < number && number < max : min <= number && number <= max;
  256. }
  257. var max$1 = Math.max,
  258. min$1 = Math.min;
  259. function clamp(number, x, y) {
  260. var minimum = min$1(x, y);
  261. var maximum = max$1(x, y);
  262. return min$1(max$1(minimum, number), maximum);
  263. }
  264. function sign(x) {
  265. return +(x > 0) - +(x < 0);
  266. }
  267. var min = Math.min,
  268. max = Math.max,
  269. floor = Math.floor,
  270. ceil = Math.ceil,
  271. abs = Math.abs,
  272. round = Math.round;
  273. function format(string, replacements) {
  274. forEach(replacements, function (replacement) {
  275. string = string.replace("%s", "" + replacement);
  276. });
  277. return string;
  278. }
  279. function pad(number) {
  280. return number < 10 ? "0" + number : "" + number;
  281. }
  282. var ids = {};
  283. function uniqueId(prefix) {
  284. return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1);
  285. }
  286. function EventBus() {
  287. var handlers = {};
  288. function on(events, callback, key, priority) {
  289. if (priority === void 0) {
  290. priority = DEFAULT_EVENT_PRIORITY;
  291. }
  292. forEachEvent(events, function (event, namespace) {
  293. handlers[event] = handlers[event] || [];
  294. push(handlers[event], {
  295. _event: event,
  296. _callback: callback,
  297. _namespace: namespace,
  298. _priority: priority,
  299. _key: key
  300. }).sort(function (handler1, handler2) {
  301. return handler1._priority - handler2._priority;
  302. });
  303. });
  304. }
  305. function off(events, key) {
  306. forEachEvent(events, function (event, namespace) {
  307. var eventHandlers = handlers[event];
  308. handlers[event] = eventHandlers && eventHandlers.filter(function (handler) {
  309. return handler._key ? handler._key !== key : handler._namespace !== namespace;
  310. });
  311. });
  312. }
  313. function offBy(key) {
  314. forOwn(handlers, function (eventHandlers, event) {
  315. off(event, key);
  316. });
  317. }
  318. function emit(event) {
  319. var _arguments = arguments;
  320. (handlers[event] || []).forEach(function (handler) {
  321. handler._callback.apply(handler, slice(_arguments, 1));
  322. });
  323. }
  324. function destroy() {
  325. handlers = {};
  326. }
  327. function forEachEvent(events, iteratee) {
  328. toArray(events).join(" ").split(" ").forEach(function (eventNS) {
  329. var fragments = eventNS.split(".");
  330. iteratee(fragments[0], fragments[1]);
  331. });
  332. }
  333. return {
  334. on: on,
  335. off: off,
  336. offBy: offBy,
  337. emit: emit,
  338. destroy: destroy
  339. };
  340. }
  341. var EVENT_MOUNTED = "mounted";
  342. var EVENT_READY = "ready";
  343. var EVENT_MOVE = "move";
  344. var EVENT_MOVED = "moved";
  345. var EVENT_CLICK = "click";
  346. var EVENT_ACTIVE = "active";
  347. var EVENT_INACTIVE = "inactive";
  348. var EVENT_VISIBLE = "visible";
  349. var EVENT_HIDDEN = "hidden";
  350. var EVENT_SLIDE_KEYDOWN = "slide:keydown";
  351. var EVENT_REFRESH = "refresh";
  352. var EVENT_UPDATED = "undated";
  353. var EVENT_RESIZE = "resize";
  354. var EVENT_RESIZED = "resized";
  355. var EVENT_DRAG = "drag";
  356. var EVENT_DRAGGING = "dragging";
  357. var EVENT_DRAGGED = "dragged";
  358. var EVENT_SCROLL = "scroll";
  359. var EVENT_SCROLLED = "scrolled";
  360. var EVENT_DESTROY = "destroy";
  361. var EVENT_ARROWS_MOUNTED = "arrows:mounted";
  362. var EVENT_ARROWS_UPDATED = "arrows:updated";
  363. var EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  364. var EVENT_PAGINATION_PAGE = "pagination:page";
  365. var EVENT_PAGINATION_UPDATED = "pagination:updated";
  366. var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  367. var EVENT_AUTOPLAY_PLAY = "autoplay:play";
  368. var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  369. var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  370. var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  371. function EventInterface(Splide2) {
  372. var event = Splide2.event;
  373. var key = {};
  374. var listeners = [];
  375. function on(events, callback, priority) {
  376. event.on(events, callback, key, priority);
  377. }
  378. function off(events) {
  379. event.off(events, key);
  380. }
  381. function bind(targets, events, callback, options) {
  382. forEachEvent(targets, events, function (target, event2) {
  383. listeners.push([target, event2, callback, options]);
  384. target.addEventListener(event2, callback, options);
  385. });
  386. }
  387. function unbind(targets, events) {
  388. forEachEvent(targets, events, function (target, event2) {
  389. listeners = listeners.filter(function (listener) {
  390. if (listener[0] === target && listener[1] === event2) {
  391. target.removeEventListener(event2, listener[2], listener[3]);
  392. return false;
  393. }
  394. return true;
  395. });
  396. });
  397. }
  398. function forEachEvent(targets, events, iteratee) {
  399. forEach(targets, function (target) {
  400. if (target) {
  401. events.split(" ").forEach(iteratee.bind(null, target));
  402. }
  403. });
  404. }
  405. function destroy() {
  406. listeners = listeners.filter(function (data) {
  407. return unbind(data[0], data[1]);
  408. });
  409. event.offBy(key);
  410. }
  411. event.on(EVENT_DESTROY, destroy, key);
  412. return {
  413. on: on,
  414. off: off,
  415. emit: event.emit,
  416. bind: bind,
  417. unbind: unbind,
  418. destroy: destroy
  419. };
  420. }
  421. function RequestInterval(interval, onInterval, onUpdate, limit) {
  422. var now = Date.now;
  423. var startTime;
  424. var rate = 0;
  425. var id;
  426. var paused = true;
  427. var count = 0;
  428. function update() {
  429. if (!paused) {
  430. var elapsed = now() - startTime;
  431. if (elapsed >= interval) {
  432. rate = 1;
  433. startTime = now();
  434. } else {
  435. rate = elapsed / interval;
  436. }
  437. if (onUpdate) {
  438. onUpdate(rate);
  439. }
  440. if (rate === 1) {
  441. onInterval();
  442. if (limit && ++count >= limit) {
  443. pause();
  444. return;
  445. }
  446. }
  447. raf(update);
  448. }
  449. }
  450. function start(resume) {
  451. !resume && cancel();
  452. startTime = now() - (resume ? rate * interval : 0);
  453. paused = false;
  454. raf(update);
  455. }
  456. function pause() {
  457. paused = true;
  458. }
  459. function rewind() {
  460. startTime = now();
  461. rate = 0;
  462. if (onUpdate) {
  463. onUpdate(rate);
  464. }
  465. }
  466. function cancel() {
  467. cancelAnimationFrame(id);
  468. rate = 0;
  469. id = 0;
  470. paused = true;
  471. }
  472. function isPaused() {
  473. return paused;
  474. }
  475. return {
  476. start: start,
  477. rewind: rewind,
  478. pause: pause,
  479. cancel: cancel,
  480. isPaused: isPaused
  481. };
  482. }
  483. function State(initialState) {
  484. var state = initialState;
  485. function set(value) {
  486. state = value;
  487. }
  488. function is(states) {
  489. return includes(toArray(states), state);
  490. }
  491. return {
  492. set: set,
  493. is: is
  494. };
  495. }
  496. function Throttle(func, duration) {
  497. var interval;
  498. function throttled() {
  499. var _arguments2 = arguments,
  500. _this = this;
  501. if (!interval) {
  502. interval = RequestInterval(duration || 0, function () {
  503. func.apply(_this, _arguments2);
  504. interval = null;
  505. }, null, 1);
  506. interval.start();
  507. }
  508. }
  509. return throttled;
  510. }
  511. function Options(Splide2, Components2, options) {
  512. var throttledObserve = Throttle(observe);
  513. var initialOptions;
  514. var points;
  515. var currPoint;
  516. function setup() {
  517. try {
  518. merge(options, JSON.parse(getAttribute(Splide2.root, DATA_ATTRIBUTE)));
  519. } catch (e) {
  520. assert(false, e.message);
  521. }
  522. initialOptions = merge({}, options);
  523. }
  524. function mount() {
  525. var breakpoints = options.breakpoints;
  526. if (breakpoints) {
  527. points = Object.keys(breakpoints).sort(function (n, m) {
  528. return +n - +m;
  529. }).map(function (point) {
  530. return [point, matchMedia("(" + (options.mediaQuery || "max") + "-width:" + point + "px)")];
  531. });
  532. addEventListener("resize", throttledObserve);
  533. observe();
  534. }
  535. }
  536. function destroy(completely) {
  537. if (completely) {
  538. removeEventListener("resize", throttledObserve);
  539. }
  540. }
  541. function observe() {
  542. var item = find(points, function (item2) {
  543. return item2[1].matches;
  544. }) || [];
  545. if (item[0] !== currPoint) {
  546. onMatch(currPoint = item[0]);
  547. }
  548. }
  549. function onMatch(point) {
  550. var newOptions = options.breakpoints[point] || initialOptions;
  551. if (newOptions.destroy) {
  552. Splide2.options = initialOptions;
  553. Splide2.destroy(newOptions.destroy === "completely");
  554. } else {
  555. if (Splide2.state.is(DESTROYED)) {
  556. destroy(true);
  557. Splide2.mount();
  558. }
  559. Splide2.options = newOptions;
  560. }
  561. }
  562. return {
  563. setup: setup,
  564. mount: mount,
  565. destroy: destroy
  566. };
  567. }
  568. var RTL = "rtl";
  569. var TTB = "ttb";
  570. var ORIENTATION_MAP = {
  571. marginRight: ["marginBottom", "marginLeft"],
  572. width: ["height"],
  573. autoWidth: ["autoHeight"],
  574. fixedWidth: ["fixedHeight"],
  575. paddingLeft: ["paddingTop", "paddingRight"],
  576. paddingRight: ["paddingBottom", "paddingLeft"],
  577. left: ["top", "right"],
  578. right: ["bottom", "left"],
  579. x: ["y"],
  580. X: ["Y"],
  581. Y: ["X"],
  582. ArrowLeft: ["ArrowUp", "ArrowRight"],
  583. ArrowRight: ["ArrowDown", "ArrowLeft"]
  584. };
  585. function Direction(Splide2, Components2, options) {
  586. function resolve(prop, axisOnly) {
  587. var direction = options.direction;
  588. var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  589. return ORIENTATION_MAP[prop][index] || prop;
  590. }
  591. function orient(value) {
  592. return value * (options.direction === RTL ? 1 : -1);
  593. }
  594. return {
  595. resolve: resolve,
  596. orient: orient
  597. };
  598. }
  599. var CLASS_ROOT = PROJECT_CODE;
  600. var CLASS_SLIDER = PROJECT_CODE + "__slider";
  601. var CLASS_TRACK = PROJECT_CODE + "__track";
  602. var CLASS_LIST = PROJECT_CODE + "__list";
  603. var CLASS_SLIDE = PROJECT_CODE + "__slide";
  604. var CLASS_CLONE = CLASS_SLIDE + "--clone";
  605. var CLASS_CONTAINER = CLASS_SLIDE + "__container";
  606. var CLASS_ARROWS = PROJECT_CODE + "__arrows";
  607. var CLASS_ARROW = PROJECT_CODE + "__arrow";
  608. var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
  609. var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
  610. var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
  611. var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
  612. var CLASS_PROGRESS = PROJECT_CODE + "__progress";
  613. var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
  614. var CLASS_AUTOPLAY = PROJECT_CODE + "__autoplay";
  615. var CLASS_PLAY = PROJECT_CODE + "__play";
  616. var CLASS_PAUSE = PROJECT_CODE + "__pause";
  617. var CLASS_SPINNER = PROJECT_CODE + "__spinner";
  618. var CLASS_INITIALIZED = "is-initialized";
  619. var CLASS_ACTIVE = "is-active";
  620. var CLASS_PREV = "is-prev";
  621. var CLASS_NEXT = "is-next";
  622. var CLASS_VISIBLE = "is-visible";
  623. var CLASS_LOADING = "is-loading";
  624. var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING];
  625. var CLASSES = {
  626. slide: CLASS_SLIDE,
  627. clone: CLASS_CLONE,
  628. arrows: CLASS_ARROWS,
  629. arrow: CLASS_ARROW,
  630. prev: CLASS_ARROW_PREV,
  631. next: CLASS_ARROW_NEXT,
  632. pagination: CLASS_PAGINATION,
  633. page: CLASS_PAGINATION_PAGE,
  634. spinner: CLASS_SPINNER
  635. };
  636. function Elements(Splide2, Components2, options) {
  637. var _EventInterface = EventInterface(Splide2),
  638. on = _EventInterface.on;
  639. var root = Splide2.root;
  640. var elements = {};
  641. var slides = [];
  642. var classes;
  643. var slider;
  644. var track;
  645. var list;
  646. function setup() {
  647. collect();
  648. identify();
  649. addClass(root, classes = getClasses());
  650. }
  651. function mount() {
  652. on(EVENT_REFRESH, refresh);
  653. on(EVENT_UPDATED, update);
  654. }
  655. function destroy() {
  656. empty(slides);
  657. removeClass(root, classes);
  658. }
  659. function refresh() {
  660. destroy();
  661. setup();
  662. }
  663. function update() {
  664. removeClass(root, classes);
  665. addClass(root, classes = getClasses());
  666. }
  667. function collect() {
  668. slider = child(root, "." + CLASS_SLIDER);
  669. track = query(root, "." + CLASS_TRACK);
  670. list = child(track, "." + CLASS_LIST);
  671. assert(track && list, "Missing a track/list element.");
  672. push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
  673. var autoplay = find("." + CLASS_AUTOPLAY);
  674. var arrows = find("." + CLASS_ARROWS);
  675. assign(elements, {
  676. root: root,
  677. slider: slider,
  678. track: track,
  679. list: list,
  680. slides: slides,
  681. arrows: arrows,
  682. prev: query(arrows, "." + CLASS_ARROW_PREV),
  683. next: query(arrows, "." + CLASS_ARROW_NEXT),
  684. bar: query(find("." + CLASS_PROGRESS), "." + CLASS_PROGRESS_BAR),
  685. play: query(autoplay, "." + CLASS_PLAY),
  686. pause: query(autoplay, "." + CLASS_PAUSE)
  687. });
  688. }
  689. function identify() {
  690. var id = root.id || uniqueId(PROJECT_CODE);
  691. root.id = id;
  692. track.id = track.id || id + "-track";
  693. list.id = list.id || id + "-list";
  694. }
  695. function find(selector) {
  696. return child(root, selector) || child(slider, selector);
  697. }
  698. function getClasses() {
  699. return [CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE];
  700. }
  701. return assign(elements, {
  702. setup: setup,
  703. mount: mount,
  704. destroy: destroy
  705. });
  706. }
  707. function Style() {
  708. var style;
  709. var sheet;
  710. function mount() {
  711. style = create("style", {}, document.head);
  712. sheet = style.sheet;
  713. }
  714. function destroy() {
  715. remove(style);
  716. sheet = null;
  717. }
  718. function rule(selector, prop, value) {
  719. var _sheet = sheet,
  720. cssRules = _sheet.cssRules;
  721. var cssRule = find(cssRules, function (cssRule2) {
  722. return isCSSStyleRule(cssRule2) && cssRule2.selectorText === selector;
  723. }) || cssRules[sheet.insertRule(selector + "{}", 0)];
  724. if (isCSSStyleRule(cssRule)) {
  725. cssRule.style[prop] = "" + value;
  726. }
  727. }
  728. function ruleBy(target, prop, value) {
  729. rule("#" + (isHTMLElement(target) ? target.id : target), prop, value);
  730. }
  731. function isCSSStyleRule(cssRule) {
  732. return cssRule instanceof CSSStyleRule;
  733. }
  734. return {
  735. mount: mount,
  736. destroy: destroy,
  737. rule: rule,
  738. ruleBy: ruleBy
  739. };
  740. }
  741. var ROLE = "role";
  742. var ARIA_CONTROLS = "aria-controls";
  743. var ARIA_CURRENT = "aria-current";
  744. var ARIA_LABEL = "aria-label";
  745. var ARIA_HIDDEN = "aria-hidden";
  746. var TAB_INDEX = "tabindex";
  747. var DISABLED = "disabled";
  748. var ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, TAB_INDEX, DISABLED];
  749. var SLIDE = "slide";
  750. var LOOP = "loop";
  751. var FADE = "fade";
  752. function Slide$1(Splide2, index, slideIndex, slide) {
  753. var _EventInterface2 = EventInterface(Splide2),
  754. on = _EventInterface2.on,
  755. emit = _EventInterface2.emit,
  756. bind = _EventInterface2.bind,
  757. destroyEvents = _EventInterface2.destroy;
  758. var Components = Splide2.Components,
  759. root = Splide2.root,
  760. options = Splide2.options;
  761. var isNavigation = options.isNavigation,
  762. updateOnMove = options.updateOnMove;
  763. var resolve = Components.Direction.resolve;
  764. var isClone = slideIndex > -1;
  765. var container = child(slide, "." + CLASS_CONTAINER);
  766. var destroyed;
  767. function mount() {
  768. var _this2 = this;
  769. init();
  770. bind(slide, "click keydown", function (e) {
  771. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  772. });
  773. on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
  774. if (updateOnMove) {
  775. on(EVENT_MOVE, onMove.bind(this));
  776. }
  777. update.call(this);
  778. }
  779. function init() {
  780. if (!isClone) {
  781. slide.id = root.id + "-slide" + pad(index + 1);
  782. }
  783. if (isNavigation) {
  784. if (!isHTMLButtonElement(slide)) {
  785. setAttribute(slide, ROLE, "button");
  786. }
  787. var idx = isClone ? slideIndex : index;
  788. var label = format(options.i18n.slideX, idx + 1);
  789. var controls = Splide2.splides.map(function (splide) {
  790. return splide.root.id;
  791. }).join(" ");
  792. setAttribute(slide, ARIA_LABEL, label);
  793. setAttribute(slide, ARIA_CONTROLS, controls);
  794. }
  795. }
  796. function destroy() {
  797. destroyed = true;
  798. destroyEvents();
  799. removeClass(slide, STATUS_CLASSES);
  800. removeAttribute(slide, ALL_ATTRIBUTES);
  801. }
  802. function onMove(next, prev, dest) {
  803. if (!destroyed) {
  804. if (dest === index) {
  805. updateActivity.call(this, true);
  806. }
  807. update.call(this);
  808. }
  809. }
  810. function update() {
  811. if (!destroyed) {
  812. var currIndex = Splide2.index;
  813. updateActivity.call(this, isActive());
  814. updateVisibility.call(this, isVisible());
  815. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  816. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  817. }
  818. }
  819. function updateActivity(active) {
  820. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  821. toggleClass(slide, CLASS_ACTIVE, active);
  822. if (isNavigation) {
  823. setAttribute(slide, ARIA_CURRENT, active || null);
  824. }
  825. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  826. }
  827. }
  828. function updateVisibility(visible) {
  829. var ariaHidden = !visible && !isActive();
  830. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  831. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  832. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  833. toggleClass(slide, CLASS_VISIBLE, visible);
  834. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  835. }
  836. }
  837. function rule(prop, value, useContainer) {
  838. var selector = "#" + slide.id + (container && useContainer ? " > ." + CLASS_CONTAINER : "");
  839. Components.Style.rule(selector, prop, value);
  840. }
  841. function isActive() {
  842. return Splide2.index === index;
  843. }
  844. function isVisible() {
  845. if (Splide2.is(FADE)) {
  846. return isActive();
  847. }
  848. var trackRect = rect(Components.Elements.track);
  849. var slideRect = rect(slide);
  850. var left = resolve("left");
  851. var right = resolve("right");
  852. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  853. }
  854. function isWithin(from, distance) {
  855. var diff = abs(from - index);
  856. if (!Splide2.is(SLIDE) && !isClone) {
  857. diff = min(diff, Splide2.length - diff);
  858. }
  859. return diff <= distance;
  860. }
  861. return {
  862. index: index,
  863. slideIndex: slideIndex,
  864. slide: slide,
  865. container: container,
  866. isClone: isClone,
  867. mount: mount,
  868. destroy: destroy,
  869. rule: rule,
  870. isWithin: isWithin
  871. };
  872. }
  873. function Slides(Splide2, Components2, options) {
  874. var _EventInterface3 = EventInterface(Splide2),
  875. on = _EventInterface3.on,
  876. emit = _EventInterface3.emit,
  877. bind = _EventInterface3.bind;
  878. var _Components2$Elements = Components2.Elements,
  879. slides = _Components2$Elements.slides,
  880. list = _Components2$Elements.list;
  881. var Slides2 = [];
  882. function mount() {
  883. init();
  884. on(EVENT_REFRESH, refresh);
  885. }
  886. function init() {
  887. slides.forEach(function (slide, index) {
  888. register(slide, index, -1);
  889. });
  890. }
  891. function destroy() {
  892. forEach$1(function (Slide2) {
  893. Slide2.destroy();
  894. });
  895. empty(Slides2);
  896. }
  897. function refresh() {
  898. destroy();
  899. init();
  900. }
  901. function register(slide, index, slideIndex) {
  902. var object = Slide$1(Splide2, index, slideIndex, slide);
  903. object.mount();
  904. Slides2.push(object);
  905. }
  906. function get(excludeClones) {
  907. return excludeClones ? filter(function (Slide2) {
  908. return !Slide2.isClone;
  909. }) : Slides2;
  910. }
  911. function getIn(page) {
  912. var Controller = Components2.Controller;
  913. var index = Controller.toIndex(page);
  914. var max = Controller.hasFocus() ? 1 : options.perPage;
  915. return filter(function (Slide2) {
  916. return between(Slide2.index, index, index + max - 1);
  917. });
  918. }
  919. function getAt(index) {
  920. return filter(index)[0];
  921. }
  922. function add(items, index) {
  923. forEach(items, function (slide) {
  924. if (isString(slide)) {
  925. slide = parseHtml(slide);
  926. }
  927. if (isHTMLElement(slide)) {
  928. var ref = slides[index];
  929. ref ? before(slide, ref) : append(list, slide);
  930. addClass(slide, options.classes.slide);
  931. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  932. }
  933. });
  934. emit(EVENT_REFRESH);
  935. }
  936. function remove$1(matcher) {
  937. remove(filter(matcher).map(function (Slide2) {
  938. return Slide2.slide;
  939. }));
  940. emit(EVENT_REFRESH);
  941. }
  942. function forEach$1(iteratee, excludeClones) {
  943. get(excludeClones).forEach(iteratee);
  944. }
  945. function filter(matcher) {
  946. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  947. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  948. });
  949. }
  950. function rule(prop, value, useContainer) {
  951. forEach$1(function (Slide2) {
  952. Slide2.rule(prop, value, useContainer);
  953. });
  954. }
  955. function observeImages(elm, callback) {
  956. var images = queryAll(elm, "img");
  957. var length = images.length;
  958. if (length) {
  959. images.forEach(function (img) {
  960. bind(img, "load error", function () {
  961. if (! --length) {
  962. callback();
  963. }
  964. });
  965. });
  966. } else {
  967. callback();
  968. }
  969. }
  970. function getLength(excludeClones) {
  971. return excludeClones ? slides.length : Slides2.length;
  972. }
  973. function isEnough() {
  974. return Slides2.length > options.perPage;
  975. }
  976. return {
  977. mount: mount,
  978. destroy: destroy,
  979. register: register,
  980. get: get,
  981. getIn: getIn,
  982. getAt: getAt,
  983. add: add,
  984. remove: remove$1,
  985. forEach: forEach$1,
  986. filter: filter,
  987. rule: rule,
  988. getLength: getLength,
  989. isEnough: isEnough
  990. };
  991. }
  992. function Clones(Splide2, Components2, options) {
  993. var _EventInterface4 = EventInterface(Splide2),
  994. on = _EventInterface4.on,
  995. emit = _EventInterface4.emit;
  996. var Elements = Components2.Elements,
  997. Slides = Components2.Slides;
  998. var resolve = Components2.Direction.resolve;
  999. var clones = [];
  1000. var cloneCount;
  1001. function mount() {
  1002. init();
  1003. on(EVENT_REFRESH, refresh);
  1004. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1005. }
  1006. function init() {
  1007. if (cloneCount = computeCloneCount()) {
  1008. generate(cloneCount);
  1009. }
  1010. }
  1011. function destroy() {
  1012. remove(clones);
  1013. empty(clones);
  1014. }
  1015. function refresh() {
  1016. destroy();
  1017. init();
  1018. }
  1019. function observe() {
  1020. if (cloneCount !== computeCloneCount()) {
  1021. emit(EVENT_REFRESH);
  1022. }
  1023. }
  1024. function generate(count) {
  1025. var slides = Slides.get().slice();
  1026. var length = slides.length;
  1027. if (length) {
  1028. while (slides.length < count) {
  1029. push(slides, slides);
  1030. }
  1031. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1032. var isHead = index < count;
  1033. var clone = cloneDeep(Slide.slide, index);
  1034. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1035. push(clones, clone);
  1036. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1037. });
  1038. }
  1039. }
  1040. function cloneDeep(elm, index) {
  1041. var clone = elm.cloneNode(true);
  1042. addClass(clone, options.classes.clone);
  1043. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1044. return clone;
  1045. }
  1046. function computeCloneCount() {
  1047. var clones2 = options.clones;
  1048. if (!Splide2.is(LOOP)) {
  1049. clones2 = 0;
  1050. } else if (!clones2) {
  1051. var fixedSize = options[resolve("fixedWidth")];
  1052. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1053. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1054. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1055. }
  1056. return clones2;
  1057. }
  1058. return {
  1059. mount: mount,
  1060. destroy: destroy
  1061. };
  1062. }
  1063. function Layout(Splide2, Components2, options) {
  1064. var _EventInterface5 = EventInterface(Splide2),
  1065. on = _EventInterface5.on,
  1066. bind = _EventInterface5.bind,
  1067. emit = _EventInterface5.emit;
  1068. var Slides = Components2.Slides;
  1069. var ruleBy = Components2.Style.ruleBy;
  1070. var resolve = Components2.Direction.resolve;
  1071. var _Components2$Elements2 = Components2.Elements,
  1072. track = _Components2$Elements2.track,
  1073. list = _Components2$Elements2.list;
  1074. var getAt = Slides.getAt;
  1075. var vertical = options.direction === TTB;
  1076. function mount() {
  1077. init();
  1078. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  1079. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1080. on(EVENT_RESIZE, resize);
  1081. }
  1082. function init() {
  1083. ruleBy(Splide2.root, "maxWidth", unit(options.width));
  1084. ruleBy(track, resolve("paddingLeft"), cssPadding(false));
  1085. ruleBy(track, resolve("paddingRight"), cssPadding(true));
  1086. Slides.rule(resolve("marginRight"), unit(options.gap));
  1087. Slides.rule("width", cssSlideWidth());
  1088. setSlidesHeight();
  1089. resize();
  1090. }
  1091. function resize() {
  1092. ruleBy(track, "height", cssTrackHeight());
  1093. options.heightRatio && setSlidesHeight();
  1094. emit(EVENT_RESIZED);
  1095. }
  1096. function setSlidesHeight() {
  1097. Slides.rule("height", cssSlideHeight(), true);
  1098. }
  1099. function cssPadding(right) {
  1100. var padding = options.padding;
  1101. var prop = resolve(right ? "right" : "left", true);
  1102. return padding ? unit(padding[prop] || (isObject(padding) ? "0" : padding)) : "";
  1103. }
  1104. function cssTrackHeight() {
  1105. var height = "";
  1106. if (vertical) {
  1107. height = cssHeight();
  1108. assert(height, '"height" or "heightRatio" is missing.');
  1109. var paddingTop = cssPadding(false);
  1110. var paddingBottom = cssPadding(true);
  1111. if (paddingTop || paddingBottom) {
  1112. height = "calc(" + height;
  1113. height += "" + (paddingTop ? " - " + paddingTop : "") + (paddingBottom ? " - " + paddingBottom : "") + ")";
  1114. }
  1115. }
  1116. return height;
  1117. }
  1118. function cssHeight() {
  1119. return unit(options.height || rect(list).width * options.heightRatio);
  1120. }
  1121. function cssSlideWidth() {
  1122. return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1123. }
  1124. function cssSlideHeight() {
  1125. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
  1126. }
  1127. function cssSlideSize() {
  1128. var gap = unit(options.gap);
  1129. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1130. }
  1131. function listSize() {
  1132. return rect(list)[resolve("width")];
  1133. }
  1134. function slideSize(index, withoutGap) {
  1135. var Slide = getAt(index || 0);
  1136. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1137. }
  1138. function totalSize(index, withoutGap) {
  1139. var Slide = getAt(index);
  1140. if (Slide) {
  1141. var right = rect(Slide.slide)[resolve("right")];
  1142. var left = rect(list)[resolve("left")];
  1143. return abs(right - left) + (withoutGap ? 0 : getGap());
  1144. }
  1145. return 0;
  1146. }
  1147. function sliderSize() {
  1148. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1149. }
  1150. function getGap() {
  1151. var Slide = getAt(0);
  1152. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1153. }
  1154. function getPadding(right) {
  1155. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left"), true))) || 0;
  1156. }
  1157. return {
  1158. mount: mount,
  1159. listSize: listSize,
  1160. slideSize: slideSize,
  1161. sliderSize: sliderSize,
  1162. totalSize: totalSize,
  1163. getPadding: getPadding
  1164. };
  1165. }
  1166. var SNAP_THRESHOLD = 10;
  1167. function Move(Splide2, Components2, options) {
  1168. var _EventInterface6 = EventInterface(Splide2),
  1169. on = _EventInterface6.on,
  1170. emit = _EventInterface6.emit;
  1171. var _Components2$Layout = Components2.Layout,
  1172. slideSize = _Components2$Layout.slideSize,
  1173. getPadding = _Components2$Layout.getPadding,
  1174. totalSize = _Components2$Layout.totalSize,
  1175. listSize = _Components2$Layout.listSize,
  1176. sliderSize = _Components2$Layout.sliderSize;
  1177. var _Components2$Directio = Components2.Direction,
  1178. resolve = _Components2$Directio.resolve,
  1179. orient = _Components2$Directio.orient;
  1180. var _Components2$Elements3 = Components2.Elements,
  1181. list = _Components2$Elements3.list,
  1182. track = _Components2$Elements3.track;
  1183. var waiting;
  1184. var shouldSnap = true;
  1185. function mount() {
  1186. on([EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
  1187. }
  1188. function reposition() {
  1189. if (exceededLimit(true)) {
  1190. translate(getLimit(true));
  1191. } else if (shouldSnap || (shouldSnap = canSnap())) {
  1192. jump(Splide2.index);
  1193. }
  1194. }
  1195. function move(dest, index, prev) {
  1196. if (!isBusy()) {
  1197. var set = Splide2.state.set;
  1198. var position = getPosition();
  1199. var looping = dest !== index;
  1200. waiting = looping || options.waitForTransition;
  1201. set(MOVING);
  1202. emit(EVENT_MOVE, index, prev, dest);
  1203. Components2.Transition.start(dest, function () {
  1204. looping && jump(index);
  1205. waiting = false;
  1206. set(IDLE);
  1207. emit(EVENT_MOVED, index, prev, dest);
  1208. if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
  1209. Components2.Controller.go(dest > prev ? ">" : "<");
  1210. }
  1211. });
  1212. }
  1213. }
  1214. function jump(index) {
  1215. waiting = false;
  1216. Components2.Transition.cancel();
  1217. translate(toPosition(index, true));
  1218. }
  1219. function translate(position) {
  1220. position = loop(position);
  1221. shouldSnap = canSnap(position);
  1222. Components2.Style.ruleBy(list, "transform", "translate" + resolve("X") + "(" + 100 * position / listSize() + "%)");
  1223. }
  1224. function loop(position) {
  1225. if (!waiting && Splide2.is(LOOP)) {
  1226. var diff = position - getPosition();
  1227. var exceededMin = exceededLimit(false, position);
  1228. var exceededMax = exceededLimit(true, position);
  1229. if (exceededMin && diff > 0 || exceededMax && diff < 0) {
  1230. position += orient(sliderSize() * (exceededMin ? 1 : -1));
  1231. }
  1232. }
  1233. return position;
  1234. }
  1235. function cancel() {
  1236. translate(getPosition());
  1237. Components2.Transition.cancel();
  1238. }
  1239. function toIndex(position) {
  1240. var Slides = Components2.Slides.get();
  1241. var index = 0;
  1242. var minDistance = Infinity;
  1243. for (var i = 0; i < Slides.length; i++) {
  1244. var slideIndex = Slides[i].index;
  1245. var distance = abs(toPosition(slideIndex, true) - position);
  1246. if (distance < minDistance) {
  1247. minDistance = distance;
  1248. index = slideIndex;
  1249. } else {
  1250. break;
  1251. }
  1252. }
  1253. return index;
  1254. }
  1255. function toPosition(index, trimming) {
  1256. var position = orient(totalSize(index - 1) - offset(index));
  1257. return trimming ? trim(position) : position;
  1258. }
  1259. function getPosition() {
  1260. var left = resolve("left");
  1261. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1262. }
  1263. function trim(position) {
  1264. if (options.trimSpace && Splide2.is(SLIDE)) {
  1265. position = clamp(position, 0, orient(sliderSize() - listSize()));
  1266. }
  1267. return position;
  1268. }
  1269. function offset(index) {
  1270. var focus = options.focus;
  1271. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1272. }
  1273. function getLimit(max) {
  1274. return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
  1275. }
  1276. function canSnap(position) {
  1277. position = isUndefined(position) ? getPosition() : position;
  1278. return abs(position - toPosition(toIndex(position), true)) < SNAP_THRESHOLD;
  1279. }
  1280. function isBusy() {
  1281. return waiting;
  1282. }
  1283. function exceededLimit(max, position) {
  1284. position = isUndefined(position) ? getPosition() : position;
  1285. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1286. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1287. return exceededMin || exceededMax;
  1288. }
  1289. return {
  1290. mount: mount,
  1291. move: move,
  1292. jump: jump,
  1293. translate: translate,
  1294. cancel: cancel,
  1295. toIndex: toIndex,
  1296. toPosition: toPosition,
  1297. getPosition: getPosition,
  1298. getLimit: getLimit,
  1299. isBusy: isBusy,
  1300. exceededLimit: exceededLimit
  1301. };
  1302. }
  1303. function Controller(Splide2, Components2, options) {
  1304. var _EventInterface7 = EventInterface(Splide2),
  1305. on = _EventInterface7.on;
  1306. var Move = Components2.Move;
  1307. var _Components2$Slides = Components2.Slides,
  1308. isEnough = _Components2$Slides.isEnough,
  1309. getLength = _Components2$Slides.getLength;
  1310. var isLoop = Splide2.is(LOOP);
  1311. var currIndex = options.start || 0;
  1312. var prevIndex = currIndex;
  1313. var slideCount;
  1314. var perMove;
  1315. var perPage;
  1316. function mount() {
  1317. init();
  1318. Move.jump(currIndex);
  1319. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1320. on(EVENT_SCROLLED, reindex, 0);
  1321. }
  1322. function init() {
  1323. slideCount = getLength(true);
  1324. perMove = options.perMove;
  1325. perPage = options.perPage;
  1326. if (currIndex >= slideCount) {
  1327. Move.jump(currIndex = slideCount - 1);
  1328. }
  1329. }
  1330. function reindex() {
  1331. setIndex(Move.toIndex(Move.getPosition()));
  1332. }
  1333. function go(control, allowSameIndex) {
  1334. var dest = parse(control);
  1335. var index = loop(dest);
  1336. if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
  1337. setIndex(index);
  1338. Move.move(dest, index, prevIndex);
  1339. }
  1340. }
  1341. function parse(control) {
  1342. var index = currIndex;
  1343. if (isString(control)) {
  1344. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1345. indicator = _ref[1],
  1346. number = _ref[2];
  1347. if (indicator === "+" || indicator === "-") {
  1348. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
  1349. } else if (indicator === ">") {
  1350. index = number ? toIndex(+number) : getNext(true);
  1351. } else if (indicator === "<") {
  1352. index = getPrev(true);
  1353. }
  1354. } else {
  1355. if (isLoop) {
  1356. index = clamp(control, -perPage, slideCount + perPage - 1);
  1357. } else {
  1358. index = clamp(control, 0, getEnd());
  1359. }
  1360. }
  1361. return index;
  1362. }
  1363. function getNext(destination) {
  1364. return getAdjacent(false, destination);
  1365. }
  1366. function getPrev(destination) {
  1367. return getAdjacent(true, destination);
  1368. }
  1369. function getAdjacent(prev, destination) {
  1370. var number = perMove || hasFocus() ? 1 : perPage;
  1371. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
  1372. if (dest === -1 && Splide2.is(SLIDE)) {
  1373. var position = Move.getPosition();
  1374. if (prev) {
  1375. if (!approximatelyEqual(position, 0, 1)) {
  1376. return 0;
  1377. }
  1378. } else {
  1379. if (!approximatelyEqual(position, Move.getLimit(true), 1)) {
  1380. return getEnd();
  1381. }
  1382. }
  1383. }
  1384. return destination ? dest : loop(dest);
  1385. }
  1386. function computeDestIndex(dest, from, incremental) {
  1387. if (isEnough()) {
  1388. var end = getEnd();
  1389. if (dest < 0 || dest > end) {
  1390. if (between(0, dest, from, true) || between(end, from, dest, true)) {
  1391. dest = toIndex(toPage(dest));
  1392. } else {
  1393. if (isLoop) {
  1394. dest = perMove ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount;
  1395. } else if (options.rewind) {
  1396. dest = dest < 0 ? end : 0;
  1397. } else {
  1398. dest = -1;
  1399. }
  1400. }
  1401. } else {
  1402. if (!isLoop && !incremental && dest !== from) {
  1403. dest = toIndex(toPage(from) + (dest < from ? -1 : 1));
  1404. }
  1405. }
  1406. } else {
  1407. dest = -1;
  1408. }
  1409. return dest;
  1410. }
  1411. function getEnd() {
  1412. var end = slideCount - perPage;
  1413. if (hasFocus() || isLoop && perMove) {
  1414. end = slideCount - 1;
  1415. }
  1416. return max(end, 0);
  1417. }
  1418. function loop(index) {
  1419. if (isLoop) {
  1420. return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1;
  1421. }
  1422. return index;
  1423. }
  1424. function toIndex(page) {
  1425. return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
  1426. }
  1427. function toPage(index) {
  1428. if (!hasFocus()) {
  1429. index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index;
  1430. index = floor(index / perPage);
  1431. }
  1432. return index;
  1433. }
  1434. function setIndex(index) {
  1435. if (index !== currIndex) {
  1436. prevIndex = currIndex;
  1437. currIndex = index;
  1438. }
  1439. }
  1440. function getIndex(prev) {
  1441. return prev ? prevIndex : currIndex;
  1442. }
  1443. function hasFocus() {
  1444. return !isUndefined(options.focus) || options.isNavigation;
  1445. }
  1446. return {
  1447. mount: mount,
  1448. go: go,
  1449. getNext: getNext,
  1450. getPrev: getPrev,
  1451. getEnd: getEnd,
  1452. setIndex: setIndex,
  1453. getIndex: getIndex,
  1454. toIndex: toIndex,
  1455. toPage: toPage,
  1456. hasFocus: hasFocus
  1457. };
  1458. }
  1459. var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1460. 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";
  1461. var SIZE = 40;
  1462. function Arrows(Splide2, Components2, options) {
  1463. var _EventInterface8 = EventInterface(Splide2),
  1464. on = _EventInterface8.on,
  1465. bind = _EventInterface8.bind,
  1466. emit = _EventInterface8.emit;
  1467. var classes = options.classes,
  1468. i18n = options.i18n;
  1469. var Elements = Components2.Elements,
  1470. Controller = Components2.Controller;
  1471. var wrapper = Elements.arrows;
  1472. var prev = Elements.prev;
  1473. var next = Elements.next;
  1474. var created;
  1475. var arrows = {};
  1476. function mount() {
  1477. init();
  1478. on(EVENT_UPDATED, init);
  1479. }
  1480. function init() {
  1481. if (options.arrows) {
  1482. if (!prev || !next) {
  1483. createArrows();
  1484. }
  1485. }
  1486. if (prev && next) {
  1487. if (!arrows.prev) {
  1488. var id = Elements.track.id;
  1489. setAttribute(prev, ARIA_CONTROLS, id);
  1490. setAttribute(next, ARIA_CONTROLS, id);
  1491. arrows.prev = prev;
  1492. arrows.next = next;
  1493. listen();
  1494. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1495. } else {
  1496. display(wrapper, options.arrows === false ? "none" : "");
  1497. }
  1498. }
  1499. }
  1500. function destroy() {
  1501. if (created) {
  1502. remove(wrapper);
  1503. } else {
  1504. removeAttribute(prev, ALL_ATTRIBUTES);
  1505. removeAttribute(next, ALL_ATTRIBUTES);
  1506. }
  1507. }
  1508. function listen() {
  1509. var go = Controller.go;
  1510. on([EVENT_MOUNTED, EVENT_MOVE, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1511. bind(next, "click", function () {
  1512. go(">", true);
  1513. });
  1514. bind(prev, "click", function () {
  1515. go("<", true);
  1516. });
  1517. }
  1518. function createArrows() {
  1519. wrapper = create("div", classes.arrows);
  1520. prev = createArrow(true);
  1521. next = createArrow(false);
  1522. created = true;
  1523. append(wrapper, [prev, next]);
  1524. before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root));
  1525. }
  1526. function createArrow(prev2) {
  1527. 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) + "\" />";
  1528. return parseHtml(arrow);
  1529. }
  1530. function update() {
  1531. var index = Splide2.index;
  1532. var prevIndex = Controller.getPrev();
  1533. var nextIndex = Controller.getNext();
  1534. var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1535. var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1536. prev.disabled = prevIndex < 0;
  1537. next.disabled = nextIndex < 0;
  1538. setAttribute(prev, ARIA_LABEL, prevLabel);
  1539. setAttribute(next, ARIA_LABEL, nextLabel);
  1540. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1541. }
  1542. return {
  1543. arrows: arrows,
  1544. mount: mount,
  1545. destroy: destroy
  1546. };
  1547. }
  1548. function Autoplay(Splide2, Components2, options) {
  1549. var _EventInterface9 = EventInterface(Splide2),
  1550. on = _EventInterface9.on,
  1551. bind = _EventInterface9.bind,
  1552. emit = _EventInterface9.emit;
  1553. var Elements = Components2.Elements;
  1554. var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), update);
  1555. var isPaused = interval.isPaused;
  1556. var hovered;
  1557. var focused;
  1558. var paused;
  1559. function mount() {
  1560. var autoplay = options.autoplay;
  1561. if (autoplay) {
  1562. initButton(true);
  1563. initButton(false);
  1564. listen();
  1565. if (autoplay !== "pause") {
  1566. play();
  1567. }
  1568. }
  1569. }
  1570. function initButton(forPause) {
  1571. var prop = forPause ? "pause" : "play";
  1572. var button = Elements[prop];
  1573. if (button) {
  1574. if (!isHTMLButtonElement(button)) {
  1575. setAttribute(button, ROLE, "button");
  1576. }
  1577. setAttribute(button, ARIA_CONTROLS, Elements.track.id);
  1578. setAttribute(button, ARIA_LABEL, options.i18n[prop]);
  1579. bind(button, "click", forPause ? pause : play);
  1580. }
  1581. }
  1582. function listen() {
  1583. var root = Elements.root;
  1584. if (options.pauseOnHover) {
  1585. bind(root, "mouseenter mouseleave", function (e) {
  1586. hovered = e.type === "mouseenter";
  1587. autoToggle();
  1588. });
  1589. }
  1590. if (options.pauseOnFocus) {
  1591. bind(root, "focusin focusout", function (e) {
  1592. focused = e.type === "focusin";
  1593. autoToggle();
  1594. });
  1595. }
  1596. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1597. }
  1598. function play() {
  1599. if (isPaused() && Components2.Slides.isEnough()) {
  1600. interval.start(!options.resetProgress);
  1601. focused = false;
  1602. hovered = false;
  1603. emit(EVENT_AUTOPLAY_PLAY);
  1604. }
  1605. }
  1606. function pause(manual) {
  1607. if (manual === void 0) {
  1608. manual = true;
  1609. }
  1610. if (!isPaused()) {
  1611. interval.pause();
  1612. emit(EVENT_AUTOPLAY_PAUSE);
  1613. }
  1614. paused = manual;
  1615. }
  1616. function autoToggle() {
  1617. if (!paused) {
  1618. if (!hovered && !focused) {
  1619. play();
  1620. } else {
  1621. pause(false);
  1622. }
  1623. }
  1624. }
  1625. function update(rate) {
  1626. var bar = Elements.bar;
  1627. if (bar) {
  1628. style(bar, {
  1629. width: rate * 100 + "%"
  1630. });
  1631. }
  1632. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1633. }
  1634. return {
  1635. mount: mount,
  1636. destroy: interval.cancel,
  1637. play: play,
  1638. pause: pause,
  1639. isPaused: isPaused
  1640. };
  1641. }
  1642. function Cover(Splide2, Components2, options) {
  1643. var _EventInterface10 = EventInterface(Splide2),
  1644. on = _EventInterface10.on;
  1645. function mount() {
  1646. if (options.cover) {
  1647. on(EVENT_LAZYLOAD_LOADED, function (img, Slide) {
  1648. toggle(true, img, Slide);
  1649. });
  1650. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply.bind(null, true));
  1651. }
  1652. }
  1653. function destroy() {
  1654. apply(false);
  1655. }
  1656. function apply(cover) {
  1657. Components2.Slides.forEach(function (Slide) {
  1658. var img = child(Slide.container || Slide.slide, "img");
  1659. if (img && img.src) {
  1660. toggle(cover, img, Slide);
  1661. }
  1662. });
  1663. }
  1664. function toggle(cover, img, Slide) {
  1665. Slide.rule("background", cover ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
  1666. display(img, cover ? "none" : "");
  1667. }
  1668. return {
  1669. mount: mount,
  1670. destroy: destroy
  1671. };
  1672. }
  1673. var BOUNCE_DIFF_THRESHOLD = 10;
  1674. var BOUNCE_DURATION = 600;
  1675. var FRICTION_FACTOR = 0.6;
  1676. var BASE_VELOCITY = 1.5;
  1677. var MIN_DURATION = 800;
  1678. function Scroll(Splide2, Components2, options) {
  1679. var _EventInterface11 = EventInterface(Splide2),
  1680. on = _EventInterface11.on,
  1681. emit = _EventInterface11.emit;
  1682. var Move = Components2.Move;
  1683. var getPosition = Move.getPosition,
  1684. getLimit = Move.getLimit,
  1685. exceededLimit = Move.exceededLimit;
  1686. var interval;
  1687. function mount() {
  1688. on(EVENT_MOVE, clear);
  1689. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1690. }
  1691. function scroll(destination, duration, suppressConstraint) {
  1692. var start = getPosition();
  1693. var friction = 1;
  1694. duration = duration || computeDuration(abs(destination - start));
  1695. clear();
  1696. interval = RequestInterval(duration, onScrolled, function (rate) {
  1697. var position = getPosition();
  1698. var target = start + (destination - start) * easing(rate);
  1699. var diff = (target - getPosition()) * friction;
  1700. Move.translate(position + diff);
  1701. if (Splide2.is(SLIDE) && !suppressConstraint && exceededLimit()) {
  1702. friction *= FRICTION_FACTOR;
  1703. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1704. bounce(exceededLimit(false));
  1705. }
  1706. }
  1707. }, 1);
  1708. emit(EVENT_SCROLL);
  1709. interval.start();
  1710. }
  1711. function bounce(backwards) {
  1712. scroll(getLimit(!backwards), BOUNCE_DURATION, true);
  1713. }
  1714. function onScrolled() {
  1715. emit(EVENT_SCROLLED);
  1716. }
  1717. function computeDuration(distance) {
  1718. return max(distance / BASE_VELOCITY, MIN_DURATION);
  1719. }
  1720. function clear() {
  1721. if (interval) {
  1722. interval.cancel();
  1723. }
  1724. }
  1725. function cancel() {
  1726. if (interval && !interval.isPaused()) {
  1727. clear();
  1728. onScrolled();
  1729. }
  1730. }
  1731. function easing(t) {
  1732. var easingFunc = options.easingFunc;
  1733. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1734. }
  1735. return {
  1736. mount: mount,
  1737. destroy: clear,
  1738. scroll: scroll,
  1739. cancel: cancel
  1740. };
  1741. }
  1742. var FRICTION = 5;
  1743. var LOG_INTERVAL = 50;
  1744. var POINTER_DOWN_EVENTS = "touchstart mousedown";
  1745. var POINTER_MOVE_EVENTS = "touchmove mousemove";
  1746. var POINTER_UP_EVENTS = "touchend touchcancel mouseup mouseleave";
  1747. function Drag(Splide2, Components2, options) {
  1748. var _EventInterface12 = EventInterface(Splide2),
  1749. on = _EventInterface12.on,
  1750. emit = _EventInterface12.emit,
  1751. bind = _EventInterface12.bind,
  1752. unbind = _EventInterface12.unbind;
  1753. var Move = Components2.Move,
  1754. Scroll = Components2.Scroll,
  1755. Controller = Components2.Controller;
  1756. var track = Components2.Elements.track;
  1757. var _Components2$Directio2 = Components2.Direction,
  1758. resolve = _Components2$Directio2.resolve,
  1759. orient = _Components2$Directio2.orient;
  1760. var getPosition = Move.getPosition,
  1761. exceededLimit = Move.exceededLimit;
  1762. var isSlide = Splide2.is(SLIDE);
  1763. var isFade = Splide2.is(FADE);
  1764. var basePosition;
  1765. var baseEvent;
  1766. var prevBaseEvent;
  1767. var lastEvent;
  1768. var isFree;
  1769. var isDragging;
  1770. var isMouse;
  1771. var hasExceeded = false;
  1772. var clickPrevented;
  1773. var disabled;
  1774. var target;
  1775. function mount() {
  1776. bind(track, POINTER_DOWN_EVENTS, onPointerDown);
  1777. bind(track, "click", onClick, {
  1778. capture: true
  1779. });
  1780. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1781. }
  1782. function init() {
  1783. var drag = options.drag;
  1784. disable(!drag);
  1785. isFree = drag === "free";
  1786. }
  1787. function onPointerDown(e) {
  1788. if (!disabled) {
  1789. isMouse = e.type === "mousedown";
  1790. if (!isMouse || !e.button) {
  1791. if (!Move.isBusy()) {
  1792. target = isMouse ? window : track;
  1793. prevBaseEvent = null;
  1794. lastEvent = null;
  1795. clickPrevented = false;
  1796. bind(target, POINTER_MOVE_EVENTS, onPointerMove);
  1797. bind(target, POINTER_UP_EVENTS, onPointerUp);
  1798. Move.cancel();
  1799. Scroll.cancel();
  1800. save(e);
  1801. } else {
  1802. prevent(e, true);
  1803. }
  1804. }
  1805. }
  1806. }
  1807. function onPointerMove(e) {
  1808. if (!lastEvent) {
  1809. clickPrevented = true;
  1810. emit(EVENT_DRAG);
  1811. }
  1812. lastEvent = e;
  1813. if (!e.cancelable) {
  1814. return;
  1815. }
  1816. if (isDragging) {
  1817. var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
  1818. var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
  1819. if (expired || exceeded) {
  1820. save(e);
  1821. }
  1822. if (!isFade) {
  1823. Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
  1824. }
  1825. emit(EVENT_DRAGGING);
  1826. prevent(e);
  1827. } else {
  1828. var threshold = options.dragMinThreshold || 15;
  1829. isDragging = isMouse || abs(coordOf(e) - coordOf(baseEvent)) > threshold;
  1830. if (isSliderDirection()) {
  1831. prevent(e);
  1832. }
  1833. }
  1834. }
  1835. function onPointerUp(e) {
  1836. unbind(target, POINTER_MOVE_EVENTS + " " + POINTER_UP_EVENTS);
  1837. if (lastEvent) {
  1838. if (isDragging || e.cancelable && isSliderDirection()) {
  1839. var velocity = computeVelocity(e);
  1840. var destination = computeDestination(velocity);
  1841. if (isFree) {
  1842. Scroll.scroll(destination);
  1843. } else if (isFade) {
  1844. Controller.go(Splide2.index + orient(sign(velocity)));
  1845. } else {
  1846. Controller.go(computeIndex(destination), true);
  1847. }
  1848. prevent(e);
  1849. }
  1850. emit(EVENT_DRAGGED);
  1851. }
  1852. isDragging = false;
  1853. }
  1854. function save(e) {
  1855. prevBaseEvent = baseEvent;
  1856. baseEvent = e;
  1857. basePosition = getPosition();
  1858. }
  1859. function onClick(e) {
  1860. if (!disabled && clickPrevented) {
  1861. prevent(e, true);
  1862. }
  1863. }
  1864. function isSliderDirection() {
  1865. var diffX = abs(coordOf(lastEvent) - coordOf(baseEvent));
  1866. var diffY = abs(coordOf(lastEvent, true) - coordOf(baseEvent, true));
  1867. return diffX > diffY;
  1868. }
  1869. function computeVelocity(e) {
  1870. if (Splide2.is(LOOP) || !hasExceeded) {
  1871. var base = baseEvent === lastEvent && prevBaseEvent || baseEvent;
  1872. var diffCoord = coordOf(lastEvent) - coordOf(base);
  1873. var diffTime = timeOf(e) - timeOf(base);
  1874. var isFlick = timeOf(e) - timeOf(lastEvent) < LOG_INTERVAL;
  1875. if (diffTime && isFlick) {
  1876. return diffCoord / diffTime;
  1877. }
  1878. }
  1879. return 0;
  1880. }
  1881. function computeDestination(velocity) {
  1882. return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
  1883. }
  1884. function computeIndex(destination) {
  1885. var dest = Move.toIndex(destination);
  1886. return isSlide ? clamp(dest, 0, Controller.getEnd()) : dest;
  1887. }
  1888. function coordOf(e, orthogonal) {
  1889. var prop = "page" + resolve(orthogonal ? "Y" : "X");
  1890. return (isMouse ? e : e.touches[0])[prop];
  1891. }
  1892. function timeOf(e) {
  1893. return e.timeStamp;
  1894. }
  1895. function constrain(diff) {
  1896. return diff / (hasExceeded && isSlide ? FRICTION : 1);
  1897. }
  1898. function disable(value) {
  1899. disabled = value;
  1900. }
  1901. return {
  1902. mount: mount,
  1903. disable: disable
  1904. };
  1905. }
  1906. var IE_ARROW_KEYS = ["Left", "Right", "Up", "Down"];
  1907. function Keyboard(Splide2, Components2, options) {
  1908. var _EventInterface13 = EventInterface(Splide2),
  1909. on = _EventInterface13.on,
  1910. bind = _EventInterface13.bind,
  1911. unbind = _EventInterface13.unbind;
  1912. var root = Components2.Elements.root;
  1913. var resolve = Components2.Direction.resolve;
  1914. var target;
  1915. function mount() {
  1916. init();
  1917. on(EVENT_UPDATED, function () {
  1918. destroy();
  1919. init();
  1920. });
  1921. }
  1922. function init() {
  1923. var _options$keyboard = options.keyboard,
  1924. keyboard = _options$keyboard === void 0 ? "global" : _options$keyboard;
  1925. if (keyboard) {
  1926. if (keyboard === "focused") {
  1927. target = root;
  1928. setAttribute(root, TAB_INDEX, 0);
  1929. } else {
  1930. target = window;
  1931. }
  1932. bind(target, "keydown", onKeydown);
  1933. }
  1934. }
  1935. function destroy() {
  1936. if (target) {
  1937. unbind(target, "keydown");
  1938. if (isHTMLElement(target)) {
  1939. removeAttribute(target, TAB_INDEX);
  1940. }
  1941. }
  1942. }
  1943. function onKeydown(e) {
  1944. var key = normalize(e.key);
  1945. if (key === resolve("ArrowLeft")) {
  1946. Splide2.go("<");
  1947. } else if (key === resolve("ArrowRight")) {
  1948. Splide2.go(">");
  1949. }
  1950. }
  1951. function normalize(key) {
  1952. return includes(IE_ARROW_KEYS, key) ? "Arrow" + key : key;
  1953. }
  1954. return {
  1955. mount: mount,
  1956. destroy: destroy
  1957. };
  1958. }
  1959. var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
  1960. var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
  1961. var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
  1962. function LazyLoad(Splide2, Components2, options) {
  1963. var _EventInterface14 = EventInterface(Splide2),
  1964. on = _EventInterface14.on,
  1965. off = _EventInterface14.off,
  1966. bind = _EventInterface14.bind,
  1967. emit = _EventInterface14.emit;
  1968. var isSequential = options.lazyLoad === "sequential";
  1969. var images = [];
  1970. var index = 0;
  1971. function mount() {
  1972. if (options.lazyLoad) {
  1973. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  1974. destroy();
  1975. init();
  1976. });
  1977. if (!isSequential) {
  1978. on([EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED], observe);
  1979. }
  1980. }
  1981. }
  1982. function init() {
  1983. Components2.Slides.forEach(function (_Slide) {
  1984. queryAll(_Slide.slide, IMAGE_SELECTOR).forEach(function (_img) {
  1985. var src = getAttribute(_img, SRC_DATA_ATTRIBUTE);
  1986. var srcset = getAttribute(_img, SRCSET_DATA_ATTRIBUTE);
  1987. if (src !== _img.src || srcset !== _img.srcset) {
  1988. var _spinner = create("span", options.classes.spinner, _img.parentElement);
  1989. setAttribute(_spinner, ROLE, "presentation");
  1990. images.push({
  1991. _img: _img,
  1992. _Slide: _Slide,
  1993. src: src,
  1994. srcset: srcset,
  1995. _spinner: _spinner
  1996. });
  1997. display(_img, "none");
  1998. }
  1999. });
  2000. });
  2001. if (isSequential) {
  2002. loadNext();
  2003. }
  2004. }
  2005. function destroy() {
  2006. index = 0;
  2007. images = [];
  2008. }
  2009. function observe() {
  2010. images = images.filter(function (data) {
  2011. if (data._Slide.isWithin(Splide2.index, options.perPage * ((options.preloadPages || 1) + 1))) {
  2012. return load(data);
  2013. }
  2014. return true;
  2015. });
  2016. if (!images.length) {
  2017. off(EVENT_MOVED);
  2018. }
  2019. }
  2020. function load(data) {
  2021. var _img = data._img;
  2022. addClass(data._Slide.slide, CLASS_LOADING);
  2023. bind(_img, "load error", function (e) {
  2024. onLoad(data, e.type === "error");
  2025. });
  2026. ["src", "srcset"].forEach(function (name) {
  2027. if (data[name]) {
  2028. setAttribute(_img, name, data[name]);
  2029. removeAttribute(_img, name === "src" ? SRC_DATA_ATTRIBUTE : SRCSET_DATA_ATTRIBUTE);
  2030. }
  2031. });
  2032. }
  2033. function onLoad(data, error) {
  2034. var _Slide = data._Slide;
  2035. removeClass(_Slide.slide, CLASS_LOADING);
  2036. if (!error) {
  2037. remove(data._spinner);
  2038. display(data._img, "");
  2039. emit(EVENT_LAZYLOAD_LOADED, data._img, _Slide);
  2040. emit(EVENT_RESIZE);
  2041. }
  2042. if (isSequential) {
  2043. loadNext();
  2044. }
  2045. }
  2046. function loadNext() {
  2047. if (index < images.length) {
  2048. load(images[index++]);
  2049. }
  2050. }
  2051. return {
  2052. mount: mount,
  2053. destroy: destroy
  2054. };
  2055. }
  2056. function Pagination(Splide2, Components2, options) {
  2057. var _EventInterface15 = EventInterface(Splide2),
  2058. on = _EventInterface15.on,
  2059. emit = _EventInterface15.emit,
  2060. bind = _EventInterface15.bind,
  2061. unbind = _EventInterface15.unbind;
  2062. var Slides = Components2.Slides,
  2063. Elements = Components2.Elements;
  2064. var _Components2$Controll = Components2.Controller,
  2065. go = _Components2$Controll.go,
  2066. toPage = _Components2$Controll.toPage,
  2067. hasFocus = _Components2$Controll.hasFocus,
  2068. getIndex = _Components2$Controll.getIndex;
  2069. var items = [];
  2070. var list;
  2071. function mount() {
  2072. init();
  2073. on([EVENT_UPDATED, EVENT_REFRESH], init);
  2074. on([EVENT_MOVE, EVENT_SCROLLED], update);
  2075. }
  2076. function init() {
  2077. destroy();
  2078. if (options.pagination && Slides.isEnough()) {
  2079. createPagination();
  2080. emit(EVENT_PAGINATION_MOUNTED, {
  2081. list: list,
  2082. items: items
  2083. }, getAt(Splide2.index));
  2084. update();
  2085. }
  2086. }
  2087. function destroy() {
  2088. if (list) {
  2089. remove(list);
  2090. items.forEach(function (item) {
  2091. unbind(item.button, "click");
  2092. });
  2093. empty(items);
  2094. list = null;
  2095. }
  2096. }
  2097. function createPagination() {
  2098. var length = Splide2.length;
  2099. var classes = options.classes,
  2100. i18n = options.i18n,
  2101. perPage = options.perPage;
  2102. var parent = options.pagination === "slider" && Elements.slider || Elements.root;
  2103. var max = hasFocus() ? length : ceil(length / perPage);
  2104. list = create("ul", classes.pagination, parent);
  2105. var _loop = function _loop(i) {
  2106. var li = create("li", null, list);
  2107. var button = create("button", {
  2108. class: classes.page,
  2109. type: "button"
  2110. }, li);
  2111. var controls = Slides.getIn(i).map(function (Slide) {
  2112. return Slide.slide.id;
  2113. });
  2114. var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2115. bind(button, "click", function () {
  2116. go(">" + i, true);
  2117. });
  2118. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2119. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2120. emit(EVENT_PAGINATION_PAGE, list, li, button, i);
  2121. items.push({
  2122. li: li,
  2123. button: button,
  2124. page: i
  2125. });
  2126. };
  2127. for (var i = 0; i < max; i++) {
  2128. _loop(i);
  2129. }
  2130. }
  2131. function getAt(index) {
  2132. return items[toPage(index)];
  2133. }
  2134. function update() {
  2135. var prev = getAt(getIndex(true));
  2136. var curr = getAt(getIndex());
  2137. if (prev) {
  2138. removeClass(prev.button, CLASS_ACTIVE);
  2139. removeAttribute(prev.button, ARIA_CURRENT);
  2140. }
  2141. if (curr) {
  2142. addClass(curr.button, CLASS_ACTIVE);
  2143. setAttribute(curr.button, ARIA_CURRENT, true);
  2144. }
  2145. emit(EVENT_PAGINATION_UPDATED, {
  2146. list: list,
  2147. items: items
  2148. }, prev, curr);
  2149. }
  2150. return {
  2151. items: items,
  2152. mount: mount,
  2153. destroy: destroy,
  2154. getAt: getAt
  2155. };
  2156. }
  2157. var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
  2158. function Sync(Splide2, Components2, options) {
  2159. var splides = Splide2.splides;
  2160. function mount() {
  2161. if (options.isNavigation) {
  2162. navigate();
  2163. } else {
  2164. sync();
  2165. }
  2166. }
  2167. function sync() {
  2168. var processed = [];
  2169. splides.concat(Splide2).forEach(function (splide, index, instances) {
  2170. EventInterface(splide).on(EVENT_MOVE, function (index2, prev, dest) {
  2171. instances.forEach(function (instance) {
  2172. if (instance !== splide && !includes(processed, splide)) {
  2173. processed.push(instance);
  2174. instance.go(instance.is(LOOP) ? dest : index2);
  2175. }
  2176. });
  2177. empty(processed);
  2178. });
  2179. });
  2180. }
  2181. function navigate() {
  2182. var _EventInterface16 = EventInterface(Splide2),
  2183. on = _EventInterface16.on,
  2184. emit = _EventInterface16.emit;
  2185. on(EVENT_CLICK, function (Slide) {
  2186. Splide2.go(Slide.index);
  2187. });
  2188. on(EVENT_SLIDE_KEYDOWN, function (Slide, e) {
  2189. if (includes(TRIGGER_KEYS, e.key)) {
  2190. Splide2.go(Slide.index);
  2191. prevent(e);
  2192. }
  2193. });
  2194. emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2195. }
  2196. return {
  2197. mount: mount
  2198. };
  2199. }
  2200. function Wheel(Splide2, Components2, options) {
  2201. var _EventInterface17 = EventInterface(Splide2),
  2202. bind = _EventInterface17.bind;
  2203. function mount() {
  2204. if (options.wheel) {
  2205. bind(Components2.Elements.track, "wheel", onWheel);
  2206. }
  2207. }
  2208. function onWheel(e) {
  2209. var deltaY = e.deltaY;
  2210. if (deltaY) {
  2211. Splide2.go(deltaY < 0 ? "<" : ">");
  2212. prevent(e);
  2213. }
  2214. }
  2215. return {
  2216. mount: mount
  2217. };
  2218. }
  2219. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2220. __proto__: null,
  2221. Options: Options,
  2222. Direction: Direction,
  2223. Elements: Elements,
  2224. Style: Style,
  2225. Slides: Slides,
  2226. Clones: Clones,
  2227. Layout: Layout,
  2228. Move: Move,
  2229. Controller: Controller,
  2230. Arrows: Arrows,
  2231. Autoplay: Autoplay,
  2232. Cover: Cover,
  2233. Scroll: Scroll,
  2234. Drag: Drag,
  2235. Keyboard: Keyboard,
  2236. LazyLoad: LazyLoad,
  2237. Pagination: Pagination,
  2238. Sync: Sync,
  2239. Wheel: Wheel
  2240. });
  2241. var I18N = {
  2242. prev: "Previous slide",
  2243. next: "Next slide",
  2244. first: "Go to first slide",
  2245. last: "Go to last slide",
  2246. slideX: "Go to slide %s",
  2247. pageX: "Go to page %s",
  2248. play: "Start autoplay",
  2249. pause: "Pause autoplay"
  2250. };
  2251. var DEFAULTS = {
  2252. type: "slide",
  2253. speed: 400,
  2254. waitForTransition: true,
  2255. perPage: 1,
  2256. arrows: true,
  2257. pagination: true,
  2258. interval: 5e3,
  2259. pauseOnHover: true,
  2260. pauseOnFocus: true,
  2261. resetProgress: true,
  2262. easing: "cubic-bezier(.42,.65,.27,.99)",
  2263. drag: true,
  2264. direction: "ltr",
  2265. slideFocus: true,
  2266. trimSpace: true,
  2267. classes: CLASSES,
  2268. i18n: I18N
  2269. };
  2270. function Fade(Splide2, Components2, options) {
  2271. var _EventInterface18 = EventInterface(Splide2),
  2272. on = _EventInterface18.on;
  2273. var ruleBy = Components2.Style.ruleBy;
  2274. function mount() {
  2275. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2276. nextTick(function () {
  2277. Components2.Slides.forEach(function (Slide) {
  2278. ruleBy(Slide.slide, "transition", "opacity " + options.speed + "ms " + options.easing);
  2279. });
  2280. });
  2281. });
  2282. }
  2283. function start(index, done) {
  2284. var track = Components2.Elements.track;
  2285. ruleBy(track, "height", unit(rect(track).height));
  2286. nextTick(function () {
  2287. done();
  2288. ruleBy(track, "height", "");
  2289. });
  2290. }
  2291. return {
  2292. mount: mount,
  2293. start: start,
  2294. cancel: noop
  2295. };
  2296. }
  2297. function Slide(Splide2, Components2, options) {
  2298. var _EventInterface19 = EventInterface(Splide2),
  2299. bind = _EventInterface19.bind;
  2300. var Move = Components2.Move,
  2301. Controller = Components2.Controller;
  2302. var list = Components2.Elements.list;
  2303. var endCallback;
  2304. function mount() {
  2305. bind(list, "transitionend", function (e) {
  2306. if (e.target === list && endCallback) {
  2307. cancel();
  2308. endCallback();
  2309. }
  2310. });
  2311. }
  2312. function start(index, done) {
  2313. var destination = Move.toPosition(index, true);
  2314. var position = Move.getPosition();
  2315. var speed = getSpeed(index);
  2316. if (abs(destination - position) >= 1 && speed >= 1) {
  2317. apply("transform " + speed + "ms " + options.easing);
  2318. Move.translate(destination);
  2319. endCallback = done;
  2320. } else {
  2321. Move.jump(index);
  2322. done();
  2323. }
  2324. }
  2325. function cancel() {
  2326. apply("");
  2327. }
  2328. function getSpeed(index) {
  2329. var rewindSpeed = options.rewindSpeed;
  2330. if (Splide2.is(SLIDE) && rewindSpeed) {
  2331. var prev = Controller.getIndex(true);
  2332. var end = Controller.getEnd();
  2333. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2334. return rewindSpeed;
  2335. }
  2336. }
  2337. return options.speed;
  2338. }
  2339. function apply(transition) {
  2340. Components2.Style.ruleBy(list, "transition", transition);
  2341. }
  2342. return {
  2343. mount: mount,
  2344. start: start,
  2345. cancel: cancel
  2346. };
  2347. }
  2348. var _Splide = /*#__PURE__*/function () {
  2349. function _Splide(target, options) {
  2350. this.event = EventBus();
  2351. this.Components = {};
  2352. this.state = State(CREATED);
  2353. this.splides = [];
  2354. this._options = {};
  2355. this._Extensions = {};
  2356. var root = isString(target) ? query(document, target) : target;
  2357. assert(root, root + " is invalid.");
  2358. this.root = root;
  2359. merge(DEFAULTS, _Splide.defaults);
  2360. merge(merge(this._options, DEFAULTS), options || {});
  2361. }
  2362. var _proto = _Splide.prototype;
  2363. _proto.mount = function mount(Extensions, Transition) {
  2364. var _this3 = this;
  2365. var state = this.state,
  2366. Components2 = this.Components;
  2367. assert(state.is([CREATED, DESTROYED]), "Already mounted.");
  2368. state.set(CREATED);
  2369. this._Components = Components2;
  2370. this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
  2371. this._Extensions = Extensions || this._Extensions;
  2372. var Constructors = assign({}, ComponentConstructors, this._Extensions, {
  2373. Transition: this._Transition
  2374. });
  2375. forOwn(Constructors, function (Component, key) {
  2376. var component = Component(_this3, Components2, _this3._options);
  2377. Components2[key] = component;
  2378. component.setup && component.setup();
  2379. });
  2380. forOwn(Components2, function (component) {
  2381. component.mount && component.mount();
  2382. });
  2383. this.emit(EVENT_MOUNTED);
  2384. addClass(this.root, CLASS_INITIALIZED);
  2385. state.set(IDLE);
  2386. this.emit(EVENT_READY);
  2387. return this;
  2388. };
  2389. _proto.sync = function sync(splide) {
  2390. this.splides.push(splide);
  2391. splide.splides.push(this);
  2392. return this;
  2393. };
  2394. _proto.go = function go(control) {
  2395. this._Components.Controller.go(control);
  2396. };
  2397. _proto.on = function on(events, callback) {
  2398. this.event.on(events, callback, null, DEFAULT_USER_EVENT_PRIORITY);
  2399. return this;
  2400. };
  2401. _proto.off = function off(events) {
  2402. this.event.off(events);
  2403. return this;
  2404. };
  2405. _proto.emit = function emit(event) {
  2406. var _this$event;
  2407. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  2408. args[_key2 - 1] = arguments[_key2];
  2409. }
  2410. (_this$event = this.event).emit.apply(_this$event, [event].concat(args));
  2411. return this;
  2412. };
  2413. _proto.add = function add(slides, index) {
  2414. this._Components.Slides.add(slides, index);
  2415. return this;
  2416. };
  2417. _proto.remove = function remove(matcher) {
  2418. this._Components.Slides.remove(matcher);
  2419. return this;
  2420. };
  2421. _proto.is = function is(type) {
  2422. return this._options.type === type;
  2423. };
  2424. _proto.refresh = function refresh() {
  2425. this.emit(EVENT_REFRESH);
  2426. return this;
  2427. };
  2428. _proto.destroy = function destroy(completely) {
  2429. var event = this.event,
  2430. state = this.state;
  2431. if (state.is(CREATED)) {
  2432. event.on(EVENT_READY, this.destroy.bind(this, completely), this);
  2433. } else {
  2434. forOwn(this._Components, function (component) {
  2435. component.destroy && component.destroy(completely);
  2436. });
  2437. event.emit(EVENT_DESTROY);
  2438. event.destroy();
  2439. empty(this.splides);
  2440. state.set(DESTROYED);
  2441. }
  2442. return this;
  2443. };
  2444. _createClass(_Splide, [{
  2445. key: "options",
  2446. get: function get() {
  2447. return this._options;
  2448. },
  2449. set: function set(options) {
  2450. var _options = this._options;
  2451. merge(_options, options);
  2452. if (!this.state.is(CREATED)) {
  2453. this.emit(EVENT_UPDATED, _options);
  2454. }
  2455. }
  2456. }, {
  2457. key: "length",
  2458. get: function get() {
  2459. return this._Components.Slides.getLength(true);
  2460. }
  2461. }, {
  2462. key: "index",
  2463. get: function get() {
  2464. return this._Components.Controller.getIndex();
  2465. }
  2466. }]);
  2467. return _Splide;
  2468. }();
  2469. var Splide = _Splide;
  2470. Splide.defaults = {};
  2471. Splide.STATES = STATES;
  2472. return Splide;
  2473. });
  2474. //# sourceMappingURL=splide.js.map