splide.cjs.js 86 KB

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