splide.js 75 KB

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