splide.js 75 KB

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