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, 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 ARIA_ORIENTATION = "aria-orientation";
  746. var ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, ARIA_ORIENTATION, TAB_INDEX, DISABLED];
  747. var SLIDE = "slide";
  748. var LOOP = "loop";
  749. var FADE = "fade";
  750. function Slide$1(Splide2, index, slideIndex, slide) {
  751. var _EventInterface2 = EventInterface(Splide2),
  752. on = _EventInterface2.on,
  753. emit = _EventInterface2.emit,
  754. bind = _EventInterface2.bind,
  755. destroyEvents = _EventInterface2.destroy;
  756. var Components = Splide2.Components,
  757. root = Splide2.root,
  758. options = Splide2.options;
  759. var isNavigation = options.isNavigation,
  760. updateOnMove = options.updateOnMove;
  761. var resolve = Components.Direction.resolve;
  762. var isClone = slideIndex > -1;
  763. var container = child(slide, "." + CLASS_CONTAINER);
  764. var destroyed;
  765. function mount() {
  766. var _this2 = this;
  767. init();
  768. bind(slide, "click keydown", function (e) {
  769. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  770. });
  771. on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
  772. if (updateOnMove) {
  773. on(EVENT_MOVE, onMove.bind(this));
  774. }
  775. update.call(this);
  776. }
  777. function init() {
  778. if (!isClone) {
  779. slide.id = root.id + "-slide" + pad(index + 1);
  780. }
  781. if (isNavigation) {
  782. var idx = isClone ? slideIndex : index;
  783. var label = format(options.i18n.slideX, idx + 1);
  784. var controls = Splide2.splides.map(function (splide) {
  785. return splide.root.id;
  786. }).join(" ");
  787. setAttribute(slide, ARIA_LABEL, label);
  788. setAttribute(slide, ARIA_CONTROLS, controls);
  789. setAttribute(slide, ROLE, "menuitem");
  790. }
  791. }
  792. function destroy() {
  793. destroyed = true;
  794. destroyEvents();
  795. removeClass(slide, STATUS_CLASSES);
  796. removeAttribute(slide, ALL_ATTRIBUTES);
  797. }
  798. function onMove(next, prev, dest) {
  799. if (!destroyed) {
  800. update.call(this);
  801. if (dest === index) {
  802. updateActivity.call(this, true);
  803. }
  804. }
  805. }
  806. function update() {
  807. if (!destroyed) {
  808. var currIndex = Splide2.index;
  809. updateActivity.call(this, isActive());
  810. updateVisibility.call(this, isVisible());
  811. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  812. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  813. }
  814. }
  815. function updateActivity(active) {
  816. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  817. toggleClass(slide, CLASS_ACTIVE, active);
  818. if (isNavigation) {
  819. setAttribute(slide, ARIA_CURRENT, active || null);
  820. }
  821. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  822. }
  823. }
  824. function updateVisibility(visible) {
  825. var focusableNodes = options.focusableNodes;
  826. var ariaHidden = !visible && !isActive();
  827. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  828. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  829. if (focusableNodes) {
  830. queryAll(slide, focusableNodes).forEach(function (node) {
  831. setAttribute(node, TAB_INDEX, ariaHidden ? -1 : null);
  832. });
  833. }
  834. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  835. toggleClass(slide, CLASS_VISIBLE, visible);
  836. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  837. }
  838. }
  839. function rule(prop, value, useContainer) {
  840. var selector = "#" + slide.id + (container && useContainer ? " > ." + CLASS_CONTAINER : "");
  841. Components.Style.rule(selector, prop, value);
  842. }
  843. function isActive() {
  844. return Splide2.index === index;
  845. }
  846. function isVisible() {
  847. if (Splide2.is(FADE)) {
  848. return isActive();
  849. }
  850. var trackRect = rect(Components.Elements.track);
  851. var slideRect = rect(slide);
  852. var left = resolve("left");
  853. var right = resolve("right");
  854. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  855. }
  856. function isWithin(from, distance) {
  857. var diff = abs(from - index);
  858. if (!Splide2.is(SLIDE) && !isClone) {
  859. diff = min(diff, Splide2.length - diff);
  860. }
  861. return diff <= distance;
  862. }
  863. return {
  864. index: index,
  865. slideIndex: slideIndex,
  866. slide: slide,
  867. container: container,
  868. isClone: isClone,
  869. mount: mount,
  870. destroy: destroy,
  871. rule: rule,
  872. isWithin: isWithin
  873. };
  874. }
  875. function Slides(Splide2, Components2, options) {
  876. var _EventInterface3 = EventInterface(Splide2),
  877. on = _EventInterface3.on,
  878. emit = _EventInterface3.emit,
  879. bind = _EventInterface3.bind;
  880. var _Components2$Elements = Components2.Elements,
  881. slides = _Components2$Elements.slides,
  882. list = _Components2$Elements.list;
  883. var Slides2 = [];
  884. function mount() {
  885. init();
  886. on(EVENT_REFRESH, refresh);
  887. }
  888. function init() {
  889. slides.forEach(function (slide, index) {
  890. register(slide, index, -1);
  891. });
  892. }
  893. function destroy() {
  894. forEach$1(function (Slide2) {
  895. Slide2.destroy();
  896. });
  897. empty(Slides2);
  898. }
  899. function refresh() {
  900. destroy();
  901. init();
  902. }
  903. function register(slide, index, slideIndex) {
  904. var object = Slide$1(Splide2, index, slideIndex, slide);
  905. object.mount();
  906. Slides2.push(object);
  907. }
  908. function get(excludeClones) {
  909. return excludeClones ? filter(function (Slide2) {
  910. return !Slide2.isClone;
  911. }) : Slides2;
  912. }
  913. function getIn(page) {
  914. var Controller = Components2.Controller;
  915. var index = Controller.toIndex(page);
  916. var max = Controller.hasFocus() ? 1 : options.perPage;
  917. return filter(function (Slide2) {
  918. return between(Slide2.index, index, index + max - 1);
  919. });
  920. }
  921. function getAt(index) {
  922. return filter(index)[0];
  923. }
  924. function add(items, index) {
  925. forEach(items, function (slide) {
  926. if (isString(slide)) {
  927. slide = parseHtml(slide);
  928. }
  929. if (isHTMLElement(slide)) {
  930. var ref = slides[index];
  931. ref ? before(slide, ref) : append(list, slide);
  932. addClass(slide, options.classes.slide);
  933. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  934. }
  935. });
  936. emit(EVENT_REFRESH);
  937. }
  938. function remove$1(matcher) {
  939. remove(filter(matcher).map(function (Slide2) {
  940. return Slide2.slide;
  941. }));
  942. emit(EVENT_REFRESH);
  943. }
  944. function forEach$1(iteratee, excludeClones) {
  945. get(excludeClones).forEach(iteratee);
  946. }
  947. function filter(matcher) {
  948. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  949. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  950. });
  951. }
  952. function rule(prop, value, useContainer) {
  953. forEach$1(function (Slide2) {
  954. Slide2.rule(prop, value, useContainer);
  955. });
  956. }
  957. function observeImages(elm, callback) {
  958. var images = queryAll(elm, "img");
  959. var length = images.length;
  960. if (length) {
  961. images.forEach(function (img) {
  962. bind(img, "load error", function () {
  963. if (! --length) {
  964. callback();
  965. }
  966. });
  967. });
  968. } else {
  969. callback();
  970. }
  971. }
  972. function getLength(excludeClones) {
  973. return excludeClones ? slides.length : Slides2.length;
  974. }
  975. function isEnough() {
  976. return Slides2.length > options.perPage;
  977. }
  978. return {
  979. mount: mount,
  980. destroy: destroy,
  981. register: register,
  982. get: get,
  983. getIn: getIn,
  984. getAt: getAt,
  985. add: add,
  986. remove: remove$1,
  987. forEach: forEach$1,
  988. filter: filter,
  989. rule: rule,
  990. getLength: getLength,
  991. isEnough: isEnough
  992. };
  993. }
  994. function Clones(Splide2, Components2, options) {
  995. var _EventInterface4 = EventInterface(Splide2),
  996. on = _EventInterface4.on,
  997. emit = _EventInterface4.emit;
  998. var Elements = Components2.Elements,
  999. Slides = Components2.Slides;
  1000. var resolve = Components2.Direction.resolve;
  1001. var clones = [];
  1002. var cloneCount;
  1003. function mount() {
  1004. init();
  1005. on(EVENT_REFRESH, refresh);
  1006. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1007. }
  1008. function init() {
  1009. if (cloneCount = computeCloneCount()) {
  1010. generate(cloneCount);
  1011. }
  1012. }
  1013. function destroy() {
  1014. remove(clones);
  1015. empty(clones);
  1016. }
  1017. function refresh() {
  1018. destroy();
  1019. init();
  1020. }
  1021. function observe() {
  1022. if (cloneCount !== computeCloneCount()) {
  1023. emit(EVENT_REFRESH);
  1024. }
  1025. }
  1026. function generate(count) {
  1027. var slides = Slides.get().slice();
  1028. var length = slides.length;
  1029. if (length) {
  1030. while (slides.length < count) {
  1031. push(slides, slides);
  1032. }
  1033. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1034. var isHead = index < count;
  1035. var clone = cloneDeep(Slide.slide, index);
  1036. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1037. push(clones, clone);
  1038. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1039. });
  1040. }
  1041. }
  1042. function cloneDeep(elm, index) {
  1043. var clone = elm.cloneNode(true);
  1044. addClass(clone, options.classes.clone);
  1045. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1046. return clone;
  1047. }
  1048. function computeCloneCount() {
  1049. var clones2 = options.clones;
  1050. if (!Splide2.is(LOOP)) {
  1051. clones2 = 0;
  1052. } else if (!clones2) {
  1053. var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
  1054. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1055. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1056. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1057. }
  1058. return clones2;
  1059. }
  1060. return {
  1061. mount: mount,
  1062. destroy: destroy
  1063. };
  1064. }
  1065. function Layout(Splide2, Components2, options) {
  1066. var _EventInterface5 = EventInterface(Splide2),
  1067. on = _EventInterface5.on,
  1068. bind = _EventInterface5.bind,
  1069. emit = _EventInterface5.emit;
  1070. var Slides = Components2.Slides;
  1071. var ruleBy = Components2.Style.ruleBy;
  1072. var resolve = Components2.Direction.resolve;
  1073. var _Components2$Elements2 = Components2.Elements,
  1074. track = _Components2$Elements2.track,
  1075. list = _Components2$Elements2.list;
  1076. var getAt = Slides.getAt;
  1077. var vertical = options.direction === TTB;
  1078. function mount() {
  1079. init();
  1080. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  1081. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1082. on(EVENT_RESIZE, resize);
  1083. }
  1084. function init() {
  1085. ruleBy(Splide2.root, "maxWidth", unit(options.width));
  1086. ruleBy(track, resolve("paddingLeft"), cssPadding(false));
  1087. ruleBy(track, resolve("paddingRight"), cssPadding(true));
  1088. Slides.rule(resolve("marginRight"), unit(options.gap));
  1089. Slides.rule("width", cssSlideWidth());
  1090. setSlidesHeight();
  1091. resize();
  1092. }
  1093. function resize() {
  1094. ruleBy(track, "height", cssTrackHeight());
  1095. options.heightRatio && setSlidesHeight();
  1096. emit(EVENT_RESIZED);
  1097. }
  1098. function setSlidesHeight() {
  1099. Slides.rule("height", cssSlideHeight(), true);
  1100. }
  1101. function cssPadding(right) {
  1102. var padding = options.padding;
  1103. var prop = resolve(right ? "right" : "left", true);
  1104. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  1105. }
  1106. function cssTrackHeight() {
  1107. var height = "";
  1108. if (vertical) {
  1109. height = cssHeight();
  1110. assert(height, "height or heightRatio is missing.");
  1111. height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")";
  1112. }
  1113. return height;
  1114. }
  1115. function cssHeight() {
  1116. return unit(options.height || rect(list).width * options.heightRatio);
  1117. }
  1118. function cssSlideWidth() {
  1119. return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1120. }
  1121. function cssSlideHeight() {
  1122. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
  1123. }
  1124. function cssSlideSize() {
  1125. var gap = unit(options.gap);
  1126. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1127. }
  1128. function listSize() {
  1129. return rect(list)[resolve("width")];
  1130. }
  1131. function slideSize(index, withoutGap) {
  1132. var Slide = getAt(index || 0);
  1133. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1134. }
  1135. function totalSize(index, withoutGap) {
  1136. var Slide = getAt(index);
  1137. if (Slide) {
  1138. var right = rect(Slide.slide)[resolve("right")];
  1139. var left = rect(list)[resolve("left")];
  1140. return abs(right - left) + (withoutGap ? 0 : getGap());
  1141. }
  1142. return 0;
  1143. }
  1144. function sliderSize() {
  1145. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1146. }
  1147. function getGap() {
  1148. var Slide = getAt(0);
  1149. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1150. }
  1151. function getPadding(right) {
  1152. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left"), true))) || 0;
  1153. }
  1154. return {
  1155. mount: mount,
  1156. listSize: listSize,
  1157. slideSize: slideSize,
  1158. sliderSize: sliderSize,
  1159. totalSize: totalSize,
  1160. getPadding: getPadding
  1161. };
  1162. }
  1163. var SNAP_THRESHOLD = 10;
  1164. function Move(Splide2, Components2, options) {
  1165. var _EventInterface6 = EventInterface(Splide2),
  1166. on = _EventInterface6.on,
  1167. emit = _EventInterface6.emit;
  1168. var _Components2$Layout = Components2.Layout,
  1169. slideSize = _Components2$Layout.slideSize,
  1170. getPadding = _Components2$Layout.getPadding,
  1171. totalSize = _Components2$Layout.totalSize,
  1172. listSize = _Components2$Layout.listSize,
  1173. sliderSize = _Components2$Layout.sliderSize;
  1174. var _Components2$Directio = Components2.Direction,
  1175. resolve = _Components2$Directio.resolve,
  1176. orient = _Components2$Directio.orient;
  1177. var _Components2$Elements3 = Components2.Elements,
  1178. list = _Components2$Elements3.list,
  1179. track = _Components2$Elements3.track;
  1180. var waiting;
  1181. var shouldSnap = true;
  1182. function mount() {
  1183. if (!Splide2.is(FADE)) {
  1184. on([EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
  1185. }
  1186. }
  1187. function reposition() {
  1188. if (exceededLimit(true)) {
  1189. translate(getLimit(true));
  1190. } else if (shouldSnap || (shouldSnap = canSnap())) {
  1191. jump(Splide2.index);
  1192. }
  1193. }
  1194. function move(dest, index, prev, callback) {
  1195. if (!isBusy()) {
  1196. var set = Splide2.state.set;
  1197. var position = getPosition();
  1198. var looping = dest !== index;
  1199. waiting = looping || options.waitForTransition;
  1200. set(MOVING);
  1201. emit(EVENT_MOVE, index, prev, dest);
  1202. Components2.Transition.start(dest, function () {
  1203. looping && jump(index);
  1204. waiting = false;
  1205. set(IDLE);
  1206. emit(EVENT_MOVED, index, prev, dest);
  1207. if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
  1208. Components2.Controller.go(dest > prev ? ">" : "<", false, callback);
  1209. } else {
  1210. callback && callback();
  1211. }
  1212. });
  1213. }
  1214. }
  1215. function jump(index) {
  1216. translate(toPosition(index, true));
  1217. }
  1218. function translate(position) {
  1219. position = loop(position);
  1220. shouldSnap = canSnap(position);
  1221. Components2.Style.ruleBy(list, "transform", "translate" + resolve("X") + "(" + 100 * position / listSize() + "%)");
  1222. }
  1223. function loop(position) {
  1224. if (!waiting && Splide2.is(LOOP)) {
  1225. var diff = position - getPosition();
  1226. var exceededMin = exceededLimit(false, position);
  1227. var exceededMax = exceededLimit(true, position);
  1228. if (exceededMin && diff > 0 || exceededMax && diff < 0) {
  1229. position += orient(sliderSize() * (exceededMin ? 1 : -1));
  1230. }
  1231. }
  1232. return position;
  1233. }
  1234. function cancel() {
  1235. waiting = false;
  1236. Components2.Transition.cancel();
  1237. translate(getPosition());
  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 jump = Move.jump,
  1308. getPosition = Move.getPosition,
  1309. getLimit = Move.getLimit;
  1310. var _Components2$Slides = Components2.Slides,
  1311. isEnough = _Components2$Slides.isEnough,
  1312. getLength = _Components2$Slides.getLength;
  1313. var isLoop = Splide2.is(LOOP);
  1314. var currIndex = options.start || 0;
  1315. var prevIndex = currIndex;
  1316. var slideCount;
  1317. var perMove;
  1318. var perPage;
  1319. function mount() {
  1320. init();
  1321. jump(currIndex);
  1322. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1323. on(EVENT_SCROLLED, reindex, 0);
  1324. }
  1325. function init() {
  1326. slideCount = getLength(true);
  1327. perMove = options.perMove;
  1328. perPage = options.perPage;
  1329. currIndex = clamp(currIndex, 0, slideCount - 1);
  1330. jump(currIndex);
  1331. }
  1332. function reindex() {
  1333. setIndex(Move.toIndex(getPosition()));
  1334. }
  1335. function go(control, allowSameIndex, callback) {
  1336. var dest = parse(control);
  1337. var index = loop(dest);
  1338. if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
  1339. setIndex(index);
  1340. Move.move(dest, index, prevIndex, callback);
  1341. }
  1342. }
  1343. function parse(control) {
  1344. var index = currIndex;
  1345. if (isString(control)) {
  1346. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1347. indicator = _ref[1],
  1348. number = _ref[2];
  1349. if (indicator === "+" || indicator === "-") {
  1350. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
  1351. } else if (indicator === ">") {
  1352. index = number ? toIndex(+number) : getNext(true);
  1353. } else if (indicator === "<") {
  1354. index = getPrev(true);
  1355. }
  1356. } else {
  1357. if (isLoop) {
  1358. index = clamp(control, -perPage, slideCount + perPage - 1);
  1359. } else {
  1360. index = clamp(control, 0, getEnd());
  1361. }
  1362. }
  1363. return index;
  1364. }
  1365. function getNext(destination) {
  1366. return getAdjacent(false, destination);
  1367. }
  1368. function getPrev(destination) {
  1369. return getAdjacent(true, destination);
  1370. }
  1371. function getAdjacent(prev, destination) {
  1372. var number = perMove || hasFocus() ? 1 : perPage;
  1373. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
  1374. if (dest === -1 && Splide2.is(SLIDE)) {
  1375. if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
  1376. return prev ? 0 : getEnd();
  1377. }
  1378. }
  1379. return destination ? dest : loop(dest);
  1380. }
  1381. function computeDestIndex(dest, from, incremental) {
  1382. if (isEnough()) {
  1383. var end = getEnd();
  1384. if (dest < 0 || dest > end) {
  1385. if (between(0, dest, from, true) || between(end, from, dest, true)) {
  1386. dest = toIndex(toPage(dest));
  1387. } else {
  1388. if (isLoop) {
  1389. dest = perMove ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount;
  1390. } else if (options.rewind) {
  1391. dest = dest < 0 ? end : 0;
  1392. } else {
  1393. dest = -1;
  1394. }
  1395. }
  1396. } else {
  1397. if (!isLoop && !incremental && dest !== from) {
  1398. dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
  1399. }
  1400. }
  1401. } else {
  1402. dest = -1;
  1403. }
  1404. return dest;
  1405. }
  1406. function getEnd() {
  1407. var end = slideCount - perPage;
  1408. if (hasFocus() || isLoop && perMove) {
  1409. end = slideCount - 1;
  1410. }
  1411. return max(end, 0);
  1412. }
  1413. function loop(index) {
  1414. if (isLoop) {
  1415. return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1;
  1416. }
  1417. return index;
  1418. }
  1419. function toIndex(page) {
  1420. return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
  1421. }
  1422. function toPage(index) {
  1423. if (!hasFocus()) {
  1424. index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index;
  1425. index = floor(index / perPage);
  1426. }
  1427. return index;
  1428. }
  1429. function setIndex(index) {
  1430. if (index !== currIndex) {
  1431. prevIndex = currIndex;
  1432. currIndex = index;
  1433. }
  1434. }
  1435. function getIndex(prev) {
  1436. return prev ? prevIndex : currIndex;
  1437. }
  1438. function hasFocus() {
  1439. return !isUndefined(options.focus) || options.isNavigation;
  1440. }
  1441. return {
  1442. mount: mount,
  1443. go: go,
  1444. getNext: getNext,
  1445. getPrev: getPrev,
  1446. getEnd: getEnd,
  1447. setIndex: setIndex,
  1448. getIndex: getIndex,
  1449. toIndex: toIndex,
  1450. toPage: toPage,
  1451. hasFocus: hasFocus
  1452. };
  1453. }
  1454. var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1455. 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";
  1456. var SIZE = 40;
  1457. function Arrows(Splide2, Components2, options) {
  1458. var _EventInterface8 = EventInterface(Splide2),
  1459. on = _EventInterface8.on,
  1460. bind = _EventInterface8.bind,
  1461. emit = _EventInterface8.emit;
  1462. var classes = options.classes,
  1463. i18n = options.i18n;
  1464. var Elements = Components2.Elements,
  1465. Controller = Components2.Controller;
  1466. var wrapper = Elements.arrows;
  1467. var prev = Elements.prev;
  1468. var next = Elements.next;
  1469. var created;
  1470. var arrows = {};
  1471. function mount() {
  1472. init();
  1473. on(EVENT_UPDATED, init);
  1474. }
  1475. function init() {
  1476. if (options.arrows) {
  1477. if (!prev || !next) {
  1478. createArrows();
  1479. }
  1480. }
  1481. if (prev && next) {
  1482. if (!arrows.prev) {
  1483. var id = Elements.track.id;
  1484. setAttribute(prev, ARIA_CONTROLS, id);
  1485. setAttribute(next, ARIA_CONTROLS, id);
  1486. arrows.prev = prev;
  1487. arrows.next = next;
  1488. listen();
  1489. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1490. } else {
  1491. display(wrapper, options.arrows === false ? "none" : "");
  1492. }
  1493. }
  1494. }
  1495. function destroy() {
  1496. if (created) {
  1497. remove(wrapper);
  1498. } else {
  1499. removeAttribute(prev, ALL_ATTRIBUTES);
  1500. removeAttribute(next, ALL_ATTRIBUTES);
  1501. }
  1502. }
  1503. function listen() {
  1504. var go = Controller.go;
  1505. on([EVENT_MOUNTED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1506. bind(next, "click", function () {
  1507. go(">", true);
  1508. });
  1509. bind(prev, "click", function () {
  1510. go("<", true);
  1511. });
  1512. }
  1513. function createArrows() {
  1514. wrapper = create("div", classes.arrows);
  1515. prev = createArrow(true);
  1516. next = createArrow(false);
  1517. created = true;
  1518. append(wrapper, [prev, next]);
  1519. before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root));
  1520. }
  1521. function createArrow(prev2) {
  1522. 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) + "\" />";
  1523. return parseHtml(arrow);
  1524. }
  1525. function update() {
  1526. var index = Splide2.index;
  1527. var prevIndex = Controller.getPrev();
  1528. var nextIndex = Controller.getNext();
  1529. var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1530. var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1531. prev.disabled = prevIndex < 0;
  1532. next.disabled = nextIndex < 0;
  1533. setAttribute(prev, ARIA_LABEL, prevLabel);
  1534. setAttribute(next, ARIA_LABEL, nextLabel);
  1535. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1536. }
  1537. return {
  1538. arrows: arrows,
  1539. mount: mount,
  1540. destroy: destroy
  1541. };
  1542. }
  1543. function Autoplay(Splide2, Components2, options) {
  1544. var _EventInterface9 = EventInterface(Splide2),
  1545. on = _EventInterface9.on,
  1546. bind = _EventInterface9.bind,
  1547. emit = _EventInterface9.emit;
  1548. var Elements = Components2.Elements;
  1549. var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), update);
  1550. var isPaused = interval.isPaused;
  1551. var hovered;
  1552. var focused;
  1553. var paused;
  1554. function mount() {
  1555. var autoplay = options.autoplay;
  1556. if (autoplay) {
  1557. initButton(true);
  1558. initButton(false);
  1559. listen();
  1560. if (autoplay !== "pause") {
  1561. play();
  1562. }
  1563. }
  1564. }
  1565. function initButton(forPause) {
  1566. var prop = forPause ? "pause" : "play";
  1567. var button = Elements[prop];
  1568. if (button) {
  1569. if (!isHTMLButtonElement(button)) {
  1570. setAttribute(button, ROLE, "button");
  1571. }
  1572. setAttribute(button, ARIA_CONTROLS, Elements.track.id);
  1573. setAttribute(button, ARIA_LABEL, options.i18n[prop]);
  1574. bind(button, "click", forPause ? pause : play);
  1575. }
  1576. }
  1577. function listen() {
  1578. var root = Elements.root;
  1579. if (options.pauseOnHover) {
  1580. bind(root, "mouseenter mouseleave", function (e) {
  1581. hovered = e.type === "mouseenter";
  1582. autoToggle();
  1583. });
  1584. }
  1585. if (options.pauseOnFocus) {
  1586. bind(root, "focusin focusout", function (e) {
  1587. focused = e.type === "focusin";
  1588. autoToggle();
  1589. });
  1590. }
  1591. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1592. }
  1593. function play() {
  1594. if (isPaused() && Components2.Slides.isEnough()) {
  1595. interval.start(!options.resetProgress);
  1596. focused = false;
  1597. hovered = false;
  1598. emit(EVENT_AUTOPLAY_PLAY);
  1599. }
  1600. }
  1601. function pause(manual) {
  1602. if (manual === void 0) {
  1603. manual = true;
  1604. }
  1605. if (!isPaused()) {
  1606. interval.pause();
  1607. emit(EVENT_AUTOPLAY_PAUSE);
  1608. }
  1609. paused = manual;
  1610. }
  1611. function autoToggle() {
  1612. if (!paused) {
  1613. if (!hovered && !focused) {
  1614. play();
  1615. } else {
  1616. pause(false);
  1617. }
  1618. }
  1619. }
  1620. function update(rate) {
  1621. var bar = Elements.bar;
  1622. if (bar) {
  1623. style(bar, {
  1624. width: rate * 100 + "%"
  1625. });
  1626. }
  1627. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1628. }
  1629. return {
  1630. mount: mount,
  1631. destroy: interval.cancel,
  1632. play: play,
  1633. pause: pause,
  1634. isPaused: isPaused
  1635. };
  1636. }
  1637. function Cover(Splide2, Components2, options) {
  1638. var _EventInterface10 = EventInterface(Splide2),
  1639. on = _EventInterface10.on;
  1640. function mount() {
  1641. if (options.cover) {
  1642. on(EVENT_LAZYLOAD_LOADED, function (img, Slide) {
  1643. toggle(true, img, Slide);
  1644. });
  1645. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply.bind(null, true));
  1646. }
  1647. }
  1648. function destroy() {
  1649. apply(false);
  1650. }
  1651. function apply(cover) {
  1652. Components2.Slides.forEach(function (Slide) {
  1653. var img = child(Slide.container || Slide.slide, "img");
  1654. if (img && img.src) {
  1655. toggle(cover, img, Slide);
  1656. }
  1657. });
  1658. }
  1659. function toggle(cover, img, Slide) {
  1660. Slide.rule("background", cover ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
  1661. display(img, cover ? "none" : "");
  1662. }
  1663. return {
  1664. mount: mount,
  1665. destroy: destroy
  1666. };
  1667. }
  1668. var BOUNCE_DIFF_THRESHOLD = 10;
  1669. var BOUNCE_DURATION = 600;
  1670. var FRICTION_FACTOR = 0.6;
  1671. var BASE_VELOCITY = 1.5;
  1672. var MIN_DURATION = 800;
  1673. function Scroll(Splide2, Components2, options) {
  1674. var _EventInterface11 = EventInterface(Splide2),
  1675. on = _EventInterface11.on,
  1676. emit = _EventInterface11.emit;
  1677. var Move = Components2.Move;
  1678. var getPosition = Move.getPosition,
  1679. getLimit = Move.getLimit,
  1680. exceededLimit = Move.exceededLimit;
  1681. var interval;
  1682. function mount() {
  1683. on(EVENT_MOVE, clear);
  1684. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1685. }
  1686. function scroll(destination, duration, suppressConstraint) {
  1687. var start = getPosition();
  1688. var friction = 1;
  1689. duration = duration || computeDuration(abs(destination - start));
  1690. clear();
  1691. interval = RequestInterval(duration, onScrolled, function (rate) {
  1692. var position = getPosition();
  1693. var target = start + (destination - start) * easing(rate);
  1694. var diff = (target - getPosition()) * friction;
  1695. Move.translate(position + diff);
  1696. if (Splide2.is(SLIDE) && !suppressConstraint && exceededLimit()) {
  1697. friction *= FRICTION_FACTOR;
  1698. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1699. bounce(exceededLimit(false));
  1700. }
  1701. }
  1702. }, 1);
  1703. emit(EVENT_SCROLL);
  1704. interval.start();
  1705. }
  1706. function bounce(backwards) {
  1707. scroll(getLimit(!backwards), BOUNCE_DURATION, true);
  1708. }
  1709. function onScrolled() {
  1710. emit(EVENT_SCROLLED);
  1711. }
  1712. function computeDuration(distance) {
  1713. return max(distance / BASE_VELOCITY, MIN_DURATION);
  1714. }
  1715. function clear() {
  1716. if (interval) {
  1717. interval.cancel();
  1718. }
  1719. }
  1720. function cancel() {
  1721. if (interval && !interval.isPaused()) {
  1722. clear();
  1723. onScrolled();
  1724. }
  1725. }
  1726. function easing(t) {
  1727. var easingFunc = options.easingFunc;
  1728. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1729. }
  1730. return {
  1731. mount: mount,
  1732. destroy: clear,
  1733. scroll: scroll,
  1734. cancel: cancel
  1735. };
  1736. }
  1737. var FRICTION = 5;
  1738. var LOG_INTERVAL = 50;
  1739. var POINTER_DOWN_EVENTS = "touchstart mousedown";
  1740. var POINTER_MOVE_EVENTS = "touchmove mousemove";
  1741. var POINTER_UP_EVENTS = "touchend touchcancel mouseup mouseleave";
  1742. function Drag(Splide2, Components2, options) {
  1743. var _EventInterface12 = EventInterface(Splide2),
  1744. on = _EventInterface12.on,
  1745. emit = _EventInterface12.emit,
  1746. bind = _EventInterface12.bind,
  1747. unbind = _EventInterface12.unbind;
  1748. var Move = Components2.Move,
  1749. Scroll = Components2.Scroll,
  1750. Controller = Components2.Controller;
  1751. var track = Components2.Elements.track;
  1752. var _Components2$Directio2 = Components2.Direction,
  1753. resolve = _Components2$Directio2.resolve,
  1754. orient = _Components2$Directio2.orient;
  1755. var getPosition = Move.getPosition,
  1756. exceededLimit = Move.exceededLimit;
  1757. var isSlide = Splide2.is(SLIDE);
  1758. var isFade = Splide2.is(FADE);
  1759. var basePosition;
  1760. var baseEvent;
  1761. var prevBaseEvent;
  1762. var lastEvent;
  1763. var isFree;
  1764. var isDragging;
  1765. var isMouse;
  1766. var hasExceeded = false;
  1767. var clickPrevented;
  1768. var disabled;
  1769. var target;
  1770. function mount() {
  1771. bind(track, POINTER_DOWN_EVENTS, onPointerDown, {
  1772. passive: false,
  1773. capture: true
  1774. });
  1775. bind(track, "click", onClick, {
  1776. capture: true
  1777. });
  1778. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1779. }
  1780. function init() {
  1781. var drag = options.drag;
  1782. disable(!drag);
  1783. isFree = drag === "free";
  1784. }
  1785. function onPointerDown(e) {
  1786. if (!disabled) {
  1787. isMouse = e.type === "mousedown";
  1788. if (!isMouse || !e.button) {
  1789. if (!Move.isBusy()) {
  1790. target = isMouse ? window : track;
  1791. prevBaseEvent = null;
  1792. lastEvent = null;
  1793. clickPrevented = false;
  1794. bind(target, POINTER_MOVE_EVENTS, onPointerMove);
  1795. bind(target, POINTER_UP_EVENTS, onPointerUp);
  1796. Move.cancel();
  1797. Scroll.cancel();
  1798. save(e);
  1799. } else {
  1800. prevent(e, true);
  1801. }
  1802. }
  1803. }
  1804. }
  1805. function onPointerMove(e) {
  1806. if (!lastEvent) {
  1807. clickPrevented = true;
  1808. emit(EVENT_DRAG);
  1809. }
  1810. lastEvent = e;
  1811. if (e.cancelable) {
  1812. if (isDragging) {
  1813. var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
  1814. var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
  1815. if (expired || exceeded) {
  1816. save(e);
  1817. }
  1818. if (!isFade) {
  1819. Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
  1820. }
  1821. emit(EVENT_DRAGGING);
  1822. prevent(e);
  1823. } else {
  1824. var threshold = options.dragMinThreshold || 15;
  1825. isDragging = isMouse || abs(coordOf(e) - coordOf(baseEvent)) > threshold;
  1826. if (isSliderDirection()) {
  1827. prevent(e);
  1828. }
  1829. }
  1830. }
  1831. }
  1832. function onPointerUp(e) {
  1833. unbind(target, POINTER_MOVE_EVENTS + " " + POINTER_UP_EVENTS);
  1834. if (lastEvent) {
  1835. if (isDragging || e.cancelable && isSliderDirection()) {
  1836. var velocity = computeVelocity(e);
  1837. var destination = computeDestination(velocity);
  1838. if (isFree) {
  1839. Scroll.scroll(destination);
  1840. } else if (isFade) {
  1841. Controller.go(Splide2.index + orient(sign(velocity)));
  1842. } else {
  1843. Controller.go(computeIndex(destination), true);
  1844. }
  1845. prevent(e);
  1846. }
  1847. emit(EVENT_DRAGGED);
  1848. }
  1849. isDragging = false;
  1850. }
  1851. function save(e) {
  1852. prevBaseEvent = baseEvent;
  1853. baseEvent = e;
  1854. basePosition = getPosition();
  1855. }
  1856. function onClick(e) {
  1857. if (!disabled && clickPrevented) {
  1858. prevent(e, true);
  1859. }
  1860. }
  1861. function isSliderDirection() {
  1862. var diffX = abs(coordOf(lastEvent) - coordOf(baseEvent));
  1863. var diffY = abs(coordOf(lastEvent, true) - coordOf(baseEvent, true));
  1864. return diffX > diffY;
  1865. }
  1866. function computeVelocity(e) {
  1867. if (Splide2.is(LOOP) || !hasExceeded) {
  1868. var base = baseEvent === lastEvent && prevBaseEvent || baseEvent;
  1869. var diffCoord = coordOf(lastEvent) - coordOf(base);
  1870. var diffTime = timeOf(e) - timeOf(base);
  1871. var isFlick = timeOf(e) - timeOf(lastEvent) < LOG_INTERVAL;
  1872. if (diffTime && isFlick) {
  1873. return diffCoord / diffTime;
  1874. }
  1875. }
  1876. return 0;
  1877. }
  1878. function computeDestination(velocity) {
  1879. return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
  1880. }
  1881. function computeIndex(destination) {
  1882. var dest = Move.toIndex(destination);
  1883. return isSlide ? clamp(dest, 0, Controller.getEnd()) : dest;
  1884. }
  1885. function coordOf(e, orthogonal) {
  1886. var prop = "page" + resolve(orthogonal ? "Y" : "X");
  1887. return (isMouse ? e : e.touches[0])[prop];
  1888. }
  1889. function timeOf(e) {
  1890. return e.timeStamp;
  1891. }
  1892. function constrain(diff) {
  1893. return diff / (hasExceeded && isSlide ? FRICTION : 1);
  1894. }
  1895. function disable(value) {
  1896. disabled = value;
  1897. }
  1898. return {
  1899. mount: mount,
  1900. disable: disable
  1901. };
  1902. }
  1903. var IE_ARROW_KEYS = ["Left", "Right", "Up", "Down"];
  1904. function Keyboard(Splide2, Components2, options) {
  1905. var _EventInterface13 = EventInterface(Splide2),
  1906. on = _EventInterface13.on,
  1907. bind = _EventInterface13.bind,
  1908. unbind = _EventInterface13.unbind;
  1909. var root = Components2.Elements.root;
  1910. var resolve = Components2.Direction.resolve;
  1911. var target;
  1912. function mount() {
  1913. init();
  1914. on(EVENT_UPDATED, function () {
  1915. destroy();
  1916. init();
  1917. });
  1918. }
  1919. function init() {
  1920. var _options$keyboard = options.keyboard,
  1921. keyboard = _options$keyboard === void 0 ? "global" : _options$keyboard;
  1922. if (keyboard) {
  1923. if (keyboard === "focused") {
  1924. target = root;
  1925. setAttribute(root, TAB_INDEX, 0);
  1926. } else {
  1927. target = window;
  1928. }
  1929. bind(target, "keydown", onKeydown);
  1930. }
  1931. }
  1932. function destroy() {
  1933. unbind(target, "keydown");
  1934. if (isHTMLElement(target)) {
  1935. removeAttribute(target, TAB_INDEX);
  1936. }
  1937. }
  1938. function onKeydown(e) {
  1939. var key = e.key;
  1940. var normalizedKey = includes(IE_ARROW_KEYS, key) ? "Arrow" + key : key;
  1941. if (normalizedKey === resolve("ArrowLeft")) {
  1942. Splide2.go("<");
  1943. } else if (normalizedKey === resolve("ArrowRight")) {
  1944. Splide2.go(">");
  1945. }
  1946. }
  1947. return {
  1948. mount: mount,
  1949. destroy: destroy
  1950. };
  1951. }
  1952. var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
  1953. var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
  1954. var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
  1955. function LazyLoad(Splide2, Components2, options) {
  1956. var _EventInterface14 = EventInterface(Splide2),
  1957. on = _EventInterface14.on,
  1958. off = _EventInterface14.off,
  1959. bind = _EventInterface14.bind,
  1960. emit = _EventInterface14.emit;
  1961. var isSequential = options.lazyLoad === "sequential";
  1962. var images = [];
  1963. var index = 0;
  1964. function mount() {
  1965. if (options.lazyLoad) {
  1966. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  1967. destroy();
  1968. init();
  1969. });
  1970. if (!isSequential) {
  1971. on([EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED], observe);
  1972. }
  1973. }
  1974. }
  1975. function init() {
  1976. Components2.Slides.forEach(function (_Slide) {
  1977. queryAll(_Slide.slide, IMAGE_SELECTOR).forEach(function (_img) {
  1978. var src = getAttribute(_img, SRC_DATA_ATTRIBUTE);
  1979. var srcset = getAttribute(_img, SRCSET_DATA_ATTRIBUTE);
  1980. if (src !== _img.src || srcset !== _img.srcset) {
  1981. var _spinner = create("span", options.classes.spinner, _img.parentElement);
  1982. setAttribute(_spinner, ROLE, "presentation");
  1983. images.push({
  1984. _img: _img,
  1985. _Slide: _Slide,
  1986. src: src,
  1987. srcset: srcset,
  1988. _spinner: _spinner
  1989. });
  1990. display(_img, "none");
  1991. }
  1992. });
  1993. });
  1994. if (isSequential) {
  1995. loadNext();
  1996. }
  1997. }
  1998. function destroy() {
  1999. index = 0;
  2000. images = [];
  2001. }
  2002. function observe() {
  2003. images = images.filter(function (data) {
  2004. if (data._Slide.isWithin(Splide2.index, options.perPage * ((options.preloadPages || 1) + 1))) {
  2005. return load(data);
  2006. }
  2007. return true;
  2008. });
  2009. if (!images.length) {
  2010. off(EVENT_MOVED);
  2011. }
  2012. }
  2013. function load(data) {
  2014. var _img = data._img;
  2015. addClass(data._Slide.slide, CLASS_LOADING);
  2016. bind(_img, "load error", function (e) {
  2017. onLoad(data, e.type === "error");
  2018. });
  2019. ["src", "srcset"].forEach(function (name) {
  2020. if (data[name]) {
  2021. setAttribute(_img, name, data[name]);
  2022. removeAttribute(_img, name === "src" ? SRC_DATA_ATTRIBUTE : SRCSET_DATA_ATTRIBUTE);
  2023. }
  2024. });
  2025. }
  2026. function onLoad(data, error) {
  2027. var _Slide = data._Slide;
  2028. removeClass(_Slide.slide, CLASS_LOADING);
  2029. if (!error) {
  2030. remove(data._spinner);
  2031. display(data._img, "");
  2032. emit(EVENT_LAZYLOAD_LOADED, data._img, _Slide);
  2033. emit(EVENT_RESIZE);
  2034. }
  2035. if (isSequential) {
  2036. loadNext();
  2037. }
  2038. }
  2039. function loadNext() {
  2040. if (index < images.length) {
  2041. load(images[index++]);
  2042. }
  2043. }
  2044. return {
  2045. mount: mount,
  2046. destroy: destroy
  2047. };
  2048. }
  2049. function Pagination(Splide2, Components2, options) {
  2050. var _EventInterface15 = EventInterface(Splide2),
  2051. on = _EventInterface15.on,
  2052. emit = _EventInterface15.emit,
  2053. bind = _EventInterface15.bind,
  2054. unbind = _EventInterface15.unbind;
  2055. var Slides = Components2.Slides,
  2056. Elements = Components2.Elements,
  2057. Controller = Components2.Controller;
  2058. var hasFocus = Controller.hasFocus,
  2059. getIndex = Controller.getIndex;
  2060. var items = [];
  2061. var list;
  2062. function mount() {
  2063. init();
  2064. on([EVENT_UPDATED, EVENT_REFRESH], init);
  2065. on([EVENT_MOVE, EVENT_SCROLLED], update);
  2066. }
  2067. function init() {
  2068. destroy();
  2069. if (options.pagination && Slides.isEnough()) {
  2070. createPagination();
  2071. emit(EVENT_PAGINATION_MOUNTED, {
  2072. list: list,
  2073. items: items
  2074. }, getAt(Splide2.index));
  2075. update();
  2076. }
  2077. }
  2078. function destroy() {
  2079. if (list) {
  2080. remove(list);
  2081. items.forEach(function (item) {
  2082. unbind(item.button, "click");
  2083. });
  2084. empty(items);
  2085. list = null;
  2086. }
  2087. }
  2088. function createPagination() {
  2089. var length = Splide2.length;
  2090. var classes = options.classes,
  2091. i18n = options.i18n,
  2092. perPage = options.perPage;
  2093. var parent = options.pagination === "slider" && Elements.slider || Elements.root;
  2094. var max = hasFocus() ? length : ceil(length / perPage);
  2095. list = create("ul", classes.pagination, parent);
  2096. for (var i = 0; i < max; i++) {
  2097. var li = create("li", null, list);
  2098. var button = create("button", {
  2099. class: classes.page,
  2100. type: "button"
  2101. }, li);
  2102. var controls = Slides.getIn(i).map(function (Slide) {
  2103. return Slide.slide.id;
  2104. });
  2105. var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2106. bind(button, "click", onClick.bind(null, i));
  2107. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2108. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2109. items.push({
  2110. li: li,
  2111. button: button,
  2112. page: i
  2113. });
  2114. }
  2115. }
  2116. function onClick(page) {
  2117. Controller.go(">" + page, true, function () {
  2118. var Slide = Slides.getAt(Controller.toIndex(page));
  2119. Slide && Slide.slide.focus();
  2120. });
  2121. }
  2122. function getAt(index) {
  2123. return items[Controller.toPage(index)];
  2124. }
  2125. function update() {
  2126. var prev = getAt(getIndex(true));
  2127. var curr = getAt(getIndex());
  2128. if (prev) {
  2129. removeClass(prev.button, CLASS_ACTIVE);
  2130. removeAttribute(prev.button, ARIA_CURRENT);
  2131. }
  2132. if (curr) {
  2133. addClass(curr.button, CLASS_ACTIVE);
  2134. setAttribute(curr.button, ARIA_CURRENT, true);
  2135. }
  2136. emit(EVENT_PAGINATION_UPDATED, {
  2137. list: list,
  2138. items: items
  2139. }, prev, curr);
  2140. }
  2141. return {
  2142. items: items,
  2143. mount: mount,
  2144. destroy: destroy,
  2145. getAt: getAt
  2146. };
  2147. }
  2148. var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
  2149. function Sync(Splide2, Components2, options) {
  2150. var splides = Splide2.splides;
  2151. var list = Components2.Elements.list;
  2152. function mount() {
  2153. if (options.isNavigation) {
  2154. navigate();
  2155. } else {
  2156. sync();
  2157. }
  2158. }
  2159. function destroy() {
  2160. removeAttribute(list, ALL_ATTRIBUTES);
  2161. }
  2162. function sync() {
  2163. var processed = [];
  2164. splides.concat(Splide2).forEach(function (splide, index, instances) {
  2165. EventInterface(splide).on(EVENT_MOVE, function (index2, prev, dest) {
  2166. instances.forEach(function (instance) {
  2167. if (instance !== splide && !includes(processed, splide)) {
  2168. processed.push(instance);
  2169. instance.go(instance.is(LOOP) ? dest : index2);
  2170. }
  2171. });
  2172. empty(processed);
  2173. });
  2174. });
  2175. }
  2176. function navigate() {
  2177. var _EventInterface16 = EventInterface(Splide2),
  2178. on = _EventInterface16.on,
  2179. emit = _EventInterface16.emit;
  2180. on(EVENT_CLICK, onClick);
  2181. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2182. emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2183. setAttribute(list, ROLE, "menu");
  2184. setAttribute(list, ARIA_ORIENTATION, options.direction !== TTB ? "horizontal" : null);
  2185. }
  2186. function onClick(Slide) {
  2187. Splide2.go(Slide.index);
  2188. }
  2189. function onKeydown(Slide, e) {
  2190. if (includes(TRIGGER_KEYS, e.key)) {
  2191. onClick(Slide);
  2192. prevent(e);
  2193. }
  2194. }
  2195. return {
  2196. mount: mount,
  2197. destroy: destroy
  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. passive: false,
  2207. capture: true
  2208. });
  2209. }
  2210. }
  2211. function onWheel(e) {
  2212. var deltaY = e.deltaY;
  2213. if (deltaY) {
  2214. Splide2.go(deltaY < 0 ? "<" : ">");
  2215. prevent(e);
  2216. }
  2217. }
  2218. return {
  2219. mount: mount
  2220. };
  2221. }
  2222. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2223. __proto__: null,
  2224. Options: Options,
  2225. Direction: Direction,
  2226. Elements: Elements,
  2227. Style: Style,
  2228. Slides: Slides,
  2229. Clones: Clones,
  2230. Layout: Layout,
  2231. Move: Move,
  2232. Controller: Controller,
  2233. Arrows: Arrows,
  2234. Autoplay: Autoplay,
  2235. Cover: Cover,
  2236. Scroll: Scroll,
  2237. Drag: Drag,
  2238. Keyboard: Keyboard,
  2239. LazyLoad: LazyLoad,
  2240. Pagination: Pagination,
  2241. Sync: Sync,
  2242. Wheel: Wheel
  2243. });
  2244. var I18N = {
  2245. prev: "Previous slide",
  2246. next: "Next slide",
  2247. first: "Go to first slide",
  2248. last: "Go to last slide",
  2249. slideX: "Go to slide %s",
  2250. pageX: "Go to page %s",
  2251. play: "Start autoplay",
  2252. pause: "Pause autoplay"
  2253. };
  2254. var DEFAULTS = {
  2255. type: "slide",
  2256. speed: 400,
  2257. waitForTransition: true,
  2258. perPage: 1,
  2259. arrows: true,
  2260. pagination: true,
  2261. interval: 5e3,
  2262. pauseOnHover: true,
  2263. pauseOnFocus: true,
  2264. resetProgress: true,
  2265. easing: "cubic-bezier(.42,.65,.27,.99)",
  2266. drag: true,
  2267. direction: "ltr",
  2268. slideFocus: true,
  2269. trimSpace: true,
  2270. focusableNodes: "a, button, textarea, input, select, iframe",
  2271. classes: CLASSES,
  2272. i18n: I18N
  2273. };
  2274. function Fade(Splide2, Components2, options) {
  2275. var _EventInterface18 = EventInterface(Splide2),
  2276. on = _EventInterface18.on;
  2277. var ruleBy = Components2.Style.ruleBy;
  2278. function mount() {
  2279. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2280. nextTick(function () {
  2281. Components2.Slides.forEach(function (Slide) {
  2282. ruleBy(Slide.slide, "transition", "opacity " + options.speed + "ms " + options.easing);
  2283. });
  2284. });
  2285. });
  2286. }
  2287. function start(index, done) {
  2288. var track = Components2.Elements.track;
  2289. ruleBy(track, "height", unit(rect(track).height));
  2290. nextTick(function () {
  2291. done();
  2292. ruleBy(track, "height", "");
  2293. });
  2294. }
  2295. return {
  2296. mount: mount,
  2297. start: start,
  2298. cancel: noop
  2299. };
  2300. }
  2301. function Slide(Splide2, Components2, options) {
  2302. var _EventInterface19 = EventInterface(Splide2),
  2303. bind = _EventInterface19.bind;
  2304. var Move = Components2.Move,
  2305. Controller = Components2.Controller;
  2306. var list = Components2.Elements.list;
  2307. var endCallback;
  2308. function mount() {
  2309. bind(list, "transitionend", function (e) {
  2310. if (e.target === list && endCallback) {
  2311. cancel();
  2312. endCallback();
  2313. }
  2314. });
  2315. }
  2316. function start(index, done) {
  2317. var destination = Move.toPosition(index, true);
  2318. var position = Move.getPosition();
  2319. var speed = getSpeed(index);
  2320. if (abs(destination - position) >= 1 && speed >= 1) {
  2321. apply("transform " + speed + "ms " + options.easing);
  2322. Move.translate(destination);
  2323. endCallback = done;
  2324. } else {
  2325. Move.jump(index);
  2326. done();
  2327. }
  2328. }
  2329. function cancel() {
  2330. apply("");
  2331. }
  2332. function getSpeed(index) {
  2333. var rewindSpeed = options.rewindSpeed;
  2334. if (Splide2.is(SLIDE) && rewindSpeed) {
  2335. var prev = Controller.getIndex(true);
  2336. var end = Controller.getEnd();
  2337. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2338. return rewindSpeed;
  2339. }
  2340. }
  2341. return options.speed;
  2342. }
  2343. function apply(transition) {
  2344. Components2.Style.ruleBy(list, "transition", transition);
  2345. }
  2346. return {
  2347. mount: mount,
  2348. start: start,
  2349. cancel: cancel
  2350. };
  2351. }
  2352. var _Splide = /*#__PURE__*/function () {
  2353. function _Splide(target, options) {
  2354. this.event = EventBus();
  2355. this.Components = {};
  2356. this.state = State(CREATED);
  2357. this.splides = [];
  2358. this._options = {};
  2359. this._Extensions = {};
  2360. var root = isString(target) ? query(document, target) : target;
  2361. assert(root, root + " is invalid.");
  2362. this.root = root;
  2363. merge(DEFAULTS, _Splide.defaults);
  2364. merge(merge(this._options, DEFAULTS), options || {});
  2365. }
  2366. var _proto = _Splide.prototype;
  2367. _proto.mount = function mount(Extensions, Transition) {
  2368. var _this3 = this;
  2369. var state = this.state,
  2370. Components2 = this.Components;
  2371. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2372. state.set(CREATED);
  2373. this._Components = Components2;
  2374. this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
  2375. this._Extensions = Extensions || this._Extensions;
  2376. var Constructors = assign({}, ComponentConstructors, this._Extensions, {
  2377. Transition: this._Transition
  2378. });
  2379. forOwn(Constructors, function (Component, key) {
  2380. var component = Component(_this3, Components2, _this3._options);
  2381. Components2[key] = component;
  2382. component.setup && component.setup();
  2383. });
  2384. forOwn(Components2, function (component) {
  2385. component.mount && component.mount();
  2386. });
  2387. this.emit(EVENT_MOUNTED);
  2388. addClass(this.root, CLASS_INITIALIZED);
  2389. state.set(IDLE);
  2390. this.emit(EVENT_READY);
  2391. return this;
  2392. };
  2393. _proto.sync = function sync(splide) {
  2394. this.splides.push(splide);
  2395. splide.splides.push(this);
  2396. return this;
  2397. };
  2398. _proto.go = function go(control) {
  2399. this._Components.Controller.go(control);
  2400. return this;
  2401. };
  2402. _proto.on = function on(events, callback) {
  2403. this.event.on(events, callback, null, DEFAULT_USER_EVENT_PRIORITY);
  2404. return this;
  2405. };
  2406. _proto.off = function off(events) {
  2407. this.event.off(events);
  2408. return this;
  2409. };
  2410. _proto.emit = function emit(event) {
  2411. var _this$event;
  2412. (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1)));
  2413. return this;
  2414. };
  2415. _proto.add = function add(slides, index) {
  2416. this._Components.Slides.add(slides, index);
  2417. return this;
  2418. };
  2419. _proto.remove = function remove(matcher) {
  2420. this._Components.Slides.remove(matcher);
  2421. return this;
  2422. };
  2423. _proto.is = function is(type) {
  2424. return this._options.type === type;
  2425. };
  2426. _proto.refresh = function refresh() {
  2427. this.emit(EVENT_REFRESH);
  2428. return this;
  2429. };
  2430. _proto.destroy = function destroy(completely) {
  2431. var event = this.event,
  2432. state = this.state;
  2433. if (state.is(CREATED)) {
  2434. event.on(EVENT_READY, this.destroy.bind(this, completely), this);
  2435. } else {
  2436. forOwn(this._Components, function (component) {
  2437. component.destroy && component.destroy(completely);
  2438. });
  2439. event.emit(EVENT_DESTROY);
  2440. event.destroy();
  2441. empty(this.splides);
  2442. state.set(DESTROYED);
  2443. }
  2444. return this;
  2445. };
  2446. _createClass(_Splide, [{
  2447. key: "options",
  2448. get: function get() {
  2449. return this._options;
  2450. },
  2451. set: function set(options) {
  2452. var _options = this._options;
  2453. merge(_options, options);
  2454. if (!this.state.is(CREATED)) {
  2455. this.emit(EVENT_UPDATED, _options);
  2456. }
  2457. }
  2458. }, {
  2459. key: "length",
  2460. get: function get() {
  2461. return this._Components.Slides.getLength(true);
  2462. }
  2463. }, {
  2464. key: "index",
  2465. get: function get() {
  2466. return this._Components.Controller.getIndex();
  2467. }
  2468. }]);
  2469. return _Splide;
  2470. }();
  2471. var Splide = _Splide;
  2472. Splide.defaults = {};
  2473. Splide.STATES = STATES;
  2474. return Splide;
  2475. });
  2476. //# sourceMappingURL=splide.js.map