splide.esm.js 93 KB

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