splide.esm.js 92 KB

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