splide.js 75 KB

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