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_UPDATED = "pagination:updated";
  371. var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  372. var EVENT_AUTOPLAY_PLAY = "autoplay:play";
  373. var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  374. var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  375. var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  376. function EventInterface(Splide2) {
  377. var event = Splide2.event;
  378. var key = {};
  379. var listeners = [];
  380. function on(events, callback, priority) {
  381. event.on(events, callback, key, priority);
  382. }
  383. function off(events) {
  384. event.off(events, key);
  385. }
  386. function bind(targets, events, callback, options) {
  387. forEachEvent(targets, events, function (target, event2) {
  388. listeners.push([target, event2, callback, options]);
  389. target.addEventListener(event2, callback, options);
  390. });
  391. }
  392. function unbind(targets, events) {
  393. forEachEvent(targets, events, function (target, event2) {
  394. listeners = listeners.filter(function (listener) {
  395. if (listener[0] === target && listener[1] === event2) {
  396. target.removeEventListener(event2, listener[2], listener[3]);
  397. return false;
  398. }
  399. return true;
  400. });
  401. });
  402. }
  403. function forEachEvent(targets, events, iteratee) {
  404. forEach(targets, function (target) {
  405. if (target) {
  406. events.split(" ").forEach(iteratee.bind(null, target));
  407. }
  408. });
  409. }
  410. function destroy() {
  411. listeners = listeners.filter(function (data) {
  412. return unbind(data[0], data[1]);
  413. });
  414. event.offBy(key);
  415. }
  416. event.on(EVENT_DESTROY, destroy, key);
  417. return {
  418. on: on,
  419. off: off,
  420. emit: event.emit,
  421. bind: bind,
  422. unbind: unbind,
  423. destroy: destroy
  424. };
  425. }
  426. function RequestInterval(interval, onInterval, onUpdate, limit) {
  427. var now = Date.now;
  428. var startTime;
  429. var rate = 0;
  430. var id;
  431. var paused = true;
  432. var count = 0;
  433. function update() {
  434. if (!paused) {
  435. var elapsed = now() - startTime;
  436. if (elapsed >= interval) {
  437. rate = 1;
  438. startTime = now();
  439. } else {
  440. rate = elapsed / interval;
  441. }
  442. if (onUpdate) {
  443. onUpdate(rate);
  444. }
  445. if (rate === 1) {
  446. onInterval();
  447. if (limit && ++count >= limit) {
  448. pause();
  449. return;
  450. }
  451. }
  452. raf(update);
  453. }
  454. }
  455. function start(resume) {
  456. !resume && cancel();
  457. startTime = now() - (resume ? rate * interval : 0);
  458. paused = false;
  459. raf(update);
  460. }
  461. function pause() {
  462. paused = true;
  463. }
  464. function rewind() {
  465. startTime = now();
  466. rate = 0;
  467. if (onUpdate) {
  468. onUpdate(rate);
  469. }
  470. }
  471. function cancel() {
  472. cancelAnimationFrame(id);
  473. rate = 0;
  474. id = 0;
  475. paused = true;
  476. }
  477. function isPaused() {
  478. return paused;
  479. }
  480. return {
  481. start: start,
  482. rewind: rewind,
  483. pause: pause,
  484. cancel: cancel,
  485. isPaused: isPaused
  486. };
  487. }
  488. function State(initialState) {
  489. var state = initialState;
  490. function set(value) {
  491. state = value;
  492. }
  493. function is(states) {
  494. return includes(toArray(states), state);
  495. }
  496. return {
  497. set: set,
  498. is: is
  499. };
  500. }
  501. function Throttle(func, duration) {
  502. var interval;
  503. function throttled() {
  504. var _arguments2 = arguments,
  505. _this = this;
  506. if (!interval) {
  507. interval = RequestInterval(duration || 0, function () {
  508. func.apply(_this, _arguments2);
  509. interval = null;
  510. }, null, 1);
  511. interval.start();
  512. }
  513. }
  514. return throttled;
  515. }
  516. function Options(Splide2, Components2, options) {
  517. var throttledObserve = Throttle(observe);
  518. var initialOptions;
  519. var points;
  520. var currPoint;
  521. function setup() {
  522. try {
  523. merge(options, JSON.parse(getAttribute(Splide2.root, DATA_ATTRIBUTE)));
  524. } catch (e) {
  525. assert(false, e.message);
  526. }
  527. initialOptions = merge({}, options);
  528. }
  529. function mount() {
  530. var breakpoints = options.breakpoints;
  531. if (breakpoints) {
  532. points = Object.keys(breakpoints).sort(function (n, m) {
  533. return +n - +m;
  534. }).map(function (point) {
  535. return [point, matchMedia("(" + (options.mediaQuery || "max") + "-width:" + point + "px)")];
  536. });
  537. addEventListener("resize", throttledObserve);
  538. observe();
  539. }
  540. }
  541. function destroy(completely) {
  542. if (completely) {
  543. removeEventListener("resize", throttledObserve);
  544. }
  545. }
  546. function observe() {
  547. var item = find(points, function (item2) {
  548. return item2[1].matches;
  549. }) || [];
  550. if (item[0] !== currPoint) {
  551. onMatch(currPoint = item[0]);
  552. }
  553. }
  554. function onMatch(point) {
  555. var newOptions = options.breakpoints[point] || initialOptions;
  556. if (newOptions.destroy) {
  557. Splide2.options = initialOptions;
  558. Splide2.destroy(newOptions.destroy === "completely");
  559. } else {
  560. if (Splide2.state.is(DESTROYED)) {
  561. destroy(true);
  562. Splide2.mount();
  563. }
  564. Splide2.options = newOptions;
  565. }
  566. }
  567. return {
  568. setup: setup,
  569. mount: mount,
  570. destroy: destroy
  571. };
  572. }
  573. var RTL = "rtl";
  574. var TTB = "ttb";
  575. var ORIENTATION_MAP = {
  576. marginRight: ["marginBottom", "marginLeft"],
  577. width: ["height"],
  578. autoWidth: ["autoHeight"],
  579. fixedWidth: ["fixedHeight"],
  580. paddingLeft: ["paddingTop", "paddingRight"],
  581. paddingRight: ["paddingBottom", "paddingLeft"],
  582. left: ["top", "right"],
  583. right: ["bottom", "left"],
  584. x: ["y"],
  585. X: ["Y"],
  586. Y: ["X"],
  587. ArrowLeft: ["ArrowUp", "ArrowRight"],
  588. ArrowRight: ["ArrowDown", "ArrowLeft"]
  589. };
  590. function Direction(Splide2, Components2, options) {
  591. function resolve(prop, axisOnly) {
  592. var direction = options.direction;
  593. var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  594. return ORIENTATION_MAP[prop][index] || prop;
  595. }
  596. function orient(value) {
  597. return value * (options.direction === RTL ? 1 : -1);
  598. }
  599. return {
  600. resolve: resolve,
  601. orient: orient
  602. };
  603. }
  604. var CLASS_ROOT = PROJECT_CODE;
  605. var CLASS_SLIDER = PROJECT_CODE + "__slider";
  606. var CLASS_TRACK = PROJECT_CODE + "__track";
  607. var CLASS_LIST = PROJECT_CODE + "__list";
  608. var CLASS_SLIDE = PROJECT_CODE + "__slide";
  609. var CLASS_CLONE = CLASS_SLIDE + "--clone";
  610. var CLASS_CONTAINER = CLASS_SLIDE + "__container";
  611. var CLASS_ARROWS = PROJECT_CODE + "__arrows";
  612. var CLASS_ARROW = PROJECT_CODE + "__arrow";
  613. var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
  614. var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
  615. var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
  616. var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
  617. var CLASS_PROGRESS = PROJECT_CODE + "__progress";
  618. var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
  619. var CLASS_AUTOPLAY = PROJECT_CODE + "__autoplay";
  620. var CLASS_PLAY = PROJECT_CODE + "__play";
  621. var CLASS_PAUSE = PROJECT_CODE + "__pause";
  622. var CLASS_SPINNER = PROJECT_CODE + "__spinner";
  623. var CLASS_INITIALIZED = "is-initialized";
  624. var CLASS_ACTIVE = "is-active";
  625. var CLASS_PREV = "is-prev";
  626. var CLASS_NEXT = "is-next";
  627. var CLASS_VISIBLE = "is-visible";
  628. var CLASS_LOADING = "is-loading";
  629. var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING];
  630. var CLASSES = {
  631. slide: CLASS_SLIDE,
  632. clone: CLASS_CLONE,
  633. arrows: CLASS_ARROWS,
  634. arrow: CLASS_ARROW,
  635. prev: CLASS_ARROW_PREV,
  636. next: CLASS_ARROW_NEXT,
  637. pagination: CLASS_PAGINATION,
  638. page: CLASS_PAGINATION_PAGE,
  639. spinner: CLASS_SPINNER
  640. };
  641. function Elements(Splide2, Components2, options) {
  642. var _EventInterface = EventInterface(Splide2),
  643. on = _EventInterface.on;
  644. var root = Splide2.root;
  645. var elements = {};
  646. var slides = [];
  647. var classes;
  648. var slider;
  649. var track;
  650. var list;
  651. function setup() {
  652. collect();
  653. identify();
  654. addClass(root, classes = getClasses());
  655. }
  656. function mount() {
  657. on(EVENT_REFRESH, refresh);
  658. on(EVENT_UPDATED, update);
  659. }
  660. function destroy() {
  661. empty(slides);
  662. removeClass(root, classes);
  663. }
  664. function refresh() {
  665. destroy();
  666. setup();
  667. }
  668. function update() {
  669. removeClass(root, classes);
  670. addClass(root, classes = getClasses());
  671. }
  672. function collect() {
  673. slider = child(root, "." + CLASS_SLIDER);
  674. track = query(root, "." + CLASS_TRACK);
  675. list = child(track, "." + CLASS_LIST);
  676. assert(track && list, "Missing a track/list element.");
  677. push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
  678. var autoplay = find("." + CLASS_AUTOPLAY);
  679. var arrows = find("." + CLASS_ARROWS);
  680. assign(elements, {
  681. root: root,
  682. slider: slider,
  683. track: track,
  684. list: list,
  685. slides: slides,
  686. arrows: arrows,
  687. prev: query(arrows, "." + CLASS_ARROW_PREV),
  688. next: query(arrows, "." + CLASS_ARROW_NEXT),
  689. bar: query(find("." + CLASS_PROGRESS), "." + CLASS_PROGRESS_BAR),
  690. play: query(autoplay, "." + CLASS_PLAY),
  691. pause: query(autoplay, "." + CLASS_PAUSE)
  692. });
  693. }
  694. function identify() {
  695. var id = root.id || uniqueId(PROJECT_CODE);
  696. root.id = id;
  697. track.id = track.id || id + "-track";
  698. list.id = list.id || id + "-list";
  699. }
  700. function find(selector) {
  701. return child(root, selector) || child(slider, selector);
  702. }
  703. function getClasses() {
  704. return [CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE];
  705. }
  706. return assign(elements, {
  707. setup: setup,
  708. mount: mount,
  709. destroy: destroy
  710. });
  711. }
  712. function Style() {
  713. var style;
  714. var sheet;
  715. function mount() {
  716. style = create("style", {}, document.head);
  717. sheet = style.sheet;
  718. }
  719. function destroy() {
  720. remove(style);
  721. sheet = null;
  722. }
  723. function rule(selector, prop, value) {
  724. var _sheet = sheet,
  725. cssRules = _sheet.cssRules;
  726. var cssRule = find(cssRules, function (cssRule2) {
  727. return isCSSStyleRule(cssRule2) && cssRule2.selectorText === selector;
  728. }) || cssRules[sheet.insertRule(selector + "{}", 0)];
  729. if (isCSSStyleRule(cssRule)) {
  730. cssRule.style[prop] = "" + value;
  731. }
  732. }
  733. function ruleBy(target, prop, value) {
  734. rule("#" + (isHTMLElement(target) ? target.id : target), prop, value);
  735. }
  736. function isCSSStyleRule(cssRule) {
  737. return cssRule instanceof CSSStyleRule;
  738. }
  739. return {
  740. mount: mount,
  741. destroy: destroy,
  742. rule: rule,
  743. ruleBy: ruleBy
  744. };
  745. }
  746. var ROLE = "role";
  747. var ARIA_CONTROLS = "aria-controls";
  748. var ARIA_CURRENT = "aria-current";
  749. var ARIA_LABEL = "aria-label";
  750. var ARIA_HIDDEN = "aria-hidden";
  751. var TAB_INDEX = "tabindex";
  752. var DISABLED = "disabled";
  753. var ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, TAB_INDEX, DISABLED];
  754. var SLIDE = "slide";
  755. var LOOP = "loop";
  756. var FADE = "fade";
  757. function Slide$1(Splide2, index, slideIndex, slide) {
  758. var _EventInterface2 = EventInterface(Splide2),
  759. on = _EventInterface2.on,
  760. emit = _EventInterface2.emit,
  761. bind = _EventInterface2.bind,
  762. destroyEvents = _EventInterface2.destroy;
  763. var Components = Splide2.Components,
  764. root = Splide2.root,
  765. options = Splide2.options;
  766. var isNavigation = options.isNavigation,
  767. updateOnMove = options.updateOnMove;
  768. var resolve = Components.Direction.resolve;
  769. var isClone = slideIndex > -1;
  770. var container = child(slide, "." + CLASS_CONTAINER);
  771. var destroyed;
  772. function mount() {
  773. var _this2 = this;
  774. init();
  775. bind(slide, "click keydown", function (e) {
  776. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  777. });
  778. on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
  779. if (updateOnMove) {
  780. on(EVENT_MOVE, onMove.bind(this));
  781. }
  782. update.call(this);
  783. }
  784. function init() {
  785. if (!isClone) {
  786. slide.id = root.id + "-slide" + pad(index + 1);
  787. }
  788. if (isNavigation) {
  789. if (!isHTMLButtonElement(slide)) {
  790. setAttribute(slide, ROLE, "button");
  791. }
  792. var idx = isClone ? slideIndex : index;
  793. var label = format(options.i18n.slideX, idx + 1);
  794. var controls = Splide2.splides.map(function (splide) {
  795. return splide.root.id;
  796. }).join(" ");
  797. setAttribute(slide, ARIA_LABEL, label);
  798. setAttribute(slide, ARIA_CONTROLS, controls);
  799. }
  800. }
  801. function destroy() {
  802. destroyed = true;
  803. destroyEvents();
  804. removeClass(slide, STATUS_CLASSES);
  805. removeAttribute(slide, ALL_ATTRIBUTES);
  806. }
  807. function onMove(next, prev, dest) {
  808. if (!destroyed) {
  809. update.call(this);
  810. if (dest === index) {
  811. updateActivity.call(this, true);
  812. }
  813. }
  814. }
  815. function update() {
  816. if (!destroyed) {
  817. var currIndex = Splide2.index;
  818. updateActivity.call(this, isActive());
  819. updateVisibility.call(this, isVisible());
  820. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  821. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  822. }
  823. }
  824. function updateActivity(active) {
  825. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  826. toggleClass(slide, CLASS_ACTIVE, active);
  827. if (isNavigation) {
  828. setAttribute(slide, ARIA_CURRENT, active || null);
  829. }
  830. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  831. }
  832. }
  833. function updateVisibility(visible) {
  834. var ariaHidden = !visible && !isActive();
  835. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  836. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  837. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  838. toggleClass(slide, CLASS_VISIBLE, visible);
  839. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  840. }
  841. }
  842. function rule(prop, value, useContainer) {
  843. var selector = "#" + slide.id + (container && useContainer ? " > ." + CLASS_CONTAINER : "");
  844. Components.Style.rule(selector, prop, value);
  845. }
  846. function isActive() {
  847. return Splide2.index === index;
  848. }
  849. function isVisible() {
  850. if (Splide2.is(FADE)) {
  851. return isActive();
  852. }
  853. var trackRect = rect(Components.Elements.track);
  854. var slideRect = rect(slide);
  855. var left = resolve("left");
  856. var right = resolve("right");
  857. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  858. }
  859. function isWithin(from, distance) {
  860. var diff = abs(from - index);
  861. if (!Splide2.is(SLIDE) && !isClone) {
  862. diff = min(diff, Splide2.length - diff);
  863. }
  864. return diff <= distance;
  865. }
  866. return {
  867. index: index,
  868. slideIndex: slideIndex,
  869. slide: slide,
  870. container: container,
  871. isClone: isClone,
  872. mount: mount,
  873. destroy: destroy,
  874. rule: rule,
  875. isWithin: isWithin
  876. };
  877. }
  878. function Slides(Splide2, Components2, options) {
  879. var _EventInterface3 = EventInterface(Splide2),
  880. on = _EventInterface3.on,
  881. emit = _EventInterface3.emit,
  882. bind = _EventInterface3.bind;
  883. var _Components2$Elements = Components2.Elements,
  884. slides = _Components2$Elements.slides,
  885. list = _Components2$Elements.list;
  886. var Slides2 = [];
  887. function mount() {
  888. init();
  889. on(EVENT_REFRESH, refresh);
  890. }
  891. function init() {
  892. slides.forEach(function (slide, index) {
  893. register(slide, index, -1);
  894. });
  895. }
  896. function destroy() {
  897. forEach$1(function (Slide2) {
  898. Slide2.destroy();
  899. });
  900. empty(Slides2);
  901. }
  902. function refresh() {
  903. destroy();
  904. init();
  905. }
  906. function register(slide, index, slideIndex) {
  907. var object = Slide$1(Splide2, index, slideIndex, slide);
  908. object.mount();
  909. Slides2.push(object);
  910. }
  911. function get(excludeClones) {
  912. return excludeClones ? filter(function (Slide2) {
  913. return !Slide2.isClone;
  914. }) : Slides2;
  915. }
  916. function getIn(page) {
  917. var Controller = Components2.Controller;
  918. var index = Controller.toIndex(page);
  919. var max = Controller.hasFocus() ? 1 : options.perPage;
  920. return filter(function (Slide2) {
  921. return between(Slide2.index, index, index + max - 1);
  922. });
  923. }
  924. function getAt(index) {
  925. return filter(index)[0];
  926. }
  927. function add(items, index) {
  928. forEach(items, function (slide) {
  929. if (isString(slide)) {
  930. slide = parseHtml(slide);
  931. }
  932. if (isHTMLElement(slide)) {
  933. var ref = slides[index];
  934. ref ? before(slide, ref) : append(list, slide);
  935. addClass(slide, options.classes.slide);
  936. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  937. }
  938. });
  939. emit(EVENT_REFRESH);
  940. }
  941. function remove$1(matcher) {
  942. remove(filter(matcher).map(function (Slide2) {
  943. return Slide2.slide;
  944. }));
  945. emit(EVENT_REFRESH);
  946. }
  947. function forEach$1(iteratee, excludeClones) {
  948. get(excludeClones).forEach(iteratee);
  949. }
  950. function filter(matcher) {
  951. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  952. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  953. });
  954. }
  955. function rule(prop, value, useContainer) {
  956. forEach$1(function (Slide2) {
  957. Slide2.rule(prop, value, useContainer);
  958. });
  959. }
  960. function observeImages(elm, callback) {
  961. var images = queryAll(elm, "img");
  962. var length = images.length;
  963. if (length) {
  964. images.forEach(function (img) {
  965. bind(img, "load error", function () {
  966. if (! --length) {
  967. callback();
  968. }
  969. });
  970. });
  971. } else {
  972. callback();
  973. }
  974. }
  975. function getLength(excludeClones) {
  976. return excludeClones ? slides.length : Slides2.length;
  977. }
  978. function isEnough() {
  979. return Slides2.length > options.perPage;
  980. }
  981. return {
  982. mount: mount,
  983. destroy: destroy,
  984. register: register,
  985. get: get,
  986. getIn: getIn,
  987. getAt: getAt,
  988. add: add,
  989. remove: remove$1,
  990. forEach: forEach$1,
  991. filter: filter,
  992. rule: rule,
  993. getLength: getLength,
  994. isEnough: isEnough
  995. };
  996. }
  997. function Clones(Splide2, Components2, options) {
  998. var _EventInterface4 = EventInterface(Splide2),
  999. on = _EventInterface4.on,
  1000. emit = _EventInterface4.emit;
  1001. var Elements = Components2.Elements,
  1002. Slides = Components2.Slides;
  1003. var resolve = Components2.Direction.resolve;
  1004. var clones = [];
  1005. var cloneCount;
  1006. function mount() {
  1007. init();
  1008. on(EVENT_REFRESH, refresh);
  1009. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1010. }
  1011. function init() {
  1012. if (cloneCount = computeCloneCount()) {
  1013. generate(cloneCount);
  1014. }
  1015. }
  1016. function destroy() {
  1017. remove(clones);
  1018. empty(clones);
  1019. }
  1020. function refresh() {
  1021. destroy();
  1022. init();
  1023. }
  1024. function observe() {
  1025. if (cloneCount !== computeCloneCount()) {
  1026. emit(EVENT_REFRESH);
  1027. }
  1028. }
  1029. function generate(count) {
  1030. var slides = Slides.get().slice();
  1031. var length = slides.length;
  1032. if (length) {
  1033. while (slides.length < count) {
  1034. push(slides, slides);
  1035. }
  1036. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1037. var isHead = index < count;
  1038. var clone = cloneDeep(Slide.slide, index);
  1039. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1040. push(clones, clone);
  1041. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1042. });
  1043. }
  1044. }
  1045. function cloneDeep(elm, index) {
  1046. var clone = elm.cloneNode(true);
  1047. addClass(clone, options.classes.clone);
  1048. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1049. return clone;
  1050. }
  1051. function computeCloneCount() {
  1052. var clones2 = options.clones;
  1053. if (!Splide2.is(LOOP)) {
  1054. clones2 = 0;
  1055. } else if (!clones2) {
  1056. var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
  1057. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1058. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1059. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1060. }
  1061. return clones2;
  1062. }
  1063. return {
  1064. mount: mount,
  1065. destroy: destroy
  1066. };
  1067. }
  1068. function Layout(Splide2, Components2, options) {
  1069. var _EventInterface5 = EventInterface(Splide2),
  1070. on = _EventInterface5.on,
  1071. bind = _EventInterface5.bind,
  1072. emit = _EventInterface5.emit;
  1073. var Slides = Components2.Slides;
  1074. var ruleBy = Components2.Style.ruleBy;
  1075. var resolve = Components2.Direction.resolve;
  1076. var _Components2$Elements2 = Components2.Elements,
  1077. track = _Components2$Elements2.track,
  1078. list = _Components2$Elements2.list;
  1079. var getAt = Slides.getAt;
  1080. var vertical = options.direction === TTB;
  1081. function mount() {
  1082. init();
  1083. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  1084. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1085. on(EVENT_RESIZE, resize);
  1086. }
  1087. function init() {
  1088. ruleBy(Splide2.root, "maxWidth", unit(options.width));
  1089. ruleBy(track, resolve("paddingLeft"), cssPadding(false));
  1090. ruleBy(track, resolve("paddingRight"), cssPadding(true));
  1091. Slides.rule(resolve("marginRight"), unit(options.gap));
  1092. Slides.rule("width", cssSlideWidth());
  1093. setSlidesHeight();
  1094. resize();
  1095. }
  1096. function resize() {
  1097. ruleBy(track, "height", cssTrackHeight());
  1098. options.heightRatio && setSlidesHeight();
  1099. emit(EVENT_RESIZED);
  1100. }
  1101. function setSlidesHeight() {
  1102. Slides.rule("height", cssSlideHeight(), true);
  1103. }
  1104. function cssPadding(right) {
  1105. var padding = options.padding;
  1106. var prop = resolve(right ? "right" : "left", true);
  1107. return padding ? unit(padding[prop] || (isObject(padding) ? "0" : padding)) : "";
  1108. }
  1109. function cssTrackHeight() {
  1110. var height = "";
  1111. if (vertical) {
  1112. height = cssHeight();
  1113. assert(height, '"height" or "heightRatio" is missing.');
  1114. var paddingTop = cssPadding(false);
  1115. var paddingBottom = cssPadding(true);
  1116. if (paddingTop || paddingBottom) {
  1117. height = "calc(" + height;
  1118. height += "" + (paddingTop ? " - " + paddingTop : "") + (paddingBottom ? " - " + paddingBottom : "") + ")";
  1119. }
  1120. }
  1121. return height;
  1122. }
  1123. function cssHeight() {
  1124. return unit(options.height || rect(list).width * options.heightRatio);
  1125. }
  1126. function cssSlideWidth() {
  1127. return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1128. }
  1129. function cssSlideHeight() {
  1130. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
  1131. }
  1132. function cssSlideSize() {
  1133. var gap = unit(options.gap);
  1134. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1135. }
  1136. function listSize() {
  1137. return rect(list)[resolve("width")];
  1138. }
  1139. function slideSize(index, withoutGap) {
  1140. var Slide = getAt(index || 0);
  1141. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1142. }
  1143. function totalSize(index, withoutGap) {
  1144. var Slide = getAt(index);
  1145. if (Slide) {
  1146. var right = rect(Slide.slide)[resolve("right")];
  1147. var left = rect(list)[resolve("left")];
  1148. return abs(right - left) + (withoutGap ? 0 : getGap());
  1149. }
  1150. return 0;
  1151. }
  1152. function sliderSize() {
  1153. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1154. }
  1155. function getGap() {
  1156. var Slide = getAt(0);
  1157. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1158. }
  1159. function getPadding(right) {
  1160. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left"), true))) || 0;
  1161. }
  1162. return {
  1163. mount: mount,
  1164. listSize: listSize,
  1165. slideSize: slideSize,
  1166. sliderSize: sliderSize,
  1167. totalSize: totalSize,
  1168. getPadding: getPadding
  1169. };
  1170. }
  1171. var SNAP_THRESHOLD = 10;
  1172. function Move(Splide2, Components2, options) {
  1173. var _EventInterface6 = EventInterface(Splide2),
  1174. on = _EventInterface6.on,
  1175. emit = _EventInterface6.emit;
  1176. var _Components2$Layout = Components2.Layout,
  1177. slideSize = _Components2$Layout.slideSize,
  1178. getPadding = _Components2$Layout.getPadding,
  1179. totalSize = _Components2$Layout.totalSize,
  1180. listSize = _Components2$Layout.listSize,
  1181. sliderSize = _Components2$Layout.sliderSize;
  1182. var _Components2$Directio = Components2.Direction,
  1183. resolve = _Components2$Directio.resolve,
  1184. orient = _Components2$Directio.orient;
  1185. var _Components2$Elements3 = Components2.Elements,
  1186. list = _Components2$Elements3.list,
  1187. track = _Components2$Elements3.track;
  1188. var waiting;
  1189. var shouldSnap = true;
  1190. function mount() {
  1191. if (!Splide2.is(FADE)) {
  1192. on([EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
  1193. }
  1194. }
  1195. function reposition() {
  1196. if (exceededLimit(true)) {
  1197. translate(getLimit(true));
  1198. } else if (shouldSnap || (shouldSnap = canSnap())) {
  1199. jump(Splide2.index);
  1200. }
  1201. }
  1202. function move(dest, index, prev) {
  1203. if (!isBusy()) {
  1204. var set = Splide2.state.set;
  1205. var position = getPosition();
  1206. var looping = dest !== index;
  1207. waiting = looping || options.waitForTransition;
  1208. set(MOVING);
  1209. emit(EVENT_MOVE, index, prev, dest);
  1210. Components2.Transition.start(dest, function () {
  1211. looping && jump(index);
  1212. waiting = false;
  1213. set(IDLE);
  1214. emit(EVENT_MOVED, index, prev, dest);
  1215. if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
  1216. Components2.Controller.go(dest > prev ? ">" : "<");
  1217. }
  1218. });
  1219. }
  1220. }
  1221. function jump(index) {
  1222. waiting = false;
  1223. Components2.Transition.cancel();
  1224. translate(toPosition(index, true));
  1225. }
  1226. function translate(position) {
  1227. position = loop(position);
  1228. shouldSnap = canSnap(position);
  1229. Components2.Style.ruleBy(list, "transform", "translate" + resolve("X") + "(" + 100 * position / listSize() + "%)");
  1230. }
  1231. function loop(position) {
  1232. if (!waiting && Splide2.is(LOOP)) {
  1233. var diff = position - getPosition();
  1234. var exceededMin = exceededLimit(false, position);
  1235. var exceededMax = exceededLimit(true, position);
  1236. if (exceededMin && diff > 0 || exceededMax && diff < 0) {
  1237. position += orient(sliderSize() * (exceededMin ? 1 : -1));
  1238. }
  1239. }
  1240. return position;
  1241. }
  1242. function cancel() {
  1243. translate(getPosition());
  1244. Components2.Transition.cancel();
  1245. }
  1246. function toIndex(position) {
  1247. var Slides = Components2.Slides.get();
  1248. var index = 0;
  1249. var minDistance = Infinity;
  1250. for (var i = 0; i < Slides.length; i++) {
  1251. var slideIndex = Slides[i].index;
  1252. var distance = abs(toPosition(slideIndex, true) - position);
  1253. if (distance < minDistance) {
  1254. minDistance = distance;
  1255. index = slideIndex;
  1256. } else {
  1257. break;
  1258. }
  1259. }
  1260. return index;
  1261. }
  1262. function toPosition(index, trimming) {
  1263. var position = orient(totalSize(index - 1) - offset(index));
  1264. return trimming ? trim(position) : position;
  1265. }
  1266. function getPosition() {
  1267. var left = resolve("left");
  1268. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1269. }
  1270. function trim(position) {
  1271. if (options.trimSpace && Splide2.is(SLIDE)) {
  1272. position = clamp(position, 0, orient(sliderSize() - listSize()));
  1273. }
  1274. return position;
  1275. }
  1276. function offset(index) {
  1277. var focus = options.focus;
  1278. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1279. }
  1280. function getLimit(max) {
  1281. return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
  1282. }
  1283. function canSnap(position) {
  1284. position = isUndefined(position) ? getPosition() : position;
  1285. return abs(position - toPosition(toIndex(position), true)) < SNAP_THRESHOLD;
  1286. }
  1287. function isBusy() {
  1288. return waiting;
  1289. }
  1290. function exceededLimit(max, position) {
  1291. position = isUndefined(position) ? getPosition() : position;
  1292. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1293. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1294. return exceededMin || exceededMax;
  1295. }
  1296. return {
  1297. mount: mount,
  1298. move: move,
  1299. jump: jump,
  1300. translate: translate,
  1301. cancel: cancel,
  1302. toIndex: toIndex,
  1303. toPosition: toPosition,
  1304. getPosition: getPosition,
  1305. getLimit: getLimit,
  1306. isBusy: isBusy,
  1307. exceededLimit: exceededLimit
  1308. };
  1309. }
  1310. function Controller(Splide2, Components2, options) {
  1311. var _EventInterface7 = EventInterface(Splide2),
  1312. on = _EventInterface7.on;
  1313. var Move = Components2.Move;
  1314. var _Components2$Slides = Components2.Slides,
  1315. isEnough = _Components2$Slides.isEnough,
  1316. getLength = _Components2$Slides.getLength;
  1317. var isLoop = Splide2.is(LOOP);
  1318. var currIndex = options.start || 0;
  1319. var prevIndex = currIndex;
  1320. var slideCount;
  1321. var perMove;
  1322. var perPage;
  1323. function mount() {
  1324. init();
  1325. Move.jump(currIndex);
  1326. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1327. on(EVENT_SCROLLED, reindex, 0);
  1328. }
  1329. function init() {
  1330. slideCount = getLength(true);
  1331. perMove = options.perMove;
  1332. perPage = options.perPage;
  1333. currIndex = min(currIndex, slideCount - 1);
  1334. Move.jump(currIndex);
  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 = perMove ? 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. items.push({
  2127. li: li,
  2128. button: button,
  2129. page: i
  2130. });
  2131. };
  2132. for (var i = 0; i < max; i++) {
  2133. _loop(i);
  2134. }
  2135. }
  2136. function getAt(index) {
  2137. return items[toPage(index)];
  2138. }
  2139. function update() {
  2140. var prev = getAt(getIndex(true));
  2141. var curr = getAt(getIndex());
  2142. if (prev) {
  2143. removeClass(prev.button, CLASS_ACTIVE);
  2144. removeAttribute(prev.button, ARIA_CURRENT);
  2145. }
  2146. if (curr) {
  2147. addClass(curr.button, CLASS_ACTIVE);
  2148. setAttribute(curr.button, ARIA_CURRENT, true);
  2149. }
  2150. emit(EVENT_PAGINATION_UPDATED, {
  2151. list: list,
  2152. items: items
  2153. }, prev, curr);
  2154. }
  2155. return {
  2156. items: items,
  2157. mount: mount,
  2158. destroy: destroy,
  2159. getAt: getAt
  2160. };
  2161. }
  2162. var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
  2163. function Sync(Splide2, Components2, options) {
  2164. var splides = Splide2.splides;
  2165. function mount() {
  2166. if (options.isNavigation) {
  2167. navigate();
  2168. } else {
  2169. sync();
  2170. }
  2171. }
  2172. function sync() {
  2173. var processed = [];
  2174. splides.concat(Splide2).forEach(function (splide, index, instances) {
  2175. EventInterface(splide).on(EVENT_MOVE, function (index2, prev, dest) {
  2176. instances.forEach(function (instance) {
  2177. if (instance !== splide && !includes(processed, splide)) {
  2178. processed.push(instance);
  2179. instance.go(instance.is(LOOP) ? dest : index2);
  2180. }
  2181. });
  2182. empty(processed);
  2183. });
  2184. });
  2185. }
  2186. function navigate() {
  2187. var _EventInterface16 = EventInterface(Splide2),
  2188. on = _EventInterface16.on,
  2189. emit = _EventInterface16.emit;
  2190. on(EVENT_CLICK, function (Slide) {
  2191. Splide2.go(Slide.index);
  2192. });
  2193. on(EVENT_SLIDE_KEYDOWN, function (Slide, e) {
  2194. if (includes(TRIGGER_KEYS, e.key)) {
  2195. Splide2.go(Slide.index);
  2196. prevent(e);
  2197. }
  2198. });
  2199. emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2200. }
  2201. return {
  2202. mount: mount
  2203. };
  2204. }
  2205. function Wheel(Splide2, Components2, options) {
  2206. var _EventInterface17 = EventInterface(Splide2),
  2207. bind = _EventInterface17.bind;
  2208. function mount() {
  2209. if (options.wheel) {
  2210. bind(Components2.Elements.track, "wheel", onWheel);
  2211. }
  2212. }
  2213. function onWheel(e) {
  2214. var deltaY = e.deltaY;
  2215. if (deltaY) {
  2216. Splide2.go(deltaY < 0 ? "<" : ">");
  2217. prevent(e);
  2218. }
  2219. }
  2220. return {
  2221. mount: mount
  2222. };
  2223. }
  2224. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2225. __proto__: null,
  2226. Options: Options,
  2227. Direction: Direction,
  2228. Elements: Elements,
  2229. Style: Style,
  2230. Slides: Slides,
  2231. Clones: Clones,
  2232. Layout: Layout,
  2233. Move: Move,
  2234. Controller: Controller,
  2235. Arrows: Arrows,
  2236. Autoplay: Autoplay,
  2237. Cover: Cover,
  2238. Scroll: Scroll,
  2239. Drag: Drag,
  2240. Keyboard: Keyboard,
  2241. LazyLoad: LazyLoad,
  2242. Pagination: Pagination,
  2243. Sync: Sync,
  2244. Wheel: Wheel
  2245. });
  2246. var I18N = {
  2247. prev: "Previous slide",
  2248. next: "Next slide",
  2249. first: "Go to first slide",
  2250. last: "Go to last slide",
  2251. slideX: "Go to slide %s",
  2252. pageX: "Go to page %s",
  2253. play: "Start autoplay",
  2254. pause: "Pause autoplay"
  2255. };
  2256. var DEFAULTS = {
  2257. type: "slide",
  2258. speed: 400,
  2259. waitForTransition: true,
  2260. perPage: 1,
  2261. arrows: true,
  2262. pagination: true,
  2263. interval: 5e3,
  2264. pauseOnHover: true,
  2265. pauseOnFocus: true,
  2266. resetProgress: true,
  2267. easing: "cubic-bezier(.42,.65,.27,.99)",
  2268. drag: true,
  2269. direction: "ltr",
  2270. slideFocus: true,
  2271. trimSpace: true,
  2272. classes: CLASSES,
  2273. i18n: I18N
  2274. };
  2275. function Fade(Splide2, Components2, options) {
  2276. var _EventInterface18 = EventInterface(Splide2),
  2277. on = _EventInterface18.on;
  2278. var ruleBy = Components2.Style.ruleBy;
  2279. function mount() {
  2280. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2281. nextTick(function () {
  2282. Components2.Slides.forEach(function (Slide) {
  2283. ruleBy(Slide.slide, "transition", "opacity " + options.speed + "ms " + options.easing);
  2284. });
  2285. });
  2286. });
  2287. }
  2288. function start(index, done) {
  2289. var track = Components2.Elements.track;
  2290. ruleBy(track, "height", unit(rect(track).height));
  2291. nextTick(function () {
  2292. done();
  2293. ruleBy(track, "height", "");
  2294. });
  2295. }
  2296. return {
  2297. mount: mount,
  2298. start: start,
  2299. cancel: noop
  2300. };
  2301. }
  2302. function Slide(Splide2, Components2, options) {
  2303. var _EventInterface19 = EventInterface(Splide2),
  2304. bind = _EventInterface19.bind;
  2305. var Move = Components2.Move,
  2306. Controller = Components2.Controller;
  2307. var list = Components2.Elements.list;
  2308. var endCallback;
  2309. function mount() {
  2310. bind(list, "transitionend", function (e) {
  2311. if (e.target === list && endCallback) {
  2312. cancel();
  2313. endCallback();
  2314. }
  2315. });
  2316. }
  2317. function start(index, done) {
  2318. var destination = Move.toPosition(index, true);
  2319. var position = Move.getPosition();
  2320. var speed = getSpeed(index);
  2321. if (abs(destination - position) >= 1 && speed >= 1) {
  2322. apply("transform " + speed + "ms " + options.easing);
  2323. Move.translate(destination);
  2324. endCallback = done;
  2325. } else {
  2326. Move.jump(index);
  2327. done();
  2328. }
  2329. }
  2330. function cancel() {
  2331. apply("");
  2332. }
  2333. function getSpeed(index) {
  2334. var rewindSpeed = options.rewindSpeed;
  2335. if (Splide2.is(SLIDE) && rewindSpeed) {
  2336. var prev = Controller.getIndex(true);
  2337. var end = Controller.getEnd();
  2338. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2339. return rewindSpeed;
  2340. }
  2341. }
  2342. return options.speed;
  2343. }
  2344. function apply(transition) {
  2345. Components2.Style.ruleBy(list, "transition", transition);
  2346. }
  2347. return {
  2348. mount: mount,
  2349. start: start,
  2350. cancel: cancel
  2351. };
  2352. }
  2353. var _Splide = /*#__PURE__*/function () {
  2354. function _Splide(target, options) {
  2355. this.event = EventBus();
  2356. this.Components = {};
  2357. this.state = State(CREATED);
  2358. this.splides = [];
  2359. this._options = {};
  2360. this._Extensions = {};
  2361. var root = isString(target) ? query(document, target) : target;
  2362. assert(root, root + " is invalid.");
  2363. this.root = root;
  2364. merge(DEFAULTS, _Splide.defaults);
  2365. merge(merge(this._options, DEFAULTS), options || {});
  2366. }
  2367. var _proto = _Splide.prototype;
  2368. _proto.mount = function mount(Extensions, Transition) {
  2369. var _this3 = this;
  2370. var state = this.state,
  2371. Components2 = this.Components;
  2372. assert(state.is([CREATED, DESTROYED]), "Already mounted.");
  2373. state.set(CREATED);
  2374. this._Components = Components2;
  2375. this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
  2376. this._Extensions = Extensions || this._Extensions;
  2377. var Constructors = assign({}, ComponentConstructors, this._Extensions, {
  2378. Transition: this._Transition
  2379. });
  2380. forOwn(Constructors, function (Component, key) {
  2381. var component = Component(_this3, Components2, _this3._options);
  2382. Components2[key] = component;
  2383. component.setup && component.setup();
  2384. });
  2385. forOwn(Components2, function (component) {
  2386. component.mount && component.mount();
  2387. });
  2388. this.emit(EVENT_MOUNTED);
  2389. addClass(this.root, CLASS_INITIALIZED);
  2390. state.set(IDLE);
  2391. this.emit(EVENT_READY);
  2392. return this;
  2393. };
  2394. _proto.sync = function sync(splide) {
  2395. this.splides.push(splide);
  2396. splide.splides.push(this);
  2397. return this;
  2398. };
  2399. _proto.go = function go(control) {
  2400. this._Components.Controller.go(control);
  2401. return this;
  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