splide.cjs.js 87 KB

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