splide.js 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939
  1. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  2. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  3. /*!
  4. * Splide.js
  5. * Version : 3.0.0
  6. * License : MIT
  7. * Copyright: 2021 Naotoshi Fujita
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Splide = factory());
  11. })(this, function () {
  12. 'use strict';
  13. var PROJECT_CODE = "splide";
  14. var DATA_ATTRIBUTE = "data-" + PROJECT_CODE;
  15. var CREATED = 1;
  16. var MOUNTED = 2;
  17. var IDLE = 3;
  18. var MOVING = 4;
  19. var DESTROYED = 5;
  20. var STATES = {
  21. CREATED: CREATED,
  22. MOUNTED: MOUNTED,
  23. IDLE: IDLE,
  24. MOVING: MOVING,
  25. DESTROYED: DESTROYED
  26. };
  27. var DEFAULT_EVENT_PRIORITY = 10;
  28. var DEFAULT_USER_EVENT_PRIORITY = 20;
  29. function empty(array) {
  30. array.length = 0;
  31. }
  32. function isObject(subject) {
  33. return !isNull(subject) && typeof subject === "object";
  34. }
  35. function isArray(subject) {
  36. return Array.isArray(subject);
  37. }
  38. function isFunction(subject) {
  39. return typeof subject === "function";
  40. }
  41. function isString(subject) {
  42. return typeof subject === "string";
  43. }
  44. function isUndefined(subject) {
  45. return typeof subject === "undefined";
  46. }
  47. function isNull(subject) {
  48. return subject === null;
  49. }
  50. function isHTMLElement(subject) {
  51. return subject instanceof HTMLElement;
  52. }
  53. function toArray(value) {
  54. return isArray(value) ? value : [value];
  55. }
  56. function forEach(values, iteratee) {
  57. toArray(values).forEach(iteratee);
  58. }
  59. function includes(array, value) {
  60. return array.indexOf(value) > -1;
  61. }
  62. function push(array, items) {
  63. array.push.apply(array, toArray(items));
  64. return array;
  65. }
  66. var arrayProto = Array.prototype;
  67. function slice(arrayLike, start, end) {
  68. return arrayProto.slice.call(arrayLike, start, end);
  69. }
  70. function find(arrayLike, predicate) {
  71. return slice(arrayLike).filter(predicate)[0];
  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.parentNode;
  91. if (parent) {
  92. parent.insertBefore(node, ref);
  93. }
  94. });
  95. }
  96. function matches(elm, selector) {
  97. return (elm["msMatchesSelector"] || elm.matches).call(elm, selector);
  98. }
  99. function children(parent, selector) {
  100. return parent ? slice(parent.children).filter(function (child) {
  101. return matches(child, selector);
  102. }) : [];
  103. }
  104. function child(parent, selector) {
  105. return selector ? children(parent, selector)[0] : parent.firstElementChild;
  106. }
  107. function forOwn(object, iteratee) {
  108. if (object) {
  109. var keys = Object.keys(object);
  110. for (var i = 0; i < keys.length; i++) {
  111. var key = keys[i];
  112. if (key !== "__proto__") {
  113. if (iteratee(object[key], key) === false) {
  114. break;
  115. }
  116. }
  117. }
  118. }
  119. return object;
  120. }
  121. function assign(object) {
  122. slice(arguments, 1).forEach(function (source) {
  123. forOwn(source, function (value, key) {
  124. object[key] = source[key];
  125. });
  126. });
  127. return object;
  128. }
  129. function merge(object, source) {
  130. forOwn(source, function (value, key) {
  131. if (isArray(value)) {
  132. object[key] = value.slice();
  133. } else if (isObject(value)) {
  134. object[key] = merge(isObject(object[key]) ? object[key] : {}, value);
  135. } else {
  136. object[key] = value;
  137. }
  138. });
  139. return object;
  140. }
  141. function removeAttribute(elm, attrs) {
  142. if (elm) {
  143. forEach(attrs, function (attr) {
  144. elm.removeAttribute(attr);
  145. });
  146. }
  147. }
  148. function setAttribute(elm, attrs, value) {
  149. if (isObject(attrs)) {
  150. forOwn(attrs, function (value2, name) {
  151. setAttribute(elm, name, value2);
  152. });
  153. } else {
  154. isNull(value) ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value));
  155. }
  156. }
  157. function create(tag, attrs, parent) {
  158. var elm = document.createElement(tag);
  159. if (attrs) {
  160. isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs);
  161. }
  162. parent && append(parent, elm);
  163. return elm;
  164. }
  165. function style(elm, styles) {
  166. if (isString(styles)) {
  167. return getComputedStyle(elm)[styles];
  168. }
  169. forOwn(styles, function (value, key) {
  170. if (!isNull(value)) {
  171. elm.style[key] = "" + value;
  172. }
  173. });
  174. }
  175. function display(elm, display2) {
  176. style(elm, {
  177. display: display2
  178. });
  179. }
  180. function getAttribute(elm, attr) {
  181. return elm.getAttribute(attr);
  182. }
  183. function hasClass(elm, className) {
  184. return elm && elm.classList.contains(className);
  185. }
  186. function rect(target) {
  187. return target.getBoundingClientRect();
  188. }
  189. function remove(nodes) {
  190. forEach(nodes, function (node) {
  191. if (node && node.parentNode) {
  192. node.parentNode.removeChild(node);
  193. }
  194. });
  195. }
  196. function measure(parent, value) {
  197. if (isString(value)) {
  198. var div = create("div", {
  199. style: "width: " + value + "; position: absolute;"
  200. }, parent);
  201. value = rect(div).width;
  202. remove(div);
  203. }
  204. return value;
  205. }
  206. function parseHtml(html) {
  207. return child(new DOMParser().parseFromString(html, "text/html").body);
  208. }
  209. function prevent(e, stopPropagation) {
  210. e.preventDefault();
  211. if (stopPropagation) {
  212. e.stopPropagation();
  213. e.stopImmediatePropagation();
  214. }
  215. }
  216. function query(parent, selector) {
  217. return parent && parent.querySelector(selector);
  218. }
  219. function queryAll(parent, selector) {
  220. return slice(parent.querySelectorAll(selector));
  221. }
  222. function removeClass(elm, classes) {
  223. toggleClass(elm, classes, false);
  224. }
  225. function unit(value) {
  226. return isString(value) ? value : value ? value + "px" : "";
  227. }
  228. function assert(condition, message) {
  229. if (message === void 0) {
  230. message = "";
  231. }
  232. if (!condition) {
  233. throw new Error("[" + PROJECT_CODE + "] " + message);
  234. }
  235. }
  236. function nextTick(callback) {
  237. setTimeout(callback);
  238. }
  239. var noop = function noop() {};
  240. function raf(func) {
  241. return requestAnimationFrame(func);
  242. }
  243. var min = Math.min,
  244. max = Math.max,
  245. floor = Math.floor,
  246. ceil = Math.ceil,
  247. abs = Math.abs;
  248. function approximatelyEqual(x, y, epsilon) {
  249. return abs(x - y) < epsilon;
  250. }
  251. function between(number, minOrMax, maxOrMin, exclusive) {
  252. var minimum = min(minOrMax, maxOrMin);
  253. var maximum = max(minOrMax, maxOrMin);
  254. return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum;
  255. }
  256. function clamp(number, x, y) {
  257. var minimum = min(x, y);
  258. var maximum = max(x, y);
  259. return min(max(minimum, number), maximum);
  260. }
  261. function sign(x) {
  262. return +(x > 0) - +(x < 0);
  263. }
  264. function format(string, replacements) {
  265. forEach(replacements, function (replacement) {
  266. string = string.replace("%s", "" + replacement);
  267. });
  268. return string;
  269. }
  270. function pad(number) {
  271. return number < 10 ? "0" + number : "" + number;
  272. }
  273. var ids = {};
  274. function uniqueId(prefix) {
  275. return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1);
  276. }
  277. function EventBus() {
  278. var handlers = {};
  279. function on(events, callback, key, priority) {
  280. if (priority === void 0) {
  281. priority = DEFAULT_EVENT_PRIORITY;
  282. }
  283. forEachEvent(events, function (event, namespace) {
  284. handlers[event] = handlers[event] || [];
  285. push(handlers[event], {
  286. _event: event,
  287. _callback: callback,
  288. _namespace: namespace,
  289. _priority: priority,
  290. _key: key
  291. }).sort(function (handler1, handler2) {
  292. return handler1._priority - handler2._priority;
  293. });
  294. });
  295. }
  296. function off(events, key) {
  297. forEachEvent(events, function (event, namespace) {
  298. var eventHandlers = handlers[event];
  299. handlers[event] = eventHandlers && eventHandlers.filter(function (handler) {
  300. return handler._key ? handler._key !== key : handler._namespace !== namespace;
  301. });
  302. });
  303. }
  304. function offBy(key) {
  305. forOwn(handlers, function (eventHandlers, event) {
  306. off(event, key);
  307. });
  308. }
  309. function emit(event) {
  310. var _arguments = arguments;
  311. (handlers[event] || []).forEach(function (handler) {
  312. handler._callback.apply(handler, slice(_arguments, 1));
  313. });
  314. }
  315. function destroy() {
  316. handlers = {};
  317. }
  318. function forEachEvent(events, iteratee) {
  319. toArray(events).join(" ").split(" ").forEach(function (eventNS) {
  320. var fragments = eventNS.split(".");
  321. iteratee(fragments[0], fragments[1]);
  322. });
  323. }
  324. return {
  325. on: on,
  326. off: off,
  327. offBy: offBy,
  328. emit: emit,
  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_CLICK = "click";
  337. var EVENT_ACTIVE = "active";
  338. var EVENT_INACTIVE = "inactive";
  339. var EVENT_VISIBLE = "visible";
  340. var EVENT_HIDDEN = "hidden";
  341. var EVENT_SLIDE_KEYDOWN = "slide:keydown";
  342. var EVENT_REFRESH = "refresh";
  343. var EVENT_UPDATED = "updated";
  344. var EVENT_RESIZE = "resize";
  345. var EVENT_RESIZED = "resized";
  346. var EVENT_DRAG = "drag";
  347. var EVENT_DRAGGING = "dragging";
  348. var EVENT_DRAGGED = "dragged";
  349. var EVENT_SCROLL = "scroll";
  350. var EVENT_SCROLLED = "scrolled";
  351. var EVENT_DESTROY = "destroy";
  352. var EVENT_ARROWS_MOUNTED = "arrows:mounted";
  353. var EVENT_ARROWS_UPDATED = "arrows:updated";
  354. var EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  355. var EVENT_PAGINATION_UPDATED = "pagination:updated";
  356. var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  357. var EVENT_AUTOPLAY_PLAY = "autoplay:play";
  358. var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  359. var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  360. var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  361. function EventInterface(Splide2) {
  362. var event = Splide2.event;
  363. var key = {};
  364. var listeners = [];
  365. function on(events, callback, priority) {
  366. event.on(events, callback, key, priority);
  367. }
  368. function off(events) {
  369. event.off(events, key);
  370. }
  371. function bind(targets, events, callback, options) {
  372. forEachEvent(targets, events, function (target, event2) {
  373. listeners.push([target, event2, callback, options]);
  374. target.addEventListener(event2, callback, options);
  375. });
  376. }
  377. function unbind(targets, events) {
  378. forEachEvent(targets, events, function (target, event2) {
  379. listeners = listeners.filter(function (listener) {
  380. if (listener[0] === target && listener[1] === event2) {
  381. target.removeEventListener(event2, listener[2], listener[3]);
  382. return false;
  383. }
  384. return true;
  385. });
  386. });
  387. }
  388. function forEachEvent(targets, events, iteratee) {
  389. forEach(targets, function (target) {
  390. if (target) {
  391. events.split(" ").forEach(iteratee.bind(null, target));
  392. }
  393. });
  394. }
  395. function destroy() {
  396. listeners = listeners.filter(function (data) {
  397. return unbind(data[0], data[1]);
  398. });
  399. event.offBy(key);
  400. }
  401. event.on(EVENT_DESTROY, destroy, key);
  402. return {
  403. on: on,
  404. off: off,
  405. emit: event.emit,
  406. bind: bind,
  407. unbind: unbind,
  408. destroy: destroy
  409. };
  410. }
  411. function RequestInterval(interval, onInterval, onUpdate, limit) {
  412. var now = Date.now;
  413. var startTime;
  414. var rate = 0;
  415. var id;
  416. var paused = true;
  417. var count = 0;
  418. function update() {
  419. if (!paused) {
  420. var elapsed = now() - startTime;
  421. if (elapsed >= interval) {
  422. rate = 1;
  423. startTime = now();
  424. } else {
  425. rate = elapsed / interval;
  426. }
  427. if (onUpdate) {
  428. onUpdate(rate);
  429. }
  430. if (rate === 1) {
  431. onInterval();
  432. if (limit && ++count >= limit) {
  433. return pause();
  434. }
  435. }
  436. raf(update);
  437. }
  438. }
  439. function start(resume) {
  440. !resume && cancel();
  441. startTime = now() - (resume ? rate * interval : 0);
  442. paused = false;
  443. raf(update);
  444. }
  445. function pause() {
  446. paused = true;
  447. }
  448. function rewind() {
  449. startTime = now();
  450. rate = 0;
  451. if (onUpdate) {
  452. onUpdate(rate);
  453. }
  454. }
  455. function cancel() {
  456. cancelAnimationFrame(id);
  457. rate = 0;
  458. id = 0;
  459. paused = true;
  460. }
  461. function isPaused() {
  462. return paused;
  463. }
  464. return {
  465. start: start,
  466. rewind: rewind,
  467. pause: pause,
  468. cancel: cancel,
  469. isPaused: isPaused
  470. };
  471. }
  472. function State(initialState) {
  473. var state = initialState;
  474. function set(value) {
  475. state = value;
  476. }
  477. function is(states) {
  478. return includes(toArray(states), state);
  479. }
  480. return {
  481. set: set,
  482. is: is
  483. };
  484. }
  485. function Throttle(func, duration) {
  486. var interval;
  487. function throttled() {
  488. var _arguments2 = arguments,
  489. _this = this;
  490. if (!interval) {
  491. interval = RequestInterval(duration || 0, function () {
  492. func.apply(_this, _arguments2);
  493. interval = null;
  494. }, null, 1);
  495. interval.start();
  496. }
  497. }
  498. return throttled;
  499. }
  500. function Options(Splide2, Components2, options) {
  501. var throttledObserve = Throttle(observe);
  502. var initialOptions;
  503. var points;
  504. var currPoint;
  505. function setup() {
  506. try {
  507. merge(options, JSON.parse(getAttribute(Splide2.root, DATA_ATTRIBUTE)));
  508. } catch (e) {
  509. assert(false, e.message);
  510. }
  511. initialOptions = merge({}, options);
  512. }
  513. function mount() {
  514. var breakpoints = options.breakpoints;
  515. var isMin = options.mediaQuery === "min";
  516. if (breakpoints) {
  517. points = Object.keys(breakpoints).sort(function (n, m) {
  518. return isMin ? +m - +n : +n - +m;
  519. }).map(function (point) {
  520. return [point, matchMedia("(" + (isMin ? "min" : "max") + "-width:" + point + "px)")];
  521. });
  522. addEventListener("resize", throttledObserve);
  523. observe();
  524. }
  525. }
  526. function destroy(completely) {
  527. if (completely) {
  528. removeEventListener("resize", throttledObserve);
  529. }
  530. }
  531. function observe() {
  532. var item = find(points, function (item2) {
  533. return item2[1].matches;
  534. }) || [];
  535. if (item[0] !== currPoint) {
  536. onMatch(currPoint = item[0]);
  537. }
  538. }
  539. function onMatch(point) {
  540. var newOptions = options.breakpoints[point] || initialOptions;
  541. if (newOptions.destroy) {
  542. Splide2.options = initialOptions;
  543. Splide2.destroy(newOptions.destroy === "completely");
  544. } else {
  545. if (Splide2.state.is(DESTROYED)) {
  546. destroy(true);
  547. Splide2.mount();
  548. }
  549. Splide2.options = newOptions;
  550. }
  551. }
  552. return {
  553. setup: setup,
  554. mount: mount,
  555. destroy: destroy
  556. };
  557. }
  558. var RTL = "rtl";
  559. var TTB = "ttb";
  560. var ORIENTATION_MAP = {
  561. marginRight: ["marginBottom", "marginLeft"],
  562. autoWidth: ["autoHeight"],
  563. fixedWidth: ["fixedHeight"],
  564. paddingLeft: ["paddingTop", "paddingRight"],
  565. paddingRight: ["paddingBottom", "paddingLeft"],
  566. width: ["height"],
  567. left: ["top", "right"],
  568. right: ["bottom", "left"],
  569. x: ["y"],
  570. X: ["Y"],
  571. Y: ["X"],
  572. ArrowLeft: ["ArrowUp", "ArrowRight"],
  573. ArrowRight: ["ArrowDown", "ArrowLeft"]
  574. };
  575. function Direction(Splide2, Components2, options) {
  576. function resolve(prop, axisOnly) {
  577. var direction = options.direction;
  578. var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  579. return ORIENTATION_MAP[prop][index] || prop;
  580. }
  581. function orient(value) {
  582. return value * (options.direction === RTL ? 1 : -1);
  583. }
  584. return {
  585. resolve: resolve,
  586. orient: orient
  587. };
  588. }
  589. var CLASS_ROOT = PROJECT_CODE;
  590. var CLASS_SLIDER = PROJECT_CODE + "__slider";
  591. var CLASS_TRACK = PROJECT_CODE + "__track";
  592. var CLASS_LIST = PROJECT_CODE + "__list";
  593. var CLASS_SLIDE = PROJECT_CODE + "__slide";
  594. var CLASS_CLONE = CLASS_SLIDE + "--clone";
  595. var CLASS_CONTAINER = CLASS_SLIDE + "__container";
  596. var CLASS_ARROWS = PROJECT_CODE + "__arrows";
  597. var CLASS_ARROW = PROJECT_CODE + "__arrow";
  598. var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
  599. var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
  600. var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
  601. var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
  602. var CLASS_PROGRESS = PROJECT_CODE + "__progress";
  603. var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
  604. var CLASS_AUTOPLAY = PROJECT_CODE + "__autoplay";
  605. var CLASS_PLAY = PROJECT_CODE + "__play";
  606. var CLASS_PAUSE = PROJECT_CODE + "__pause";
  607. var CLASS_SPINNER = PROJECT_CODE + "__spinner";
  608. var CLASS_INITIALIZED = "is-initialized";
  609. var CLASS_ACTIVE = "is-active";
  610. var CLASS_PREV = "is-prev";
  611. var CLASS_NEXT = "is-next";
  612. var CLASS_VISIBLE = "is-visible";
  613. var CLASS_LOADING = "is-loading";
  614. var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING];
  615. var CLASSES = {
  616. slide: CLASS_SLIDE,
  617. clone: CLASS_CLONE,
  618. arrows: CLASS_ARROWS,
  619. arrow: CLASS_ARROW,
  620. prev: CLASS_ARROW_PREV,
  621. next: CLASS_ARROW_NEXT,
  622. pagination: CLASS_PAGINATION,
  623. page: CLASS_PAGINATION_PAGE,
  624. spinner: CLASS_SPINNER
  625. };
  626. function Elements(Splide2, Components2, options) {
  627. var _EventInterface = EventInterface(Splide2),
  628. on = _EventInterface.on;
  629. var root = Splide2.root;
  630. var elements = {};
  631. var slides = [];
  632. var classes;
  633. var slider;
  634. var track;
  635. var list;
  636. function setup() {
  637. collect();
  638. identify();
  639. addClass(root, classes = getClasses());
  640. }
  641. function mount() {
  642. on(EVENT_REFRESH, refresh);
  643. on(EVENT_UPDATED, update);
  644. }
  645. function destroy() {
  646. empty(slides);
  647. removeClass(root, classes);
  648. }
  649. function refresh() {
  650. destroy();
  651. setup();
  652. }
  653. function update() {
  654. removeClass(root, classes);
  655. addClass(root, classes = getClasses());
  656. }
  657. function collect() {
  658. slider = child(root, "." + CLASS_SLIDER);
  659. track = query(root, "." + CLASS_TRACK);
  660. list = child(track, "." + CLASS_LIST);
  661. assert(track && list, "A track/list element is missing.");
  662. push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
  663. var autoplay = find("." + CLASS_AUTOPLAY);
  664. var arrows = find("." + CLASS_ARROWS);
  665. assign(elements, {
  666. root: root,
  667. slider: slider,
  668. track: track,
  669. list: list,
  670. slides: slides,
  671. arrows: arrows,
  672. autoplay: autoplay,
  673. prev: query(arrows, "." + CLASS_ARROW_PREV),
  674. next: query(arrows, "." + CLASS_ARROW_NEXT),
  675. bar: query(find("." + CLASS_PROGRESS), "." + CLASS_PROGRESS_BAR),
  676. play: query(autoplay, "." + CLASS_PLAY),
  677. pause: query(autoplay, "." + CLASS_PAUSE)
  678. });
  679. }
  680. function identify() {
  681. var id = root.id || uniqueId(PROJECT_CODE);
  682. root.id = id;
  683. track.id = track.id || id + "-track";
  684. list.id = list.id || id + "-list";
  685. }
  686. function find(selector) {
  687. return child(root, selector) || child(slider, selector);
  688. }
  689. function getClasses() {
  690. return [CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE];
  691. }
  692. return assign(elements, {
  693. setup: setup,
  694. mount: mount,
  695. destroy: destroy
  696. });
  697. }
  698. function Style() {
  699. var style;
  700. var sheet;
  701. function mount() {
  702. style = create("style", {}, document.head);
  703. sheet = style.sheet;
  704. }
  705. function destroy() {
  706. remove(style);
  707. sheet = null;
  708. }
  709. function rule(selector, prop, value) {
  710. var _sheet = sheet,
  711. cssRules = _sheet.cssRules;
  712. var cssRule = find(cssRules, function (cssRule2) {
  713. return isCSSStyleRule(cssRule2) && cssRule2.selectorText === selector;
  714. }) || cssRules[sheet.insertRule(selector + "{}", 0)];
  715. if (isCSSStyleRule(cssRule)) {
  716. var style2 = cssRule.style;
  717. value = "" + value;
  718. if (style2[prop] !== value) {
  719. style2[prop] = value;
  720. }
  721. }
  722. }
  723. function ruleBy(target, prop, value) {
  724. rule("#" + (isHTMLElement(target) ? target.id : target), prop, value);
  725. }
  726. function isCSSStyleRule(cssRule) {
  727. return cssRule instanceof CSSStyleRule;
  728. }
  729. return {
  730. mount: mount,
  731. destroy: destroy,
  732. rule: rule,
  733. ruleBy: ruleBy
  734. };
  735. }
  736. var ROLE = "role";
  737. var ARIA_CONTROLS = "aria-controls";
  738. var ARIA_CURRENT = "aria-current";
  739. var ARIA_LABEL = "aria-label";
  740. var ARIA_HIDDEN = "aria-hidden";
  741. var TAB_INDEX = "tabindex";
  742. var DISABLED = "disabled";
  743. var ARIA_ORIENTATION = "aria-orientation";
  744. var ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, ARIA_ORIENTATION, TAB_INDEX, DISABLED];
  745. var SLIDE = "slide";
  746. var LOOP = "loop";
  747. var FADE = "fade";
  748. function Slide$1(Splide2, index, slideIndex, slide) {
  749. var _EventInterface2 = EventInterface(Splide2),
  750. on = _EventInterface2.on,
  751. emit = _EventInterface2.emit,
  752. bind = _EventInterface2.bind,
  753. destroyEvents = _EventInterface2.destroy;
  754. var Components = Splide2.Components,
  755. root = Splide2.root,
  756. options = Splide2.options;
  757. var isNavigation = options.isNavigation,
  758. updateOnMove = options.updateOnMove;
  759. var resolve = Components.Direction.resolve;
  760. var isClone = slideIndex > -1;
  761. var container = child(slide, "." + CLASS_CONTAINER);
  762. var destroyed;
  763. function mount() {
  764. var _this2 = this;
  765. init();
  766. bind(slide, "click keydown", function (e) {
  767. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  768. });
  769. on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
  770. if (updateOnMove) {
  771. on(EVENT_MOVE, onMove.bind(this));
  772. }
  773. update.call(this);
  774. }
  775. function init() {
  776. if (!isClone) {
  777. slide.id = root.id + "-slide" + pad(index + 1);
  778. }
  779. if (isNavigation) {
  780. var idx = isClone ? slideIndex : index;
  781. var label = format(options.i18n.slideX, idx + 1);
  782. var controls = Splide2.splides.map(function (splide) {
  783. return splide.root.id;
  784. }).join(" ");
  785. setAttribute(slide, ARIA_LABEL, label);
  786. setAttribute(slide, ARIA_CONTROLS, controls);
  787. setAttribute(slide, ROLE, "menuitem");
  788. }
  789. }
  790. function destroy() {
  791. destroyed = true;
  792. destroyEvents();
  793. removeClass(slide, STATUS_CLASSES);
  794. removeAttribute(slide, ALL_ATTRIBUTES);
  795. }
  796. function onMove(next, prev, dest) {
  797. if (!destroyed) {
  798. update.call(this);
  799. if (dest === index) {
  800. updateActivity.call(this, true);
  801. }
  802. }
  803. }
  804. function update() {
  805. if (!destroyed) {
  806. var currIndex = Splide2.index;
  807. updateActivity.call(this, isActive());
  808. updateVisibility.call(this, isVisible());
  809. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  810. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  811. }
  812. }
  813. function updateActivity(active) {
  814. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  815. toggleClass(slide, CLASS_ACTIVE, active);
  816. if (isNavigation) {
  817. setAttribute(slide, ARIA_CURRENT, active || null);
  818. }
  819. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  820. }
  821. }
  822. function updateVisibility(visible) {
  823. var focusableNodes = options.focusableNodes;
  824. var ariaHidden = !visible && !isActive();
  825. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  826. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  827. if (focusableNodes) {
  828. queryAll(slide, focusableNodes).forEach(function (node) {
  829. setAttribute(node, TAB_INDEX, ariaHidden ? -1 : null);
  830. });
  831. }
  832. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  833. toggleClass(slide, CLASS_VISIBLE, visible);
  834. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  835. }
  836. }
  837. function rule(prop, value, useContainer) {
  838. var selector = "#" + slide.id + (container && useContainer ? " > ." + CLASS_CONTAINER : "");
  839. Components.Style.rule(selector, prop, value);
  840. }
  841. function isActive() {
  842. return Splide2.index === index;
  843. }
  844. function isVisible() {
  845. if (Splide2.is(FADE)) {
  846. return isActive();
  847. }
  848. var trackRect = rect(Components.Elements.track);
  849. var slideRect = rect(slide);
  850. var left = resolve("left");
  851. var right = resolve("right");
  852. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  853. }
  854. function isWithin(from, distance) {
  855. var diff = abs(from - index);
  856. if (!Splide2.is(SLIDE) && !isClone) {
  857. diff = min(diff, Splide2.length - diff);
  858. }
  859. return diff <= distance;
  860. }
  861. return {
  862. index: index,
  863. slideIndex: slideIndex,
  864. slide: slide,
  865. container: container,
  866. isClone: isClone,
  867. mount: mount,
  868. destroy: destroy,
  869. rule: rule,
  870. isWithin: isWithin
  871. };
  872. }
  873. function Slides(Splide2, Components2, options) {
  874. var _EventInterface3 = EventInterface(Splide2),
  875. on = _EventInterface3.on,
  876. emit = _EventInterface3.emit,
  877. bind = _EventInterface3.bind;
  878. var _Components2$Elements = Components2.Elements,
  879. slides = _Components2$Elements.slides,
  880. list = _Components2$Elements.list;
  881. var Slides2 = [];
  882. function mount() {
  883. init();
  884. on(EVENT_REFRESH, refresh);
  885. }
  886. function init() {
  887. slides.forEach(function (slide, index) {
  888. register(slide, index, -1);
  889. });
  890. }
  891. function destroy() {
  892. forEach$1(function (Slide2) {
  893. Slide2.destroy();
  894. });
  895. empty(Slides2);
  896. }
  897. function refresh() {
  898. destroy();
  899. init();
  900. }
  901. function register(slide, index, slideIndex) {
  902. var object = Slide$1(Splide2, index, slideIndex, slide);
  903. object.mount();
  904. Slides2.push(object);
  905. }
  906. function get(excludeClones) {
  907. return excludeClones ? filter(function (Slide2) {
  908. return !Slide2.isClone;
  909. }) : Slides2;
  910. }
  911. function getIn(page) {
  912. var Controller = Components2.Controller;
  913. var index = Controller.toIndex(page);
  914. var max = Controller.hasFocus() ? 1 : options.perPage;
  915. return filter(function (Slide2) {
  916. return between(Slide2.index, index, index + max - 1);
  917. });
  918. }
  919. function getAt(index) {
  920. return filter(index)[0];
  921. }
  922. function add(items, index) {
  923. forEach(items, function (slide) {
  924. if (isString(slide)) {
  925. slide = parseHtml(slide);
  926. }
  927. if (isHTMLElement(slide)) {
  928. var ref = slides[index];
  929. ref ? before(slide, ref) : append(list, slide);
  930. addClass(slide, options.classes.slide);
  931. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  932. }
  933. });
  934. emit(EVENT_REFRESH);
  935. }
  936. function remove$1(matcher) {
  937. remove(filter(matcher).map(function (Slide2) {
  938. return Slide2.slide;
  939. }));
  940. emit(EVENT_REFRESH);
  941. }
  942. function forEach$1(iteratee, excludeClones) {
  943. get(excludeClones).forEach(iteratee);
  944. }
  945. function filter(matcher) {
  946. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  947. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  948. });
  949. }
  950. function rule(prop, value, useContainer) {
  951. forEach$1(function (Slide2) {
  952. Slide2.rule(prop, value, useContainer);
  953. });
  954. }
  955. function observeImages(elm, callback) {
  956. var images = queryAll(elm, "img");
  957. var length = images.length;
  958. if (length) {
  959. images.forEach(function (img) {
  960. bind(img, "load error", function () {
  961. if (! --length) {
  962. callback();
  963. }
  964. });
  965. });
  966. } else {
  967. callback();
  968. }
  969. }
  970. function getLength(excludeClones) {
  971. return excludeClones ? slides.length : Slides2.length;
  972. }
  973. function isEnough() {
  974. return Slides2.length > options.perPage;
  975. }
  976. return {
  977. mount: mount,
  978. destroy: destroy,
  979. register: register,
  980. get: get,
  981. getIn: getIn,
  982. getAt: getAt,
  983. add: add,
  984. remove: remove$1,
  985. forEach: forEach$1,
  986. filter: filter,
  987. rule: rule,
  988. getLength: getLength,
  989. isEnough: isEnough
  990. };
  991. }
  992. function Clones(Splide2, Components2, options) {
  993. var _EventInterface4 = EventInterface(Splide2),
  994. on = _EventInterface4.on,
  995. emit = _EventInterface4.emit;
  996. var Elements = Components2.Elements,
  997. Slides = Components2.Slides;
  998. var resolve = Components2.Direction.resolve;
  999. var clones = [];
  1000. var cloneCount;
  1001. function mount() {
  1002. init();
  1003. on(EVENT_REFRESH, refresh);
  1004. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1005. }
  1006. function init() {
  1007. if (cloneCount = computeCloneCount()) {
  1008. generate(cloneCount);
  1009. }
  1010. }
  1011. function destroy() {
  1012. remove(clones);
  1013. empty(clones);
  1014. }
  1015. function refresh() {
  1016. destroy();
  1017. init();
  1018. }
  1019. function observe() {
  1020. if (cloneCount !== computeCloneCount()) {
  1021. emit(EVENT_REFRESH);
  1022. }
  1023. }
  1024. function generate(count) {
  1025. var slides = Slides.get().slice();
  1026. var length = slides.length;
  1027. if (length) {
  1028. while (slides.length < count) {
  1029. push(slides, slides);
  1030. }
  1031. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1032. var isHead = index < count;
  1033. var clone = cloneDeep(Slide.slide, index);
  1034. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1035. push(clones, clone);
  1036. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1037. });
  1038. }
  1039. }
  1040. function cloneDeep(elm, index) {
  1041. var clone = elm.cloneNode(true);
  1042. addClass(clone, options.classes.clone);
  1043. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1044. return clone;
  1045. }
  1046. function computeCloneCount() {
  1047. var clones2 = options.clones;
  1048. if (!Splide2.is(LOOP)) {
  1049. clones2 = 0;
  1050. } else if (!clones2) {
  1051. var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
  1052. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1053. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1054. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1055. }
  1056. return clones2;
  1057. }
  1058. return {
  1059. mount: mount,
  1060. destroy: destroy
  1061. };
  1062. }
  1063. function Layout(Splide2, Components2, options) {
  1064. var _EventInterface5 = EventInterface(Splide2),
  1065. on = _EventInterface5.on,
  1066. bind = _EventInterface5.bind,
  1067. emit = _EventInterface5.emit;
  1068. var Slides = Components2.Slides;
  1069. var ruleBy = Components2.Style.ruleBy;
  1070. var resolve = Components2.Direction.resolve;
  1071. var _Components2$Elements2 = Components2.Elements,
  1072. track = _Components2$Elements2.track,
  1073. list = _Components2$Elements2.list;
  1074. var getAt = Slides.getAt;
  1075. var vertical = options.direction === TTB;
  1076. function mount() {
  1077. init();
  1078. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  1079. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1080. on(EVENT_RESIZE, resize);
  1081. }
  1082. function init() {
  1083. ruleBy(Splide2.root, "maxWidth", unit(options.width));
  1084. ruleBy(track, resolve("paddingLeft"), cssPadding(false));
  1085. ruleBy(track, resolve("paddingRight"), cssPadding(true));
  1086. Slides.rule(resolve("marginRight"), unit(options.gap));
  1087. Slides.rule("width", cssSlideWidth());
  1088. setSlidesHeight();
  1089. resize();
  1090. }
  1091. function resize() {
  1092. ruleBy(track, "height", cssTrackHeight());
  1093. options.heightRatio && setSlidesHeight();
  1094. emit(EVENT_RESIZED);
  1095. }
  1096. function setSlidesHeight() {
  1097. Slides.rule("height", cssSlideHeight(), true);
  1098. }
  1099. function cssPadding(right) {
  1100. var padding = options.padding;
  1101. var prop = resolve(right ? "right" : "left", true);
  1102. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  1103. }
  1104. function cssTrackHeight() {
  1105. var height = "";
  1106. if (vertical) {
  1107. height = cssHeight();
  1108. assert(height, "height or heightRatio is missing.");
  1109. height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")";
  1110. }
  1111. return height;
  1112. }
  1113. function cssHeight() {
  1114. return unit(options.height || rect(list).width * options.heightRatio);
  1115. }
  1116. function cssSlideWidth() {
  1117. return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1118. }
  1119. function cssSlideHeight() {
  1120. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
  1121. }
  1122. function cssSlideSize() {
  1123. var gap = unit(options.gap);
  1124. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1125. }
  1126. function listSize() {
  1127. return rect(list)[resolve("width")];
  1128. }
  1129. function slideSize(index, withoutGap) {
  1130. var Slide = getAt(index || 0);
  1131. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1132. }
  1133. function totalSize(index, withoutGap) {
  1134. var Slide = getAt(index);
  1135. if (Slide) {
  1136. var right = rect(Slide.slide)[resolve("right")];
  1137. var left = rect(list)[resolve("left")];
  1138. return abs(right - left) + (withoutGap ? 0 : getGap());
  1139. }
  1140. return 0;
  1141. }
  1142. function sliderSize() {
  1143. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1144. }
  1145. function getGap() {
  1146. var Slide = getAt(0);
  1147. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1148. }
  1149. function getPadding(right) {
  1150. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left"), true))) || 0;
  1151. }
  1152. return {
  1153. mount: mount,
  1154. listSize: listSize,
  1155. slideSize: slideSize,
  1156. sliderSize: sliderSize,
  1157. totalSize: totalSize,
  1158. getPadding: getPadding
  1159. };
  1160. }
  1161. function Move(Splide2, Components2, options) {
  1162. var _EventInterface6 = EventInterface(Splide2),
  1163. on = _EventInterface6.on,
  1164. emit = _EventInterface6.emit;
  1165. var _Components2$Layout = Components2.Layout,
  1166. slideSize = _Components2$Layout.slideSize,
  1167. getPadding = _Components2$Layout.getPadding,
  1168. totalSize = _Components2$Layout.totalSize,
  1169. listSize = _Components2$Layout.listSize,
  1170. sliderSize = _Components2$Layout.sliderSize;
  1171. var _Components2$Directio = Components2.Direction,
  1172. resolve = _Components2$Directio.resolve,
  1173. orient = _Components2$Directio.orient;
  1174. var _Components2$Elements3 = Components2.Elements,
  1175. list = _Components2$Elements3.list,
  1176. track = _Components2$Elements3.track;
  1177. var waiting;
  1178. function mount() {
  1179. if (!Splide2.is(FADE)) {
  1180. on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
  1181. }
  1182. }
  1183. function reposition() {
  1184. Components2.Scroll.cancel();
  1185. cancel();
  1186. jump(Splide2.index);
  1187. }
  1188. function move(dest, index, prev, callback) {
  1189. if (!isBusy()) {
  1190. var set = Splide2.state.set;
  1191. var position = getPosition();
  1192. var looping = dest !== index;
  1193. waiting = looping || options.waitForTransition;
  1194. set(MOVING);
  1195. emit(EVENT_MOVE, index, prev, dest);
  1196. Components2.Transition.start(dest, function () {
  1197. looping && jump(index);
  1198. waiting = false;
  1199. set(IDLE);
  1200. emit(EVENT_MOVED, index, prev, dest);
  1201. if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
  1202. Components2.Controller.go(dest > prev ? ">" : "<", false, callback);
  1203. } else {
  1204. callback && callback();
  1205. }
  1206. });
  1207. }
  1208. }
  1209. function jump(index) {
  1210. translate(toPosition(index, true));
  1211. }
  1212. function translate(position) {
  1213. Components2.Style.ruleBy(list, "transform", "translate" + resolve("X") + "(" + loop(position) + "px)");
  1214. }
  1215. function loop(position) {
  1216. if (!waiting && Splide2.is(LOOP)) {
  1217. var diff = position - getPosition();
  1218. var exceededMin = exceededLimit(false, position);
  1219. var exceededMax = exceededLimit(true, position);
  1220. if (exceededMin && diff > 0 || exceededMax && diff < 0) {
  1221. position += orient(sliderSize() * (exceededMin ? 1 : -1));
  1222. }
  1223. }
  1224. return position;
  1225. }
  1226. function cancel() {
  1227. waiting = false;
  1228. Components2.Transition.cancel();
  1229. translate(getPosition());
  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 isBusy() {
  1269. return !!waiting;
  1270. }
  1271. function exceededLimit(max, position) {
  1272. position = isUndefined(position) ? getPosition() : position;
  1273. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1274. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1275. return exceededMin || exceededMax;
  1276. }
  1277. return {
  1278. mount: mount,
  1279. move: move,
  1280. jump: jump,
  1281. translate: translate,
  1282. cancel: cancel,
  1283. toIndex: toIndex,
  1284. toPosition: toPosition,
  1285. getPosition: getPosition,
  1286. getLimit: getLimit,
  1287. isBusy: isBusy,
  1288. exceededLimit: exceededLimit
  1289. };
  1290. }
  1291. function Controller(Splide2, Components2, options) {
  1292. var _EventInterface7 = EventInterface(Splide2),
  1293. on = _EventInterface7.on;
  1294. var Move = Components2.Move;
  1295. var getPosition = Move.getPosition,
  1296. getLimit = Move.getLimit;
  1297. var _Components2$Slides = Components2.Slides,
  1298. isEnough = _Components2$Slides.isEnough,
  1299. getLength = _Components2$Slides.getLength;
  1300. var isLoop = Splide2.is(LOOP);
  1301. var currIndex = options.start || 0;
  1302. var prevIndex = currIndex;
  1303. var slideCount;
  1304. var perMove;
  1305. var perPage;
  1306. function mount() {
  1307. init();
  1308. on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 2);
  1309. on(EVENT_SCROLLED, reindex, 0);
  1310. }
  1311. function init() {
  1312. slideCount = getLength(true);
  1313. perMove = options.perMove;
  1314. perPage = options.perPage;
  1315. currIndex = clamp(currIndex, 0, slideCount - 1);
  1316. }
  1317. function reindex() {
  1318. setIndex(Move.toIndex(getPosition()));
  1319. }
  1320. function go(control, allowSameIndex, callback) {
  1321. var dest = parse(control);
  1322. var index = loop(dest);
  1323. if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
  1324. setIndex(index);
  1325. Move.move(dest, index, prevIndex, callback);
  1326. }
  1327. }
  1328. function parse(control) {
  1329. var index = currIndex;
  1330. if (isString(control)) {
  1331. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1332. indicator = _ref[1],
  1333. number = _ref[2];
  1334. if (indicator === "+" || indicator === "-") {
  1335. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
  1336. } else if (indicator === ">") {
  1337. index = number ? toIndex(+number) : getNext(true);
  1338. } else if (indicator === "<") {
  1339. index = getPrev(true);
  1340. }
  1341. } else {
  1342. if (isLoop) {
  1343. index = clamp(control, -perPage, slideCount + perPage - 1);
  1344. } else {
  1345. index = clamp(control, 0, getEnd());
  1346. }
  1347. }
  1348. return index;
  1349. }
  1350. function getNext(destination) {
  1351. return getAdjacent(false, destination);
  1352. }
  1353. function getPrev(destination) {
  1354. return getAdjacent(true, destination);
  1355. }
  1356. function getAdjacent(prev, destination) {
  1357. var number = perMove || hasFocus() ? 1 : perPage;
  1358. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
  1359. if (dest === -1 && Splide2.is(SLIDE)) {
  1360. if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
  1361. return prev ? 0 : getEnd();
  1362. }
  1363. }
  1364. return destination ? dest : loop(dest);
  1365. }
  1366. function computeDestIndex(dest, from, incremental) {
  1367. if (isEnough()) {
  1368. var end = getEnd();
  1369. if (dest < 0 || dest > end) {
  1370. if (between(0, dest, from, true) || between(end, from, dest, true)) {
  1371. dest = toIndex(toPage(dest));
  1372. } else {
  1373. if (isLoop) {
  1374. dest = perMove ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount;
  1375. } else if (options.rewind) {
  1376. dest = dest < 0 ? end : 0;
  1377. } else {
  1378. dest = -1;
  1379. }
  1380. }
  1381. } else {
  1382. if (!isLoop && !incremental && dest !== from) {
  1383. dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
  1384. }
  1385. }
  1386. } else {
  1387. dest = -1;
  1388. }
  1389. return dest;
  1390. }
  1391. function getEnd() {
  1392. var end = slideCount - perPage;
  1393. if (hasFocus() || isLoop && perMove) {
  1394. end = slideCount - 1;
  1395. }
  1396. return max(end, 0);
  1397. }
  1398. function loop(index) {
  1399. if (isLoop) {
  1400. return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1;
  1401. }
  1402. return index;
  1403. }
  1404. function toIndex(page) {
  1405. return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
  1406. }
  1407. function toPage(index) {
  1408. if (!hasFocus()) {
  1409. index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index;
  1410. index = floor(index / perPage);
  1411. }
  1412. return index;
  1413. }
  1414. function setIndex(index) {
  1415. if (index !== currIndex) {
  1416. prevIndex = currIndex;
  1417. currIndex = index;
  1418. }
  1419. }
  1420. function getIndex(prev) {
  1421. return prev ? prevIndex : currIndex;
  1422. }
  1423. function hasFocus() {
  1424. return !isUndefined(options.focus) || options.isNavigation;
  1425. }
  1426. return {
  1427. mount: mount,
  1428. go: go,
  1429. getNext: getNext,
  1430. getPrev: getPrev,
  1431. getEnd: getEnd,
  1432. setIndex: setIndex,
  1433. getIndex: getIndex,
  1434. toIndex: toIndex,
  1435. toPage: toPage,
  1436. hasFocus: hasFocus
  1437. };
  1438. }
  1439. var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1440. 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";
  1441. var SIZE = 40;
  1442. function Arrows(Splide2, Components2, options) {
  1443. var _EventInterface8 = EventInterface(Splide2),
  1444. on = _EventInterface8.on,
  1445. bind = _EventInterface8.bind,
  1446. emit = _EventInterface8.emit;
  1447. var classes = options.classes,
  1448. i18n = options.i18n;
  1449. var Elements = Components2.Elements,
  1450. Controller = Components2.Controller;
  1451. var wrapper = Elements.arrows;
  1452. var prev = Elements.prev;
  1453. var next = Elements.next;
  1454. var created;
  1455. var arrows = {};
  1456. function mount() {
  1457. init();
  1458. on(EVENT_UPDATED, init);
  1459. }
  1460. function init() {
  1461. if (options.arrows) {
  1462. if (!prev || !next) {
  1463. createArrows();
  1464. }
  1465. }
  1466. if (prev && next) {
  1467. if (!arrows.prev) {
  1468. var id = Elements.track.id;
  1469. setAttribute(prev, ARIA_CONTROLS, id);
  1470. setAttribute(next, ARIA_CONTROLS, id);
  1471. arrows.prev = prev;
  1472. arrows.next = next;
  1473. listen();
  1474. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1475. } else {
  1476. display(wrapper, options.arrows === false ? "none" : "");
  1477. }
  1478. }
  1479. }
  1480. function destroy() {
  1481. if (created) {
  1482. remove(wrapper);
  1483. } else {
  1484. removeAttribute(prev, ALL_ATTRIBUTES);
  1485. removeAttribute(next, ALL_ATTRIBUTES);
  1486. }
  1487. }
  1488. function listen() {
  1489. var go = Controller.go;
  1490. on([EVENT_MOUNTED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1491. bind(next, "click", function () {
  1492. go(">", true);
  1493. });
  1494. bind(prev, "click", function () {
  1495. go("<", true);
  1496. });
  1497. }
  1498. function createArrows() {
  1499. wrapper = create("div", classes.arrows);
  1500. prev = createArrow(true);
  1501. next = createArrow(false);
  1502. created = true;
  1503. append(wrapper, [prev, next]);
  1504. before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root));
  1505. }
  1506. function createArrow(prev2) {
  1507. 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) + "\" />";
  1508. return parseHtml(arrow);
  1509. }
  1510. function update() {
  1511. var index = Splide2.index;
  1512. var prevIndex = Controller.getPrev();
  1513. var nextIndex = Controller.getNext();
  1514. var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1515. var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1516. prev.disabled = prevIndex < 0;
  1517. next.disabled = nextIndex < 0;
  1518. setAttribute(prev, ARIA_LABEL, prevLabel);
  1519. setAttribute(next, ARIA_LABEL, nextLabel);
  1520. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1521. }
  1522. return {
  1523. arrows: arrows,
  1524. mount: mount,
  1525. destroy: destroy
  1526. };
  1527. }
  1528. function Autoplay(Splide2, Components2, options) {
  1529. var _EventInterface9 = EventInterface(Splide2),
  1530. on = _EventInterface9.on,
  1531. bind = _EventInterface9.bind,
  1532. emit = _EventInterface9.emit;
  1533. var Elements = Components2.Elements;
  1534. var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), update);
  1535. var isPaused = interval.isPaused;
  1536. var hovered;
  1537. var focused;
  1538. var paused;
  1539. function mount() {
  1540. var autoplay = options.autoplay;
  1541. if (autoplay) {
  1542. initButton(true);
  1543. initButton(false);
  1544. listen();
  1545. if (autoplay !== "pause") {
  1546. play();
  1547. }
  1548. }
  1549. }
  1550. function initButton(forPause) {
  1551. var prop = forPause ? "pause" : "play";
  1552. var button = Elements[prop];
  1553. if (button) {
  1554. setAttribute(button, ARIA_CONTROLS, Elements.track.id);
  1555. setAttribute(button, ARIA_LABEL, options.i18n[prop]);
  1556. bind(button, "click", forPause ? pause : play);
  1557. }
  1558. }
  1559. function listen() {
  1560. var root = Elements.root;
  1561. if (options.pauseOnHover) {
  1562. bind(root, "mouseenter mouseleave", function (e) {
  1563. hovered = e.type === "mouseenter";
  1564. autoToggle();
  1565. });
  1566. }
  1567. if (options.pauseOnFocus) {
  1568. bind(root, "focusin focusout", function (e) {
  1569. focused = e.type === "focusin";
  1570. autoToggle();
  1571. });
  1572. }
  1573. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1574. }
  1575. function play() {
  1576. if (isPaused() && Components2.Slides.isEnough()) {
  1577. interval.start(!options.resetProgress);
  1578. focused = hovered = paused = false;
  1579. emit(EVENT_AUTOPLAY_PLAY);
  1580. }
  1581. }
  1582. function pause(manual) {
  1583. if (manual === void 0) {
  1584. manual = true;
  1585. }
  1586. if (!isPaused()) {
  1587. interval.pause();
  1588. emit(EVENT_AUTOPLAY_PAUSE);
  1589. }
  1590. paused = manual;
  1591. }
  1592. function autoToggle() {
  1593. if (!paused) {
  1594. if (!hovered && !focused) {
  1595. play();
  1596. } else {
  1597. pause(false);
  1598. }
  1599. }
  1600. }
  1601. function update(rate) {
  1602. var bar = Elements.bar;
  1603. if (bar) {
  1604. style(bar, {
  1605. width: rate * 100 + "%"
  1606. });
  1607. }
  1608. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1609. }
  1610. return {
  1611. mount: mount,
  1612. destroy: interval.cancel,
  1613. play: play,
  1614. pause: pause,
  1615. isPaused: isPaused
  1616. };
  1617. }
  1618. function Cover(Splide2, Components2, options) {
  1619. var _EventInterface10 = EventInterface(Splide2),
  1620. on = _EventInterface10.on;
  1621. function mount() {
  1622. if (options.cover) {
  1623. on(EVENT_LAZYLOAD_LOADED, function (img, Slide) {
  1624. toggle(true, img, Slide);
  1625. });
  1626. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply.bind(null, true));
  1627. }
  1628. }
  1629. function destroy() {
  1630. apply(false);
  1631. }
  1632. function apply(cover) {
  1633. Components2.Slides.forEach(function (Slide) {
  1634. var img = child(Slide.container || Slide.slide, "img");
  1635. if (img && img.src) {
  1636. toggle(cover, img, Slide);
  1637. }
  1638. });
  1639. }
  1640. function toggle(cover, img, Slide) {
  1641. Slide.rule("background", cover ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
  1642. display(img, cover ? "none" : "");
  1643. }
  1644. return {
  1645. mount: mount,
  1646. destroy: destroy
  1647. };
  1648. }
  1649. var BOUNCE_DIFF_THRESHOLD = 10;
  1650. var BOUNCE_DURATION = 600;
  1651. var FRICTION_FACTOR = 0.6;
  1652. var BASE_VELOCITY = 1.5;
  1653. var MIN_DURATION = 800;
  1654. function Scroll(Splide2, Components2, options) {
  1655. var _EventInterface11 = EventInterface(Splide2),
  1656. on = _EventInterface11.on,
  1657. emit = _EventInterface11.emit;
  1658. var Move = Components2.Move;
  1659. var getPosition = Move.getPosition,
  1660. getLimit = Move.getLimit,
  1661. exceededLimit = Move.exceededLimit;
  1662. var interval;
  1663. function mount() {
  1664. on(EVENT_MOVE, clear);
  1665. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1666. }
  1667. function scroll(destination, duration, suppressConstraint) {
  1668. var start = getPosition();
  1669. var friction = 1;
  1670. duration = duration || computeDuration(abs(destination - start));
  1671. clear();
  1672. interval = RequestInterval(duration, onScrolled, function (rate) {
  1673. var position = getPosition();
  1674. var target = start + (destination - start) * easing(rate);
  1675. var diff = (target - getPosition()) * friction;
  1676. Move.translate(position + diff);
  1677. if (Splide2.is(SLIDE) && !suppressConstraint && exceededLimit()) {
  1678. friction *= FRICTION_FACTOR;
  1679. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1680. bounce(exceededLimit(false));
  1681. }
  1682. }
  1683. }, 1);
  1684. emit(EVENT_SCROLL);
  1685. interval.start();
  1686. }
  1687. function bounce(backwards) {
  1688. scroll(getLimit(!backwards), BOUNCE_DURATION, true);
  1689. }
  1690. function onScrolled() {
  1691. emit(EVENT_SCROLLED);
  1692. }
  1693. function computeDuration(distance) {
  1694. return max(distance / BASE_VELOCITY, MIN_DURATION);
  1695. }
  1696. function clear() {
  1697. if (interval) {
  1698. interval.cancel();
  1699. }
  1700. }
  1701. function cancel() {
  1702. if (interval && !interval.isPaused()) {
  1703. clear();
  1704. onScrolled();
  1705. }
  1706. }
  1707. function easing(t) {
  1708. var easingFunc = options.easingFunc;
  1709. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1710. }
  1711. return {
  1712. mount: mount,
  1713. destroy: clear,
  1714. scroll: scroll,
  1715. cancel: cancel
  1716. };
  1717. }
  1718. var FRICTION = 5;
  1719. var LOG_INTERVAL = 50;
  1720. var POINTER_DOWN_EVENTS = "touchstart mousedown";
  1721. var POINTER_MOVE_EVENTS = "touchmove mousemove";
  1722. var POINTER_UP_EVENTS = "touchend touchcancel mouseup mouseleave";
  1723. function Drag(Splide2, Components2, options) {
  1724. var _EventInterface12 = EventInterface(Splide2),
  1725. on = _EventInterface12.on,
  1726. emit = _EventInterface12.emit,
  1727. bind = _EventInterface12.bind,
  1728. unbind = _EventInterface12.unbind;
  1729. var Move = Components2.Move,
  1730. Scroll = Components2.Scroll,
  1731. Controller = Components2.Controller;
  1732. var track = Components2.Elements.track;
  1733. var _Components2$Directio2 = Components2.Direction,
  1734. resolve = _Components2$Directio2.resolve,
  1735. orient = _Components2$Directio2.orient;
  1736. var getPosition = Move.getPosition,
  1737. exceededLimit = Move.exceededLimit;
  1738. var isSlide = Splide2.is(SLIDE);
  1739. var isFade = Splide2.is(FADE);
  1740. var basePosition;
  1741. var baseEvent;
  1742. var prevBaseEvent;
  1743. var lastEvent;
  1744. var isFree;
  1745. var isDragging;
  1746. var isMouse;
  1747. var hasExceeded = false;
  1748. var clickPrevented;
  1749. var disabled;
  1750. var target;
  1751. function mount() {
  1752. bind(track, POINTER_DOWN_EVENTS, onPointerDown, {
  1753. passive: false,
  1754. capture: true
  1755. });
  1756. bind(track, "click", onClick, {
  1757. capture: true
  1758. });
  1759. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1760. }
  1761. function init() {
  1762. var drag = options.drag;
  1763. disable(!drag);
  1764. isFree = drag === "free";
  1765. }
  1766. function onPointerDown(e) {
  1767. if (!disabled) {
  1768. isMouse = e.type === "mousedown";
  1769. if (!isMouse || !e.button) {
  1770. if (!Move.isBusy()) {
  1771. target = isMouse ? window : track;
  1772. prevBaseEvent = null;
  1773. lastEvent = null;
  1774. clickPrevented = false;
  1775. bind(target, POINTER_MOVE_EVENTS, onPointerMove);
  1776. bind(target, POINTER_UP_EVENTS, onPointerUp);
  1777. Move.cancel();
  1778. Scroll.cancel();
  1779. save(e);
  1780. } else {
  1781. prevent(e, true);
  1782. }
  1783. }
  1784. }
  1785. }
  1786. function onPointerMove(e) {
  1787. if (!lastEvent) {
  1788. clickPrevented = true;
  1789. emit(EVENT_DRAG);
  1790. }
  1791. lastEvent = e;
  1792. if (e.cancelable) {
  1793. if (isDragging) {
  1794. var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
  1795. var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
  1796. if (expired || exceeded) {
  1797. save(e);
  1798. }
  1799. if (!isFade) {
  1800. Move.translate(basePosition + constrain(coordOf(e) - coordOf(baseEvent)));
  1801. }
  1802. emit(EVENT_DRAGGING);
  1803. prevent(e);
  1804. } else {
  1805. var threshold = options.dragMinThreshold || 15;
  1806. isDragging = isMouse || abs(coordOf(e) - coordOf(baseEvent)) > threshold;
  1807. if (isSliderDirection()) {
  1808. prevent(e);
  1809. }
  1810. }
  1811. }
  1812. }
  1813. function onPointerUp(e) {
  1814. unbind(target, POINTER_MOVE_EVENTS + " " + POINTER_UP_EVENTS);
  1815. if (lastEvent) {
  1816. if (isDragging || e.cancelable && isSliderDirection()) {
  1817. var velocity = computeVelocity(e);
  1818. var destination = computeDestination(velocity);
  1819. if (isFree) {
  1820. Scroll.scroll(destination);
  1821. } else if (isFade) {
  1822. Controller.go(Splide2.index + orient(sign(velocity)));
  1823. } else {
  1824. Controller.go(computeIndex(destination), true);
  1825. }
  1826. prevent(e);
  1827. }
  1828. emit(EVENT_DRAGGED);
  1829. }
  1830. isDragging = false;
  1831. }
  1832. function save(e) {
  1833. prevBaseEvent = baseEvent;
  1834. baseEvent = e;
  1835. basePosition = getPosition();
  1836. }
  1837. function onClick(e) {
  1838. if (!disabled && clickPrevented) {
  1839. prevent(e, true);
  1840. }
  1841. }
  1842. function isSliderDirection() {
  1843. var diffX = abs(coordOf(lastEvent) - coordOf(baseEvent));
  1844. var diffY = abs(coordOf(lastEvent, true) - coordOf(baseEvent, true));
  1845. return diffX > diffY;
  1846. }
  1847. function computeVelocity(e) {
  1848. if (Splide2.is(LOOP) || !hasExceeded) {
  1849. var base = baseEvent === lastEvent && prevBaseEvent || baseEvent;
  1850. var diffCoord = coordOf(lastEvent) - coordOf(base);
  1851. var diffTime = timeOf(e) - timeOf(base);
  1852. var isFlick = timeOf(e) - timeOf(lastEvent) < LOG_INTERVAL;
  1853. if (diffTime && isFlick) {
  1854. return diffCoord / diffTime;
  1855. }
  1856. }
  1857. return 0;
  1858. }
  1859. function computeDestination(velocity) {
  1860. return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
  1861. }
  1862. function computeIndex(destination) {
  1863. var dest = Move.toIndex(destination);
  1864. return isSlide ? clamp(dest, 0, Controller.getEnd()) : dest;
  1865. }
  1866. function coordOf(e, orthogonal) {
  1867. var prop = "page" + resolve(orthogonal ? "Y" : "X");
  1868. return (isMouse ? e : e.touches[0])[prop];
  1869. }
  1870. function timeOf(e) {
  1871. return e.timeStamp;
  1872. }
  1873. function constrain(diff) {
  1874. return diff / (hasExceeded && isSlide ? FRICTION : 1);
  1875. }
  1876. function disable(value) {
  1877. disabled = value;
  1878. }
  1879. return {
  1880. mount: mount,
  1881. disable: disable
  1882. };
  1883. }
  1884. var IE_ARROW_KEYS = ["Left", "Right", "Up", "Down"];
  1885. function Keyboard(Splide2, Components2, options) {
  1886. var _EventInterface13 = EventInterface(Splide2),
  1887. on = _EventInterface13.on,
  1888. bind = _EventInterface13.bind,
  1889. unbind = _EventInterface13.unbind;
  1890. var root = Components2.Elements.root;
  1891. var resolve = Components2.Direction.resolve;
  1892. var target;
  1893. function mount() {
  1894. init();
  1895. on(EVENT_UPDATED, function () {
  1896. destroy();
  1897. init();
  1898. });
  1899. }
  1900. function init() {
  1901. var _options$keyboard = options.keyboard,
  1902. keyboard = _options$keyboard === void 0 ? "global" : _options$keyboard;
  1903. if (keyboard) {
  1904. if (keyboard === "focused") {
  1905. target = root;
  1906. setAttribute(root, TAB_INDEX, 0);
  1907. } else {
  1908. target = window;
  1909. }
  1910. bind(target, "keydown", onKeydown);
  1911. }
  1912. }
  1913. function destroy() {
  1914. unbind(target, "keydown");
  1915. if (isHTMLElement(target)) {
  1916. removeAttribute(target, TAB_INDEX);
  1917. }
  1918. }
  1919. function onKeydown(e) {
  1920. var key = e.key;
  1921. var normalizedKey = includes(IE_ARROW_KEYS, key) ? "Arrow" + key : key;
  1922. if (normalizedKey === resolve("ArrowLeft")) {
  1923. Splide2.go("<");
  1924. } else if (normalizedKey === resolve("ArrowRight")) {
  1925. Splide2.go(">");
  1926. }
  1927. }
  1928. return {
  1929. mount: mount,
  1930. destroy: destroy
  1931. };
  1932. }
  1933. var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
  1934. var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
  1935. var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
  1936. function LazyLoad(Splide2, Components2, options) {
  1937. var _EventInterface14 = EventInterface(Splide2),
  1938. on = _EventInterface14.on,
  1939. off = _EventInterface14.off,
  1940. bind = _EventInterface14.bind,
  1941. emit = _EventInterface14.emit;
  1942. var isSequential = options.lazyLoad === "sequential";
  1943. var images = [];
  1944. var index = 0;
  1945. function mount() {
  1946. if (options.lazyLoad) {
  1947. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  1948. destroy();
  1949. init();
  1950. });
  1951. if (!isSequential) {
  1952. on([EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED], observe);
  1953. }
  1954. }
  1955. }
  1956. function init() {
  1957. Components2.Slides.forEach(function (_Slide) {
  1958. queryAll(_Slide.slide, IMAGE_SELECTOR).forEach(function (_img) {
  1959. var src = getAttribute(_img, SRC_DATA_ATTRIBUTE);
  1960. var srcset = getAttribute(_img, SRCSET_DATA_ATTRIBUTE);
  1961. if (src !== _img.src || srcset !== _img.srcset) {
  1962. var _spinner = create("span", options.classes.spinner, _img.parentElement);
  1963. setAttribute(_spinner, ROLE, "presentation");
  1964. images.push({
  1965. _img: _img,
  1966. _Slide: _Slide,
  1967. src: src,
  1968. srcset: srcset,
  1969. _spinner: _spinner
  1970. });
  1971. display(_img, "none");
  1972. }
  1973. });
  1974. });
  1975. if (isSequential) {
  1976. loadNext();
  1977. }
  1978. }
  1979. function destroy() {
  1980. index = 0;
  1981. images = [];
  1982. }
  1983. function observe() {
  1984. images = images.filter(function (data) {
  1985. if (data._Slide.isWithin(Splide2.index, options.perPage * ((options.preloadPages || 1) + 1))) {
  1986. return load(data);
  1987. }
  1988. return true;
  1989. });
  1990. if (!images.length) {
  1991. off(EVENT_MOVED);
  1992. }
  1993. }
  1994. function load(data) {
  1995. var _img = data._img;
  1996. addClass(data._Slide.slide, CLASS_LOADING);
  1997. bind(_img, "load error", function (e) {
  1998. onLoad(data, e.type === "error");
  1999. });
  2000. ["src", "srcset"].forEach(function (name) {
  2001. if (data[name]) {
  2002. setAttribute(_img, name, data[name]);
  2003. removeAttribute(_img, name === "src" ? SRC_DATA_ATTRIBUTE : SRCSET_DATA_ATTRIBUTE);
  2004. }
  2005. });
  2006. }
  2007. function onLoad(data, error) {
  2008. var _Slide = data._Slide;
  2009. removeClass(_Slide.slide, CLASS_LOADING);
  2010. if (!error) {
  2011. remove(data._spinner);
  2012. display(data._img, "");
  2013. emit(EVENT_LAZYLOAD_LOADED, data._img, _Slide);
  2014. emit(EVENT_RESIZE);
  2015. }
  2016. if (isSequential) {
  2017. loadNext();
  2018. }
  2019. }
  2020. function loadNext() {
  2021. if (index < images.length) {
  2022. load(images[index++]);
  2023. }
  2024. }
  2025. return {
  2026. mount: mount,
  2027. destroy: destroy
  2028. };
  2029. }
  2030. function Pagination(Splide2, Components2, options) {
  2031. var _EventInterface15 = EventInterface(Splide2),
  2032. on = _EventInterface15.on,
  2033. emit = _EventInterface15.emit,
  2034. bind = _EventInterface15.bind,
  2035. unbind = _EventInterface15.unbind;
  2036. var Slides = Components2.Slides,
  2037. Elements = Components2.Elements,
  2038. Controller = Components2.Controller;
  2039. var hasFocus = Controller.hasFocus,
  2040. getIndex = Controller.getIndex;
  2041. var items = [];
  2042. var list;
  2043. function mount() {
  2044. init();
  2045. on([EVENT_UPDATED, EVENT_REFRESH], init);
  2046. on([EVENT_MOVE, EVENT_SCROLLED], update);
  2047. }
  2048. function init() {
  2049. destroy();
  2050. if (options.pagination && Slides.isEnough()) {
  2051. createPagination();
  2052. emit(EVENT_PAGINATION_MOUNTED, {
  2053. list: list,
  2054. items: items
  2055. }, getAt(Splide2.index));
  2056. update();
  2057. }
  2058. }
  2059. function destroy() {
  2060. if (list) {
  2061. remove(list);
  2062. items.forEach(function (item) {
  2063. unbind(item.button, "click");
  2064. });
  2065. empty(items);
  2066. list = null;
  2067. }
  2068. }
  2069. function createPagination() {
  2070. var length = Splide2.length;
  2071. var classes = options.classes,
  2072. i18n = options.i18n,
  2073. perPage = options.perPage;
  2074. var parent = options.pagination === "slider" && Elements.slider || Elements.root;
  2075. var max = hasFocus() ? length : ceil(length / perPage);
  2076. list = create("ul", classes.pagination, parent);
  2077. for (var i = 0; i < max; i++) {
  2078. var li = create("li", null, list);
  2079. var button = create("button", {
  2080. class: classes.page,
  2081. type: "button"
  2082. }, li);
  2083. var controls = Slides.getIn(i).map(function (Slide) {
  2084. return Slide.slide.id;
  2085. });
  2086. var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2087. bind(button, "click", onClick.bind(null, i));
  2088. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2089. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2090. items.push({
  2091. li: li,
  2092. button: button,
  2093. page: i
  2094. });
  2095. }
  2096. }
  2097. function onClick(page) {
  2098. Controller.go(">" + page, true, function () {
  2099. var Slide = Slides.getAt(Controller.toIndex(page));
  2100. Slide && Slide.slide.focus();
  2101. });
  2102. }
  2103. function getAt(index) {
  2104. return items[Controller.toPage(index)];
  2105. }
  2106. function update() {
  2107. var prev = getAt(getIndex(true));
  2108. var curr = getAt(getIndex());
  2109. if (prev) {
  2110. removeClass(prev.button, CLASS_ACTIVE);
  2111. removeAttribute(prev.button, ARIA_CURRENT);
  2112. }
  2113. if (curr) {
  2114. addClass(curr.button, CLASS_ACTIVE);
  2115. setAttribute(curr.button, ARIA_CURRENT, true);
  2116. }
  2117. emit(EVENT_PAGINATION_UPDATED, {
  2118. list: list,
  2119. items: items
  2120. }, prev, curr);
  2121. }
  2122. return {
  2123. items: items,
  2124. mount: mount,
  2125. destroy: destroy,
  2126. getAt: getAt
  2127. };
  2128. }
  2129. var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
  2130. function Sync(Splide2, Components2, options) {
  2131. var splides = Splide2.splides;
  2132. var list = Components2.Elements.list;
  2133. function mount() {
  2134. if (options.isNavigation) {
  2135. navigate();
  2136. } else {
  2137. sync();
  2138. }
  2139. }
  2140. function destroy() {
  2141. removeAttribute(list, ALL_ATTRIBUTES);
  2142. }
  2143. function sync() {
  2144. var processed = [];
  2145. splides.concat(Splide2).forEach(function (splide, index, instances) {
  2146. EventInterface(splide).on(EVENT_MOVE, function (index2, prev, dest) {
  2147. instances.forEach(function (instance) {
  2148. if (instance !== splide && !includes(processed, splide)) {
  2149. processed.push(instance);
  2150. instance.go(instance.is(LOOP) ? dest : index2);
  2151. }
  2152. });
  2153. empty(processed);
  2154. });
  2155. });
  2156. }
  2157. function navigate() {
  2158. var _EventInterface16 = EventInterface(Splide2),
  2159. on = _EventInterface16.on,
  2160. emit = _EventInterface16.emit;
  2161. on(EVENT_CLICK, onClick);
  2162. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2163. emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2164. setAttribute(list, ROLE, "menu");
  2165. setAttribute(list, ARIA_ORIENTATION, options.direction !== TTB ? "horizontal" : null);
  2166. }
  2167. function onClick(Slide) {
  2168. Splide2.go(Slide.index);
  2169. }
  2170. function onKeydown(Slide, e) {
  2171. if (includes(TRIGGER_KEYS, e.key)) {
  2172. onClick(Slide);
  2173. prevent(e);
  2174. }
  2175. }
  2176. return {
  2177. mount: mount,
  2178. destroy: destroy
  2179. };
  2180. }
  2181. function Wheel(Splide2, Components2, options) {
  2182. var _EventInterface17 = EventInterface(Splide2),
  2183. bind = _EventInterface17.bind;
  2184. function mount() {
  2185. if (options.wheel) {
  2186. bind(Components2.Elements.track, "wheel", onWheel, {
  2187. passive: false,
  2188. capture: true
  2189. });
  2190. }
  2191. }
  2192. function onWheel(e) {
  2193. var deltaY = e.deltaY;
  2194. if (deltaY) {
  2195. Splide2.go(deltaY < 0 ? "<" : ">");
  2196. prevent(e);
  2197. }
  2198. }
  2199. return {
  2200. mount: mount
  2201. };
  2202. }
  2203. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2204. __proto__: null,
  2205. Options: Options,
  2206. Direction: Direction,
  2207. Elements: Elements,
  2208. Style: Style,
  2209. Slides: Slides,
  2210. Clones: Clones,
  2211. Layout: Layout,
  2212. Move: Move,
  2213. Controller: Controller,
  2214. Arrows: Arrows,
  2215. Autoplay: Autoplay,
  2216. Cover: Cover,
  2217. Scroll: Scroll,
  2218. Drag: Drag,
  2219. Keyboard: Keyboard,
  2220. LazyLoad: LazyLoad,
  2221. Pagination: Pagination,
  2222. Sync: Sync,
  2223. Wheel: Wheel
  2224. });
  2225. var I18N = {
  2226. prev: "Previous slide",
  2227. next: "Next slide",
  2228. first: "Go to first slide",
  2229. last: "Go to last slide",
  2230. slideX: "Go to slide %s",
  2231. pageX: "Go to page %s",
  2232. play: "Start autoplay",
  2233. pause: "Pause autoplay"
  2234. };
  2235. var DEFAULTS = {
  2236. type: "slide",
  2237. speed: 400,
  2238. waitForTransition: true,
  2239. perPage: 1,
  2240. arrows: true,
  2241. pagination: true,
  2242. interval: 5e3,
  2243. pauseOnHover: true,
  2244. pauseOnFocus: true,
  2245. resetProgress: true,
  2246. easing: "cubic-bezier(.42,.65,.27,.99)",
  2247. drag: true,
  2248. direction: "ltr",
  2249. slideFocus: true,
  2250. trimSpace: true,
  2251. focusableNodes: "a, button, textarea, input, select, iframe",
  2252. classes: CLASSES,
  2253. i18n: I18N
  2254. };
  2255. function Fade(Splide2, Components2, options) {
  2256. var _EventInterface18 = EventInterface(Splide2),
  2257. on = _EventInterface18.on;
  2258. var ruleBy = Components2.Style.ruleBy;
  2259. function mount() {
  2260. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2261. nextTick(function () {
  2262. Components2.Slides.forEach(function (Slide) {
  2263. ruleBy(Slide.slide, "transition", "opacity " + options.speed + "ms " + options.easing);
  2264. });
  2265. });
  2266. });
  2267. }
  2268. function start(index, done) {
  2269. var track = Components2.Elements.track;
  2270. ruleBy(track, "height", unit(rect(track).height));
  2271. nextTick(function () {
  2272. done();
  2273. ruleBy(track, "height", "");
  2274. });
  2275. }
  2276. return {
  2277. mount: mount,
  2278. start: start,
  2279. cancel: noop
  2280. };
  2281. }
  2282. function Slide(Splide2, Components2, options) {
  2283. var _EventInterface19 = EventInterface(Splide2),
  2284. bind = _EventInterface19.bind;
  2285. var Move = Components2.Move,
  2286. Controller = Components2.Controller;
  2287. var list = Components2.Elements.list;
  2288. var endCallback;
  2289. function mount() {
  2290. bind(list, "transitionend", function (e) {
  2291. if (e.target === list && endCallback) {
  2292. cancel();
  2293. endCallback();
  2294. }
  2295. });
  2296. }
  2297. function start(index, done) {
  2298. var destination = Move.toPosition(index, true);
  2299. var position = Move.getPosition();
  2300. var speed = getSpeed(index);
  2301. if (abs(destination - position) >= 1 && speed >= 1) {
  2302. apply("transform " + speed + "ms " + options.easing);
  2303. Move.translate(destination);
  2304. endCallback = done;
  2305. } else {
  2306. Move.jump(index);
  2307. done();
  2308. }
  2309. }
  2310. function cancel() {
  2311. apply("");
  2312. }
  2313. function getSpeed(index) {
  2314. var rewindSpeed = options.rewindSpeed;
  2315. if (Splide2.is(SLIDE) && rewindSpeed) {
  2316. var prev = Controller.getIndex(true);
  2317. var end = Controller.getEnd();
  2318. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2319. return rewindSpeed;
  2320. }
  2321. }
  2322. return options.speed;
  2323. }
  2324. function apply(transition) {
  2325. Components2.Style.ruleBy(list, "transition", transition);
  2326. }
  2327. return {
  2328. mount: mount,
  2329. start: start,
  2330. cancel: cancel
  2331. };
  2332. }
  2333. var _Splide = /*#__PURE__*/function () {
  2334. function _Splide(target, options) {
  2335. this.event = EventBus();
  2336. this.Components = {};
  2337. this.state = State(CREATED);
  2338. this.splides = [];
  2339. this._options = {};
  2340. this._Extensions = {};
  2341. var root = isString(target) ? query(document, target) : target;
  2342. assert(root, root + " is invalid.");
  2343. this.root = root;
  2344. merge(DEFAULTS, _Splide.defaults);
  2345. merge(merge(this._options, DEFAULTS), options || {});
  2346. }
  2347. var _proto = _Splide.prototype;
  2348. _proto.mount = function mount(Extensions, Transition) {
  2349. var _this3 = this;
  2350. var state = this.state,
  2351. Components2 = this.Components;
  2352. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2353. state.set(CREATED);
  2354. this._Components = Components2;
  2355. this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
  2356. this._Extensions = Extensions || this._Extensions;
  2357. var Constructors = assign({}, ComponentConstructors, this._Extensions, {
  2358. Transition: this._Transition
  2359. });
  2360. forOwn(Constructors, function (Component, key) {
  2361. var component = Component(_this3, Components2, _this3._options);
  2362. Components2[key] = component;
  2363. component.setup && component.setup();
  2364. });
  2365. forOwn(Components2, function (component) {
  2366. component.mount && component.mount();
  2367. });
  2368. this.emit(EVENT_MOUNTED);
  2369. addClass(this.root, CLASS_INITIALIZED);
  2370. state.set(IDLE);
  2371. this.emit(EVENT_READY);
  2372. return this;
  2373. };
  2374. _proto.sync = function sync(splide) {
  2375. this.splides.push(splide);
  2376. splide.splides.push(this);
  2377. return this;
  2378. };
  2379. _proto.go = function go(control) {
  2380. this._Components.Controller.go(control);
  2381. return this;
  2382. };
  2383. _proto.on = function on(events, callback) {
  2384. this.event.on(events, callback, null, DEFAULT_USER_EVENT_PRIORITY);
  2385. return this;
  2386. };
  2387. _proto.off = function off(events) {
  2388. this.event.off(events);
  2389. return this;
  2390. };
  2391. _proto.emit = function emit(event) {
  2392. var _this$event;
  2393. (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1)));
  2394. return this;
  2395. };
  2396. _proto.add = function add(slides, index) {
  2397. this._Components.Slides.add(slides, index);
  2398. return this;
  2399. };
  2400. _proto.remove = function remove(matcher) {
  2401. this._Components.Slides.remove(matcher);
  2402. return this;
  2403. };
  2404. _proto.is = function is(type) {
  2405. return this._options.type === type;
  2406. };
  2407. _proto.refresh = function refresh() {
  2408. this.emit(EVENT_REFRESH);
  2409. return this;
  2410. };
  2411. _proto.destroy = function destroy(completely) {
  2412. if (completely === void 0) {
  2413. completely = true;
  2414. }
  2415. var event = this.event,
  2416. state = this.state;
  2417. if (state.is(CREATED)) {
  2418. event.on(EVENT_READY, this.destroy.bind(this, completely), this);
  2419. } else {
  2420. forOwn(this._Components, function (component) {
  2421. component.destroy && component.destroy(completely);
  2422. });
  2423. event.emit(EVENT_DESTROY);
  2424. event.destroy();
  2425. empty(this.splides);
  2426. state.set(DESTROYED);
  2427. }
  2428. return this;
  2429. };
  2430. _createClass(_Splide, [{
  2431. key: "options",
  2432. get: function get() {
  2433. return this._options;
  2434. },
  2435. set: function set(options) {
  2436. var _options = this._options;
  2437. merge(_options, options);
  2438. if (!this.state.is(CREATED)) {
  2439. this.emit(EVENT_UPDATED, _options);
  2440. }
  2441. }
  2442. }, {
  2443. key: "length",
  2444. get: function get() {
  2445. return this._Components.Slides.getLength(true);
  2446. }
  2447. }, {
  2448. key: "index",
  2449. get: function get() {
  2450. return this._Components.Controller.getIndex();
  2451. }
  2452. }]);
  2453. return _Splide;
  2454. }();
  2455. var Splide = _Splide;
  2456. Splide.defaults = {};
  2457. Splide.STATES = STATES;
  2458. return Splide;
  2459. });
  2460. //# sourceMappingURL=splide.js.map