splide.js 75 KB

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