splide.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007
  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.4.0
  6. * License : MIT
  7. * Copyright: 2021 Naotoshi Fujita
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Splide = factory());
  11. })(this, function () {
  12. 'use strict';
  13. var PROJECT_CODE = "splide";
  14. var DATA_ATTRIBUTE = "data-" + PROJECT_CODE;
  15. var CREATED = 1;
  16. var MOUNTED = 2;
  17. var IDLE = 3;
  18. var MOVING = 4;
  19. var DESTROYED = 5;
  20. var STATES = {
  21. CREATED: CREATED,
  22. MOUNTED: MOUNTED,
  23. IDLE: IDLE,
  24. MOVING: MOVING,
  25. DESTROYED: DESTROYED
  26. };
  27. var DEFAULT_EVENT_PRIORITY = 10;
  28. var DEFAULT_USER_EVENT_PRIORITY = 20;
  29. function empty(array) {
  30. array.length = 0;
  31. }
  32. function isObject(subject) {
  33. return !isNull(subject) && typeof subject === "object";
  34. }
  35. function isArray(subject) {
  36. return Array.isArray(subject);
  37. }
  38. function isFunction(subject) {
  39. return typeof subject === "function";
  40. }
  41. function isString(subject) {
  42. return typeof subject === "string";
  43. }
  44. function isUndefined(subject) {
  45. return typeof subject === "undefined";
  46. }
  47. function isNull(subject) {
  48. return subject === null;
  49. }
  50. function isHTMLElement(subject) {
  51. return subject instanceof HTMLElement;
  52. }
  53. function 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. if (!isClone) {
  742. slide.id = root.id + "-slide" + pad(index + 1);
  743. }
  744. bind(slide, "click keydown", function (e) {
  745. emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, _this2, e);
  746. });
  747. on([EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], update.bind(this));
  748. on(EVENT_NAVIGATION_MOUNTED, initNavigation.bind(this));
  749. if (updateOnMove) {
  750. on(EVENT_MOVE, onMove.bind(this));
  751. }
  752. }
  753. function destroy() {
  754. destroyed = true;
  755. destroyEvents();
  756. removeClass(slide, STATUS_CLASSES);
  757. removeAttribute(slide, ALL_ATTRIBUTES);
  758. setAttribute(slide, "style", styles);
  759. }
  760. function initNavigation() {
  761. var idx = isClone ? slideIndex : index;
  762. var label = format(options.i18n.slideX, idx + 1);
  763. var controls = Splide2.splides.map(function (target) {
  764. return target.splide.root.id;
  765. }).join(" ");
  766. setAttribute(slide, ARIA_LABEL, label);
  767. setAttribute(slide, ARIA_CONTROLS, controls);
  768. setAttribute(slide, ROLE, "menuitem");
  769. updateActivity.call(this, isActive());
  770. }
  771. function onMove(next, prev, dest) {
  772. if (!destroyed) {
  773. update.call(this);
  774. if (dest === index) {
  775. updateActivity.call(this, true);
  776. }
  777. }
  778. }
  779. function update() {
  780. if (!destroyed) {
  781. var currIndex = Splide2.index;
  782. updateActivity.call(this, isActive());
  783. updateVisibility.call(this, isVisible());
  784. toggleClass(slide, CLASS_PREV, index === currIndex - 1);
  785. toggleClass(slide, CLASS_NEXT, index === currIndex + 1);
  786. }
  787. }
  788. function updateActivity(active) {
  789. if (active !== hasClass(slide, CLASS_ACTIVE)) {
  790. toggleClass(slide, CLASS_ACTIVE, active);
  791. if (isNavigation) {
  792. setAttribute(slide, ARIA_CURRENT, active || null);
  793. }
  794. emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, this);
  795. }
  796. }
  797. function updateVisibility(visible) {
  798. var ariaHidden = !visible && !isActive();
  799. setAttribute(slide, ARIA_HIDDEN, ariaHidden || null);
  800. setAttribute(slide, TAB_INDEX, !ariaHidden && options.slideFocus ? 0 : null);
  801. if (focusableNodes) {
  802. focusableNodes.forEach(function (node) {
  803. setAttribute(node, TAB_INDEX, ariaHidden ? -1 : null);
  804. });
  805. }
  806. if (visible !== hasClass(slide, CLASS_VISIBLE)) {
  807. toggleClass(slide, CLASS_VISIBLE, visible);
  808. emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, this);
  809. }
  810. }
  811. function style$1(prop, value, useContainer) {
  812. style(useContainer && container || slide, prop, value);
  813. }
  814. function isActive() {
  815. return Splide2.index === index;
  816. }
  817. function isVisible() {
  818. if (Splide2.is(FADE)) {
  819. return isActive();
  820. }
  821. var trackRect = rect(Components.Elements.track);
  822. var slideRect = rect(slide);
  823. var left = resolve("left");
  824. var right = resolve("right");
  825. return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]);
  826. }
  827. function isWithin(from, distance) {
  828. var diff = abs(from - index);
  829. if (!isClone && (options.rewind || Splide2.is(LOOP))) {
  830. diff = min(diff, Splide2.length - diff);
  831. }
  832. return diff <= distance;
  833. }
  834. return {
  835. index: index,
  836. slideIndex: slideIndex,
  837. slide: slide,
  838. container: container,
  839. isClone: isClone,
  840. mount: mount,
  841. destroy: destroy,
  842. style: style$1,
  843. isWithin: isWithin
  844. };
  845. }
  846. function Slides(Splide2, Components2, options) {
  847. var _EventInterface3 = EventInterface(Splide2),
  848. on = _EventInterface3.on,
  849. emit = _EventInterface3.emit,
  850. bind = _EventInterface3.bind;
  851. var _Components2$Elements = Components2.Elements,
  852. slides = _Components2$Elements.slides,
  853. list = _Components2$Elements.list;
  854. var Slides2 = [];
  855. function mount() {
  856. init();
  857. on(EVENT_REFRESH, refresh);
  858. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  859. Slides2.sort(function (Slide1, Slide2) {
  860. return Slide1.index - Slide2.index;
  861. });
  862. });
  863. }
  864. function init() {
  865. slides.forEach(function (slide, index) {
  866. register(slide, index, -1);
  867. });
  868. }
  869. function destroy() {
  870. forEach$1(function (Slide2) {
  871. Slide2.destroy();
  872. });
  873. empty(Slides2);
  874. }
  875. function refresh() {
  876. destroy();
  877. init();
  878. }
  879. function register(slide, index, slideIndex) {
  880. var object = Slide$1(Splide2, index, slideIndex, slide);
  881. object.mount();
  882. Slides2.push(object);
  883. }
  884. function get(excludeClones) {
  885. return excludeClones ? filter(function (Slide2) {
  886. return !Slide2.isClone;
  887. }) : Slides2;
  888. }
  889. function getIn(page) {
  890. var Controller = Components2.Controller;
  891. var index = Controller.toIndex(page);
  892. var max = Controller.hasFocus() ? 1 : options.perPage;
  893. return filter(function (Slide2) {
  894. return between(Slide2.index, index, index + max - 1);
  895. });
  896. }
  897. function getAt(index) {
  898. return filter(index)[0];
  899. }
  900. function add(items, index) {
  901. forEach(items, function (slide) {
  902. if (isString(slide)) {
  903. slide = parseHtml(slide);
  904. }
  905. if (isHTMLElement(slide)) {
  906. var ref = slides[index];
  907. ref ? before(slide, ref) : append(list, slide);
  908. addClass(slide, options.classes.slide);
  909. observeImages(slide, emit.bind(null, EVENT_RESIZE));
  910. }
  911. });
  912. emit(EVENT_REFRESH);
  913. }
  914. function remove$1(matcher) {
  915. remove(filter(matcher).map(function (Slide2) {
  916. return Slide2.slide;
  917. }));
  918. emit(EVENT_REFRESH);
  919. }
  920. function forEach$1(iteratee, excludeClones) {
  921. get(excludeClones).forEach(iteratee);
  922. }
  923. function filter(matcher) {
  924. return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) {
  925. return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index);
  926. });
  927. }
  928. function style(prop, value, useContainer) {
  929. forEach$1(function (Slide2) {
  930. Slide2.style(prop, value, useContainer);
  931. });
  932. }
  933. function observeImages(elm, callback) {
  934. var images = queryAll(elm, "img");
  935. var length = images.length;
  936. if (length) {
  937. images.forEach(function (img) {
  938. bind(img, "load error", function () {
  939. if (! --length) {
  940. callback();
  941. }
  942. });
  943. });
  944. } else {
  945. callback();
  946. }
  947. }
  948. function getLength(excludeClones) {
  949. return excludeClones ? slides.length : Slides2.length;
  950. }
  951. function isEnough() {
  952. return Slides2.length > options.perPage;
  953. }
  954. return {
  955. mount: mount,
  956. destroy: destroy,
  957. register: register,
  958. get: get,
  959. getIn: getIn,
  960. getAt: getAt,
  961. add: add,
  962. remove: remove$1,
  963. forEach: forEach$1,
  964. filter: filter,
  965. style: style,
  966. getLength: getLength,
  967. isEnough: isEnough
  968. };
  969. }
  970. function Layout(Splide2, Components2, options) {
  971. var _EventInterface4 = EventInterface(Splide2),
  972. on = _EventInterface4.on,
  973. bind = _EventInterface4.bind,
  974. emit = _EventInterface4.emit;
  975. var Slides = Components2.Slides;
  976. var resolve = Components2.Direction.resolve;
  977. var _Components2$Elements2 = Components2.Elements,
  978. root = _Components2$Elements2.root,
  979. track = _Components2$Elements2.track,
  980. list = _Components2$Elements2.list;
  981. var getAt = Slides.getAt;
  982. var vertical;
  983. var rootRect;
  984. function mount() {
  985. init();
  986. bind(window, "resize load", Throttle(emit.bind(this, EVENT_RESIZE)));
  987. on([EVENT_UPDATED, EVENT_REFRESH], init);
  988. on(EVENT_RESIZE, resize);
  989. }
  990. function init() {
  991. rootRect = null;
  992. vertical = options.direction === TTB;
  993. style(root, "maxWidth", unit(options.width));
  994. style(track, resolve("paddingLeft"), cssPadding(false));
  995. style(track, resolve("paddingRight"), cssPadding(true));
  996. resize();
  997. }
  998. function resize() {
  999. var newRect = rect(root);
  1000. if (!rootRect || rootRect.width !== newRect.width || rootRect.height !== newRect.height) {
  1001. style(track, "height", cssTrackHeight());
  1002. Slides.style(resolve("marginRight"), unit(options.gap));
  1003. Slides.style("width", cssSlideWidth() || null);
  1004. setSlidesHeight();
  1005. rootRect = newRect;
  1006. emit(EVENT_RESIZED);
  1007. }
  1008. }
  1009. function setSlidesHeight() {
  1010. Slides.style("height", cssSlideHeight() || null, true);
  1011. }
  1012. function cssPadding(right) {
  1013. var padding = options.padding;
  1014. var prop = resolve(right ? "right" : "left");
  1015. return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px";
  1016. }
  1017. function cssTrackHeight() {
  1018. var height = "";
  1019. if (vertical) {
  1020. height = cssHeight();
  1021. assert(height, "height or heightRatio is missing.");
  1022. height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")";
  1023. }
  1024. return height;
  1025. }
  1026. function cssHeight() {
  1027. return unit(options.height || rect(list).width * options.heightRatio);
  1028. }
  1029. function cssSlideWidth() {
  1030. return options.autoWidth ? "" : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize());
  1031. }
  1032. function cssSlideHeight() {
  1033. return unit(options.fixedHeight) || (vertical ? options.autoHeight ? "" : cssSlideSize() : cssHeight());
  1034. }
  1035. function cssSlideSize() {
  1036. var gap = unit(options.gap);
  1037. return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")";
  1038. }
  1039. function listSize() {
  1040. return rect(list)[resolve("width")];
  1041. }
  1042. function slideSize(index, withoutGap) {
  1043. var Slide = getAt(index || 0);
  1044. return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0;
  1045. }
  1046. function totalSize(index, withoutGap) {
  1047. var Slide = getAt(index);
  1048. if (Slide) {
  1049. var right = rect(Slide.slide)[resolve("right")];
  1050. var left = rect(list)[resolve("left")];
  1051. return abs(right - left) + (withoutGap ? 0 : getGap());
  1052. }
  1053. return 0;
  1054. }
  1055. function sliderSize() {
  1056. return totalSize(Splide2.length - 1, true) - totalSize(-1, true);
  1057. }
  1058. function getGap() {
  1059. var Slide = getAt(0);
  1060. return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0;
  1061. }
  1062. function getPadding(right) {
  1063. return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0;
  1064. }
  1065. return {
  1066. mount: mount,
  1067. listSize: listSize,
  1068. slideSize: slideSize,
  1069. sliderSize: sliderSize,
  1070. totalSize: totalSize,
  1071. getPadding: getPadding
  1072. };
  1073. }
  1074. function Clones(Splide2, Components2, options) {
  1075. var _EventInterface5 = EventInterface(Splide2),
  1076. on = _EventInterface5.on,
  1077. emit = _EventInterface5.emit;
  1078. var Elements = Components2.Elements,
  1079. Slides = Components2.Slides;
  1080. var resolve = Components2.Direction.resolve;
  1081. var clones = [];
  1082. var cloneCount;
  1083. function mount() {
  1084. init();
  1085. on(EVENT_REFRESH, refresh);
  1086. on([EVENT_UPDATED, EVENT_RESIZE], observe);
  1087. }
  1088. function init() {
  1089. if (cloneCount = computeCloneCount()) {
  1090. generate(cloneCount);
  1091. emit(EVENT_RESIZE);
  1092. }
  1093. }
  1094. function destroy() {
  1095. remove(clones);
  1096. empty(clones);
  1097. }
  1098. function refresh() {
  1099. destroy();
  1100. init();
  1101. }
  1102. function observe() {
  1103. if (cloneCount < computeCloneCount()) {
  1104. emit(EVENT_REFRESH);
  1105. }
  1106. }
  1107. function generate(count) {
  1108. var slides = Slides.get().slice();
  1109. var length = slides.length;
  1110. if (length) {
  1111. while (slides.length < count) {
  1112. push(slides, slides);
  1113. }
  1114. push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) {
  1115. var isHead = index < count;
  1116. var clone = cloneDeep(Slide.slide, index);
  1117. isHead ? before(clone, slides[0].slide) : append(Elements.list, clone);
  1118. push(clones, clone);
  1119. Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index);
  1120. });
  1121. }
  1122. }
  1123. function cloneDeep(elm, index) {
  1124. var clone = elm.cloneNode(true);
  1125. addClass(clone, options.classes.clone);
  1126. clone.id = Splide2.root.id + "-clone" + pad(index + 1);
  1127. return clone;
  1128. }
  1129. function computeCloneCount() {
  1130. var clones2 = options.clones;
  1131. if (!Splide2.is(LOOP)) {
  1132. clones2 = 0;
  1133. } else if (!clones2) {
  1134. var fixedSize = measure(Elements.list, options[resolve("fixedWidth")]);
  1135. var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize);
  1136. var baseCount = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage;
  1137. clones2 = baseCount * (options.drag ? (options.flickMaxPages || 1) + 1 : 2);
  1138. }
  1139. return clones2;
  1140. }
  1141. return {
  1142. mount: mount,
  1143. destroy: destroy
  1144. };
  1145. }
  1146. function Move(Splide2, Components2, options) {
  1147. var _EventInterface6 = EventInterface(Splide2),
  1148. on = _EventInterface6.on,
  1149. emit = _EventInterface6.emit;
  1150. var _Components2$Layout = Components2.Layout,
  1151. slideSize = _Components2$Layout.slideSize,
  1152. getPadding = _Components2$Layout.getPadding,
  1153. totalSize = _Components2$Layout.totalSize,
  1154. listSize = _Components2$Layout.listSize,
  1155. sliderSize = _Components2$Layout.sliderSize;
  1156. var _Components2$Directio = Components2.Direction,
  1157. resolve = _Components2$Directio.resolve,
  1158. orient = _Components2$Directio.orient;
  1159. var _Components2$Elements3 = Components2.Elements,
  1160. list = _Components2$Elements3.list,
  1161. track = _Components2$Elements3.track;
  1162. var Transition;
  1163. function mount() {
  1164. Transition = Components2.Transition;
  1165. on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition);
  1166. }
  1167. function destroy() {
  1168. removeAttribute(list, "style");
  1169. }
  1170. function reposition() {
  1171. if (!isBusy()) {
  1172. Components2.Scroll.cancel();
  1173. jump(Splide2.index);
  1174. emit(EVENT_REPOSITIONED);
  1175. }
  1176. }
  1177. function move(dest, index, prev, callback) {
  1178. if (!isBusy()) {
  1179. var set = Splide2.state.set;
  1180. var position = getPosition();
  1181. if (dest !== index) {
  1182. Transition.cancel();
  1183. translate(shift(position, dest > index), true);
  1184. }
  1185. set(MOVING);
  1186. emit(EVENT_MOVE, index, prev, dest);
  1187. Transition.start(index, function () {
  1188. set(IDLE);
  1189. emit(EVENT_MOVED, index, prev, dest);
  1190. if (options.trimSpace === "move" && dest !== prev && position === getPosition()) {
  1191. Components2.Controller.go(dest > prev ? ">" : "<", false, callback);
  1192. } else {
  1193. callback && callback();
  1194. }
  1195. });
  1196. }
  1197. }
  1198. function jump(index) {
  1199. translate(toPosition(index, true));
  1200. }
  1201. function translate(position, preventLoop) {
  1202. if (!Splide2.is(FADE)) {
  1203. list.style.transform = "translate" + resolve("X") + "(" + (preventLoop ? position : loop(position)) + "px)";
  1204. }
  1205. }
  1206. function loop(position) {
  1207. if (Splide2.is(LOOP)) {
  1208. var diff = orient(position - getPosition());
  1209. var exceededMin = exceededLimit(false, position) && diff < 0;
  1210. var exceededMax = exceededLimit(true, position) && diff > 0;
  1211. if (exceededMin || exceededMax) {
  1212. position = shift(position, exceededMax);
  1213. }
  1214. }
  1215. return position;
  1216. }
  1217. function shift(position, backwards) {
  1218. var excess = position - getLimit(backwards);
  1219. var size = sliderSize();
  1220. position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1);
  1221. return position;
  1222. }
  1223. function cancel() {
  1224. translate(getPosition());
  1225. Transition.cancel();
  1226. }
  1227. function toIndex(position) {
  1228. var Slides = Components2.Slides.get();
  1229. var index = 0;
  1230. var minDistance = Infinity;
  1231. for (var i = 0; i < Slides.length; i++) {
  1232. var slideIndex = Slides[i].index;
  1233. var distance = abs(toPosition(slideIndex, true) - position);
  1234. if (distance <= minDistance) {
  1235. minDistance = distance;
  1236. index = slideIndex;
  1237. } else {
  1238. break;
  1239. }
  1240. }
  1241. return index;
  1242. }
  1243. function toPosition(index, trimming) {
  1244. var position = orient(totalSize(index - 1) - offset(index));
  1245. return trimming ? trim(position) : position;
  1246. }
  1247. function getPosition() {
  1248. var left = resolve("left");
  1249. return rect(list)[left] - rect(track)[left] + orient(getPadding(false));
  1250. }
  1251. function trim(position) {
  1252. if (options.trimSpace && Splide2.is(SLIDE)) {
  1253. position = clamp(position, 0, orient(sliderSize() - listSize()));
  1254. }
  1255. return position;
  1256. }
  1257. function offset(index) {
  1258. var focus = options.focus;
  1259. return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0;
  1260. }
  1261. function getLimit(max) {
  1262. return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace);
  1263. }
  1264. function isBusy() {
  1265. return Splide2.state.is(MOVING) && options.waitForTransition;
  1266. }
  1267. function exceededLimit(max, position) {
  1268. position = isUndefined(position) ? getPosition() : position;
  1269. var exceededMin = max !== true && orient(position) < orient(getLimit(false));
  1270. var exceededMax = max !== false && orient(position) > orient(getLimit(true));
  1271. return exceededMin || exceededMax;
  1272. }
  1273. return {
  1274. mount: mount,
  1275. destroy: destroy,
  1276. move: move,
  1277. jump: jump,
  1278. translate: translate,
  1279. shift: shift,
  1280. cancel: cancel,
  1281. toIndex: toIndex,
  1282. toPosition: toPosition,
  1283. getPosition: getPosition,
  1284. getLimit: getLimit,
  1285. isBusy: isBusy,
  1286. exceededLimit: exceededLimit
  1287. };
  1288. }
  1289. function Controller(Splide2, Components2, options) {
  1290. var _EventInterface7 = EventInterface(Splide2),
  1291. on = _EventInterface7.on;
  1292. var Move = Components2.Move;
  1293. var getPosition = Move.getPosition,
  1294. getLimit = Move.getLimit;
  1295. var _Components2$Slides = Components2.Slides,
  1296. isEnough = _Components2$Slides.isEnough,
  1297. getLength = _Components2$Slides.getLength;
  1298. var isLoop = Splide2.is(LOOP);
  1299. var isSlide = Splide2.is(SLIDE);
  1300. var currIndex = options.start || 0;
  1301. var prevIndex = currIndex;
  1302. var slideCount;
  1303. var perMove;
  1304. var perPage;
  1305. function mount() {
  1306. init();
  1307. on([EVENT_UPDATED, EVENT_REFRESH], init, DEFAULT_EVENT_PRIORITY - 1);
  1308. }
  1309. function init() {
  1310. slideCount = getLength(true);
  1311. perMove = options.perMove;
  1312. perPage = options.perPage;
  1313. currIndex = clamp(currIndex, 0, slideCount - 1);
  1314. }
  1315. function go(control, allowSameIndex, callback) {
  1316. var dest = parse(control);
  1317. if (options.useScroll) {
  1318. scroll(dest, true, true, options.speed, callback);
  1319. } else {
  1320. var index = loop(dest);
  1321. if (index > -1 && !Move.isBusy() && (allowSameIndex || index !== currIndex)) {
  1322. setIndex(index);
  1323. Move.move(dest, index, prevIndex, callback);
  1324. }
  1325. }
  1326. }
  1327. function scroll(destination, useIndex, snap, duration, callback) {
  1328. var dest = useIndex ? destination : toDest(destination);
  1329. Components2.Scroll.scroll(useIndex || snap ? Move.toPosition(dest, true) : destination, duration, function () {
  1330. setIndex(Move.toIndex(Move.getPosition()));
  1331. callback && callback();
  1332. });
  1333. }
  1334. function parse(control) {
  1335. var index = currIndex;
  1336. if (isString(control)) {
  1337. var _ref = control.match(/([+\-<>])(\d+)?/) || [],
  1338. indicator = _ref[1],
  1339. number = _ref[2];
  1340. if (indicator === "+" || indicator === "-") {
  1341. index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex, true);
  1342. } else if (indicator === ">") {
  1343. index = number ? toIndex(+number) : getNext(true);
  1344. } else if (indicator === "<") {
  1345. index = getPrev(true);
  1346. }
  1347. } else {
  1348. index = isLoop ? control : clamp(control, 0, getEnd());
  1349. }
  1350. return index;
  1351. }
  1352. function getNext(destination) {
  1353. return getAdjacent(false, destination);
  1354. }
  1355. function getPrev(destination) {
  1356. return getAdjacent(true, destination);
  1357. }
  1358. function getAdjacent(prev, destination) {
  1359. var number = perMove || (hasFocus() ? 1 : perPage);
  1360. var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex);
  1361. if (dest === -1 && isSlide) {
  1362. if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) {
  1363. return prev ? 0 : getEnd();
  1364. }
  1365. }
  1366. return destination ? dest : loop(dest);
  1367. }
  1368. function computeDestIndex(dest, from, incremental) {
  1369. if (isEnough()) {
  1370. var end = getEnd();
  1371. if (dest < 0 || dest > end) {
  1372. if (between(0, dest, from, true) || between(end, from, dest, true)) {
  1373. dest = toIndex(toPage(dest));
  1374. } else {
  1375. if (isLoop) {
  1376. dest = perMove ? dest : dest < 0 ? -(slideCount % perPage || perPage) : slideCount;
  1377. } else if (options.rewind) {
  1378. dest = dest < 0 ? end : 0;
  1379. } else {
  1380. dest = -1;
  1381. }
  1382. }
  1383. } else {
  1384. if (!incremental && dest !== from) {
  1385. dest = perMove ? dest : toIndex(toPage(from) + (dest < from ? -1 : 1));
  1386. }
  1387. }
  1388. } else {
  1389. dest = -1;
  1390. }
  1391. return dest;
  1392. }
  1393. function getEnd() {
  1394. var end = slideCount - perPage;
  1395. if (hasFocus() || isLoop && perMove) {
  1396. end = slideCount - 1;
  1397. }
  1398. return max(end, 0);
  1399. }
  1400. function loop(index) {
  1401. if (isLoop) {
  1402. return isEnough() ? index % slideCount + (index < 0 ? slideCount : 0) : -1;
  1403. }
  1404. return index;
  1405. }
  1406. function toIndex(page) {
  1407. return clamp(hasFocus() ? page : perPage * page, 0, getEnd());
  1408. }
  1409. function toPage(index) {
  1410. if (!hasFocus()) {
  1411. index = between(index, slideCount - perPage, slideCount - 1) ? slideCount - 1 : index;
  1412. index = floor(index / perPage);
  1413. }
  1414. return index;
  1415. }
  1416. function toDest(destination) {
  1417. var closest = Move.toIndex(destination);
  1418. return isSlide ? clamp(closest, 0, getEnd()) : closest;
  1419. }
  1420. function setIndex(index) {
  1421. if (index !== currIndex) {
  1422. prevIndex = currIndex;
  1423. currIndex = index;
  1424. }
  1425. }
  1426. function getIndex(prev) {
  1427. return prev ? prevIndex : currIndex;
  1428. }
  1429. function hasFocus() {
  1430. return !isUndefined(options.focus) || options.isNavigation;
  1431. }
  1432. return {
  1433. mount: mount,
  1434. go: go,
  1435. scroll: scroll,
  1436. getNext: getNext,
  1437. getPrev: getPrev,
  1438. getAdjacent: getAdjacent,
  1439. getEnd: getEnd,
  1440. setIndex: setIndex,
  1441. getIndex: getIndex,
  1442. toIndex: toIndex,
  1443. toPage: toPage,
  1444. toDest: toDest,
  1445. hasFocus: hasFocus
  1446. };
  1447. }
  1448. var XML_NAME_SPACE = "http://www.w3.org/2000/svg";
  1449. var PATH = "m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z";
  1450. var SIZE = 40;
  1451. function Arrows(Splide2, Components2, options) {
  1452. var _EventInterface8 = EventInterface(Splide2),
  1453. on = _EventInterface8.on,
  1454. bind = _EventInterface8.bind,
  1455. emit = _EventInterface8.emit;
  1456. var classes = options.classes,
  1457. i18n = options.i18n;
  1458. var Elements = Components2.Elements,
  1459. Controller = Components2.Controller;
  1460. var wrapper = Elements.arrows;
  1461. var prev = Elements.prev;
  1462. var next = Elements.next;
  1463. var created;
  1464. var arrows = {};
  1465. function mount() {
  1466. init();
  1467. on(EVENT_UPDATED, init);
  1468. }
  1469. function init() {
  1470. if (options.arrows) {
  1471. if (!prev || !next) {
  1472. createArrows();
  1473. }
  1474. }
  1475. if (prev && next) {
  1476. if (!arrows.prev) {
  1477. var id = Elements.track.id;
  1478. setAttribute(prev, ARIA_CONTROLS, id);
  1479. setAttribute(next, ARIA_CONTROLS, id);
  1480. arrows.prev = prev;
  1481. arrows.next = next;
  1482. listen();
  1483. emit(EVENT_ARROWS_MOUNTED, prev, next);
  1484. } else {
  1485. display(wrapper, options.arrows === false ? "none" : "");
  1486. }
  1487. }
  1488. }
  1489. function destroy() {
  1490. if (created) {
  1491. remove(wrapper);
  1492. } else {
  1493. removeAttribute(prev, ALL_ATTRIBUTES);
  1494. removeAttribute(next, ALL_ATTRIBUTES);
  1495. }
  1496. }
  1497. function listen() {
  1498. var go = Controller.go;
  1499. on([EVENT_MOUNTED, EVENT_MOVED, EVENT_UPDATED, EVENT_REFRESH, EVENT_SCROLLED], update);
  1500. bind(next, "click", function () {
  1501. go(">", true);
  1502. });
  1503. bind(prev, "click", function () {
  1504. go("<", true);
  1505. });
  1506. }
  1507. function createArrows() {
  1508. wrapper = create("div", classes.arrows);
  1509. prev = createArrow(true);
  1510. next = createArrow(false);
  1511. created = true;
  1512. append(wrapper, [prev, next]);
  1513. before(wrapper, child(options.arrows === "slider" && Elements.slider || Splide2.root));
  1514. }
  1515. function createArrow(prev2) {
  1516. var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><svg xmlns=\"" + XML_NAME_SPACE + "\" viewBox=\"0 0 " + SIZE + " " + SIZE + "\" width=\"" + SIZE + "\" height=\"" + SIZE + "\"><path d=\"" + (options.arrowPath || PATH) + "\" />";
  1517. return parseHtml(arrow);
  1518. }
  1519. function update() {
  1520. var index = Splide2.index;
  1521. var prevIndex = Controller.getPrev();
  1522. var nextIndex = Controller.getNext();
  1523. var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev;
  1524. var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next;
  1525. prev.disabled = prevIndex < 0;
  1526. next.disabled = nextIndex < 0;
  1527. setAttribute(prev, ARIA_LABEL, prevLabel);
  1528. setAttribute(next, ARIA_LABEL, nextLabel);
  1529. emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex);
  1530. }
  1531. return {
  1532. arrows: arrows,
  1533. mount: mount,
  1534. destroy: destroy
  1535. };
  1536. }
  1537. function Autoplay(Splide2, Components2, options) {
  1538. var _EventInterface9 = EventInterface(Splide2),
  1539. on = _EventInterface9.on,
  1540. bind = _EventInterface9.bind,
  1541. emit = _EventInterface9.emit;
  1542. var Elements = Components2.Elements;
  1543. var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), update);
  1544. var isPaused = interval.isPaused;
  1545. var hovered;
  1546. var focused;
  1547. var paused;
  1548. function mount() {
  1549. var autoplay = options.autoplay;
  1550. if (autoplay) {
  1551. initButton(true);
  1552. initButton(false);
  1553. listen();
  1554. if (autoplay !== "pause") {
  1555. play();
  1556. }
  1557. }
  1558. }
  1559. function initButton(forPause) {
  1560. var prop = forPause ? "pause" : "play";
  1561. var button = Elements[prop];
  1562. if (button) {
  1563. setAttribute(button, ARIA_CONTROLS, Elements.track.id);
  1564. setAttribute(button, ARIA_LABEL, options.i18n[prop]);
  1565. bind(button, "click", forPause ? pause : play);
  1566. }
  1567. }
  1568. function listen() {
  1569. var root = Elements.root;
  1570. if (options.pauseOnHover) {
  1571. bind(root, "mouseenter mouseleave", function (e) {
  1572. hovered = e.type === "mouseenter";
  1573. autoToggle();
  1574. });
  1575. }
  1576. if (options.pauseOnFocus) {
  1577. bind(root, "focusin focusout", function (e) {
  1578. focused = e.type === "focusin";
  1579. autoToggle();
  1580. });
  1581. }
  1582. on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind);
  1583. }
  1584. function play() {
  1585. if (isPaused() && Components2.Slides.isEnough()) {
  1586. interval.start(!options.resetProgress);
  1587. focused = hovered = paused = false;
  1588. emit(EVENT_AUTOPLAY_PLAY);
  1589. }
  1590. }
  1591. function pause(manual) {
  1592. if (manual === void 0) {
  1593. manual = true;
  1594. }
  1595. if (!isPaused()) {
  1596. interval.pause();
  1597. emit(EVENT_AUTOPLAY_PAUSE);
  1598. }
  1599. paused = manual;
  1600. }
  1601. function autoToggle() {
  1602. if (!paused) {
  1603. if (!hovered && !focused) {
  1604. play();
  1605. } else {
  1606. pause(false);
  1607. }
  1608. }
  1609. }
  1610. function update(rate) {
  1611. var bar = Elements.bar;
  1612. if (bar) {
  1613. style(bar, "width", rate * 100 + "%");
  1614. }
  1615. emit(EVENT_AUTOPLAY_PLAYING, rate);
  1616. }
  1617. return {
  1618. mount: mount,
  1619. destroy: interval.cancel,
  1620. play: play,
  1621. pause: pause,
  1622. isPaused: isPaused
  1623. };
  1624. }
  1625. function Cover(Splide2, Components2, options) {
  1626. var _EventInterface10 = EventInterface(Splide2),
  1627. on = _EventInterface10.on;
  1628. function mount() {
  1629. if (options.cover) {
  1630. on(EVENT_LAZYLOAD_LOADED, function (img, Slide) {
  1631. toggle(true, img, Slide);
  1632. });
  1633. on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply.bind(null, true));
  1634. }
  1635. }
  1636. function destroy() {
  1637. apply(false);
  1638. }
  1639. function apply(cover) {
  1640. Components2.Slides.forEach(function (Slide) {
  1641. var img = child(Slide.container || Slide.slide, "img");
  1642. if (img && img.src) {
  1643. toggle(cover, img, Slide);
  1644. }
  1645. });
  1646. }
  1647. function toggle(cover, img, Slide) {
  1648. Slide.style("background", cover ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true);
  1649. display(img, cover ? "none" : "");
  1650. }
  1651. return {
  1652. mount: mount,
  1653. destroy: destroy
  1654. };
  1655. }
  1656. var BOUNCE_DIFF_THRESHOLD = 10;
  1657. var BOUNCE_DURATION = 600;
  1658. var FRICTION_FACTOR = 0.6;
  1659. var BASE_VELOCITY = 1.5;
  1660. var MIN_DURATION = 800;
  1661. function Scroll(Splide2, Components2, options) {
  1662. var _EventInterface11 = EventInterface(Splide2),
  1663. on = _EventInterface11.on,
  1664. emit = _EventInterface11.emit;
  1665. var Move = Components2.Move;
  1666. var getPosition = Move.getPosition,
  1667. getLimit = Move.getLimit,
  1668. exceededLimit = Move.exceededLimit;
  1669. var interval;
  1670. var scrollCallback;
  1671. function mount() {
  1672. on(EVENT_MOVE, clear);
  1673. on([EVENT_UPDATED, EVENT_REFRESH], cancel);
  1674. }
  1675. function scroll(destination, duration, callback, suppressConstraint) {
  1676. var start = getPosition();
  1677. var friction = 1;
  1678. duration = duration || computeDuration(abs(destination - start));
  1679. scrollCallback = callback;
  1680. clear();
  1681. interval = RequestInterval(duration, onScrolled, function (rate) {
  1682. var position = getPosition();
  1683. var target = start + (destination - start) * easing(rate);
  1684. var diff = (target - getPosition()) * friction;
  1685. Move.translate(position + diff);
  1686. if (Splide2.is(SLIDE) && !suppressConstraint && exceededLimit()) {
  1687. friction *= FRICTION_FACTOR;
  1688. if (abs(diff) < BOUNCE_DIFF_THRESHOLD) {
  1689. bounce(exceededLimit(false));
  1690. }
  1691. }
  1692. }, 1);
  1693. emit(EVENT_SCROLL);
  1694. interval.start();
  1695. }
  1696. function bounce(backwards) {
  1697. scroll(getLimit(!backwards), BOUNCE_DURATION, null, true);
  1698. }
  1699. function onScrolled() {
  1700. var position = getPosition();
  1701. var index = Move.toIndex(position);
  1702. if (!between(index, 0, Splide2.length - 1)) {
  1703. Move.translate(Move.shift(position, index > 0), true);
  1704. }
  1705. scrollCallback && scrollCallback();
  1706. emit(EVENT_SCROLLED);
  1707. }
  1708. function computeDuration(distance) {
  1709. return max(distance / BASE_VELOCITY, MIN_DURATION);
  1710. }
  1711. function clear() {
  1712. if (interval) {
  1713. interval.cancel();
  1714. }
  1715. }
  1716. function cancel() {
  1717. if (interval && !interval.isPaused()) {
  1718. clear();
  1719. onScrolled();
  1720. }
  1721. }
  1722. function easing(t) {
  1723. var easingFunc = options.easingFunc;
  1724. return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4);
  1725. }
  1726. return {
  1727. mount: mount,
  1728. destroy: clear,
  1729. scroll: scroll,
  1730. cancel: cancel
  1731. };
  1732. }
  1733. var FRICTION = 5;
  1734. var LOG_INTERVAL = 200;
  1735. var POINTER_DOWN_EVENTS = "touchstart mousedown";
  1736. var POINTER_MOVE_EVENTS = "touchmove mousemove";
  1737. var POINTER_UP_EVENTS = "touchend touchcancel mouseup";
  1738. function Drag(Splide2, Components2, options) {
  1739. var _EventInterface12 = EventInterface(Splide2),
  1740. on = _EventInterface12.on,
  1741. emit = _EventInterface12.emit,
  1742. bind = _EventInterface12.bind,
  1743. unbind = _EventInterface12.unbind;
  1744. var Move = Components2.Move,
  1745. Scroll = Components2.Scroll,
  1746. Controller = Components2.Controller;
  1747. var track = Components2.Elements.track;
  1748. var _Components2$Directio2 = Components2.Direction,
  1749. resolve = _Components2$Directio2.resolve,
  1750. orient = _Components2$Directio2.orient;
  1751. var getPosition = Move.getPosition,
  1752. exceededLimit = Move.exceededLimit;
  1753. var listenerOptions = {
  1754. passive: false,
  1755. capture: true
  1756. };
  1757. var basePosition;
  1758. var baseEvent;
  1759. var prevBaseEvent;
  1760. var lastEvent;
  1761. var isFree;
  1762. var dragging;
  1763. var hasExceeded = false;
  1764. var clickPrevented;
  1765. var disabled;
  1766. var target;
  1767. function mount() {
  1768. bind(track, POINTER_MOVE_EVENTS, noop, listenerOptions);
  1769. bind(track, POINTER_UP_EVENTS, noop, listenerOptions);
  1770. bind(track, POINTER_DOWN_EVENTS, onPointerDown, listenerOptions);
  1771. bind(track, "click", onClick, {
  1772. capture: true
  1773. });
  1774. bind(track, "dragstart", prevent);
  1775. on([EVENT_MOUNTED, EVENT_UPDATED], init);
  1776. }
  1777. function init() {
  1778. var drag = options.drag;
  1779. disable(!drag);
  1780. isFree = drag === "free";
  1781. }
  1782. function onPointerDown(e) {
  1783. if (!disabled) {
  1784. var noDrag = options.noDrag;
  1785. var isTouch = isTouchEvent(e);
  1786. var isDraggable = !noDrag || isHTMLElement(e.target) && !matches(e.target, noDrag);
  1787. if (isDraggable && (isTouch || !e.button)) {
  1788. if (!Move.isBusy()) {
  1789. target = isTouch ? track : window;
  1790. prevBaseEvent = null;
  1791. lastEvent = null;
  1792. clickPrevented = false;
  1793. bind(target, POINTER_MOVE_EVENTS, onPointerMove, listenerOptions);
  1794. bind(target, POINTER_UP_EVENTS, onPointerUp, listenerOptions);
  1795. Move.cancel();
  1796. Scroll.cancel();
  1797. save(e);
  1798. } else {
  1799. prevent(e, true);
  1800. }
  1801. }
  1802. }
  1803. }
  1804. function onPointerMove(e) {
  1805. if (!lastEvent) {
  1806. emit(EVENT_DRAG);
  1807. }
  1808. lastEvent = e;
  1809. if (e.cancelable) {
  1810. var diff = coordOf(e) - coordOf(baseEvent);
  1811. if (dragging) {
  1812. Move.translate(basePosition + constrain(diff));
  1813. var expired = timeOf(e) - timeOf(baseEvent) > LOG_INTERVAL;
  1814. var exceeded = hasExceeded !== (hasExceeded = exceededLimit());
  1815. if (expired || exceeded) {
  1816. save(e);
  1817. }
  1818. emit(EVENT_DRAGGING);
  1819. clickPrevented = true;
  1820. prevent(e);
  1821. } else {
  1822. var thresholds = options.dragMinThreshold;
  1823. thresholds = isObject(thresholds) ? thresholds : {
  1824. mouse: 0,
  1825. touch: +thresholds || 10
  1826. };
  1827. dragging = abs(diff) > (isTouchEvent(e) ? thresholds.touch : thresholds.mouse);
  1828. if (isSliderDirection()) {
  1829. prevent(e);
  1830. }
  1831. }
  1832. }
  1833. }
  1834. function onPointerUp(e) {
  1835. unbind(target, POINTER_MOVE_EVENTS, onPointerMove);
  1836. unbind(target, POINTER_UP_EVENTS, onPointerUp);
  1837. if (lastEvent) {
  1838. if (dragging || e.cancelable && isSliderDirection()) {
  1839. var velocity = computeVelocity(e);
  1840. var destination = computeDestination(velocity);
  1841. if (isFree) {
  1842. Controller.scroll(destination);
  1843. } else if (Splide2.is(FADE)) {
  1844. Controller.go(Splide2.index + orient(sign(velocity)));
  1845. } else {
  1846. Controller.go(Controller.toDest(destination), true);
  1847. }
  1848. prevent(e);
  1849. }
  1850. emit(EVENT_DRAGGED);
  1851. } else {
  1852. if (!isFree) {
  1853. Controller.go(Splide2.index, true);
  1854. }
  1855. }
  1856. dragging = false;
  1857. }
  1858. function save(e) {
  1859. prevBaseEvent = baseEvent;
  1860. baseEvent = e;
  1861. basePosition = getPosition();
  1862. }
  1863. function onClick(e) {
  1864. if (!disabled && clickPrevented) {
  1865. prevent(e, true);
  1866. }
  1867. }
  1868. function isSliderDirection() {
  1869. var diffX = abs(coordOf(lastEvent) - coordOf(baseEvent));
  1870. var diffY = abs(coordOf(lastEvent, true) - coordOf(baseEvent, true));
  1871. return diffX > diffY;
  1872. }
  1873. function computeVelocity(e) {
  1874. if (Splide2.is(LOOP) || !hasExceeded) {
  1875. var base = baseEvent === lastEvent && prevBaseEvent || baseEvent;
  1876. var diffCoord = coordOf(lastEvent) - coordOf(base);
  1877. var diffTime = timeOf(e) - timeOf(base);
  1878. var isFlick = timeOf(e) - timeOf(lastEvent) < LOG_INTERVAL;
  1879. if (diffTime && isFlick) {
  1880. return diffCoord / diffTime;
  1881. }
  1882. }
  1883. return 0;
  1884. }
  1885. function computeDestination(velocity) {
  1886. return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1));
  1887. }
  1888. function coordOf(e, orthogonal) {
  1889. return (isTouchEvent(e) ? e.touches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")];
  1890. }
  1891. function timeOf(e) {
  1892. return e.timeStamp;
  1893. }
  1894. function constrain(diff) {
  1895. return diff / (hasExceeded && Splide2.is(SLIDE) ? FRICTION : 1);
  1896. }
  1897. function isTouchEvent(e) {
  1898. return typeof TouchEvent !== "undefined" && e instanceof TouchEvent;
  1899. }
  1900. function isDragging() {
  1901. return dragging;
  1902. }
  1903. function disable(value) {
  1904. disabled = value;
  1905. }
  1906. return {
  1907. mount: mount,
  1908. disable: disable,
  1909. isDragging: isDragging
  1910. };
  1911. }
  1912. var IE_ARROW_KEYS = ["Left", "Right", "Up", "Down"];
  1913. function Keyboard(Splide2, Components2, options) {
  1914. var _EventInterface13 = EventInterface(Splide2),
  1915. on = _EventInterface13.on,
  1916. bind = _EventInterface13.bind,
  1917. unbind = _EventInterface13.unbind;
  1918. var root = Components2.Elements.root;
  1919. var resolve = Components2.Direction.resolve;
  1920. var target;
  1921. var disabled;
  1922. function mount() {
  1923. init();
  1924. on(EVENT_UPDATED, onUpdated);
  1925. on(EVENT_MOVE, onMove);
  1926. }
  1927. function init() {
  1928. var _options$keyboard = options.keyboard,
  1929. keyboard = _options$keyboard === void 0 ? "global" : _options$keyboard;
  1930. if (keyboard) {
  1931. if (keyboard === "focused") {
  1932. target = root;
  1933. setAttribute(root, TAB_INDEX, 0);
  1934. } else {
  1935. target = window;
  1936. }
  1937. bind(target, "keydown", onKeydown);
  1938. }
  1939. }
  1940. function destroy() {
  1941. unbind(target, "keydown");
  1942. if (isHTMLElement(target)) {
  1943. removeAttribute(target, TAB_INDEX);
  1944. }
  1945. }
  1946. function onMove() {
  1947. disabled = true;
  1948. nextTick(function () {
  1949. disabled = false;
  1950. });
  1951. }
  1952. function onUpdated() {
  1953. destroy();
  1954. init();
  1955. }
  1956. function onKeydown(e) {
  1957. if (!disabled) {
  1958. var key = e.key;
  1959. var normalizedKey = includes(IE_ARROW_KEYS, key) ? "Arrow" + key : key;
  1960. if (normalizedKey === resolve("ArrowLeft")) {
  1961. Splide2.go("<");
  1962. } else if (normalizedKey === resolve("ArrowRight")) {
  1963. Splide2.go(">");
  1964. }
  1965. }
  1966. }
  1967. return {
  1968. mount: mount,
  1969. destroy: destroy
  1970. };
  1971. }
  1972. var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy";
  1973. var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset";
  1974. var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]";
  1975. function LazyLoad(Splide2, Components2, options) {
  1976. var _EventInterface14 = EventInterface(Splide2),
  1977. on = _EventInterface14.on,
  1978. off = _EventInterface14.off,
  1979. bind = _EventInterface14.bind,
  1980. emit = _EventInterface14.emit;
  1981. var isSequential = options.lazyLoad === "sequential";
  1982. var images = [];
  1983. var index = 0;
  1984. function mount() {
  1985. if (options.lazyLoad) {
  1986. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  1987. destroy();
  1988. init();
  1989. });
  1990. if (!isSequential) {
  1991. on([EVENT_MOUNTED, EVENT_REFRESH, EVENT_MOVED], observe);
  1992. }
  1993. }
  1994. }
  1995. function init() {
  1996. Components2.Slides.forEach(function (_Slide) {
  1997. queryAll(_Slide.slide, IMAGE_SELECTOR).forEach(function (_img) {
  1998. var src = getAttribute(_img, SRC_DATA_ATTRIBUTE);
  1999. var srcset = getAttribute(_img, SRCSET_DATA_ATTRIBUTE);
  2000. if (src !== _img.src || srcset !== _img.srcset) {
  2001. var _spinner = create("span", options.classes.spinner, _img.parentElement);
  2002. setAttribute(_spinner, ROLE, "presentation");
  2003. images.push({
  2004. _img: _img,
  2005. _Slide: _Slide,
  2006. src: src,
  2007. srcset: srcset,
  2008. _spinner: _spinner
  2009. });
  2010. !_img.src && display(_img, "none");
  2011. }
  2012. });
  2013. });
  2014. if (isSequential) {
  2015. loadNext();
  2016. }
  2017. }
  2018. function destroy() {
  2019. index = 0;
  2020. images = [];
  2021. }
  2022. function observe() {
  2023. images = images.filter(function (data) {
  2024. var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
  2025. if (data._Slide.isWithin(Splide2.index, distance)) {
  2026. return load(data);
  2027. }
  2028. return true;
  2029. });
  2030. if (!images.length) {
  2031. off(EVENT_MOVED);
  2032. }
  2033. }
  2034. function load(data) {
  2035. var _img = data._img;
  2036. addClass(data._Slide.slide, CLASS_LOADING);
  2037. bind(_img, "load error", function (e) {
  2038. onLoad(data, e.type === "error");
  2039. });
  2040. ["src", "srcset"].forEach(function (name) {
  2041. if (data[name]) {
  2042. setAttribute(_img, name, data[name]);
  2043. removeAttribute(_img, name === "src" ? SRC_DATA_ATTRIBUTE : SRCSET_DATA_ATTRIBUTE);
  2044. }
  2045. });
  2046. }
  2047. function onLoad(data, error) {
  2048. var _Slide = data._Slide;
  2049. removeClass(_Slide.slide, CLASS_LOADING);
  2050. if (!error) {
  2051. remove(data._spinner);
  2052. display(data._img, "");
  2053. emit(EVENT_LAZYLOAD_LOADED, data._img, _Slide);
  2054. emit(EVENT_RESIZE);
  2055. }
  2056. if (isSequential) {
  2057. loadNext();
  2058. }
  2059. }
  2060. function loadNext() {
  2061. if (index < images.length) {
  2062. load(images[index++]);
  2063. }
  2064. }
  2065. return {
  2066. mount: mount,
  2067. destroy: destroy
  2068. };
  2069. }
  2070. function Pagination(Splide2, Components2, options) {
  2071. var _EventInterface15 = EventInterface(Splide2),
  2072. on = _EventInterface15.on,
  2073. emit = _EventInterface15.emit,
  2074. bind = _EventInterface15.bind,
  2075. unbind = _EventInterface15.unbind;
  2076. var Slides = Components2.Slides,
  2077. Elements = Components2.Elements,
  2078. Controller = Components2.Controller;
  2079. var hasFocus = Controller.hasFocus,
  2080. getIndex = Controller.getIndex;
  2081. var items = [];
  2082. var list;
  2083. function mount() {
  2084. init();
  2085. on([EVENT_UPDATED, EVENT_REFRESH], init);
  2086. on([EVENT_MOVE, EVENT_SCROLLED], update);
  2087. }
  2088. function init() {
  2089. destroy();
  2090. if (options.pagination && Slides.isEnough()) {
  2091. createPagination();
  2092. emit(EVENT_PAGINATION_MOUNTED, {
  2093. list: list,
  2094. items: items
  2095. }, getAt(Splide2.index));
  2096. update();
  2097. }
  2098. }
  2099. function destroy() {
  2100. if (list) {
  2101. remove(list);
  2102. items.forEach(function (item) {
  2103. unbind(item.button, "click");
  2104. });
  2105. empty(items);
  2106. list = null;
  2107. }
  2108. }
  2109. function createPagination() {
  2110. var length = Splide2.length;
  2111. var classes = options.classes,
  2112. i18n = options.i18n,
  2113. perPage = options.perPage;
  2114. var parent = options.pagination === "slider" && Elements.slider || Elements.root;
  2115. var max = hasFocus() ? length : ceil(length / perPage);
  2116. list = create("ul", classes.pagination, parent);
  2117. for (var i = 0; i < max; i++) {
  2118. var li = create("li", null, list);
  2119. var button = create("button", {
  2120. class: classes.page,
  2121. type: "button"
  2122. }, li);
  2123. var controls = Slides.getIn(i).map(function (Slide) {
  2124. return Slide.slide.id;
  2125. });
  2126. var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX;
  2127. bind(button, "click", onClick.bind(null, i));
  2128. setAttribute(button, ARIA_CONTROLS, controls.join(" "));
  2129. setAttribute(button, ARIA_LABEL, format(text, i + 1));
  2130. items.push({
  2131. li: li,
  2132. button: button,
  2133. page: i
  2134. });
  2135. }
  2136. }
  2137. function onClick(page) {
  2138. Controller.go(">" + page, true, function () {
  2139. var Slide = Slides.getAt(Controller.toIndex(page));
  2140. Slide && focus(Slide.slide);
  2141. });
  2142. }
  2143. function getAt(index) {
  2144. return items[Controller.toPage(index)];
  2145. }
  2146. function update() {
  2147. var prev = getAt(getIndex(true));
  2148. var curr = getAt(getIndex());
  2149. if (prev) {
  2150. removeClass(prev.button, CLASS_ACTIVE);
  2151. removeAttribute(prev.button, ARIA_CURRENT);
  2152. }
  2153. if (curr) {
  2154. addClass(curr.button, CLASS_ACTIVE);
  2155. setAttribute(curr.button, ARIA_CURRENT, true);
  2156. }
  2157. emit(EVENT_PAGINATION_UPDATED, {
  2158. list: list,
  2159. items: items
  2160. }, prev, curr);
  2161. }
  2162. return {
  2163. items: items,
  2164. mount: mount,
  2165. destroy: destroy,
  2166. getAt: getAt
  2167. };
  2168. }
  2169. var TRIGGER_KEYS = [" ", "Enter", "Spacebar"];
  2170. function Sync(Splide2, Components2, options) {
  2171. var list = Components2.Elements.list;
  2172. var events = [];
  2173. function mount() {
  2174. Splide2.splides.forEach(function (target) {
  2175. !target.isParent && sync(target.splide);
  2176. });
  2177. if (options.isNavigation) {
  2178. navigate();
  2179. }
  2180. }
  2181. function destroy() {
  2182. removeAttribute(list, ALL_ATTRIBUTES);
  2183. events.forEach(function (event) {
  2184. event.destroy();
  2185. });
  2186. empty(events);
  2187. }
  2188. function remount() {
  2189. destroy();
  2190. mount();
  2191. }
  2192. function sync(splide) {
  2193. [Splide2, splide].forEach(function (instance) {
  2194. var event = EventInterface(instance);
  2195. var target = instance === Splide2 ? splide : Splide2;
  2196. event.on(EVENT_MOVE, function (index, prev, dest) {
  2197. target.go(target.is(LOOP) ? dest : index);
  2198. });
  2199. events.push(event);
  2200. });
  2201. }
  2202. function navigate() {
  2203. var event = EventInterface(Splide2);
  2204. var on = event.on;
  2205. on(EVENT_CLICK, onClick);
  2206. on(EVENT_SLIDE_KEYDOWN, onKeydown);
  2207. on([EVENT_MOUNTED, EVENT_UPDATED], update);
  2208. setAttribute(list, ROLE, "menu");
  2209. events.push(event);
  2210. event.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides);
  2211. }
  2212. function update() {
  2213. setAttribute(list, ARIA_ORIENTATION, options.direction !== TTB ? "horizontal" : null);
  2214. }
  2215. function onClick(Slide) {
  2216. Splide2.go(Slide.index);
  2217. }
  2218. function onKeydown(Slide, e) {
  2219. if (includes(TRIGGER_KEYS, e.key)) {
  2220. onClick(Slide);
  2221. prevent(e);
  2222. }
  2223. }
  2224. return {
  2225. mount: mount,
  2226. destroy: destroy,
  2227. remount: remount
  2228. };
  2229. }
  2230. function Wheel(Splide2, Components2, options) {
  2231. var _EventInterface16 = EventInterface(Splide2),
  2232. bind = _EventInterface16.bind;
  2233. function mount() {
  2234. if (options.wheel) {
  2235. bind(Components2.Elements.track, "wheel", onWheel, {
  2236. passive: false,
  2237. capture: true
  2238. });
  2239. }
  2240. }
  2241. function onWheel(e) {
  2242. var deltaY = e.deltaY;
  2243. if (deltaY) {
  2244. var backwards = deltaY < 0;
  2245. Splide2.go(backwards ? "<" : ">");
  2246. shouldPrevent(backwards) && prevent(e);
  2247. }
  2248. }
  2249. function shouldPrevent(backwards) {
  2250. return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1;
  2251. }
  2252. return {
  2253. mount: mount
  2254. };
  2255. }
  2256. var ComponentConstructors = /*#__PURE__*/Object.freeze({
  2257. __proto__: null,
  2258. Options: Options,
  2259. Direction: Direction,
  2260. Elements: Elements,
  2261. Slides: Slides,
  2262. Layout: Layout,
  2263. Clones: Clones,
  2264. Move: Move,
  2265. Controller: Controller,
  2266. Arrows: Arrows,
  2267. Autoplay: Autoplay,
  2268. Cover: Cover,
  2269. Scroll: Scroll,
  2270. Drag: Drag,
  2271. Keyboard: Keyboard,
  2272. LazyLoad: LazyLoad,
  2273. Pagination: Pagination,
  2274. Sync: Sync,
  2275. Wheel: Wheel
  2276. });
  2277. var I18N = {
  2278. prev: "Previous slide",
  2279. next: "Next slide",
  2280. first: "Go to first slide",
  2281. last: "Go to last slide",
  2282. slideX: "Go to slide %s",
  2283. pageX: "Go to page %s",
  2284. play: "Start autoplay",
  2285. pause: "Pause autoplay"
  2286. };
  2287. var DEFAULTS = {
  2288. type: "slide",
  2289. speed: 400,
  2290. waitForTransition: true,
  2291. perPage: 1,
  2292. arrows: true,
  2293. pagination: true,
  2294. interval: 5e3,
  2295. pauseOnHover: true,
  2296. pauseOnFocus: true,
  2297. resetProgress: true,
  2298. easing: "cubic-bezier(0.25, 1, 0.5, 1)",
  2299. drag: true,
  2300. direction: "ltr",
  2301. slideFocus: true,
  2302. trimSpace: true,
  2303. focusableNodes: "a, button, textarea, input, select, iframe",
  2304. classes: CLASSES,
  2305. i18n: I18N
  2306. };
  2307. function Fade(Splide2, Components2, options) {
  2308. var _EventInterface17 = EventInterface(Splide2),
  2309. on = _EventInterface17.on;
  2310. function mount() {
  2311. on([EVENT_MOUNTED, EVENT_REFRESH], function () {
  2312. nextTick(function () {
  2313. Components2.Slides.style("transition", "opacity " + options.speed + "ms " + options.easing);
  2314. });
  2315. });
  2316. }
  2317. function start(index, done) {
  2318. var track = Components2.Elements.track;
  2319. style(track, "height", unit(rect(track).height));
  2320. nextTick(function () {
  2321. done();
  2322. style(track, "height", "");
  2323. });
  2324. }
  2325. return {
  2326. mount: mount,
  2327. start: start,
  2328. cancel: noop
  2329. };
  2330. }
  2331. function Slide(Splide2, Components2, options) {
  2332. var _EventInterface18 = EventInterface(Splide2),
  2333. bind = _EventInterface18.bind;
  2334. var Move = Components2.Move,
  2335. Controller = Components2.Controller;
  2336. var list = Components2.Elements.list;
  2337. var endCallback;
  2338. function mount() {
  2339. bind(list, "transitionend", function (e) {
  2340. if (e.target === list && endCallback) {
  2341. cancel();
  2342. endCallback();
  2343. }
  2344. });
  2345. }
  2346. function start(index, done) {
  2347. var destination = Move.toPosition(index, true);
  2348. var position = Move.getPosition();
  2349. var speed = getSpeed(index);
  2350. if (abs(destination - position) >= 1 && speed >= 1) {
  2351. apply("transform " + speed + "ms " + options.easing);
  2352. Move.translate(destination, true);
  2353. endCallback = done;
  2354. } else {
  2355. Move.jump(index);
  2356. done();
  2357. }
  2358. }
  2359. function cancel() {
  2360. apply("");
  2361. }
  2362. function getSpeed(index) {
  2363. var rewindSpeed = options.rewindSpeed;
  2364. if (Splide2.is(SLIDE) && rewindSpeed) {
  2365. var prev = Controller.getIndex(true);
  2366. var end = Controller.getEnd();
  2367. if (prev === 0 && index >= end || prev >= end && index === 0) {
  2368. return rewindSpeed;
  2369. }
  2370. }
  2371. return options.speed;
  2372. }
  2373. function apply(transition) {
  2374. style(list, "transition", transition);
  2375. }
  2376. return {
  2377. mount: mount,
  2378. start: start,
  2379. cancel: cancel
  2380. };
  2381. }
  2382. var _Splide = /*#__PURE__*/function () {
  2383. function _Splide(target, options) {
  2384. this.event = EventBus();
  2385. this.Components = {};
  2386. this.state = State(CREATED);
  2387. this.splides = [];
  2388. this._options = {};
  2389. this._Extensions = {};
  2390. var root = isString(target) ? query(document, target) : target;
  2391. assert(root, root + " is invalid.");
  2392. this.root = root;
  2393. merge(DEFAULTS, _Splide.defaults);
  2394. merge(merge(this._options, DEFAULTS), options || {});
  2395. }
  2396. var _proto = _Splide.prototype;
  2397. _proto.mount = function mount(Extensions, Transition) {
  2398. var _this3 = this;
  2399. var state = this.state,
  2400. Components2 = this.Components;
  2401. assert(state.is([CREATED, DESTROYED]), "Already mounted!");
  2402. state.set(CREATED);
  2403. this._Components = Components2;
  2404. this._Transition = Transition || this._Transition || (this.is(FADE) ? Fade : Slide);
  2405. this._Extensions = Extensions || this._Extensions;
  2406. var Constructors = assign({}, ComponentConstructors, this._Extensions, {
  2407. Transition: this._Transition
  2408. });
  2409. forOwn(Constructors, function (Component, key) {
  2410. var component = Component(_this3, Components2, _this3._options);
  2411. Components2[key] = component;
  2412. component.setup && component.setup();
  2413. });
  2414. forOwn(Components2, function (component) {
  2415. component.mount && component.mount();
  2416. });
  2417. this.emit(EVENT_MOUNTED);
  2418. addClass(this.root, CLASS_INITIALIZED);
  2419. state.set(IDLE);
  2420. this.emit(EVENT_READY);
  2421. return this;
  2422. };
  2423. _proto.sync = function sync(splide) {
  2424. this.splides.push({
  2425. splide: splide
  2426. });
  2427. splide.splides.push({
  2428. splide: this,
  2429. isParent: true
  2430. });
  2431. if (this.state.is(IDLE)) {
  2432. this._Components.Sync.remount();
  2433. splide.Components.Sync.remount();
  2434. }
  2435. return this;
  2436. };
  2437. _proto.go = function go(control) {
  2438. this._Components.Controller.go(control);
  2439. return this;
  2440. };
  2441. _proto.on = function on(events, callback) {
  2442. this.event.on(events, callback, null, DEFAULT_USER_EVENT_PRIORITY);
  2443. return this;
  2444. };
  2445. _proto.off = function off(events) {
  2446. this.event.off(events);
  2447. return this;
  2448. };
  2449. _proto.emit = function emit(event) {
  2450. var _this$event;
  2451. (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1)));
  2452. return this;
  2453. };
  2454. _proto.add = function add(slides, index) {
  2455. this._Components.Slides.add(slides, index);
  2456. return this;
  2457. };
  2458. _proto.remove = function remove(matcher) {
  2459. this._Components.Slides.remove(matcher);
  2460. return this;
  2461. };
  2462. _proto.is = function is(type) {
  2463. return this._options.type === type;
  2464. };
  2465. _proto.refresh = function refresh() {
  2466. this.emit(EVENT_REFRESH);
  2467. return this;
  2468. };
  2469. _proto.destroy = function destroy(completely) {
  2470. if (completely === void 0) {
  2471. completely = true;
  2472. }
  2473. var event = this.event,
  2474. state = this.state;
  2475. if (state.is(CREATED)) {
  2476. event.on(EVENT_READY, this.destroy.bind(this, completely), this);
  2477. } else {
  2478. forOwn(this._Components, function (component) {
  2479. component.destroy && component.destroy(completely);
  2480. }, true);
  2481. event.emit(EVENT_DESTROY);
  2482. event.destroy();
  2483. completely && empty(this.splides);
  2484. state.set(DESTROYED);
  2485. }
  2486. return this;
  2487. };
  2488. _createClass(_Splide, [{
  2489. key: "options",
  2490. get: function get() {
  2491. return this._options;
  2492. },
  2493. set: function set(options) {
  2494. var _options = this._options;
  2495. merge(_options, options);
  2496. if (!this.state.is(CREATED)) {
  2497. this.emit(EVENT_UPDATED, _options);
  2498. }
  2499. }
  2500. }, {
  2501. key: "length",
  2502. get: function get() {
  2503. return this._Components.Slides.getLength(true);
  2504. }
  2505. }, {
  2506. key: "index",
  2507. get: function get() {
  2508. return this._Components.Controller.getIndex();
  2509. }
  2510. }]);
  2511. return _Splide;
  2512. }();
  2513. var Splide = _Splide;
  2514. Splide.defaults = {};
  2515. Splide.STATES = STATES;
  2516. return Splide;
  2517. });
  2518. //# sourceMappingURL=splide.js.map