splide.js 71 KB

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