splide.cjs.js 94 KB

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