splide.cjs.js 87 KB

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