splide.js 75 KB

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