splide.esm.js 92 KB

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