splide.cjs.js 86 KB

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