splide.js 75 KB

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