splide.cjs.js 88 KB

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