splide.cjs.js 87 KB

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