splide.js 75 KB

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