splide.cjs.js 87 KB

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