splide.js 71 KB

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