splide.js 75 KB

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