splide.js 75 KB

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