splide.js 74 KB

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