splide.cjs.js 94 KB

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