splide.cjs.js 88 KB

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