splide.cjs.js 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016
  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. Transition.cancel();
  1175. if (dest !== index && canShift(dest > prev)) {
  1176. translate(shift(getPosition(), dest > prev), true);
  1177. }
  1178. indices = [index, prev, dest];
  1179. set(MOVING);
  1180. emit(EVENT_MOVE, index, prev, dest);
  1181. Transition.start(index, () => {
  1182. set(IDLE);
  1183. emit(EVENT_MOVED, index, prev, dest);
  1184. callback && callback();
  1185. });
  1186. }
  1187. function jump(index) {
  1188. translate(toPosition(index));
  1189. }
  1190. function translate(position, preventLoop) {
  1191. if (!Splide.is(FADE)) {
  1192. const destination = preventLoop ? position : loop(position);
  1193. style(list, "transform", `translate${resolve("X")}(${destination}px)`);
  1194. position !== destination && emit(EVENT_SHIFTED);
  1195. }
  1196. }
  1197. function loop(position) {
  1198. if (Splide.is(LOOP)) {
  1199. const diff = orient(position) - orient(getPosition());
  1200. if (diff && exceededLimit(diff > 0, position)) {
  1201. position = shift(position, diff > 0);
  1202. }
  1203. }
  1204. return position;
  1205. }
  1206. function shift(position, backwards) {
  1207. const excess = position - getLimit(backwards);
  1208. const size = sliderSize();
  1209. position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1);
  1210. return position;
  1211. }
  1212. function cancel() {
  1213. if (Splide.state.is(MOVING) && indices) {
  1214. translate(getPosition(), true);
  1215. Transition.cancel();
  1216. emit(EVENT_MOVED, ...indices);
  1217. }
  1218. }
  1219. function toIndex(position) {
  1220. const slides = Slides.get();
  1221. let index = 0;
  1222. let minDistance = Infinity;
  1223. for (let i = 0; i < slides.length; i++) {
  1224. const slideIndex = slides[i].index;
  1225. const distance = abs(toPosition(slideIndex) - position);
  1226. if (distance <= minDistance) {
  1227. minDistance = distance;
  1228. index = slideIndex;
  1229. } else {
  1230. break;
  1231. }
  1232. }
  1233. return index;
  1234. }
  1235. function toPosition(index) {
  1236. let position = orient(totalSize(index - 1) - offset(index));
  1237. if (options.trimSpace && Splide.is(SLIDE)) {
  1238. position = clamp(position, 0, orient(sliderSize(true) - listSize()));
  1239. }
  1240. return position;
  1241. }
  1242. function getPosition() {
  1243. const left = resolve("left");
  1244. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1245. }
  1246. function getRate() {
  1247. let rate;
  1248. if (Splide.is(FADE)) {
  1249. rate = Splide.index / (Splide.length - 1);
  1250. } else {
  1251. const isLoop = Splide.is(LOOP);
  1252. const position = orient(getPosition());
  1253. const min = orient(getLimit(false));
  1254. const max = orient(getLimit(true));
  1255. const size = sliderSize();
  1256. const curr = (position - min) % size;
  1257. const base = isLoop ? size : max - min;
  1258. rate = curr / base || 0;
  1259. if (isLoop && rate < 0) {
  1260. rate += 1;
  1261. }
  1262. }
  1263. return clamp(rate, 0, 1);
  1264. }
  1265. function offset(index) {
  1266. const { focus } = options;
  1267. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1268. }
  1269. function getLimit(max) {
  1270. return toPosition(max ? Components.Controller.getEnd() : 0);
  1271. }
  1272. function canShift(backwards) {
  1273. const padding = getPadding(false);
  1274. const shifted = orient(shift(getPosition(), backwards));
  1275. return backwards ? shifted >= padding : shifted <= listSize(true) - trackSize() + padding;
  1276. }
  1277. function exceededLimit(max, position = getPosition()) {
  1278. const exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1279. const exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1280. return exceededMin || exceededMax;
  1281. }
  1282. return {
  1283. mount,
  1284. move,
  1285. jump,
  1286. translate,
  1287. shift,
  1288. cancel,
  1289. toIndex,
  1290. toPosition,
  1291. getPosition,
  1292. getRate,
  1293. getLimit,
  1294. exceededLimit,
  1295. reposition,
  1296. canShift
  1297. };
  1298. };
  1299. const Controller = (Splide, Components, options, event) => {
  1300. const { on, emit } = event;
  1301. const { Move, Scroll } = Components;
  1302. const { getPosition, getLimit, toPosition } = Move;
  1303. const { isEnough, getLength } = Components.Slides;
  1304. const { omitEnd } = options;
  1305. const isLoop = Splide.is(LOOP);
  1306. const isSlide = Splide.is(SLIDE);
  1307. const getNext = apply(getAdjacent, false);
  1308. const getPrev = apply(getAdjacent, true);
  1309. let currIndex = options.start || 0;
  1310. let endIndex;
  1311. let prevIndex = currIndex;
  1312. let slideCount;
  1313. let perMove;
  1314. let perPage;
  1315. function mount() {
  1316. init();
  1317. on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init);
  1318. on(EVENT_RESIZED, onResized);
  1319. }
  1320. function init() {
  1321. slideCount = getLength(true);
  1322. perMove = options.perMove;
  1323. perPage = options.perPage;
  1324. endIndex = getEnd();
  1325. const end = omitEnd ? endIndex : slideCount - 1;
  1326. const index = clamp(currIndex, 0, end);
  1327. prevIndex = index;
  1328. if (index !== currIndex) {
  1329. currIndex = index;
  1330. Move.reposition();
  1331. }
  1332. }
  1333. function onResized() {
  1334. if (endIndex !== getEnd()) {
  1335. emit(EVENT_END_INDEX_CHANGED);
  1336. }
  1337. }
  1338. function go(control, allowSameIndex, callback) {
  1339. if (!isBusy()) {
  1340. const dest = parse(control);
  1341. const index = loop(dest);
  1342. const validIndex = index > -1 && (allowSameIndex || index !== currIndex);
  1343. const canMove = dest === index || Move.canShift(dest > prevIndex);
  1344. if (validIndex && canMove) {
  1345. Scroll.cancel();
  1346. setIndex(index);
  1347. Move.move(dest, index, prevIndex, callback);
  1348. }
  1349. }
  1350. }
  1351. function jump(control) {
  1352. const { set } = Components.Breakpoints;
  1353. const { speed } = options;
  1354. set({ speed: 0 });
  1355. go(control);
  1356. set({ speed });
  1357. }
  1358. function scroll(destination, duration, snap, callback) {
  1359. Scroll.scroll(destination, duration, snap, () => {
  1360. const index = loop(Move.toIndex(getPosition()));
  1361. setIndex(omitEnd ? min(index, endIndex) : index);
  1362. callback && callback();
  1363. });
  1364. }
  1365. function parse(control) {
  1366. let index = currIndex;
  1367. if (isString(control)) {
  1368. const [, indicator, number] = control.match(/([+\-<>])(\d+)?/) || [];
  1369. if (indicator === "+" || indicator === "-") {
  1370. index = computeDestIndex(currIndex + +`${indicator}${+number || 1}`, currIndex);
  1371. } else if (indicator === ">") {
  1372. index = number ? toIndex(+number) : getNext(true);
  1373. } else if (indicator === "<") {
  1374. index = getPrev(true);
  1375. }
  1376. } else {
  1377. index = isLoop ? control : clamp(control, 0, endIndex);
  1378. }
  1379. return index;
  1380. }
  1381. function getAdjacent(prev, destination) {
  1382. const number = perMove || (hasFocus() ? 1 : perPage);
  1383. const dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus()));
  1384. if (dest === -1 && isSlide) {
  1385. if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
  1386. return prev ? 0 : endIndex;
  1387. }
  1388. }
  1389. return destination ? dest : loop(dest);
  1390. }
  1391. function computeDestIndex(dest, from, snapPage) {
  1392. if (isEnough() || hasFocus()) {
  1393. const index = computeMovableDestIndex(dest);
  1394. if (index !== dest) {
  1395. from = dest;
  1396. dest = index;
  1397. snapPage = false;
  1398. }
  1399. if (dest < 0 || dest > endIndex) {
  1400. if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) {
  1401. dest = toIndex(toPage(dest));
  1402. } else {
  1403. if (isLoop) {
  1404. dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest;
  1405. } else if (options.rewind) {
  1406. dest = dest < 0 ? endIndex : 0;
  1407. } else {
  1408. dest = -1;
  1409. }
  1410. }
  1411. } else {
  1412. if (snapPage && dest !== from) {
  1413. dest = toIndex(toPage(from) + (dest < from ? -1 : 1));
  1414. }
  1415. }
  1416. } else {
  1417. dest = -1;
  1418. }
  1419. return dest;
  1420. }
  1421. function computeMovableDestIndex(dest) {
  1422. if (isSlide && options.trimSpace === "move" && dest !== currIndex) {
  1423. const position = getPosition();
  1424. while (position === toPosition(dest) && between(dest, 0, Splide.length - 1, !options.rewind)) {
  1425. dest < currIndex ? --dest : ++dest;
  1426. }
  1427. }
  1428. return dest;
  1429. }
  1430. function loop(index) {
  1431. return isLoop ? (index + slideCount) % slideCount || 0 : index;
  1432. }
  1433. function getEnd() {
  1434. let end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage);
  1435. while (omitEnd && end-- > 0) {
  1436. if (toPosition(slideCount - 1) !== toPosition(end)) {
  1437. end++;
  1438. break;
  1439. }
  1440. }
  1441. return clamp(end, 0, slideCount - 1);
  1442. }
  1443. function toIndex(page) {
  1444. return clamp(hasFocus() ? page : perPage * page, 0, endIndex);
  1445. }
  1446. function toPage(index) {
  1447. return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage);
  1448. }
  1449. function toDest(destination) {
  1450. const closest = Move.toIndex(destination);
  1451. return isSlide ? clamp(closest, 0, endIndex) : closest;
  1452. }
  1453. function setIndex(index) {
  1454. if (index !== currIndex) {
  1455. prevIndex = currIndex;
  1456. currIndex = index;
  1457. }
  1458. }
  1459. function getIndex(prev) {
  1460. return prev ? prevIndex : currIndex;
  1461. }
  1462. function hasFocus() {
  1463. return !isUndefined(options.focus) || options.isNavigation;
  1464. }
  1465. function isBusy() {
  1466. return Splide.state.is([MOVING, SCROLLING]) && !!options.waitForTransition;
  1467. }
  1468. return {
  1469. mount,
  1470. go,
  1471. jump,
  1472. scroll,
  1473. getNext,
  1474. getPrev,
  1475. getAdjacent,
  1476. getEnd,
  1477. setIndex,
  1478. getIndex,
  1479. toIndex,
  1480. toPage,
  1481. toDest,
  1482. hasFocus,
  1483. isBusy
  1484. };
  1485. };
  1486. const XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1487. 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";
  1488. const SIZE = 40;
  1489. const Arrows = (Splide, Components, options, event) => {
  1490. const { on, bind, emit } = event;
  1491. const { classes, i18n } = options;
  1492. const { Elements, Controller } = Components;
  1493. const { arrows: placeholder, track } = Elements;
  1494. let wrapper = placeholder;
  1495. let prev = Elements.prev;
  1496. let next = Elements.next;
  1497. let created;
  1498. let wrapperClasses;
  1499. const arrows = {};
  1500. function mount() {
  1501. init();
  1502. on(EVENT_UPDATED, remount);
  1503. }
  1504. function remount() {
  1505. destroy();
  1506. mount();
  1507. }
  1508. function init() {
  1509. const { arrows: enabled = true } = options;
  1510. if (enabled && !(prev && next)) {
  1511. createArrows();
  1512. }
  1513. if (prev && next) {
  1514. assign(arrows, { prev, next });
  1515. display(wrapper, enabled ? "" : "none");
  1516. addClass(wrapper, wrapperClasses = `${CLASS_ARROWS}--${options.direction}`);
  1517. if (enabled) {
  1518. listen();
  1519. update();
  1520. setAttribute([prev, next], ARIA_CONTROLS, track.id);
  1521. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1522. }
  1523. }
  1524. }
  1525. function destroy() {
  1526. event.destroy();
  1527. removeClass(wrapper, wrapperClasses);
  1528. if (created) {
  1529. removeNode(placeholder ? [prev, next] : wrapper);
  1530. prev = next = null;
  1531. } else {
  1532. removeAttribute([prev, next], ALL_ATTRIBUTES);
  1533. }
  1534. }
  1535. function listen() {
  1536. on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update);
  1537. bind(next, "click", apply(go, ">"));
  1538. bind(prev, "click", apply(go, "<"));
  1539. }
  1540. function go(control) {
  1541. Controller.go(control, true);
  1542. }
  1543. function createArrows() {
  1544. wrapper = placeholder || create("div", classes.arrows);
  1545. prev = createArrow(true);
  1546. next = createArrow(false);
  1547. created = true;
  1548. append(wrapper, prev, next);
  1549. !placeholder && before(track, wrapper);
  1550. }
  1551. function createArrow(prev2) {
  1552. 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}" />`;
  1553. return parseHtml(arrow);
  1554. }
  1555. function update() {
  1556. if (prev && next) {
  1557. const index = Splide.index;
  1558. const prevIndex = Controller.getPrev();
  1559. const nextIndex = Controller.getNext();
  1560. const prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1561. const nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1562. prev.disabled = prevIndex < 0;
  1563. next.disabled = nextIndex < 0;
  1564. setAttribute(prev, ARIA_LABEL, prevLabel);
  1565. setAttribute(next, ARIA_LABEL, nextLabel);
  1566. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1567. }
  1568. }
  1569. return {
  1570. arrows,
  1571. mount,
  1572. destroy,
  1573. update
  1574. };
  1575. };
  1576. const INTERVAL_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-interval`;
  1577. const Autoplay = (Splide, Components, options, event) => {
  1578. const { on, bind, emit } = event;
  1579. const { interval: duration = 5e3, pauseOnHover = true, pauseOnFocus = true, resetProgress = true } = options;
  1580. const interval = RequestInterval(duration, Splide.go.bind(Splide, ">"), onAnimationFrame);
  1581. const { isPaused } = interval;
  1582. const { Elements, Elements: { root, toggle } } = Components;
  1583. const { autoplay } = options;
  1584. let hovered;
  1585. let focused;
  1586. let stopped = autoplay === "pause";
  1587. function mount() {
  1588. if (autoplay) {
  1589. listen();
  1590. toggle && setAttribute(toggle, ARIA_CONTROLS, Elements.track.id);
  1591. stopped || play();
  1592. update();
  1593. }
  1594. }
  1595. function listen() {
  1596. if (pauseOnHover) {
  1597. bind(root, "mouseenter mouseleave", (e) => {
  1598. hovered = e.type === "mouseenter";
  1599. autoToggle();
  1600. });
  1601. }
  1602. if (pauseOnFocus) {
  1603. bind(root, "focusin focusout", (e) => {
  1604. focused = e.type === "focusin";
  1605. autoToggle();
  1606. });
  1607. }
  1608. if (toggle) {
  1609. bind(toggle, "click", () => {
  1610. stopped ? play() : pause(true);
  1611. });
  1612. }
  1613. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1614. on(EVENT_MOVE, onMove);
  1615. }
  1616. function play() {
  1617. if (isPaused() && Components.Slides.isEnough()) {
  1618. interval.start(!resetProgress);
  1619. focused = hovered = stopped = false;
  1620. update();
  1621. emit(EVENT_AUTOPLAY_PLAY);
  1622. }
  1623. }
  1624. function pause(stop = true) {
  1625. stopped = !!stop;
  1626. update();
  1627. if (!isPaused()) {
  1628. interval.pause();
  1629. emit(EVENT_AUTOPLAY_PAUSE);
  1630. }
  1631. }
  1632. function autoToggle() {
  1633. if (!stopped) {
  1634. hovered || focused ? pause(false) : play();
  1635. }
  1636. }
  1637. function update() {
  1638. if (toggle) {
  1639. toggleClass(toggle, CLASS_ACTIVE, !stopped);
  1640. setAttribute(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]);
  1641. }
  1642. }
  1643. function onAnimationFrame(rate) {
  1644. const { bar } = Elements;
  1645. bar && style(bar, "width", `${rate * 100}%`);
  1646. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1647. }
  1648. function onMove(index) {
  1649. const Slide = Components.Slides.getAt(index);
  1650. interval.set(Slide && +getAttribute(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval);
  1651. }
  1652. return {
  1653. mount,
  1654. destroy: interval.cancel,
  1655. play,
  1656. pause,
  1657. isPaused
  1658. };
  1659. };
  1660. const BOUNCE_DIFF_THRESHOLD = 10;
  1661. const BOUNCE_DURATION = 600;
  1662. const FRICTION_FACTOR = 0.6;
  1663. const BASE_VELOCITY = 1.5;
  1664. const MIN_DURATION = 800;
  1665. const Scroll = (Splide, Components, options, event) => {
  1666. const { on, emit } = event;
  1667. const { state: { set } } = Splide;
  1668. const { Move } = Components;
  1669. const { getPosition, getLimit, exceededLimit, translate } = Move;
  1670. const isSlide = Splide.is(SLIDE);
  1671. let interval;
  1672. let callback;
  1673. let friction = 1;
  1674. function mount() {
  1675. on(EVENT_MOVE, clear);
  1676. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1677. }
  1678. function scroll(destination, duration, snap, onScrolled, noConstrain) {
  1679. clear();
  1680. const dest = computeDestination(destination, snap);
  1681. const from = getPosition();
  1682. const immediately = approximatelyEqual(from, dest, 1) || duration === 0;
  1683. friction = 1;
  1684. duration = immediately ? 0 : duration || max(abs(dest - from) / BASE_VELOCITY, MIN_DURATION);
  1685. callback = onScrolled;
  1686. interval = RequestInterval(duration, onEnd, apply(update, from, dest, noConstrain), 1);
  1687. set(SCROLLING);
  1688. emit(EVENT_SCROLL);
  1689. interval.start();
  1690. }
  1691. function computeDestination(destination, snap) {
  1692. if (snap) {
  1693. if (!isSlide || !exceededLimit()) {
  1694. const position = destination % Components.Layout.sliderSize();
  1695. const snapped = Move.toPosition(Components.Controller.toDest(position));
  1696. destination -= position - snapped;
  1697. }
  1698. }
  1699. return destination;
  1700. }
  1701. function onEnd() {
  1702. set(IDLE);
  1703. callback && callback();
  1704. emit(EVENT_SCROLLED);
  1705. }
  1706. function update(from, to, noConstrain, rate) {
  1707. const { easingFunc = (t) => 1 - Math.pow(1 - t, 4) } = options;
  1708. const position = getPosition();
  1709. const target = from + (to - from) * easingFunc(rate);
  1710. const diff = (target - position) * friction;
  1711. translate(position + diff);
  1712. emit(EVENT_SCROLLING);
  1713. if (isSlide && !noConstrain && exceededLimit()) {
  1714. friction *= FRICTION_FACTOR;
  1715. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1716. scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true);
  1717. }
  1718. }
  1719. }
  1720. function clear() {
  1721. if (interval) {
  1722. interval.cancel();
  1723. }
  1724. }
  1725. function cancel() {
  1726. if (interval && !interval.isPaused()) {
  1727. clear();
  1728. onEnd();
  1729. }
  1730. }
  1731. return {
  1732. mount,
  1733. destroy: clear,
  1734. scroll,
  1735. cancel
  1736. };
  1737. };
  1738. const SCROLL_LISTENER_OPTIONS = { passive: false, capture: true };
  1739. const Drag = (Splide, Components, options, event) => {
  1740. const { on, emit, bind } = event;
  1741. const binder = event.create();
  1742. const { state } = Splide;
  1743. const { Move, Scroll, Controller, Elements: { track }, Breakpoints: { reduce } } = Components;
  1744. const { resolve, orient } = Components.Direction;
  1745. const { getPosition, exceededLimit } = Move;
  1746. let basePosition;
  1747. let baseEvent;
  1748. let prevBaseEvent;
  1749. let isFree;
  1750. let dragging;
  1751. let exceeded = false;
  1752. let clickPrevented;
  1753. let disabled;
  1754. let target;
  1755. function mount() {
  1756. bind(track, POINTER_MOVE_EVENTS, noop, SCROLL_LISTENER_OPTIONS);
  1757. bind(track, POINTER_UP_EVENTS, noop, SCROLL_LISTENER_OPTIONS);
  1758. bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS);
  1759. bind(track, "click", onClick, { capture: true });
  1760. bind(track, "dragstart", prevent);
  1761. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1762. }
  1763. function init() {
  1764. const { drag } = options;
  1765. disable(!drag);
  1766. isFree = drag === "free";
  1767. }
  1768. function onPointerDown(e) {
  1769. clickPrevented = false;
  1770. if (!disabled) {
  1771. const isTouch = isTouchEvent(e);
  1772. if (isDraggable(e.target) && (isTouch || !e.button)) {
  1773. if (!Controller.isBusy()) {
  1774. target = isTouch ? track : window;
  1775. dragging = state.is([MOVING, SCROLLING]);
  1776. prevBaseEvent = null;
  1777. binder.bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS);
  1778. binder.bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS);
  1779. Move.cancel();
  1780. Scroll.cancel();
  1781. save(e);
  1782. } else {
  1783. prevent(e, true);
  1784. }
  1785. }
  1786. }
  1787. }
  1788. function onPointerMove(e) {
  1789. if (!state.is(DRAGGING)) {
  1790. state.set(DRAGGING);
  1791. emit(EVENT_DRAG);
  1792. }
  1793. if (shouldRelease(e)) {
  1794. return onPointerUp(e);
  1795. }
  1796. if (e.cancelable) {
  1797. if (dragging) {
  1798. Move.translate(basePosition + constrain(diffCoord(e)));
  1799. const expired = diffTime(e) > LOG_INTERVAL;
  1800. const hasExceeded = exceeded !== (exceeded = exceededLimit());
  1801. if (expired || hasExceeded) {
  1802. save(e);
  1803. }
  1804. clickPrevented = true;
  1805. emit(EVENT_DRAGGING);
  1806. prevent(e);
  1807. } else if (isSliderDirection(e)) {
  1808. dragging = shouldStart(e);
  1809. prevent(e);
  1810. }
  1811. }
  1812. }
  1813. function onPointerUp(e) {
  1814. if (state.is(DRAGGING)) {
  1815. state.set(IDLE);
  1816. emit(EVENT_DRAGGED);
  1817. }
  1818. if (dragging) {
  1819. move(e);
  1820. prevent(e);
  1821. }
  1822. binder.destroy();
  1823. dragging = false;
  1824. exceeded = false;
  1825. }
  1826. function onClick(e) {
  1827. if (!disabled && clickPrevented) {
  1828. prevent(e, true);
  1829. }
  1830. }
  1831. function save(e) {
  1832. prevBaseEvent = baseEvent;
  1833. baseEvent = e;
  1834. basePosition = getPosition();
  1835. }
  1836. function move(e) {
  1837. const { updateOnDragged = true } = options;
  1838. const velocity = computeVelocity(e);
  1839. const destination = computeDestination(velocity);
  1840. const rewind = options.rewind && options.rewindByDrag;
  1841. const scroll = updateOnDragged ? Controller.scroll : Scroll.scroll;
  1842. reduce(false);
  1843. if (isFree) {
  1844. scroll(destination, void 0, options.snap);
  1845. } else if (Splide.is(FADE)) {
  1846. Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+");
  1847. } else if (Splide.is(SLIDE) && exceeded && rewind) {
  1848. Controller.go(exceededLimit(true) ? ">" : "<");
  1849. } else {
  1850. Controller.go(Controller.toDest(destination), true);
  1851. }
  1852. reduce(true);
  1853. }
  1854. function shouldRelease(e) {
  1855. if (options.releaseTouch && Splide.is(SLIDE) && isTouchEvent(e)) {
  1856. const { index } = Splide;
  1857. const diff = diffCoord(e);
  1858. if (exceededLimit() || index === 0 && diff > 0 || index === Splide.length - 1 && diff < 0) {
  1859. return true;
  1860. }
  1861. }
  1862. return false;
  1863. }
  1864. function shouldStart(e) {
  1865. const { dragMinThreshold: thresholds } = options;
  1866. const isObj = isObject(thresholds);
  1867. const mouse = isObj && thresholds.mouse || 0;
  1868. const touch = (isObj ? thresholds.touch : +thresholds) || 10;
  1869. return abs(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse);
  1870. }
  1871. function isSliderDirection(e) {
  1872. return abs(diffCoord(e)) > abs(diffCoord(e, true));
  1873. }
  1874. function computeVelocity(e) {
  1875. if (Splide.is(LOOP) || !exceeded) {
  1876. const time = diffTime(e);
  1877. if (time && time < LOG_INTERVAL) {
  1878. return diffCoord(e) / time;
  1879. }
  1880. }
  1881. return 0;
  1882. }
  1883. function computeDestination(velocity) {
  1884. return getPosition() + sign(velocity) * min(
  1885. abs(velocity) * (options.flickPower || 600),
  1886. isFree ? Infinity : Components.Layout.listSize() * (options.flickMaxPages || 1)
  1887. );
  1888. }
  1889. function diffCoord(e, orthogonal) {
  1890. return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal);
  1891. }
  1892. function diffTime(e) {
  1893. return timeOf(e) - timeOf(getBaseEvent(e));
  1894. }
  1895. function getBaseEvent(e) {
  1896. return baseEvent === e && prevBaseEvent || baseEvent;
  1897. }
  1898. function coordOf(e, orthogonal) {
  1899. return (isTouchEvent(e) ? e.changedTouches[0] : e)[`page${resolve(orthogonal ? "Y" : "X")}`];
  1900. }
  1901. function constrain(diff) {
  1902. return diff / (exceeded && Splide.is(SLIDE) ? FRICTION : 1);
  1903. }
  1904. function isDraggable(target2) {
  1905. const { noDrag } = options;
  1906. return !matches(target2, `.${CLASS_PAGINATION_PAGE}, .${CLASS_ARROW}`) && (!noDrag || !matches(target2, noDrag));
  1907. }
  1908. function isTouchEvent(e) {
  1909. return typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
  1910. }
  1911. function isDragging() {
  1912. return dragging;
  1913. }
  1914. function disable(value) {
  1915. disabled = value;
  1916. }
  1917. return {
  1918. mount,
  1919. disable,
  1920. isDragging
  1921. };
  1922. };
  1923. const KEYBOARD_EVENT = "keydown";
  1924. const Keyboard = (Splide, Components, options, event) => {
  1925. const { destroy } = event;
  1926. const { resolve } = Components.Direction;
  1927. function mount() {
  1928. const { keyboard } = options;
  1929. destroy();
  1930. keyboard && event.bind(keyboard === "global" ? window : Splide.root, KEYBOARD_EVENT, onKeydown);
  1931. event.on(EVENT_UPDATED, mount);
  1932. }
  1933. function disable(value) {
  1934. value ? destroy() : mount();
  1935. }
  1936. function onKeydown(e) {
  1937. if (e.key === resolve(ARROW_LEFT)) {
  1938. Splide.go("<");
  1939. prevent(e, true);
  1940. } else if (e.key === resolve(ARROW_RIGHT)) {
  1941. Splide.go(">");
  1942. prevent(e, true);
  1943. }
  1944. }
  1945. return {
  1946. mount,
  1947. destroy,
  1948. disable
  1949. };
  1950. };
  1951. const SRC_DATA_ATTRIBUTE = `${DATA_ATTRIBUTE}-lazy`;
  1952. const SRCSET_DATA_ATTRIBUTE = `${SRC_DATA_ATTRIBUTE}-srcset`;
  1953. const IMAGE_SELECTOR = `[${SRC_DATA_ATTRIBUTE}], [${SRCSET_DATA_ATTRIBUTE}]`;
  1954. const LazyLoad = (Splide, Components, options, event) => {
  1955. const { on, off, bind, emit } = event;
  1956. const isSequential = options.lazyLoad === "sequential";
  1957. const events = [EVENT_MOVED, EVENT_SCROLLED];
  1958. let entries = [];
  1959. function mount() {
  1960. if (options.lazyLoad) {
  1961. init();
  1962. on(EVENT_REFRESH, init);
  1963. }
  1964. }
  1965. function init() {
  1966. empty(entries);
  1967. register();
  1968. if (isSequential) {
  1969. loadNext();
  1970. } else {
  1971. off(events);
  1972. on(events, check);
  1973. check();
  1974. }
  1975. }
  1976. function register() {
  1977. Components.Slides.forEach((Slide) => {
  1978. queryAll(Slide.slide, IMAGE_SELECTOR).forEach((img) => {
  1979. const src = getAttribute(img, SRC_DATA_ATTRIBUTE);
  1980. const srcset = getAttribute(img, SRCSET_DATA_ATTRIBUTE);
  1981. if (src !== img.src || srcset !== img.srcset) {
  1982. const parent = img.parentElement;
  1983. const spinner = child(parent, `.${CLASS_SPINNER}`) || create("span", options.classes.spinner, parent);
  1984. entries.push([img, Slide, spinner]);
  1985. img.src || display(img, "none");
  1986. }
  1987. });
  1988. });
  1989. }
  1990. function check() {
  1991. entries = entries.filter((data) => {
  1992. const distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
  1993. return data[1].isWithin(Splide.index, distance) ? load(data) : true;
  1994. });
  1995. entries.length || off(events);
  1996. }
  1997. function load(data) {
  1998. const [img] = data;
  1999. addClass(data[1].slide, CLASS_LOADING);
  2000. bind(img, "load error", apply(onLoad, data));
  2001. setAttribute(img, "src", getAttribute(img, SRC_DATA_ATTRIBUTE));
  2002. setAttribute(img, "srcset", getAttribute(img, SRCSET_DATA_ATTRIBUTE));
  2003. removeAttribute(img, [SRC_DATA_ATTRIBUTE, SRCSET_DATA_ATTRIBUTE]);
  2004. }
  2005. function onLoad(data, e) {
  2006. const [img, Slide] = data;
  2007. removeClass(Slide.slide, CLASS_LOADING);
  2008. if (e.type !== "error") {
  2009. removeNode(data[2]);
  2010. display(img, "");
  2011. emit(EVENT_LAZYLOAD_LOADED, img, Slide);
  2012. emit(EVENT_RESIZE);
  2013. } else {
  2014. emit(EVENT_LAZYLOAD_ERROR, img, Slide);
  2015. }
  2016. isSequential && loadNext();
  2017. }
  2018. function loadNext() {
  2019. entries.length && load(entries.shift());
  2020. }
  2021. return {
  2022. mount,
  2023. destroy: apply(empty, entries),
  2024. check
  2025. };
  2026. };
  2027. const Pagination = (Splide, Components, options, event) => {
  2028. const { on, emit, bind } = event;
  2029. const { Slides, Elements, Controller } = Components;
  2030. const { hasFocus, getIndex, go } = Controller;
  2031. const { resolve } = Components.Direction;
  2032. const { pagination: placeholder } = Elements;
  2033. const items = [];
  2034. let list;
  2035. let paginationClasses;
  2036. function mount() {
  2037. destroy();
  2038. on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount);
  2039. const { pagination: enabled = true } = options;
  2040. placeholder && display(placeholder, enabled ? "" : "none");
  2041. if (enabled) {
  2042. on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update);
  2043. createPagination();
  2044. update();
  2045. emit(EVENT_PAGINATION_MOUNTED, { list, items }, getAt(Splide.index));
  2046. }
  2047. }
  2048. function destroy() {
  2049. if (list) {
  2050. removeNode(placeholder ? slice(list.children) : list);
  2051. removeClass(list, paginationClasses);
  2052. empty(items);
  2053. list = null;
  2054. }
  2055. event.destroy();
  2056. }
  2057. function createPagination() {
  2058. const { length } = Splide;
  2059. const { classes, i18n, perPage, paginationKeyboard = true } = options;
  2060. const max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage);
  2061. const dir = getDirection();
  2062. list = placeholder || create("ul", classes.pagination, Elements.track.parentElement);
  2063. addClass(list, paginationClasses = `${CLASS_PAGINATION}--${dir}`);
  2064. setAttribute(list, ROLE, "tablist");
  2065. setAttribute(list, ARIA_LABEL, i18n.select);
  2066. setAttribute(list, ARIA_ORIENTATION, dir === TTB ? "vertical" : "");
  2067. for (let i = 0; i < max; i++) {
  2068. const li = create("li", null, list);
  2069. const button = create("button", { class: classes.page, type: "button" }, li);
  2070. const controls = Slides.getIn(i).map((Slide) => Slide.slide.id);
  2071. const text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2072. bind(button, "click", () => {
  2073. go(`>${i}`, true);
  2074. });
  2075. paginationKeyboard && bind(button, "keydown", apply(onKeydown, i));
  2076. setAttribute(li, ROLE, "presentation");
  2077. setAttribute(button, ROLE, "tab");
  2078. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2079. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2080. setAttribute(button, TAB_INDEX, -1);
  2081. items.push({ li, button, page: i });
  2082. }
  2083. }
  2084. function onKeydown(page, e) {
  2085. const { length } = items;
  2086. const { key } = e;
  2087. const dir = getDirection();
  2088. let nextPage = -1;
  2089. if (key === resolve(ARROW_RIGHT, false, dir)) {
  2090. nextPage = ++page % length;
  2091. } else if (key === resolve(ARROW_LEFT, false, dir)) {
  2092. nextPage = (--page + length) % length;
  2093. } else if (key === "Home") {
  2094. nextPage = 0;
  2095. } else if (key === "End") {
  2096. nextPage = length - 1;
  2097. }
  2098. const item = items[nextPage];
  2099. if (item) {
  2100. focus(item.button);
  2101. go(`>${nextPage}`);
  2102. prevent(e, true);
  2103. }
  2104. }
  2105. function getDirection() {
  2106. return options.paginationDirection || options.direction;
  2107. }
  2108. function getAt(index) {
  2109. return items[Controller.toPage(index)];
  2110. }
  2111. function update() {
  2112. const prev = getAt(getIndex(true));
  2113. const curr = getAt(getIndex());
  2114. if (prev) {
  2115. const { button } = prev;
  2116. removeClass(button, CLASS_ACTIVE);
  2117. removeAttribute(button, ARIA_SELECTED);
  2118. setAttribute(button, TAB_INDEX, -1);
  2119. }
  2120. if (curr) {
  2121. const { button } = curr;
  2122. addClass(button, CLASS_ACTIVE);
  2123. setAttribute(button, ARIA_SELECTED, true);
  2124. setAttribute(button, TAB_INDEX, "");
  2125. }
  2126. emit(EVENT_PAGINATION_UPDATED, { list, items }, prev, curr);
  2127. }
  2128. return {
  2129. items,
  2130. mount,
  2131. destroy,
  2132. getAt,
  2133. update
  2134. };
  2135. };
  2136. const TRIGGER_KEYS = [" ", "Enter"];
  2137. const Sync = (Splide2, Components, options, event) => {
  2138. const { isNavigation, slideFocus } = options;
  2139. const events = [];
  2140. function mount() {
  2141. Splide2.splides.forEach((target) => {
  2142. if (!target.isParent) {
  2143. sync(Splide2, target.splide);
  2144. sync(target.splide, Splide2);
  2145. }
  2146. });
  2147. if (isNavigation) {
  2148. navigate();
  2149. }
  2150. }
  2151. function destroy() {
  2152. events.forEach((event2) => {
  2153. event2.destroy();
  2154. });
  2155. empty(events);
  2156. }
  2157. function remount() {
  2158. destroy();
  2159. mount();
  2160. }
  2161. function sync(splide, target) {
  2162. const event2 = splide.event.create();
  2163. event2.on(EVENT_MOVE, (index, prev, dest) => {
  2164. target.go(target.is(LOOP) ? dest : index);
  2165. });
  2166. events.push(event2);
  2167. }
  2168. function navigate() {
  2169. const ev = event.create();
  2170. const { on } = ev;
  2171. on(EVENT_CLICK, onClick);
  2172. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2173. on([EVENT_MOUNTED, EVENT_UPDATED], update);
  2174. events.push(ev);
  2175. ev.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2176. }
  2177. function update() {
  2178. setAttribute(
  2179. Components.Elements.list,
  2180. ARIA_ORIENTATION,
  2181. options.direction === TTB ? "vertical" : ""
  2182. );
  2183. }
  2184. function onClick(Slide) {
  2185. Splide2.go(Slide.index);
  2186. }
  2187. function onKeydown(Slide, e) {
  2188. if (includes(TRIGGER_KEYS, e.key)) {
  2189. onClick(Slide);
  2190. prevent(e);
  2191. }
  2192. }
  2193. return {
  2194. setup: apply(
  2195. Components.Breakpoints.set,
  2196. { slideFocus: isUndefined(slideFocus) ? isNavigation : slideFocus },
  2197. true
  2198. ),
  2199. mount,
  2200. destroy,
  2201. remount
  2202. };
  2203. };
  2204. const Wheel = (Splide, Components, options, event) => {
  2205. let lastTime = 0;
  2206. function mount() {
  2207. event.destroy();
  2208. if (options.wheel) {
  2209. event.bind(Components.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS);
  2210. }
  2211. event.on(EVENT_UPDATED, mount);
  2212. }
  2213. function onWheel(e) {
  2214. if (e.cancelable) {
  2215. const delta = parse(e);
  2216. const backwards = delta < 0;
  2217. const timeStamp = timeOf(e);
  2218. const min = options.wheelMinThreshold || 0;
  2219. const sleep = options.wheelSleep || 0;
  2220. if (abs(delta) > min && timeStamp - lastTime > sleep) {
  2221. Splide.go(delta < 0 ? "<" : ">");
  2222. lastTime = timeStamp;
  2223. }
  2224. shouldPrevent(backwards) && prevent(e);
  2225. }
  2226. }
  2227. function parse(e) {
  2228. const { wheelAxis = "y" } = options;
  2229. const { deltaX, deltaY } = e;
  2230. const x = includes(wheelAxis, "x") ? Components.Direction.orient(-deltaX) : 0;
  2231. const y = includes(wheelAxis, "y") ? deltaY : 0;
  2232. return x || y;
  2233. }
  2234. function shouldPrevent(backwards) {
  2235. return !options.releaseWheel || Splide.state.is(MOVING) || Components.Controller.getAdjacent(backwards) !== -1;
  2236. }
  2237. return {
  2238. mount
  2239. };
  2240. };
  2241. const SR_REMOVAL_DELAY = 90;
  2242. const Live = (Splide, Components, options, event) => {
  2243. const { on } = event;
  2244. const { track } = Components.Elements;
  2245. const { live = true } = options;
  2246. const enabled = live && !options.isNavigation;
  2247. const sr = create("span", CLASS_SR);
  2248. const interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false));
  2249. function mount() {
  2250. if (enabled) {
  2251. disable(!Components.Autoplay.isPaused());
  2252. setAttribute(track, ARIA_ATOMIC, true);
  2253. sr.textContent = "\u2026";
  2254. on(EVENT_AUTOPLAY_PLAY, apply(disable, true));
  2255. on(EVENT_AUTOPLAY_PAUSE, apply(disable, false));
  2256. on([EVENT_MOVED, EVENT_SCROLLED], apply(toggle, true));
  2257. }
  2258. }
  2259. function toggle(active) {
  2260. setAttribute(track, ARIA_BUSY, active);
  2261. if (active) {
  2262. append(track, sr);
  2263. interval.start();
  2264. } else {
  2265. removeNode(sr);
  2266. interval.cancel();
  2267. }
  2268. }
  2269. function destroy() {
  2270. removeAttribute(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]);
  2271. removeNode(sr);
  2272. }
  2273. function disable(disabled) {
  2274. if (enabled) {
  2275. setAttribute(track, ARIA_LIVE, disabled ? "off" : "polite");
  2276. }
  2277. }
  2278. return {
  2279. mount,
  2280. disable,
  2281. destroy
  2282. };
  2283. };
  2284. const COMPONENTS = {
  2285. Breakpoints,
  2286. Direction,
  2287. Elements,
  2288. Slides,
  2289. Layout,
  2290. Clones,
  2291. Move,
  2292. Scroll,
  2293. Controller,
  2294. Arrows,
  2295. Autoplay,
  2296. Drag,
  2297. Keyboard,
  2298. LazyLoad,
  2299. Pagination,
  2300. Sync,
  2301. Wheel,
  2302. Live
  2303. };
  2304. const I18N = {
  2305. prev: "Previous slide",
  2306. next: "Next slide",
  2307. first: "Go to first slide",
  2308. last: "Go to last slide",
  2309. slideX: "Go to slide %s",
  2310. pageX: "Go to page %s",
  2311. play: "Start autoplay",
  2312. pause: "Pause autoplay",
  2313. carousel: "carousel",
  2314. slide: "slide",
  2315. select: "Select a slide to show",
  2316. slideLabel: "%s of %s"
  2317. };
  2318. const DEFAULTS = {
  2319. type: "slide",
  2320. speed: 400,
  2321. perPage: 1,
  2322. easing: "cubic-bezier(0.25, 1, 0.5, 1)",
  2323. drag: true,
  2324. direction: "ltr",
  2325. trimSpace: true,
  2326. focusableNodes: "a, button, textarea, input, select, iframe",
  2327. classes: CLASSES,
  2328. i18n: I18N,
  2329. reducedMotion: {
  2330. speed: 0,
  2331. rewindSpeed: 0,
  2332. autoplay: "pause"
  2333. }
  2334. };
  2335. const Fade = (Splide, Components, options, event) => {
  2336. const { Slides } = Components;
  2337. function mount() {
  2338. event.on([EVENT_MOUNTED, EVENT_REFRESH], init);
  2339. }
  2340. function init() {
  2341. Slides.forEach((Slide) => {
  2342. Slide.style("transform", `translateX(-${100 * Slide.index}%)`);
  2343. });
  2344. }
  2345. function start(index, done) {
  2346. Slides.style("transition", `opacity ${options.speed}ms ${options.easing}`);
  2347. nextTick(done);
  2348. }
  2349. return {
  2350. mount,
  2351. start,
  2352. cancel: noop
  2353. };
  2354. };
  2355. const Slide = (Splide, Components, options, event) => {
  2356. const { Move, Controller, Scroll } = Components;
  2357. const { list } = Components.Elements;
  2358. const transition = apply(style, list, "transition");
  2359. let endCallback;
  2360. function mount() {
  2361. event.bind(list, "transitionend", (e) => {
  2362. if (e.target === list && endCallback) {
  2363. cancel();
  2364. endCallback();
  2365. }
  2366. });
  2367. }
  2368. function start(index, done) {
  2369. const destination = Move.toPosition(index);
  2370. const position = Move.getPosition();
  2371. const speed = getSpeed(index);
  2372. if (abs(destination - position) >= 1 && speed >= 1) {
  2373. if (options.useScroll) {
  2374. Scroll.scroll(destination, speed, false, done);
  2375. } else {
  2376. transition(`transform ${speed}ms ${options.easing}`);
  2377. Move.translate(destination, true);
  2378. endCallback = done;
  2379. }
  2380. } else {
  2381. Move.jump(index);
  2382. done();
  2383. }
  2384. }
  2385. function cancel() {
  2386. transition("");
  2387. Scroll.cancel();
  2388. }
  2389. function getSpeed(index) {
  2390. const { rewindSpeed } = options;
  2391. if (Splide.is(SLIDE) && rewindSpeed) {
  2392. const prev = Controller.getIndex(true);
  2393. const end = Controller.getEnd();
  2394. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2395. return rewindSpeed;
  2396. }
  2397. }
  2398. return options.speed;
  2399. }
  2400. return {
  2401. mount,
  2402. start,
  2403. cancel
  2404. };
  2405. };
  2406. class Splide {
  2407. static defaults = {};
  2408. static STATES = STATES;
  2409. root;
  2410. event = EventInterface();
  2411. Components = {};
  2412. state = State(CREATED);
  2413. splides = [];
  2414. _o = {};
  2415. _C;
  2416. _E = {};
  2417. _T;
  2418. constructor(target, options = {}) {
  2419. const root = isString(target) ? query(document, target) : target;
  2420. assert(root, `${root} is invalid.`);
  2421. this.root = root;
  2422. options = merge({
  2423. label: getAttribute(root, ARIA_LABEL) || "",
  2424. labelledby: getAttribute(root, ARIA_LABELLEDBY) || ""
  2425. }, DEFAULTS, Splide.defaults, options);
  2426. try {
  2427. merge(options, JSON.parse(getAttribute(root, DATA_ATTRIBUTE)));
  2428. } catch (e) {
  2429. assert(false, "Invalid JSON");
  2430. }
  2431. this._o = Object.create(merge({}, options));
  2432. }
  2433. mount(Extensions = this._E, Transition = this._T) {
  2434. const { state, Components: Components2 } = this;
  2435. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2436. state.set(CREATED);
  2437. this._C = Components2;
  2438. this._T = Transition || (this.is(FADE) ? Fade : Slide);
  2439. this._E = Extensions;
  2440. const Constructors = assign({}, COMPONENTS, this._E, { Transition: this._T });
  2441. forOwn(Constructors, (Component, key) => {
  2442. const component = Component(this, Components2, this._o, this.event.create());
  2443. Components2[key] = component;
  2444. component.setup && component.setup();
  2445. });
  2446. forOwn(Components2, (component) => {
  2447. component.mount && component.mount();
  2448. });
  2449. this.emit(EVENT_MOUNTED);
  2450. addClass(this.root, CLASS_INITIALIZED);
  2451. state.set(IDLE);
  2452. this.emit(EVENT_READY);
  2453. return this;
  2454. }
  2455. sync(splide) {
  2456. this.splides.push({ splide });
  2457. splide.splides.push({ splide: this, isParent: true });
  2458. if (this.state.is(IDLE)) {
  2459. this._C.Sync.remount();
  2460. splide.Components.Sync.remount();
  2461. }
  2462. return this;
  2463. }
  2464. go(control) {
  2465. this._C.Controller.go(control);
  2466. return this;
  2467. }
  2468. jump(control) {
  2469. this._C.Controller.jump(control);
  2470. return this;
  2471. }
  2472. on(events, callback) {
  2473. this.event.on(events, callback);
  2474. return this;
  2475. }
  2476. off(events, callback) {
  2477. this.event.off(events, callback);
  2478. return this;
  2479. }
  2480. emit(event, ...args) {
  2481. this.event.emit(event, ...args);
  2482. return this;
  2483. }
  2484. add(slides, index) {
  2485. this._C.Slides.add(slides, index);
  2486. return this;
  2487. }
  2488. remove(matcher) {
  2489. this._C.Slides.remove(matcher);
  2490. return this;
  2491. }
  2492. is(type) {
  2493. return this._o.type === type;
  2494. }
  2495. refresh() {
  2496. this.emit(EVENT_REFRESH);
  2497. return this;
  2498. }
  2499. destroy(completely = true) {
  2500. const { event, state } = this;
  2501. if (state.is(CREATED)) {
  2502. this.on(EVENT_READY, this.destroy.bind(this, completely));
  2503. } else {
  2504. forOwn(this._C, (component) => {
  2505. component.destroy && component.destroy(completely);
  2506. }, true);
  2507. event.emit(EVENT_DESTROY);
  2508. event.destroy();
  2509. completely && empty(this.splides);
  2510. state.set(DESTROYED);
  2511. }
  2512. return this;
  2513. }
  2514. get options() {
  2515. return this._o;
  2516. }
  2517. set options(options) {
  2518. this._C.Breakpoints.set(options, true, true);
  2519. }
  2520. get length() {
  2521. return this._C.Slides.getLength(true);
  2522. }
  2523. get index() {
  2524. return this._C.Controller.getIndex();
  2525. }
  2526. }
  2527. const CLASS_RENDERED = "is-rendered";
  2528. const RENDERER_DEFAULT_CONFIG = {
  2529. listTag: "ul",
  2530. slideTag: "li"
  2531. };
  2532. class Style {
  2533. styles = {};
  2534. id;
  2535. options;
  2536. constructor(id, options) {
  2537. this.id = id;
  2538. this.options = options;
  2539. }
  2540. rule(selector, prop, value, breakpoint) {
  2541. breakpoint = breakpoint || "default";
  2542. const selectors = this.styles[breakpoint] = this.styles[breakpoint] || {};
  2543. const styles = selectors[selector] = selectors[selector] || {};
  2544. styles[prop] = value;
  2545. }
  2546. build() {
  2547. let css = "";
  2548. if (this.styles.default) {
  2549. css += this.buildSelectors(this.styles.default);
  2550. }
  2551. Object.keys(this.styles).sort((n, m) => this.options.mediaQuery === "min" ? +n - +m : +m - +n).forEach((breakpoint) => {
  2552. if (breakpoint !== "default") {
  2553. css += `@media screen and (max-width: ${breakpoint}px) {`;
  2554. css += this.buildSelectors(this.styles[breakpoint]);
  2555. css += `}`;
  2556. }
  2557. });
  2558. return css;
  2559. }
  2560. buildSelectors(selectors) {
  2561. let css = "";
  2562. forOwn(selectors, (styles, selector) => {
  2563. css += `${`#${this.id} ${selector}`.trim()} {`;
  2564. forOwn(styles, (value, prop) => {
  2565. if (value || value === 0) {
  2566. css += `${prop}: ${value};`;
  2567. }
  2568. });
  2569. css += "}";
  2570. });
  2571. return css;
  2572. }
  2573. }
  2574. class SplideRenderer {
  2575. static clean(splide) {
  2576. const { on } = splide.event;
  2577. const { root } = splide;
  2578. const clones = queryAll(root, `.${CLASS_CLONE}`);
  2579. on(EVENT_MOUNTED, () => {
  2580. removeNode(child(root, "style"));
  2581. });
  2582. removeNode(clones);
  2583. }
  2584. contents;
  2585. slides = [];
  2586. Direction;
  2587. Style;
  2588. options = {};
  2589. config;
  2590. id;
  2591. breakpoints = [];
  2592. constructor(contents, options, config, defaults) {
  2593. merge(DEFAULTS, defaults || {});
  2594. merge(merge(this.options, DEFAULTS), options || {});
  2595. this.contents = contents;
  2596. this.config = assign({}, RENDERER_DEFAULT_CONFIG, config || {});
  2597. this.id = this.config.id || uniqueId("splide");
  2598. this.Style = new Style(this.id, this.options);
  2599. this.Direction = Direction(null, null, this.options);
  2600. assert(this.contents.length, "Provide at least 1 content.");
  2601. this.init();
  2602. }
  2603. init() {
  2604. this.parseBreakpoints();
  2605. this.initSlides();
  2606. this.registerRootStyles();
  2607. this.registerTrackStyles();
  2608. this.registerSlideStyles();
  2609. this.registerListStyles();
  2610. }
  2611. initSlides() {
  2612. push(this.slides, this.contents.map((content, index) => {
  2613. content = isString(content) ? { html: content } : content;
  2614. content.styles = content.styles || {};
  2615. content.attrs = content.attrs || {};
  2616. this.cover(content);
  2617. const classes = `${this.options.classes.slide} ${index === 0 ? CLASS_ACTIVE : ""}`;
  2618. assign(content.attrs, {
  2619. class: `${classes} ${content.attrs.class || ""}`.trim(),
  2620. style: this.buildStyles(content.styles)
  2621. });
  2622. return content;
  2623. }));
  2624. if (this.isLoop()) {
  2625. this.generateClones(this.slides);
  2626. }
  2627. }
  2628. registerRootStyles() {
  2629. this.breakpoints.forEach(([width, options]) => {
  2630. this.Style.rule(" ", "max-width", unit(options.width), width);
  2631. });
  2632. }
  2633. registerTrackStyles() {
  2634. const { Style: Style2 } = this;
  2635. const selector = `.${CLASS_TRACK}`;
  2636. this.breakpoints.forEach(([width, options]) => {
  2637. Style2.rule(selector, this.resolve("paddingLeft"), this.cssPadding(options, false), width);
  2638. Style2.rule(selector, this.resolve("paddingRight"), this.cssPadding(options, true), width);
  2639. Style2.rule(selector, "height", this.cssTrackHeight(options), width);
  2640. });
  2641. }
  2642. registerListStyles() {
  2643. const { Style: Style2 } = this;
  2644. const selector = `.${CLASS_LIST}`;
  2645. this.breakpoints.forEach(([width, options]) => {
  2646. Style2.rule(selector, "transform", this.buildTranslate(options), width);
  2647. if (!this.cssSlideHeight(options)) {
  2648. Style2.rule(selector, "aspect-ratio", this.cssAspectRatio(options), width);
  2649. }
  2650. });
  2651. }
  2652. registerSlideStyles() {
  2653. const { Style: Style2 } = this;
  2654. const selector = `.${CLASS_SLIDE}`;
  2655. this.breakpoints.forEach(([width, options]) => {
  2656. Style2.rule(selector, "width", this.cssSlideWidth(options), width);
  2657. Style2.rule(selector, "height", this.cssSlideHeight(options) || "100%", width);
  2658. Style2.rule(selector, this.resolve("marginRight"), unit(options.gap) || "0px", width);
  2659. Style2.rule(`${selector} > img`, "display", options.cover ? "none" : "inline", width);
  2660. });
  2661. }
  2662. buildTranslate(options) {
  2663. const { resolve, orient } = this.Direction;
  2664. const values = [];
  2665. values.push(this.cssOffsetClones(options));
  2666. values.push(this.cssOffsetGaps(options));
  2667. if (this.isCenter(options)) {
  2668. values.push(this.buildCssValue(orient(-50), "%"));
  2669. values.push(...this.cssOffsetCenter(options));
  2670. }
  2671. return values.filter(Boolean).map((value) => `translate${resolve("X")}(${value})`).join(" ");
  2672. }
  2673. cssOffsetClones(options) {
  2674. const { resolve, orient } = this.Direction;
  2675. const cloneCount = this.getCloneCount();
  2676. if (this.isFixedWidth(options)) {
  2677. const { value, unit: unit2 } = this.parseCssValue(options[resolve("fixedWidth")]);
  2678. return this.buildCssValue(orient(value) * cloneCount, unit2);
  2679. }
  2680. const percent = 100 * cloneCount / options.perPage;
  2681. return `${orient(percent)}%`;
  2682. }
  2683. cssOffsetCenter(options) {
  2684. const { resolve, orient } = this.Direction;
  2685. if (this.isFixedWidth(options)) {
  2686. const { value, unit: unit2 } = this.parseCssValue(options[resolve("fixedWidth")]);
  2687. return [this.buildCssValue(orient(value / 2), unit2)];
  2688. }
  2689. const values = [];
  2690. const { perPage, gap } = options;
  2691. values.push(`${orient(50 / perPage)}%`);
  2692. if (gap) {
  2693. const { value, unit: unit2 } = this.parseCssValue(gap);
  2694. const gapOffset = (value / perPage - value) / 2;
  2695. values.push(this.buildCssValue(orient(gapOffset), unit2));
  2696. }
  2697. return values;
  2698. }
  2699. cssOffsetGaps(options) {
  2700. const cloneCount = this.getCloneCount();
  2701. if (cloneCount && options.gap) {
  2702. const { orient } = this.Direction;
  2703. const { value, unit: unit2 } = this.parseCssValue(options.gap);
  2704. if (this.isFixedWidth(options)) {
  2705. return this.buildCssValue(orient(value * cloneCount), unit2);
  2706. }
  2707. const { perPage } = options;
  2708. const gaps = cloneCount / perPage;
  2709. return this.buildCssValue(orient(gaps * value), unit2);
  2710. }
  2711. return "";
  2712. }
  2713. resolve(prop) {
  2714. return camelToKebab(this.Direction.resolve(prop));
  2715. }
  2716. cssPadding(options, right) {
  2717. const { padding } = options;
  2718. const prop = this.Direction.resolve(right ? "right" : "left", true);
  2719. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  2720. }
  2721. cssTrackHeight(options) {
  2722. let height = "";
  2723. if (this.isVertical()) {
  2724. height = this.cssHeight(options);
  2725. assert(height, '"height" is missing.');
  2726. height = `calc(${height} - ${this.cssPadding(options, false)} - ${this.cssPadding(options, true)})`;
  2727. }
  2728. return height;
  2729. }
  2730. cssHeight(options) {
  2731. return unit(options.height);
  2732. }
  2733. cssSlideWidth(options) {
  2734. return options.autoWidth ? "" : unit(options.fixedWidth) || (this.isVertical() ? "" : this.cssSlideSize(options));
  2735. }
  2736. cssSlideHeight(options) {
  2737. return unit(options.fixedHeight) || (this.isVertical() ? options.autoHeight ? "" : this.cssSlideSize(options) : this.cssHeight(options));
  2738. }
  2739. cssSlideSize(options) {
  2740. const gap = unit(options.gap);
  2741. return `calc((100%${gap && ` + ${gap}`})/${options.perPage || 1}${gap && ` - ${gap}`})`;
  2742. }
  2743. cssAspectRatio(options) {
  2744. const { heightRatio } = options;
  2745. return heightRatio ? `${1 / heightRatio}` : "";
  2746. }
  2747. buildCssValue(value, unit2) {
  2748. return `${value}${unit2}`;
  2749. }
  2750. parseCssValue(value) {
  2751. if (isString(value)) {
  2752. const number = parseFloat(value) || 0;
  2753. const unit2 = value.replace(/\d*(\.\d*)?/, "") || "px";
  2754. return { value: number, unit: unit2 };
  2755. }
  2756. return { value, unit: "px" };
  2757. }
  2758. parseBreakpoints() {
  2759. const { breakpoints } = this.options;
  2760. this.breakpoints.push(["default", this.options]);
  2761. if (breakpoints) {
  2762. forOwn(breakpoints, (options, width) => {
  2763. this.breakpoints.push([width, merge(merge({}, this.options), options)]);
  2764. });
  2765. }
  2766. }
  2767. isFixedWidth(options) {
  2768. return !!options[this.Direction.resolve("fixedWidth")];
  2769. }
  2770. isLoop() {
  2771. return this.options.type === LOOP;
  2772. }
  2773. isCenter(options) {
  2774. if (options.focus === "center") {
  2775. if (this.isLoop()) {
  2776. return true;
  2777. }
  2778. if (this.options.type === SLIDE) {
  2779. return !this.options.trimSpace;
  2780. }
  2781. }
  2782. return false;
  2783. }
  2784. isVertical() {
  2785. return this.options.direction === TTB;
  2786. }
  2787. buildClasses() {
  2788. const { options } = this;
  2789. return [
  2790. CLASS_ROOT,
  2791. `${CLASS_ROOT}--${options.type}`,
  2792. `${CLASS_ROOT}--${options.direction}`,
  2793. options.drag && `${CLASS_ROOT}--draggable`,
  2794. options.isNavigation && `${CLASS_ROOT}--nav`,
  2795. CLASS_ACTIVE,
  2796. !this.config.hidden && CLASS_RENDERED
  2797. ].filter(Boolean).join(" ");
  2798. }
  2799. buildAttrs(attrs) {
  2800. let attr = "";
  2801. forOwn(attrs, (value, key) => {
  2802. attr += value ? ` ${camelToKebab(key)}="${value}"` : "";
  2803. });
  2804. return attr.trim();
  2805. }
  2806. buildStyles(styles) {
  2807. let style = "";
  2808. forOwn(styles, (value, key) => {
  2809. style += ` ${camelToKebab(key)}:${value};`;
  2810. });
  2811. return style.trim();
  2812. }
  2813. renderSlides() {
  2814. const { slideTag: tag } = this.config;
  2815. return this.slides.map((content) => {
  2816. return `<${tag} ${this.buildAttrs(content.attrs)}>${content.html || ""}</${tag}>`;
  2817. }).join("");
  2818. }
  2819. cover(content) {
  2820. const { styles, html = "" } = content;
  2821. if (this.options.cover && !this.options.lazyLoad) {
  2822. const src = html.match(/<img.*?src\s*=\s*(['"])(.+?)\1.*?>/);
  2823. if (src && src[2]) {
  2824. styles.background = `center/cover no-repeat url('${src[2]}')`;
  2825. }
  2826. }
  2827. }
  2828. generateClones(contents) {
  2829. const { classes } = this.options;
  2830. const count = this.getCloneCount();
  2831. const slides = contents.slice();
  2832. while (slides.length < count) {
  2833. push(slides, slides);
  2834. }
  2835. push(slides.slice(-count).reverse(), slides.slice(0, count)).forEach((content, index) => {
  2836. const attrs = assign({}, content.attrs, { class: `${content.attrs.class} ${classes.clone}` });
  2837. const clone = assign({}, content, { attrs });
  2838. index < count ? contents.unshift(clone) : contents.push(clone);
  2839. });
  2840. }
  2841. getCloneCount() {
  2842. if (this.isLoop()) {
  2843. const { options } = this;
  2844. if (options.clones) {
  2845. return options.clones;
  2846. }
  2847. const perPage = max(...this.breakpoints.map(([, options2]) => options2.perPage));
  2848. return perPage * ((options.flickMaxPages || 1) + 1);
  2849. }
  2850. return 0;
  2851. }
  2852. renderArrows() {
  2853. let html = "";
  2854. html += `<div class="${this.options.classes.arrows}">`;
  2855. html += this.renderArrow(true);
  2856. html += this.renderArrow(false);
  2857. html += `</div>`;
  2858. return html;
  2859. }
  2860. renderArrow(prev) {
  2861. const { classes, i18n } = this.options;
  2862. const attrs = {
  2863. class: `${classes.arrow} ${prev ? classes.prev : classes.next}`,
  2864. type: "button",
  2865. ariaLabel: prev ? i18n.prev : i18n.next
  2866. };
  2867. return `<button ${this.buildAttrs(attrs)}><svg xmlns="${XML_NAME_SPACE}" viewBox="0 0 ${SIZE} ${SIZE}" width="${SIZE}" height="${SIZE}"><path d="${this.options.arrowPath || PATH}" /></svg></button>`;
  2868. }
  2869. html() {
  2870. const { rootClass, listTag, arrows, beforeTrack, afterTrack, slider, beforeSlider, afterSlider } = this.config;
  2871. let html = "";
  2872. html += `<div id="${this.id}" class="${this.buildClasses()} ${rootClass || ""}">`;
  2873. html += `<style>${this.Style.build()}</style>`;
  2874. if (slider) {
  2875. html += beforeSlider || "";
  2876. html += `<div class="splide__slider">`;
  2877. }
  2878. html += beforeTrack || "";
  2879. if (arrows) {
  2880. html += this.renderArrows();
  2881. }
  2882. html += `<div class="splide__track">`;
  2883. html += `<${listTag} class="splide__list">`;
  2884. html += this.renderSlides();
  2885. html += `</${listTag}>`;
  2886. html += `</div>`;
  2887. html += afterTrack || "";
  2888. if (slider) {
  2889. html += `</div>`;
  2890. html += afterSlider || "";
  2891. }
  2892. html += `</div>`;
  2893. return html;
  2894. }
  2895. }
  2896. exports.CLASSES = CLASSES;
  2897. exports.CLASS_ACTIVE = CLASS_ACTIVE;
  2898. exports.CLASS_ARROW = CLASS_ARROW;
  2899. exports.CLASS_ARROWS = CLASS_ARROWS;
  2900. exports.CLASS_ARROW_NEXT = CLASS_ARROW_NEXT;
  2901. exports.CLASS_ARROW_PREV = CLASS_ARROW_PREV;
  2902. exports.CLASS_CLONE = CLASS_CLONE;
  2903. exports.CLASS_CONTAINER = CLASS_CONTAINER;
  2904. exports.CLASS_FOCUS_IN = CLASS_FOCUS_IN;
  2905. exports.CLASS_INITIALIZED = CLASS_INITIALIZED;
  2906. exports.CLASS_LIST = CLASS_LIST;
  2907. exports.CLASS_LOADING = CLASS_LOADING;
  2908. exports.CLASS_NEXT = CLASS_NEXT;
  2909. exports.CLASS_OVERFLOW = CLASS_OVERFLOW;
  2910. exports.CLASS_PAGINATION = CLASS_PAGINATION;
  2911. exports.CLASS_PAGINATION_PAGE = CLASS_PAGINATION_PAGE;
  2912. exports.CLASS_PREV = CLASS_PREV;
  2913. exports.CLASS_PROGRESS = CLASS_PROGRESS;
  2914. exports.CLASS_PROGRESS_BAR = CLASS_PROGRESS_BAR;
  2915. exports.CLASS_ROOT = CLASS_ROOT;
  2916. exports.CLASS_SLIDE = CLASS_SLIDE;
  2917. exports.CLASS_SPINNER = CLASS_SPINNER;
  2918. exports.CLASS_SR = CLASS_SR;
  2919. exports.CLASS_TOGGLE = CLASS_TOGGLE;
  2920. exports.CLASS_TOGGLE_PAUSE = CLASS_TOGGLE_PAUSE;
  2921. exports.CLASS_TOGGLE_PLAY = CLASS_TOGGLE_PLAY;
  2922. exports.CLASS_TRACK = CLASS_TRACK;
  2923. exports.CLASS_VISIBLE = CLASS_VISIBLE;
  2924. exports.DEFAULTS = DEFAULTS;
  2925. exports.EVENT_ACTIVE = EVENT_ACTIVE;
  2926. exports.EVENT_ARROWS_MOUNTED = EVENT_ARROWS_MOUNTED;
  2927. exports.EVENT_ARROWS_UPDATED = EVENT_ARROWS_UPDATED;
  2928. exports.EVENT_AUTOPLAY_PAUSE = EVENT_AUTOPLAY_PAUSE;
  2929. exports.EVENT_AUTOPLAY_PLAY = EVENT_AUTOPLAY_PLAY;
  2930. exports.EVENT_AUTOPLAY_PLAYING = EVENT_AUTOPLAY_PLAYING;
  2931. exports.EVENT_CLICK = EVENT_CLICK;
  2932. exports.EVENT_DESTROY = EVENT_DESTROY;
  2933. exports.EVENT_DRAG = EVENT_DRAG;
  2934. exports.EVENT_DRAGGED = EVENT_DRAGGED;
  2935. exports.EVENT_DRAGGING = EVENT_DRAGGING;
  2936. exports.EVENT_END_INDEX_CHANGED = EVENT_END_INDEX_CHANGED;
  2937. exports.EVENT_HIDDEN = EVENT_HIDDEN;
  2938. exports.EVENT_INACTIVE = EVENT_INACTIVE;
  2939. exports.EVENT_LAZYLOAD_ERROR = EVENT_LAZYLOAD_ERROR;
  2940. exports.EVENT_LAZYLOAD_LOADED = EVENT_LAZYLOAD_LOADED;
  2941. exports.EVENT_MOUNTED = EVENT_MOUNTED;
  2942. exports.EVENT_MOVE = EVENT_MOVE;
  2943. exports.EVENT_MOVED = EVENT_MOVED;
  2944. exports.EVENT_NAVIGATION_MOUNTED = EVENT_NAVIGATION_MOUNTED;
  2945. exports.EVENT_OVERFLOW = EVENT_OVERFLOW;
  2946. exports.EVENT_PAGINATION_MOUNTED = EVENT_PAGINATION_MOUNTED;
  2947. exports.EVENT_PAGINATION_UPDATED = EVENT_PAGINATION_UPDATED;
  2948. exports.EVENT_READY = EVENT_READY;
  2949. exports.EVENT_REFRESH = EVENT_REFRESH;
  2950. exports.EVENT_RESIZE = EVENT_RESIZE;
  2951. exports.EVENT_RESIZED = EVENT_RESIZED;
  2952. exports.EVENT_SCROLL = EVENT_SCROLL;
  2953. exports.EVENT_SCROLLED = EVENT_SCROLLED;
  2954. exports.EVENT_SCROLLING = EVENT_SCROLLING;
  2955. exports.EVENT_SHIFTED = EVENT_SHIFTED;
  2956. exports.EVENT_SLIDE_KEYDOWN = EVENT_SLIDE_KEYDOWN;
  2957. exports.EVENT_UPDATED = EVENT_UPDATED;
  2958. exports.EVENT_VISIBLE = EVENT_VISIBLE;
  2959. exports.FADE = FADE;
  2960. exports.LOOP = LOOP;
  2961. exports.LTR = LTR;
  2962. exports.RTL = RTL;
  2963. exports.SLIDE = SLIDE;
  2964. exports.STATUS_CLASSES = STATUS_CLASSES;
  2965. exports.Splide = Splide;
  2966. exports.SplideRenderer = SplideRenderer;
  2967. exports.TTB = TTB;
  2968. exports["default"] = Splide;