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 between(number, minOrMax, maxOrMin, exclusive) {
  250. var min = Math.min(minOrMax, maxOrMin);
  251. var max = Math.max(minOrMax, maxOrMin);
  252. return exclusive ? min < number && number < max : min <= number && number <= max;
  253. }
  254. var max$1 = Math.max,
  255. min$1 = Math.min;
  256. function clamp(number, x, y) {
  257. var minimum = min$1(x, y);
  258. var maximum = max$1(x, y);
  259. return min$1(max$1(minimum, number), maximum);
  260. }
  261. function sign(x) {
  262. return +(x > 0) - +(x < 0);
  263. }
  264. var min = Math.min,
  265. max = Math.max,
  266. floor = Math.floor,
  267. ceil = Math.ceil,
  268. abs = Math.abs,
  269. round = Math.round;
  270. function format(string, replacements) {
  271. forEach(replacements, function (replacement) {
  272. string = string.replace("%s", "" + replacement);
  273. });
  274. return string;
  275. }
  276. function pad(number) {
  277. return number < 10 ? "0" + number : "" + number;
  278. }
  279. var ids = {};
  280. function uniqueId(prefix) {
  281. return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1);
  282. }
  283. function EventBus() {
  284. var handlers = {};
  285. function on(events, callback, key, priority) {
  286. if (priority === void 0) {
  287. priority = DEFAULT_EVENT_PRIORITY;
  288. }
  289. forEachEvent(events, function (event, namespace) {
  290. handlers[event] = handlers[event] || [];
  291. push(handlers[event], {
  292. _event: event,
  293. _callback: callback,
  294. _namespace: namespace,
  295. _priority: priority,
  296. _key: key
  297. }).sort(function (handler1, handler2) {
  298. return handler1._priority - handler2._priority;
  299. });
  300. });
  301. }
  302. function off(events, key) {
  303. forEachEvent(events, function (event, namespace) {
  304. var eventHandlers = handlers[event];
  305. handlers[event] = eventHandlers && eventHandlers.filter(function (handler) {
  306. return handler._key ? handler._key !== key : handler._namespace !== namespace;
  307. });
  308. });
  309. }
  310. function offBy(key) {
  311. forOwn(handlers, function (eventHandlers, event) {
  312. off(event, key);
  313. });
  314. }
  315. function emit(event) {
  316. var _arguments = arguments;
  317. (handlers[event] || []).forEach(function (handler) {
  318. handler._callback.apply(handler, slice(_arguments, 1));
  319. });
  320. }
  321. function destroy() {
  322. handlers = {};
  323. }
  324. function forEachEvent(events, iteratee) {
  325. toArray(events).join(" ").split(" ").forEach(function (eventNS) {
  326. var fragments = eventNS.split(".");
  327. iteratee(fragments[0], fragments[1]);
  328. });
  329. }
  330. return {
  331. on: on,
  332. off: off,
  333. offBy: offBy,
  334. emit: emit,
  335. destroy: destroy
  336. };
  337. }
  338. var EVENT_MOUNTED = "mounted";
  339. var EVENT_READY = "ready";
  340. var EVENT_MOVE = "move";
  341. var EVENT_MOVED = "moved";
  342. var EVENT_CLICK = "click";
  343. var EVENT_ACTIVE = "active";
  344. var EVENT_INACTIVE = "inactive";
  345. var EVENT_VISIBLE = "visible";
  346. var EVENT_HIDDEN = "hidden";
  347. var EVENT_SLIDE_KEYDOWN = "slide:keydown";
  348. var EVENT_REFRESH = "refresh";
  349. var EVENT_UPDATED = "undated";
  350. var EVENT_RESIZE = "resize";
  351. var EVENT_RESIZED = "resized";
  352. var EVENT_DRAG = "drag";
  353. var EVENT_DRAGGING = "dragging";
  354. var EVENT_DRAGGED = "dragged";
  355. var EVENT_SCROLL = "scroll";
  356. var EVENT_SCROLLED = "scrolled";
  357. var EVENT_DESTROY = "destroy";
  358. var EVENT_ARROWS_MOUNTED = "arrows:mounted";
  359. var EVENT_ARROWS_UPDATED = "arrows:updated";
  360. var EVENT_PAGINATION_MOUNTED = "pagination:mounted";
  361. var EVENT_PAGINATION_PAGE = "pagination:page";
  362. var EVENT_PAGINATION_UPDATED = "pagination:updated";
  363. var EVENT_NAVIGATION_MOUNTED = "navigation:mounted";
  364. var EVENT_AUTOPLAY_PLAY = "autoplay:play";
  365. var EVENT_AUTOPLAY_PLAYING = "autoplay:playing";
  366. var EVENT_AUTOPLAY_PAUSE = "autoplay:pause";
  367. var EVENT_LAZYLOAD_LOADED = "lazyload:loaded";
  368. function EventInterface(Splide2) {
  369. var event = Splide2.event;
  370. var key = {};
  371. var listeners = [];
  372. function on(events, callback, priority) {
  373. event.on(events, callback, key, priority);
  374. }
  375. function off(events) {
  376. event.off(events, key);
  377. }
  378. function bind(targets, events, callback, options) {
  379. forEachEvent(targets, events, function (target, event2) {
  380. listeners.push([target, event2, callback, options]);
  381. target.addEventListener(event2, callback, options);
  382. });
  383. }
  384. function unbind(targets, events) {
  385. forEachEvent(targets, events, function (target, event2) {
  386. listeners = listeners.filter(function (listener) {
  387. if (listener[0] === target && listener[1] === event2) {
  388. target.removeEventListener(event2, listener[2], listener[3]);
  389. return false;
  390. }
  391. return true;
  392. });
  393. });
  394. }
  395. function forEachEvent(targets, events, iteratee) {
  396. forEach(targets, function (target) {
  397. if (target) {
  398. events.split(" ").forEach(iteratee.bind(null, target));
  399. }
  400. });
  401. }
  402. function destroy() {
  403. listeners = listeners.filter(function (data) {
  404. return unbind(data[0], data[1]);
  405. });
  406. event.offBy(key);
  407. }
  408. event.on(EVENT_DESTROY, destroy, key);
  409. return {
  410. on: on,
  411. off: off,
  412. emit: event.emit,
  413. bind: bind,
  414. unbind: unbind,
  415. destroy: destroy
  416. };
  417. }
  418. function RequestInterval(interval, onInterval, onUpdate, limit) {
  419. var now = Date.now;
  420. var startTime;
  421. var rate = 0;
  422. var id;
  423. var paused = true;
  424. var count = 0;
  425. function update() {
  426. if (!paused) {
  427. var elapsed = now() - startTime;
  428. if (elapsed >= interval) {
  429. rate = 1;
  430. startTime = now();
  431. } else {
  432. rate = elapsed / interval;
  433. }
  434. if (onUpdate) {
  435. onUpdate(rate);
  436. }
  437. if (rate === 1) {
  438. onInterval();
  439. if (limit && ++count >= limit) {
  440. pause();
  441. return;
  442. }
  443. }
  444. raf(update);
  445. }
  446. }
  447. function start(resume) {
  448. !resume && cancel();
  449. startTime = now() - (resume ? rate * interval : 0);
  450. paused = false;
  451. raf(update);
  452. }
  453. function pause() {
  454. paused = true;
  455. }
  456. function rewind() {
  457. startTime = now();
  458. rate = 0;
  459. if (onUpdate) {
  460. onUpdate(rate);
  461. }
  462. }
  463. function cancel() {
  464. cancelAnimationFrame(id);
  465. rate = 0;
  466. id = 0;
  467. paused = true;
  468. }
  469. function isPaused() {
  470. return paused;
  471. }
  472. return {
  473. start: start,
  474. rewind: rewind,
  475. pause: pause,
  476. cancel: cancel,
  477. isPaused: isPaused
  478. };
  479. }
  480. function State(initialState) {
  481. var state = initialState;
  482. function set(value) {
  483. state = value;
  484. }
  485. function is(states) {
  486. return includes(toArray(states), state);
  487. }
  488. return {
  489. set: set,
  490. is: is
  491. };
  492. }
  493. function Throttle(func, duration) {
  494. var interval;
  495. function throttled() {
  496. var _arguments2 = arguments,
  497. _this = this;
  498. if (!interval) {
  499. interval = RequestInterval(duration || 0, function () {
  500. func.apply(_this, _arguments2);
  501. interval = null;
  502. }, null, 1);
  503. interval.start();
  504. }
  505. }
  506. return throttled;
  507. }
  508. function Options(Splide2, Components2, options) {
  509. var throttledObserve = Throttle(observe);
  510. var initialOptions;
  511. var points;
  512. var currPoint;
  513. function setup() {
  514. try {
  515. merge(options, JSON.parse(getAttribute(Splide2.root, DATA_ATTRIBUTE)));
  516. } catch (e) {
  517. assert(false, e.message);
  518. }
  519. initialOptions = merge({}, options);
  520. }
  521. function mount() {
  522. var breakpoints = options.breakpoints;
  523. if (breakpoints) {
  524. points = Object.keys(breakpoints).sort(function (n, m) {
  525. return +n - +m;
  526. }).map(function (point) {
  527. return [point, matchMedia("(" + (options.mediaQuery || "max") + "-width:" + point + "px)")];
  528. });
  529. addEventListener("resize", throttledObserve);
  530. observe();
  531. }
  532. }
  533. function destroy(completely) {
  534. if (completely) {
  535. removeEventListener("resize", throttledObserve);
  536. }
  537. }
  538. function observe() {
  539. var item = find(points, function (item2) {
  540. return item2[1].matches;
  541. }) || [];
  542. if (item[0] !== currPoint) {
  543. onMatch(currPoint = item[0]);
  544. }
  545. }
  546. function onMatch(point) {
  547. var newOptions = options.breakpoints[point] || initialOptions;
  548. if (newOptions.destroy) {
  549. Splide2.options = initialOptions;
  550. Splide2.destroy(newOptions.destroy === "completely");
  551. } else {
  552. if (Splide2.state.is(DESTROYED)) {
  553. destroy(true);
  554. Splide2.mount();
  555. }
  556. Splide2.options = newOptions;
  557. }
  558. }
  559. return {
  560. setup: setup,
  561. mount: mount,
  562. destroy: destroy
  563. };
  564. }
  565. var RTL = "rtl";
  566. var TTB = "ttb";
  567. var ORIENTATION_MAP = {
  568. marginRight: ["marginBottom", "marginLeft"],
  569. width: ["height"],
  570. autoWidth: ["autoHeight"],
  571. fixedWidth: ["fixedHeight"],
  572. paddingLeft: ["paddingTop", "paddingRight"],
  573. paddingRight: ["paddingBottom", "paddingLeft"],
  574. left: ["top", "right"],
  575. right: ["bottom", "left"],
  576. x: ["y"],
  577. X: ["Y"],
  578. Y: ["X"],
  579. ArrowLeft: ["ArrowUp", "ArrowRight"],
  580. ArrowRight: ["ArrowDown", "ArrowLeft"]
  581. };
  582. function Direction(Splide2, Components2, options) {
  583. function resolve(prop, axisOnly) {
  584. var direction = options.direction;
  585. var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1;
  586. return ORIENTATION_MAP[prop][index] || prop;
  587. }
  588. function orient(value) {
  589. return value * (options.direction === RTL ? 1 : -1);
  590. }
  591. return {
  592. resolve: resolve,
  593. orient: orient
  594. };
  595. }
  596. var CLASS_ROOT = PROJECT_CODE;
  597. var CLASS_SLIDER = PROJECT_CODE + "__slider";
  598. var CLASS_TRACK = PROJECT_CODE + "__track";
  599. var CLASS_LIST = PROJECT_CODE + "__list";
  600. var CLASS_SLIDE = PROJECT_CODE + "__slide";
  601. var CLASS_CLONE = CLASS_SLIDE + "--clone";
  602. var CLASS_CONTAINER = CLASS_SLIDE + "__container";
  603. var CLASS_ARROWS = PROJECT_CODE + "__arrows";
  604. var CLASS_ARROW = PROJECT_CODE + "__arrow";
  605. var CLASS_ARROW_PREV = CLASS_ARROW + "--prev";
  606. var CLASS_ARROW_NEXT = CLASS_ARROW + "--next";
  607. var CLASS_PAGINATION = PROJECT_CODE + "__pagination";
  608. var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page";
  609. var CLASS_PROGRESS = PROJECT_CODE + "__progress";
  610. var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar";
  611. var CLASS_AUTOPLAY = PROJECT_CODE + "__autoplay";
  612. var CLASS_PLAY = PROJECT_CODE + "__play";
  613. var CLASS_PAUSE = PROJECT_CODE + "__pause";
  614. var CLASS_SPINNER = PROJECT_CODE + "__spinner";
  615. var CLASS_INITIALIZED = "is-initialized";
  616. var CLASS_ACTIVE = "is-active";
  617. var CLASS_PREV = "is-prev";
  618. var CLASS_NEXT = "is-next";
  619. var CLASS_VISIBLE = "is-visible";
  620. var CLASS_LOADING = "is-loading";
  621. var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING];
  622. var CLASSES = {
  623. slide: CLASS_SLIDE,
  624. clone: CLASS_CLONE,
  625. arrows: CLASS_ARROWS,
  626. arrow: CLASS_ARROW,
  627. prev: CLASS_ARROW_PREV,
  628. next: CLASS_ARROW_NEXT,
  629. pagination: CLASS_PAGINATION,
  630. page: CLASS_PAGINATION_PAGE,
  631. spinner: CLASS_SPINNER
  632. };
  633. function Elements(Splide2, Components2, options) {
  634. var _EventInterface = EventInterface(Splide2),
  635. on = _EventInterface.on;
  636. var root = Splide2.root;
  637. var elements = {};
  638. var slides = [];
  639. var classes;
  640. var slider;
  641. var track;
  642. var list;
  643. function setup() {
  644. collect();
  645. identify();
  646. addClass(root, classes = getClasses());
  647. }
  648. function mount() {
  649. on(EVENT_REFRESH, refresh);
  650. on(EVENT_UPDATED, update);
  651. }
  652. function destroy() {
  653. empty(slides);
  654. removeClass(root, classes);
  655. }
  656. function refresh() {
  657. destroy();
  658. setup();
  659. }
  660. function update() {
  661. removeClass(root, classes);
  662. addClass(root, classes = getClasses());
  663. }
  664. function collect() {
  665. slider = child(root, "." + CLASS_SLIDER);
  666. track = query(root, "." + CLASS_TRACK);
  667. list = child(track, "." + CLASS_LIST);
  668. assert(track && list, "Missing a track/list element.");
  669. push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")"));
  670. var autoplay = find("." + CLASS_AUTOPLAY);
  671. var arrows = find("." + CLASS_ARROWS);
  672. assign(elements, {
  673. root: root,
  674. slider: slider,
  675. track: track,
  676. list: list,
  677. slides: slides,
  678. arrows: arrows,
  679. prev: query(arrows, "." + CLASS_ARROW_PREV),
  680. next: query(arrows, "." + CLASS_ARROW_NEXT),
  681. bar: query(find("." + CLASS_PROGRESS), "." + CLASS_PROGRESS_BAR),
  682. play: query(autoplay, "." + CLASS_PLAY),
  683. pause: query(autoplay, "." + CLASS_PAUSE)
  684. });
  685. }
  686. function identify() {
  687. var id = root.id || uniqueId(PROJECT_CODE);
  688. root.id = id;
  689. track.id = track.id || id + "-track";
  690. list.id = list.id || id + "-list";
  691. }
  692. function find(selector) {
  693. return child(root, selector) || child(slider, selector);
  694. }
  695. function getClasses() {
  696. return [CLASS_ROOT + "--" + options.type, CLASS_ROOT + "--" + options.direction, options.drag && CLASS_ROOT + "--draggable", options.isNavigation && CLASS_ROOT + "--nav", CLASS_ACTIVE];
  697. }
  698. return assign(elements, {
  699. setup: setup,
  700. mount: mount,
  701. destroy: destroy
  702. });
  703. }
  704. function Style() {
  705. var style;
  706. var sheet;
  707. function mount() {
  708. style = create("style", {}, document.head);
  709. sheet = style.sheet;
  710. }
  711. function destroy() {
  712. remove(style);
  713. sheet = null;
  714. }
  715. function rule(selector, prop, value) {
  716. var _sheet = sheet,
  717. cssRules = _sheet.cssRules;
  718. var cssRule = find(cssRules, function (cssRule2) {
  719. return isCSSStyleRule(cssRule2) && cssRule2.selectorText === selector;
  720. }) || cssRules[sheet.insertRule(selector + "{}", 0)];
  721. if (isCSSStyleRule(cssRule)) {
  722. cssRule.style[prop] = "" + value;
  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 ALL_ATTRIBUTES = [ROLE, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_HIDDEN, TAB_INDEX, DISABLED];
  746. var SLIDE = "slide";
  747. var LOOP = "loop";
  748. var FADE = "fade";
  749. function Slide$1(Splide2, index, slideIndex, slide) {
  750. var _EventInterface2 = EventInterface(Splide2),
  751. on = _EventInterface2.on,
  752. emit = _EventInterface2.emit,
  753. bind = _EventInterface2.bind,
  754. destroyEvents = _EventInterface2.destroy;
  755. var Components = Splide2.Components,
  756. root = Splide2.root,
  757. options = Splide2.options;
  758. var isNavigation = options.isNavigation,
  759. updateOnMove = options.updateOnMove;
  760. var resolve = Components.Direction.resolve;
  761. var isClone = slideIndex > -1;
  762. var container = child(slide, "." + CLASS_CONTAINER);
  763. var destroyed;
  764. function mount() {
  765. var _this2 = this;
  766. init();
  767. bind(slide, "click keydown", function (e) {
  768. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  769. });
  770. on([EVENT_RESIZED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update.bind(this));
  771. if (updateOnMove) {
  772. on(EVENT_MOVE, onMove.bind(this));
  773. }
  774. update.call(this);
  775. }
  776. function init() {
  777. if (!isClone) {
  778. slide.id = root.id + "-slide" + pad(index + 1);
  779. }
  780. if (isNavigation) {
  781. if (!isHTMLButtonElement(slide)) {
  782. setAttribute(slide, ROLE, "button");
  783. }
  784. var idx = isClone ? slideIndex : index;
  785. var label = format(options.i18n.slideX, idx + 1);
  786. var controls = Splide2.splides.map(function (splide) {
  787. return splide.root.id;
  788. }).join(" ");
  789. setAttribute(slide, ARIA_LABEL, label);
  790. setAttribute(slide, ARIA_CONTROLS, controls);
  791. }
  792. }
  793. function destroy() {
  794. destroyed = true;
  795. destroyEvents();
  796. removeClass(slide, STATUS_CLASSES);
  797. removeAttribute(slide, ALL_ATTRIBUTES);
  798. }
  799. function onMove(next, prev, dest) {
  800. if (!destroyed) {
  801. if (dest === index) {
  802. updateActivity.call(this, true);
  803. }
  804. update.call(this);
  805. }
  806. }
  807. function update() {
  808. if (!destroyed) {
  809. var currIndex = Splide2.index;
  810. updateActivity.call(this, isActive());
  811. updateVisibility.call(this, isVisible());
  812. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  813. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  814. }
  815. }
  816. function updateActivity(active) {
  817. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  818. toggleClass(slide, CLASS_ACTIVE, active);
  819. if (isNavigation) {
  820. setAttribute(slide, ARIA_CURRENT, active || null);
  821. }
  822. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  823. }
  824. }
  825. function updateVisibility(visible) {
  826. var ariaHidden = !visible && !isActive();
  827. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  828. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  829. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  830. toggleClass(slide, CLASS_VISIBLE, visible);
  831. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  832. }
  833. }
  834. function rule(prop, value, useContainer) {
  835. var selector = "#" + slide.id + (container && useContainer ? " > ." + CLASS_CONTAINER : "");
  836. Components.Style.rule(selector, prop, value);
  837. }
  838. function isActive() {
  839. return Splide2.index === index;
  840. }
  841. function isVisible() {
  842. if (Splide2.is(FADE)) {
  843. return isActive();
  844. }
  845. var trackRect = rect(Components.Elements.track);
  846. var slideRect = rect(slide);
  847. var left = resolve("left");
  848. var right = resolve("right");
  849. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  850. }
  851. function isWithin(from, distance) {
  852. var diff = abs(from - index);
  853. if (!Splide2.is(SLIDE) && !isClone) {
  854. diff = min(diff, Splide2.length - diff);
  855. }
  856. return diff <= distance;
  857. }
  858. return {
  859. index: index,
  860. slideIndex: slideIndex,
  861. slide: slide,
  862. container: container,
  863. isClone: isClone,
  864. mount: mount,
  865. destroy: destroy,
  866. rule: rule,
  867. isWithin: isWithin
  868. };
  869. }
  870. function Slides(Splide2, Components2, options) {
  871. var _EventInterface3 = EventInterface(Splide2),
  872. on = _EventInterface3.on,
  873. emit = _EventInterface3.emit,
  874. bind = _EventInterface3.bind;
  875. var _Components2$Elements = Components2.Elements,
  876. slides = _Components2$Elements.slides,
  877. list = _Components2$Elements.list;
  878. var Slides2 = [];
  879. function mount() {
  880. init();
  881. on(EVENT_REFRESH, refresh);
  882. }
  883. function init() {
  884. slides.forEach(function (slide, index) {
  885. register(slide, index, -1);
  886. });
  887. }
  888. function destroy() {
  889. forEach$1(function (Slide2) {
  890. Slide2.destroy();
  891. });
  892. empty(Slides2);
  893. }
  894. function refresh() {
  895. destroy();
  896. init();
  897. }
  898. function register(slide, index, slideIndex) {
  899. var object = Slide$1(Splide2, index, slideIndex, slide);
  900. object.mount();
  901. Slides2.push(object);
  902. }
  903. function get(excludeClones) {
  904. return excludeClones ? filter(function (Slide2) {
  905. return !Slide2.isClone;
  906. }) : Slides2;
  907. }
  908. function getIn(page) {
  909. var Controller = Components2.Controller;
  910. var index = Controller.toIndex(page);
  911. var max = Controller.hasFocus() ? 1 : options.perPage;
  912. return filter(function (Slide2) {
  913. return between(Slide2.index, index, index + max - 1);
  914. });
  915. }
  916. function getAt(index) {
  917. return filter(index)[0];
  918. }
  919. function add(items, index) {
  920. forEach(items, function (slide) {
  921. if (isString(slide)) {
  922. slide = parseHtml(slide);
  923. }
  924. if (isHTMLElement(slide)) {
  925. var ref = slides[index];
  926. ref ? before(slide, ref) : append(list, slide);
  927. addClass(slide, options.classes.slide);
  928. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  929. }
  930. });
  931. emit(EVENT_REFRESH);
  932. }
  933. function remove$1(matcher) {
  934. remove(filter(matcher).map(function (Slide2) {
  935. return Slide2.slide;
  936. }));
  937. emit(EVENT_REFRESH);
  938. }
  939. function forEach$1(iteratee, excludeClones) {
  940. get(excludeClones).forEach(iteratee);
  941. }
  942. function filter(matcher) {
  943. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  944. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  945. });
  946. }
  947. function rule(prop, value, useContainer) {
  948. forEach$1(function (Slide2) {
  949. Slide2.rule(prop, value, useContainer);
  950. });
  951. }
  952. function observeImages(elm, callback) {
  953. var images = queryAll(elm, "img");
  954. var length = images.length;
  955. if (length) {
  956. images.forEach(function (img) {
  957. bind(img, "load error", function () {
  958. if (! --length) {
  959. callback();
  960. }
  961. });
  962. });
  963. } else {
  964. callback();
  965. }
  966. }
  967. function getLength(excludeClones) {
  968. return excludeClones ? slides.length : Slides2.length;
  969. }
  970. function isEnough() {
  971. return Slides2.length > options.perPage;
  972. }
  973. return {
  974. mount: mount,
  975. destroy: destroy,
  976. register: register,
  977. get: get,
  978. getIn: getIn,
  979. getAt: getAt,
  980. add: add,
  981. remove: remove$1,
  982. forEach: forEach$1,
  983. filter: filter,
  984. rule: rule,
  985. getLength: getLength,
  986. isEnough: isEnough
  987. };
  988. }
  989. function Clones(Splide2, Components2, options) {
  990. var _EventInterface4 = EventInterface(Splide2),
  991. on = _EventInterface4.on,
  992. emit = _EventInterface4.emit;
  993. var Elements = Components2.Elements,
  994. Slides = Components2.Slides;
  995. var resolve = Components2.Direction.resolve;
  996. var clones = [];
  997. var cloneCount;
  998. function mount() {
  999. init();
  1000. on(EVENT_REFRESH, refresh);
  1001. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1002. }
  1003. function init() {
  1004. if (cloneCount = computeCloneCount()) {
  1005. generate(cloneCount);
  1006. }
  1007. }
  1008. function destroy() {
  1009. remove(clones);
  1010. empty(clones);
  1011. }
  1012. function refresh() {
  1013. destroy();
  1014. init();
  1015. }
  1016. function observe() {
  1017. if (cloneCount !== computeCloneCount()) {
  1018. emit(EVENT_REFRESH);
  1019. }
  1020. }
  1021. function generate(count) {
  1022. var slides = Slides.get().slice();
  1023. var length = slides.length;
  1024. if (length) {
  1025. while (slides.length < count) {
  1026. push(slides, slides);
  1027. }
  1028. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1029. var isHead = index < count;
  1030. var clone = cloneDeep(Slide.slide, index);
  1031. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1032. push(clones, clone);
  1033. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1034. });
  1035. }
  1036. }
  1037. function cloneDeep(elm, index) {
  1038. var clone = elm.cloneNode(true);
  1039. addClass(clone, options.classes.clone);
  1040. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1041. return clone;
  1042. }
  1043. function computeCloneCount() {
  1044. var clones2 = options.clones;
  1045. if (!Splide2.is(LOOP)) {
  1046. clones2 = 0;
  1047. } else if (!clones2) {
  1048. var fixedSize = options[resolve("fixedWidth")];
  1049. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1050. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1051. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1052. }
  1053. return clones2;
  1054. }
  1055. return {
  1056. mount: mount,
  1057. destroy: destroy
  1058. };
  1059. }
  1060. function Layout(Splide2, Components2, options) {
  1061. var _EventInterface5 = EventInterface(Splide2),
  1062. on = _EventInterface5.on,
  1063. bind = _EventInterface5.bind,
  1064. emit = _EventInterface5.emit;
  1065. var Slides = Components2.Slides;
  1066. var ruleBy = Components2.Style.ruleBy;
  1067. var resolve = Components2.Direction.resolve;
  1068. var _Components2$Elements2 = Components2.Elements,
  1069. track = _Components2$Elements2.track,
  1070. list = _Components2$Elements2.list;
  1071. var getAt = Slides.getAt;
  1072. var vertical = options.direction === TTB;
  1073. function mount() {
  1074. init();
  1075. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  1076. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1077. on(EVENT_RESIZE, resize);
  1078. }
  1079. function init() {
  1080. ruleBy(Splide2.root, "maxWidth", unit(options.width));
  1081. ruleBy(track, resolve("paddingLeft"), cssPadding(false));
  1082. ruleBy(track, resolve("paddingRight"), cssPadding(true));
  1083. Slides.rule(resolve("marginRight"), unit(options.gap));
  1084. Slides.rule("width", cssSlideWidth());
  1085. setSlidesHeight();
  1086. resize();
  1087. }
  1088. function resize() {
  1089. ruleBy(track, "height", cssTrackHeight());
  1090. options.heightRatio && setSlidesHeight();
  1091. emit(EVENT_RESIZED);
  1092. }
  1093. function setSlidesHeight() {
  1094. Slides.rule("height", cssSlideHeight(), true);
  1095. }
  1096. function cssPadding(right) {
  1097. var padding = options.padding;
  1098. var prop = resolve(right ? "right" : "left", true);
  1099. return padding ? unit(padding[prop] || (isObject(padding) ? "0" : padding)) : "";
  1100. }
  1101. function cssTrackHeight() {
  1102. var height = "";
  1103. if (vertical) {
  1104. height = cssHeight();
  1105. assert(height, '"height" or "heightRatio" is missing.');
  1106. var paddingTop = cssPadding(false);
  1107. var paddingBottom = cssPadding(true);
  1108. if (paddingTop || paddingBottom) {
  1109. height = "calc(" + height;
  1110. height += "" + (paddingTop ? " - " + paddingTop : "") + (paddingBottom ? " - " + paddingBottom : "") + ")";
  1111. }
  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. var firstSlide = getAt(0);
  1146. var lastSlide = getAt(Slides.getLength(true) - 1);
  1147. if (firstSlide && lastSlide) {
  1148. return rect(lastSlide.slide)[resolve("right")] - rect(firstSlide.slide)[resolve("left")];
  1149. }
  1150. return 0;
  1151. }
  1152. function getGap() {
  1153. var Slide = getAt(0);
  1154. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1155. }
  1156. function getPadding(right) {
  1157. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left"), true))) || 0;
  1158. }
  1159. return {
  1160. mount: mount,
  1161. listSize: listSize,
  1162. slideSize: slideSize,
  1163. sliderSize: sliderSize,
  1164. totalSize: totalSize,
  1165. getPadding: getPadding
  1166. };
  1167. }
  1168. var SNAP_THRESHOLD = 10;
  1169. function Move(Splide2, Components2, options) {
  1170. var _EventInterface6 = EventInterface(Splide2),
  1171. on = _EventInterface6.on,
  1172. emit = _EventInterface6.emit;
  1173. var _Components2$Layout = Components2.Layout,
  1174. slideSize = _Components2$Layout.slideSize,
  1175. getPadding = _Components2$Layout.getPadding,
  1176. totalSize = _Components2$Layout.totalSize,
  1177. listSize = _Components2$Layout.listSize,
  1178. sliderSize = _Components2$Layout.sliderSize;
  1179. var _Components2$Directio = Components2.Direction,
  1180. resolve = _Components2$Directio.resolve,
  1181. orient = _Components2$Directio.orient;
  1182. var _Components2$Elements3 = Components2.Elements,
  1183. list = _Components2$Elements3.list,
  1184. track = _Components2$Elements3.track;
  1185. var looping;
  1186. var waiting;
  1187. var currPosition = 0;
  1188. var positionRate = 0;
  1189. function mount() {
  1190. on([EVENT_RESIZE, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition, DEFAULT_EVENT_PRIORITY - 1);
  1191. }
  1192. function reposition() {
  1193. if (options.drag !== "free") {
  1194. jump(Splide2.index);
  1195. } else {
  1196. if (!options[resolve("fixedWidth")] && !options[resolve("autoWidth")]) {
  1197. translate(listSize() * positionRate);
  1198. }
  1199. if (exceededLimit(true)) {
  1200. translate(getLimit(true));
  1201. } else {
  1202. snap(SNAP_THRESHOLD);
  1203. }
  1204. }
  1205. }
  1206. function snap(threshold) {
  1207. var position = getPosition();
  1208. var index = toIndex(position);
  1209. if (abs(position - toPosition(index)) < threshold) {
  1210. jump(index);
  1211. }
  1212. }
  1213. function move(dest, index, prev) {
  1214. if (!isBusy()) {
  1215. var position = getPosition();
  1216. looping = dest !== index;
  1217. waiting = options.waitForTransition;
  1218. Splide2.state.set(MOVING);
  1219. emit(EVENT_MOVE, index, prev, dest);
  1220. Components2.Transition.start(dest, function () {
  1221. onMoved(dest, index, prev, position);
  1222. });
  1223. }
  1224. }
  1225. function onMoved(dest, index, prev, oldPosition) {
  1226. if (looping) {
  1227. jump(index);
  1228. }
  1229. waiting = false;
  1230. Splide2.state.set(IDLE);
  1231. emit(EVENT_MOVED, index, prev, dest);
  1232. if (options.trimSpace === "move" && dest !== prev && oldPosition === getPosition()) {
  1233. Components2.Controller.go(dest > prev ? ">" : "<");
  1234. }
  1235. }
  1236. function jump(index) {
  1237. waiting = false;
  1238. looping = false;
  1239. Components2.Transition.cancel();
  1240. translate(toPosition(index, true));
  1241. }
  1242. function translate(position) {
  1243. currPosition = loop(position);
  1244. positionRate = currPosition / listSize();
  1245. Components2.Style.ruleBy(list, "transform", "translate" + resolve("X") + "(" + currPosition + "px)");
  1246. }
  1247. function loop(position) {
  1248. if (!looping && Splide2.is(LOOP)) {
  1249. var diff = position - currPosition;
  1250. var exceededMin = exceededLimit(false, position);
  1251. var exceededMax = exceededLimit(true, position);
  1252. if (exceededMin && diff > 0 || exceededMax && diff < 0) {
  1253. position += orient(sliderSize() * (exceededMin ? 1 : -1));
  1254. }
  1255. }
  1256. return position;
  1257. }
  1258. function cancel() {
  1259. translate(getPosition());
  1260. Components2.Transition.cancel();
  1261. }
  1262. function toIndex(position) {
  1263. var Slides = Components2.Slides.get();
  1264. var index = 0;
  1265. var minDistance = Infinity;
  1266. for (var i = 0; i < Slides.length; i++) {
  1267. var slideIndex = Slides[i].index;
  1268. var distance = abs(toPosition(slideIndex) - position);
  1269. if (distance < minDistance) {
  1270. minDistance = distance;
  1271. index = slideIndex;
  1272. } else {
  1273. break;
  1274. }
  1275. }
  1276. return index;
  1277. }
  1278. function toPosition(index, trimming) {
  1279. var position = orient(totalSize(index - 1) - offset(index));
  1280. return trimming ? trim(position) : position;
  1281. }
  1282. function getPosition() {
  1283. var left = resolve("left");
  1284. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1285. }
  1286. function trim(position) {
  1287. if (options.trimSpace && Splide2.is(SLIDE)) {
  1288. position = clamp(position, 0, orient(sliderSize() - listSize()));
  1289. }
  1290. return position;
  1291. }
  1292. function offset(index) {
  1293. var focus = options.focus;
  1294. if (focus === "center") {
  1295. return (listSize() - slideSize(index, true)) / 2;
  1296. }
  1297. return (+focus || 0) * slideSize(index);
  1298. }
  1299. function getLimit(max) {
  1300. var trimming = !!options.trimSpace;
  1301. return max ? toPosition(Components2.Controller.getEnd(), trimming) : toPosition(0, trimming);
  1302. }
  1303. function isBusy() {
  1304. return !!(looping || waiting);
  1305. }
  1306. function exceededLimit(max, position) {
  1307. if (position === void 0) {
  1308. position = currPosition;
  1309. }
  1310. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1311. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1312. return exceededMin || exceededMax;
  1313. }
  1314. return {
  1315. mount: mount,
  1316. move: move,
  1317. jump: jump,
  1318. translate: translate,
  1319. cancel: cancel,
  1320. toIndex: toIndex,
  1321. toPosition: toPosition,
  1322. getPosition: getPosition,
  1323. getLimit: getLimit,
  1324. isBusy: isBusy,
  1325. exceededLimit: exceededLimit
  1326. };
  1327. }
  1328. function Controller(Splide2, Components2, options) {
  1329. var _EventInterface7 = EventInterface(Splide2),
  1330. on = _EventInterface7.on;
  1331. var Move = Components2.Move;
  1332. var _Components2$Slides = Components2.Slides,
  1333. isEnough = _Components2$Slides.isEnough,
  1334. getLength = _Components2$Slides.getLength;
  1335. var isLoop = Splide2.is(LOOP);
  1336. var currIndex = options.start || 0;
  1337. var prevIndex = currIndex;
  1338. var slideCount;
  1339. var perMove;
  1340. var perPage;
  1341. function mount() {
  1342. init();
  1343. Move.jump(currIndex);
  1344. on([EVENT_UPDATED, EVENT_REFRESH], init);
  1345. on(EVENT_SCROLLED, reindex, 0);
  1346. }
  1347. function init() {
  1348. slideCount = getLength(true);
  1349. perMove = options.perMove;
  1350. perPage = options.perPage;
  1351. if (currIndex >= slideCount) {
  1352. Move.jump(currIndex = slideCount - 1);
  1353. }
  1354. }
  1355. function reindex() {
  1356. setIndex(Move.toIndex(Move.getPosition()));
  1357. }
  1358. function go(control, allowSameIndex) {
  1359. var dest = parse(control);
  1360. var index = loop(dest);
  1361. if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
  1362. setIndex(index);
  1363. Move.move(dest, index, prevIndex);
  1364. }
  1365. }
  1366. function parse(control) {
  1367. var index = currIndex;
  1368. if (isString(control)) {
  1369. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1370. indicator = _ref[1],
  1371. number = _ref[2];
  1372. if (indicator === "+" || indicator === "-") {
  1373. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
  1374. } else if (indicator === ">") {
  1375. index = number ? toIndex(+number) : getNext(true);
  1376. } else if (indicator === "<") {
  1377. index = getPrev(true);
  1378. }
  1379. } else {
  1380. if (isLoop) {
  1381. index = clamp(control, -perPage, slideCount + perPage - 1);
  1382. } else {
  1383. index = clamp(control, 0, getEnd());
  1384. }
  1385. }
  1386. return index;
  1387. }
  1388. function getNext(destination) {
  1389. return getAdjacent(false, destination);
  1390. }
  1391. function getPrev(destination) {
  1392. return getAdjacent(true, destination);
  1393. }
  1394. function getAdjacent(prev, destination) {
  1395. var number = perMove || hasFocus() ? 1 : perPage;
  1396. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
  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_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1524. bind(next, "click", function () {
  1525. go(">");
  1526. });
  1527. bind(prev, "click", function () {
  1528. go("<");
  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.2;
  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);
  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