splide.cjs.js 87 KB

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