splide.esm.js 86 KB

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