splide.cjs.js 88 KB

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