splide.cjs.js 93 KB

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