splide.js 76 KB

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