vendor: 51,351 bytes, lines 1-1855
1function _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 3function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 4 5/*! 6 * Splide.js 7 * Version : 4.1.4 8 * License : MIT 9 * Copyright: 2022 Naotoshi Fujita 10 */ 11(function (global, factory) { 12 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()); 13})(this, function () { 14 'use strict'; 15 16 var MEDIA_PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)"; 17 var CREATED = 1; 18 var MOUNTED = 2; 19 var IDLE = 3; 20 var MOVING = 4; 21 var SCROLLING = 5; 22 var DRAGGING = 6; 23 var DESTROYED = 7; 24 var STATES = { 25 CREATED: CREATED, 26 MOUNTED: MOUNTED, 27 IDLE: IDLE, 28 MOVING: MOVING, 29 SCROLLING: SCROLLING, 30 DRAGGING: DRAGGING, 31 DESTROYED: DESTROYED 32 }; 33 34 function empty(array) { 35 array.length = 0; 36 } 37 38 function slice(arrayLike, start, end) { 39 return Array.prototype.slice.call(arrayLike, start, end); 40 } 41 42 function apply(func) { 43 return func.bind.apply(func, [null].concat(slice(arguments, 1))); 44 } 45 46 var nextTick = setTimeout; 47 48 var noop = function noop() {}; 49 50 function raf(func) { 51 return requestAnimationFrame(func); 52 } 53 54 function typeOf(type, subject) { 55 return typeof subject === type; 56 } 57 58 function isObject(subject) { 59 return !isNull(subject) && typeOf("object", subject); 60 } 61 62 var isArray = Array.isArray; 63 var isFunction = apply(typeOf, "function"); 64 var isString = apply(typeOf, "string"); 65 var isUndefined = apply(typeOf, "undefined"); 66 67 function isNull(subject) { 68 return subject === null; 69 } 70 71 function isHTMLElement(subject) { 72 try { 73 return subject instanceof (subject.ownerDocument.defaultView || window).HTMLElement; 74 } catch (e) { 75 return false; 76 } 77 } 78 79 function toArray(value) { 80 return isArray(value) ? value : [value]; 81 } 82 83 function forEach(values, iteratee) { 84 toArray(values).forEach(iteratee); 85 } 86 87 function includes(array, value) { 88 return array.indexOf(value) > -1; 89 } 90 91 function push(array, items) { 92 array.push.apply(array, toArray(items)); 93 return array; 94 } 95 96 function toggleClass(elm, classes, add) { 97 if (elm) { 98 forEach(classes, function (name) { 99 if (name) { 100 elm.classList[add ? "add" : "remove"](name); 101 } 102 }); 103 } 104 } 105 106 function addClass(elm, classes) { 107 toggleClass(elm, isString(classes) ? classes.split(" ") : classes, true); 108 } 109 110 function append(parent, children) { 111 forEach(children, parent.appendChild.bind(parent)); 112 } 113 114 function before(nodes, ref) { 115 forEach(nodes, function (node) { 116 var parent = (ref || node).parentNode; 117 118 if (parent) { 119 parent.insertBefore(node, ref); 120 } 121 }); 122 } 123 124 function matches(elm, selector) { 125 return isHTMLElement(elm) && (elm["msMatchesSelector"] || elm.matches).call(elm, selector); 126 } 127 128 function children(parent, selector) { 129 var children2 = parent ? slice(parent.children) : []; 130 return selector ? children2.filter(function (child) { 131 return matches(child, selector); 132 }) : children2; 133 } 134 135 function child(parent, selector) { 136 return selector ? children(parent, selector)[0] : parent.firstElementChild; 137 } 138 139 var ownKeys = Object.keys; 140 141 function forOwn(object, iteratee, right) { 142 if (object) { 143 (right ? ownKeys(object).reverse() : ownKeys(object)).forEach(function (key) { 144 key !== "__proto__" && iteratee(object[key], key); 145 }); 146 } 147 148 return object; 149 } 150 151 function assign(object) { 152 slice(arguments, 1).forEach(function (source) { 153 forOwn(source, function (value, key) { 154 object[key] = source[key]; 155 }); 156 }); 157 return object; 158 } 159 160 function merge(object) { 161 slice(arguments, 1).forEach(function (source) { 162 forOwn(source, function (value, key) { 163 if (isArray(value)) { 164 object[key] = value.slice(); 165 } else if (isObject(value)) { 166 object[key] = merge({}, isObject(object[key]) ? object[key] : {}, value); 167 } else { 168 object[key] = value; 169 } 170 }); 171 }); 172 return object; 173 } 174 175 function omit(object, keys) { 176 forEach(keys || ownKeys(object), function (key) { 177 delete object[key]; 178 }); 179 } 180 181 function removeAttribute(elms, attrs) { 182 forEach(elms, function (elm) { 183 forEach(attrs, function (attr) { 184 elm && elm.removeAttribute(attr); 185 }); 186 }); 187 } 188 189 function setAttribute(elms, attrs, value) { 190 if (isObject(attrs)) { 191 forOwn(attrs, function (value2, name) { 192 setAttribute(elms, name, value2); 193 }); 194 } else { 195 forEach(elms, function (elm) { 196 isNull(value) || value === "" ? removeAttribute(elm, attrs) : elm.setAttribute(attrs, String(value)); 197 }); 198 } 199 } 200 201 function create(tag, attrs, parent) { 202 var elm = document.createElement(tag); 203 204 if (attrs) { 205 isString(attrs) ? addClass(elm, attrs) : setAttribute(elm, attrs); 206 } 207 208 parent && append(parent, elm); 209 return elm; 210 } 211 212 function style(elm, prop, value) { 213 if (isUndefined(value)) { 214 return getComputedStyle(elm)[prop]; 215 } 216 217 if (!isNull(value)) { 218 elm.style[prop] = "" + value; 219 } 220 } 221 222 function display(elm, display2) { 223 style(elm, "display", display2); 224 } 225 226 function focus(elm) { 227 elm["setActive"] && elm["setActive"]() || elm.focus({ 228 preventScroll: true 229 }); 230 } 231 232 function getAttribute(elm, attr) { 233 return elm.getAttribute(attr); 234 } 235 236 function hasClass(elm, className) { 237 return elm && elm.classList.contains(className); 238 } 239 240 function rect(target) { 241 return target.getBoundingClientRect(); 242 } 243 244 function remove(nodes) { 245 forEach(nodes, function (node) { 246 if (node && node.parentNode) { 247 node.parentNode.removeChild(node); 248 } 249 }); 250 } 251 252 function parseHtml(html) { 253 return child(new DOMParser().parseFromString(html, "text/html").body); 254 } 255 256 function prevent(e, stopPropagation) { 257 e.preventDefault(); 258 259 if (stopPropagation) { 260 e.stopPropagation(); 261 e.stopImmediatePropagation(); 262 } 263 } 264 265 function query(parent, selector) { 266 return parent && parent.querySelector(selector); 267 } 268 269 function queryAll(parent, selector) { 270 return selector ? slice(parent.querySelectorAll(selector)) : []; 271 } 272 273 function removeClass(elm, classes) { 274 toggleClass(elm, classes, false); 275 } 276 277 function timeOf(e) { 278 return e.timeStamp; 279 } 280 281 function unit(value) { 282 return isString(value) ? value : value ? value + "px" : ""; 283 } 284 285 var PROJECT_CODE = "splide"; 286 var DATA_ATTRIBUTE = "data-" + PROJECT_CODE; 287 288 function assert(condition, message) { 289 if (!condition) { 290 throw new Error("[" + PROJECT_CODE + "] " + (message || "")); 291 } 292 } 293 294 var min = Math.min, 295 max = Math.max, 296 floor = Math.floor, 297 ceil = Math.ceil, 298 abs = Math.abs; 299 300 function approximatelyEqual(x, y, epsilon) { 301 return abs(x - y) < epsilon; 302 } 303 304 function between(number, x, y, exclusive) { 305 var minimum = min(x, y); 306 var maximum = max(x, y); 307 return exclusive ? minimum < number && number < maximum : minimum <= number && number <= maximum; 308 } 309 310 function clamp(number, x, y) { 311 var minimum = min(x, y); 312 var maximum = max(x, y); 313 return min(max(minimum, number), maximum); 314 } 315 316 function sign(x) { 317 return +(x > 0) - +(x < 0); 318 } 319 320 function format(string, replacements) { 321 forEach(replacements, function (replacement) { 322 string = string.replace("%s", "" + replacement); 323 }); 324 return string; 325 } 326 327 function pad(number) { 328 return number < 10 ? "0" + number : "" + number; 329 } 330 331 var ids = {}; 332 333 function uniqueId(prefix) { 334 return "" + prefix + pad(ids[prefix] = (ids[prefix] || 0) + 1); 335 } 336 337 function EventBinder() { 338 var listeners = []; 339 340 function bind(targets, events, callback, options) { 341 forEachEvent(targets, events, function (target, event, namespace) { 342 var isEventTarget = ("addEventListener" in target); 343 var remover = isEventTarget ? target.removeEventListener.bind(target, event, callback, options) : target["removeListener"].bind(target, callback); 344 isEventTarget ? target.addEventListener(event, callback, options) : target["addListener"](callback); 345 listeners.push([target, event, namespace, callback, remover]); 346 }); 347 } 348 349 function unbind(targets, events, callback) { 350 forEachEvent(targets, events, function (target, event, namespace) { 351 listeners = listeners.filter(function (listener) { 352 if (listener[0] === target && listener[1] === event && listener[2] === namespace && (!callback || listener[3] === callback)) { 353 listener[4](); 354 return false; 355 } 356 357 return true; 358 }); 359 }); 360 } 361 362 function dispatch(target, type, detail) { 363 var e; 364 var bubbles = true; 365 366 if (typeof CustomEvent === "function") { 367 e = new CustomEvent(type, { 368 bubbles: bubbles, 369 detail: detail 370 }); 371 } else { 372 e = document.createEvent("CustomEvent"); 373 e.initCustomEvent(type, bubbles, false, detail); 374 } 375 376 target.dispatchEvent(e); 377 return e; 378 } 379 380 function forEachEvent(targets, events, iteratee) { 381 forEach(targets, function (target) { 382 target && forEach(events, function (events2) { 383 events2.split(" ").forEach(function (eventNS) { 384 var fragment = eventNS.split("."); 385 iteratee(target, fragment[0], fragment[1]); 386 }); 387 }); 388 }); 389 } 390 391 function destroy() { 392 listeners.forEach(function (data) { 393 data[4](); 394 }); 395 empty(listeners); 396 } 397 398 return { 399 bind: bind, 400 unbind: unbind, 401 dispatch: dispatch, 402 destroy: destroy 403 }; 404 } 405 406 var EVENT_MOUNTED = "mounted"; 407 var EVENT_READY = "ready"; 408 var EVENT_MOVE = "move"; 409 var EVENT_MOVED = "moved"; 410 var EVENT_CLICK = "click"; 411 var EVENT_ACTIVE = "active"; 412 var EVENT_INACTIVE = "inactive"; 413 var EVENT_VISIBLE = "visible"; 414 var EVENT_HIDDEN = "hidden"; 415 var EVENT_REFRESH = "refresh"; 416 var EVENT_UPDATED = "updated"; 417 var EVENT_RESIZE = "resize"; 418 var EVENT_RESIZED = "resized"; 419 var EVENT_DRAG = "drag"; 420 var EVENT_DRAGGING = "dragging"; 421 var EVENT_DRAGGED = "dragged"; 422 var EVENT_SCROLL = "scroll"; 423 var EVENT_SCROLLED = "scrolled"; 424 var EVENT_OVERFLOW = "overflow"; 425 var EVENT_DESTROY = "destroy"; 426 var EVENT_ARROWS_MOUNTED = "arrows:mounted"; 427 var EVENT_ARROWS_UPDATED = "arrows:updated"; 428 var EVENT_PAGINATION_MOUNTED = "pagination:mounted"; 429 var EVENT_PAGINATION_UPDATED = "pagination:updated"; 430 var EVENT_NAVIGATION_MOUNTED = "navigation:mounted"; 431 var EVENT_AUTOPLAY_PLAY = "autoplay:play"; 432 var EVENT_AUTOPLAY_PLAYING = "autoplay:playing"; 433 var EVENT_AUTOPLAY_PAUSE = "autoplay:pause"; 434 var EVENT_LAZYLOAD_LOADED = "lazyload:loaded"; 435 var EVENT_SLIDE_KEYDOWN = "sk"; 436 var EVENT_SHIFTED = "sh"; 437 var EVENT_END_INDEX_CHANGED = "ei"; 438 439 function EventInterface(Splide2) { 440 var bus = Splide2 ? Splide2.event.bus : document.createDocumentFragment(); 441 var binder = EventBinder(); 442 443 function on(events, callback) { 444 binder.bind(bus, toArray(events).join(" "), function (e) { 445 callback.apply(callback, isArray(e.detail) ? e.detail : []); 446 }); 447 } 448 449 function emit(event) { 450 binder.dispatch(bus, event, slice(arguments, 1)); 451 } 452 453 if (Splide2) { 454 Splide2.event.on(EVENT_DESTROY, binder.destroy); 455 } 456 457 return assign(binder, { 458 bus: bus, 459 on: on, 460 off: apply(binder.unbind, bus), 461 emit: emit 462 }); 463 } 464 465 function RequestInterval(interval, onInterval, onUpdate, limit) { 466 var now = Date.now; 467 var startTime; 468 var rate = 0; 469 var id; 470 var paused = true; 471 var count = 0; 472 473 function update() { 474 if (!paused) { 475 rate = interval ? min((now() - startTime) / interval, 1) : 1; 476 onUpdate && onUpdate(rate); 477 478 if (rate >= 1) { 479 onInterval(); 480 startTime = now(); 481 482 if (limit && ++count >= limit) { 483 return pause(); 484 } 485 } 486 487 id = raf(update); 488 } 489 } 490 491 function start(resume) { 492 resume || cancel(); 493 startTime = now() - (resume ? rate * interval : 0); 494 paused = false; 495 id = raf(update); 496 } 497 498 function pause() { 499 paused = true; 500 } 501 502 function rewind() { 503 startTime = now(); 504 rate = 0; 505 506 if (onUpdate) { 507 onUpdate(rate); 508 } 509 } 510 511 function cancel() { 512 id && cancelAnimationFrame(id); 513 rate = 0; 514 id = 0; 515 paused = true; 516 } 517 518 function set(time) { 519 interval = time; 520 } 521 522 function isPaused() { 523 return paused; 524 } 525 526 return { 527 start: start, 528 rewind: rewind, 529 pause: pause, 530 cancel: cancel, 531 set: set, 532 isPaused: isPaused 533 }; 534 } 535 536 function State(initialState) { 537 var state = initialState; 538 539 function set(value) { 540 state = value; 541 } 542 543 function is(states) { 544 return includes(toArray(states), state); 545 } 546 547 return { 548 set: set, 549 is: is 550 }; 551 } 552 553 function Throttle(func, duration) { 554 var interval = RequestInterval(duration || 0, func, null, 1); 555 return function () { 556 interval.isPaused() && interval.start(); 557 }; 558 } 559 560 function Media(Splide2, Components2, options) { 561 var state = Splide2.state; 562 var breakpoints = options.breakpoints || {}; 563 var reducedMotion = options.reducedMotion || {}; 564 var binder = EventBinder(); 565 var queries = []; 566 567 function setup() { 568 var isMin = options.mediaQuery === "min"; 569 ownKeys(breakpoints).sort(function (n, m) { 570 return isMin ? +n - +m : +m - +n; 571 }).forEach(function (key) { 572 register(breakpoints[key], "(" + (isMin ? "min" : "max") + "-width:" + key + "px)"); 573 }); 574 register(reducedMotion, MEDIA_PREFERS_REDUCED_MOTION); 575 update(); 576 } 577 578 function destroy(completely) { 579 if (completely) { 580 binder.destroy(); 581 } 582 } 583 584 function register(options2, query) { 585 var queryList = matchMedia(query); 586 binder.bind(queryList, "change", update); 587 queries.push([options2, queryList]); 588 } 589 590 function update() { 591 var destroyed = state.is(DESTROYED); 592 var direction = options.direction; 593 var merged = queries.reduce(function (merged2, entry) { 594 return merge(merged2, entry[1].matches ? entry[0] : {}); 595 }, {}); 596 omit(options); 597 set(merged); 598 599 if (options.destroy) { 600 Splide2.destroy(options.destroy === "completely"); 601 } else if (destroyed) { 602 destroy(true); 603 Splide2.mount(); 604 } else { 605 direction !== options.direction && Splide2.refresh(); 606 } 607 } 608 609 function reduce(enable) { 610 if (matchMedia(MEDIA_PREFERS_REDUCED_MOTION).matches) { 611 enable ? merge(options, reducedMotion) : omit(options, ownKeys(reducedMotion)); 612 } 613 } 614 615 function set(opts, base, notify) { 616 merge(options, opts); 617 base && merge(Object.getPrototypeOf(options), opts); 618 619 if (notify || !state.is(CREATED)) { 620 Splide2.emit(EVENT_UPDATED, options); 621 } 622 } 623 624 return { 625 setup: setup, 626 destroy: destroy, 627 reduce: reduce, 628 set: set 629 }; 630 } 631 632 var ARROW = "Arrow"; 633 var ARROW_LEFT = ARROW + "Left"; 634 var ARROW_RIGHT = ARROW + "Right"; 635 var ARROW_UP = ARROW + "Up"; 636 var ARROW_DOWN = ARROW + "Down"; 637 var RTL = "rtl"; 638 var TTB = "ttb"; 639 var ORIENTATION_MAP = { 640 width: ["height"], 641 left: ["top", "right"], 642 right: ["bottom", "left"], 643 x: ["y"], 644 X: ["Y"], 645 Y: ["X"], 646 ArrowLeft: [ARROW_UP, ARROW_RIGHT], 647 ArrowRight: [ARROW_DOWN, ARROW_LEFT] 648 }; 649 650 function Direction(Splide2, Components2, options) { 651 function resolve(prop, axisOnly, direction) { 652 direction = direction || options.direction; 653 var index = direction === RTL && !axisOnly ? 1 : direction === TTB ? 0 : -1; 654 return ORIENTATION_MAP[prop] && ORIENTATION_MAP[prop][index] || prop.replace(/width|left|right/i, function (match, offset) { 655 var replacement = ORIENTATION_MAP[match.toLowerCase()][index] || match; 656 return offset > 0 ? replacement.charAt(0).toUpperCase() + replacement.slice(1) : replacement; 657 }); 658 } 659 660 function orient(value) { 661 return value * (options.direction === RTL ? 1 : -1); 662 } 663 664 return { 665 resolve: resolve, 666 orient: orient 667 }; 668 } 669 670 var ROLE = "role"; 671 var TAB_INDEX = "tabindex"; 672 var DISABLED = "disabled"; 673 var ARIA_PREFIX = "aria-"; 674 var ARIA_CONTROLS = ARIA_PREFIX + "controls"; 675 var ARIA_CURRENT = ARIA_PREFIX + "current"; 676 var ARIA_SELECTED = ARIA_PREFIX + "selected"; 677 var ARIA_LABEL = ARIA_PREFIX + "label"; 678 var ARIA_LABELLEDBY = ARIA_PREFIX + "labelledby"; 679 var ARIA_HIDDEN = ARIA_PREFIX + "hidden"; 680 var ARIA_ORIENTATION = ARIA_PREFIX + "orientation"; 681 var ARIA_ROLEDESCRIPTION = ARIA_PREFIX + "roledescription"; 682 var ARIA_LIVE = ARIA_PREFIX + "live"; 683 var ARIA_BUSY = ARIA_PREFIX + "busy"; 684 var ARIA_ATOMIC = ARIA_PREFIX + "atomic"; 685 var ALL_ATTRIBUTES = [ROLE, TAB_INDEX, DISABLED, ARIA_CONTROLS, ARIA_CURRENT, ARIA_LABEL, ARIA_LABELLEDBY, ARIA_HIDDEN, ARIA_ORIENTATION, ARIA_ROLEDESCRIPTION]; 686 var CLASS_PREFIX = PROJECT_CODE + "__"; 687 var STATUS_CLASS_PREFIX = "is-"; 688 var CLASS_ROOT = PROJECT_CODE; 689 var CLASS_TRACK = CLASS_PREFIX + "track"; 690 var CLASS_LIST = CLASS_PREFIX + "list"; 691 var CLASS_SLIDE = CLASS_PREFIX + "slide"; 692 var CLASS_CLONE = CLASS_SLIDE + "--clone"; 693 var CLASS_CONTAINER = CLASS_SLIDE + "__container"; 694 var CLASS_ARROWS = CLASS_PREFIX + "arrows"; 695 var CLASS_ARROW = CLASS_PREFIX + "arrow"; 696 var CLASS_ARROW_PREV = CLASS_ARROW + "--prev"; 697 var CLASS_ARROW_NEXT = CLASS_ARROW + "--next"; 698 var CLASS_PAGINATION = CLASS_PREFIX + "pagination"; 699 var CLASS_PAGINATION_PAGE = CLASS_PAGINATION + "__page"; 700 var CLASS_PROGRESS = CLASS_PREFIX + "progress"; 701 var CLASS_PROGRESS_BAR = CLASS_PROGRESS + "__bar"; 702 var CLASS_TOGGLE = CLASS_PREFIX + "toggle"; 703 var CLASS_SPINNER = CLASS_PREFIX + "spinner"; 704 var CLASS_SR = CLASS_PREFIX + "sr"; 705 var CLASS_INITIALIZED = STATUS_CLASS_PREFIX + "initialized"; 706 var CLASS_ACTIVE = STATUS_CLASS_PREFIX + "active"; 707 var CLASS_PREV = STATUS_CLASS_PREFIX + "prev"; 708 var CLASS_NEXT = STATUS_CLASS_PREFIX + "next"; 709 var CLASS_VISIBLE = STATUS_CLASS_PREFIX + "visible"; 710 var CLASS_LOADING = STATUS_CLASS_PREFIX + "loading"; 711 var CLASS_FOCUS_IN = STATUS_CLASS_PREFIX + "focus-in"; 712 var CLASS_OVERFLOW = STATUS_CLASS_PREFIX + "overflow"; 713 var STATUS_CLASSES = [CLASS_ACTIVE, CLASS_VISIBLE, CLASS_PREV, CLASS_NEXT, CLASS_LOADING, CLASS_FOCUS_IN, CLASS_OVERFLOW]; 714 var CLASSES = { 715 slide: CLASS_SLIDE, 716 clone: CLASS_CLONE, 717 arrows: CLASS_ARROWS, 718 arrow: CLASS_ARROW, 719 prev: CLASS_ARROW_PREV, 720 next: CLASS_ARROW_NEXT, 721 pagination: CLASS_PAGINATION, 722 page: CLASS_PAGINATION_PAGE, 723 spinner: CLASS_SPINNER 724 }; 725 726 function closest(from, selector) { 727 if (isFunction(from.closest)) { 728 return from.closest(selector); 729 } 730 731 var elm = from; 732 733 while (elm && elm.nodeType === 1) { 734 if (matches(elm, selector)) { 735 break; 736 } 737 738 elm = elm.parentElement; 739 } 740 741 return elm; 742 } 743 744 var FRICTION = 5; 745 var LOG_INTERVAL = 200; 746 var POINTER_DOWN_EVENTS = "touchstart mousedown"; 747 var POINTER_MOVE_EVENTS = "touchmove mousemove"; 748 var POINTER_UP_EVENTS = "touchend touchcancel mouseup click"; 749 750 function Elements(Splide2, Components2, options) { 751 var _EventInterface = EventInterface(Splide2), 752 on = _EventInterface.on, 753 bind = _EventInterface.bind; 754 755 var root = Splide2.root; 756 var i18n = options.i18n; 757 var elements = {}; 758 var slides = []; 759 var rootClasses = []; 760 var trackClasses = []; 761 var track; 762 var list; 763 var isUsingKey; 764 765 function setup() { 766 collect(); 767 init(); 768 update(); 769 } 770 771 function mount() { 772 on(EVENT_REFRESH, destroy); 773 on(EVENT_REFRESH, setup); 774 on(EVENT_UPDATED, update); 775 bind(document, POINTER_DOWN_EVENTS + " keydown", function (e) { 776 isUsingKey = e.type === "keydown"; 777 }, { 778 capture: true 779 }); 780 bind(root, "focusin", function () { 781 toggleClass(root, CLASS_FOCUS_IN, !!isUsingKey); 782 }); 783 } 784 785 function destroy(completely) { 786 var attrs = ALL_ATTRIBUTES.concat("style"); 787 empty(slides); 788 removeClass(root, rootClasses); 789 removeClass(track, trackClasses); 790 removeAttribute([track, list], attrs); 791 removeAttribute(root, completely ? attrs : ["style", ARIA_ROLEDESCRIPTION]); 792 } 793 794 function update() { 795 removeClass(root, rootClasses); 796 removeClass(track, trackClasses); 797 rootClasses = getClasses(CLASS_ROOT); 798 trackClasses = getClasses(CLASS_TRACK); 799 addClass(root, rootClasses); 800 addClass(track, trackClasses); 801 setAttribute(root, ARIA_LABEL, options.label); 802 setAttribute(root, ARIA_LABELLEDBY, options.labelledby); 803 } 804 805 function collect() { 806 track = find("." + CLASS_TRACK); 807 list = child(track, "." + CLASS_LIST); 808 assert(track && list, "A track/list element is missing."); 809 push(slides, children(list, "." + CLASS_SLIDE + ":not(." + CLASS_CLONE + ")")); 810 forOwn({ 811 arrows: CLASS_ARROWS, 812 pagination: CLASS_PAGINATION, 813 prev: CLASS_ARROW_PREV, 814 next: CLASS_ARROW_NEXT, 815 bar: CLASS_PROGRESS_BAR, 816 toggle: CLASS_TOGGLE 817 }, function (className, key) { 818 elements[key] = find("." + className); 819 }); 820 assign(elements, { 821 root: root, 822 track: track, 823 list: list, 824 slides: slides 825 }); 826 } 827 828 function init() { 829 var id = root.id || uniqueId(PROJECT_CODE); 830 var role = options.role; 831 root.id = id; 832 track.id = track.id || id + "-track"; 833 list.id = list.id || id + "-list"; 834 835 if (!getAttribute(root, ROLE) && root.tagName !== "SECTION" && role) { 836 setAttribute(root, ROLE, role); 837 } 838 839 setAttribute(root, ARIA_ROLEDESCRIPTION, i18n.carousel); 840 setAttribute(list, ROLE, "presentation"); 841 } 842 843 function find(selector) { 844 var elm = query(root, selector); 845 return elm && closest(elm, "." + CLASS_ROOT) === root ? elm : void 0; 846 } 847 848 function getClasses(base) { 849 return [base + "--" + options.type, base + "--" + options.direction, options.drag && base + "--draggable", options.isNavigation && base + "--nav", base === CLASS_ROOT && CLASS_ACTIVE]; 850 } 851 852 return assign(elements, { 853 setup: setup, 854 mount: mount, 855 destroy: destroy 856 }); 857 } 858 859 var SLIDE = "slide"; 860 var LOOP = "loop"; 861 var FADE = "fade"; 862 863 function Slide$1(Splide2, index, slideIndex, slide) { 864 var event = EventInterface(Splide2); 865 var on = event.on, 866 emit = event.emit, 867 bind = event.bind; 868 var Components = Splide2.Components, 869 root = Splide2.root, 870 options = Splide2.options; 871 var isNavigation = options.isNavigation, 872 updateOnMove = options.updateOnMove, 873 i18n = options.i18n, 874 pagination = options.pagination, 875 slideFocus = options.slideFocus; 876 var resolve = Components.Direction.resolve; 877 var styles = getAttribute(slide, "style"); 878 var label = getAttribute(slide, ARIA_LABEL); 879 var isClone = slideIndex > -1; 880 var container = child(slide, "." + CLASS_CONTAINER); 881 var destroyed; 882 883 function mount() { 884 if (!isClone) { 885 slide.id = root.id + "-slide" + pad(index + 1); 886 setAttribute(slide, ROLE, pagination ? "tabpanel" : "group"); 887 setAttribute(slide, ARIA_ROLEDESCRIPTION, i18n.slide); 888 setAttribute(slide, ARIA_LABEL, label || format(i18n.slideLabel, [index + 1, Splide2.length])); 889 } 890 891 listen(); 892 } 893 894 function listen() { 895 bind(slide, "click", apply(emit, EVENT_CLICK, self)); 896 bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self)); 897 on([EVENT_MOVED, EVENT_SHIFTED, EVENT_SCROLLED], update); 898 on(EVENT_NAVIGATION_MOUNTED, initNavigation); 899 900 if (updateOnMove) { 901 on(EVENT_MOVE, onMove); 902 } 903 } 904 905 function destroy() { 906 destroyed = true; 907 event.destroy(); 908 removeClass(slide, STATUS_CLASSES); 909 removeAttribute(slide, ALL_ATTRIBUTES); 910 setAttribute(slide, "style", styles); 911 setAttribute(slide, ARIA_LABEL, label || ""); 912 } 913 914 function initNavigation() { 915 var controls = Splide2.splides.map(function (target) { 916 var Slide2 = target.splide.Components.Slides.getAt(index); 917 return Slide2 ? Slide2.slide.id : ""; 918 }).join(" "); 919 setAttribute(slide, ARIA_LABEL, format(i18n.slideX, (isClone ? slideIndex : index) + 1)); 920 setAttribute(slide, ARIA_CONTROLS, controls); 921 setAttribute(slide, ROLE, slideFocus ? "button" : ""); 922 slideFocus && removeAttribute(slide, ARIA_ROLEDESCRIPTION); 923 } 924 925 function onMove() { 926 if (!destroyed) { 927 update(); 928 } 929 } 930 931 function update() { 932 if (!destroyed) { 933 var curr = Splide2.index; 934 updateActivity(); 935 updateVisibility(); 936 toggleClass(slide, CLASS_PREV, index === curr - 1); 937 toggleClass(slide, CLASS_NEXT, index === curr + 1); 938 } 939 } 940 941 function updateActivity() { 942 var active = isActive(); 943 944 if (active !== hasClass(slide, CLASS_ACTIVE)) { 945 toggleClass(slide, CLASS_ACTIVE, active); 946 setAttribute(slide, ARIA_CURRENT, isNavigation && active || ""); 947 emit(active ? EVENT_ACTIVE : EVENT_INACTIVE, self); 948 } 949 } 950 951 function updateVisibility() { 952 var visible = isVisible(); 953 var hidden = !visible && (!isActive() || isClone); 954 955 if (!Splide2.state.is([MOVING, SCROLLING])) { 956 setAttribute(slide, ARIA_HIDDEN, hidden || ""); 957 } 958 959 setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : ""); 960 961 if (slideFocus) { 962 setAttribute(slide, TAB_INDEX, hidden ? -1 : 0); 963 } 964 965 if (visible !== hasClass(slide, CLASS_VISIBLE)) { 966 toggleClass(slide, CLASS_VISIBLE, visible); 967 emit(visible ? EVENT_VISIBLE : EVENT_HIDDEN, self); 968 } 969 970 if (!visible && document.activeElement === slide) { 971 var Slide2 = Components.Slides.getAt(Splide2.index); 972 Slide2 && focus(Slide2.slide); 973 } 974 } 975 976 function style$1(prop, value, useContainer) { 977 style(useContainer && container || slide, prop, value); 978 } 979 980 function isActive() { 981 var curr = Splide2.index; 982 return curr === index || options.cloneStatus && curr === slideIndex; 983 } 984 985 function isVisible() { 986 if (Splide2.is(FADE)) { 987 return isActive(); 988 } 989 990 var trackRect = rect(Components.Elements.track); 991 var slideRect = rect(slide); 992 var left = resolve("left", true); 993 var right = resolve("right", true); 994 return floor(trackRect[left]) <= ceil(slideRect[left]) && floor(slideRect[right]) <= ceil(trackRect[right]); 995 } 996 997 function isWithin(from, distance) { 998 var diff = abs(from - index); 999 1000 if (!isClone && (options.rewind || Splide2.is(LOOP))) { 1001 diff = min(diff, Splide2.length - diff); 1002 } 1003 1004 return diff <= distance; 1005 } 1006 1007 var self = { 1008 index: index, 1009 slideIndex: slideIndex, 1010 slide: slide, 1011 container: container, 1012 isClone: isClone, 1013 mount: mount, 1014 destroy: destroy, 1015 update: update, 1016 style: style$1, 1017 isWithin: isWithin 1018 }; 1019 return self; 1020 } 1021 1022 function Slides(Splide2, Components2, options) { 1023 var _EventInterface2 = EventInterface(Splide2), 1024 on = _EventInterface2.on, 1025 emit = _EventInterface2.emit, 1026 bind = _EventInterface2.bind; 1027 1028 var _Components2$Elements = Components2.Elements, 1029 slides = _Components2$Elements.slides, 1030 list = _Components2$Elements.list; 1031 var Slides2 = []; 1032 1033 function mount() { 1034 init(); 1035 on(EVENT_REFRESH, destroy); 1036 on(EVENT_REFRESH, init); 1037 } 1038 1039 function init() { 1040 slides.forEach(function (slide, index) { 1041 register(slide, index, -1); 1042 }); 1043 } 1044 1045 function destroy() { 1046 forEach$1(function (Slide2) { 1047 Slide2.destroy(); 1048 }); 1049 empty(Slides2); 1050 } 1051 1052 function update() { 1053 forEach$1(function (Slide2) { 1054 Slide2.update(); 1055 }); 1056 } 1057 1058 function register(slide, index, slideIndex) { 1059 var object = Slide$1(Splide2, index, slideIndex, slide); 1060 object.mount(); 1061 Slides2.push(object); 1062 Slides2.sort(function (Slide1, Slide2) { 1063 return Slide1.index - Slide2.index; 1064 }); 1065 } 1066 1067 function get(excludeClones) { 1068 return excludeClones ? filter(function (Slide2) { 1069 return !Slide2.isClone; 1070 }) : Slides2; 1071 } 1072 1073 function getIn(page) { 1074 var Controller = Components2.Controller; 1075 var index = Controller.toIndex(page); 1076 var max = Controller.hasFocus() ? 1 : options.perPage; 1077 return filter(function (Slide2) { 1078 return between(Slide2.index, index, index + max - 1); 1079 }); 1080 } 1081 1082 function getAt(index) { 1083 return filter(index)[0]; 1084 } 1085 1086 function add(items, index) { 1087 forEach(items, function (slide) { 1088 if (isString(slide)) { 1089 slide = parseHtml(slide); 1090 } 1091 1092 if (isHTMLElement(slide)) { 1093 var ref = slides[index]; 1094 ref ? before(slide, ref) : append(list, slide); 1095 addClass(slide, options.classes.slide); 1096 observeImages(slide, apply(emit, EVENT_RESIZE)); 1097 } 1098 }); 1099 emit(EVENT_REFRESH); 1100 } 1101 1102 function remove$1(matcher) { 1103 remove(filter(matcher).map(function (Slide2) { 1104 return Slide2.slide; 1105 })); 1106 emit(EVENT_REFRESH); 1107 } 1108 1109 function forEach$1(iteratee, excludeClones) { 1110 get(excludeClones).forEach(iteratee); 1111 } 1112 1113 function filter(matcher) { 1114 return Slides2.filter(isFunction(matcher) ? matcher : function (Slide2) { 1115 return isString(matcher) ? matches(Slide2.slide, matcher) : includes(toArray(matcher), Slide2.index); 1116 }); 1117 } 1118 1119 function style(prop, value, useContainer) { 1120 forEach$1(function (Slide2) { 1121 Slide2.style(prop, value, useContainer); 1122 }); 1123 } 1124 1125 function observeImages(elm, callback) { 1126 var images = queryAll(elm, "img"); 1127 var length = images.length; 1128 1129 if (length) { 1130 images.forEach(function (img) { 1131 bind(img, "load error", function () { 1132 if (! --length) { 1133 callback(); 1134 } 1135 }); 1136 }); 1137 } else { 1138 callback(); 1139 } 1140 } 1141 1142 function getLength(excludeClones) { 1143 return excludeClones ? slides.length : Slides2.length; 1144 } 1145 1146 function isEnough() { 1147 return Slides2.length > options.perPage; 1148 } 1149 1150 return { 1151 mount: mount, 1152 destroy: destroy, 1153 update: update, 1154 register: register, 1155 get: get, 1156 getIn: getIn, 1157 getAt: getAt, 1158 add: add, 1159 remove: remove$1, 1160 forEach: forEach$1, 1161 filter: filter, 1162 style: style, 1163 getLength: getLength, 1164 isEnough: isEnough 1165 }; 1166 } 1167 1168 function Layout(Splide2, Components2, options) { 1169 var _EventInterface3 = EventInterface(Splide2), 1170 on = _EventInterface3.on, 1171 bind = _EventInterface3.bind, 1172 emit = _EventInterface3.emit; 1173 1174 var Slides = Components2.Slides; 1175 var resolve = Components2.Direction.resolve; 1176 var _Components2$Elements2 = Components2.Elements, 1177 root = _Components2$Elements2.root, 1178 track = _Components2$Elements2.track, 1179 list = _Components2$Elements2.list; 1180 var getAt = Slides.getAt, 1181 styleSlides = Slides.style; 1182 var vertical; 1183 var rootRect; 1184 var overflow; 1185 1186 function mount() { 1187 init(); 1188 bind(window, "resize load", Throttle(apply(emit, EVENT_RESIZE))); 1189 on([EVENT_UPDATED, EVENT_REFRESH], init); 1190 on(EVENT_RESIZE, resize); 1191 } 1192 1193 function init() { 1194 vertical = options.direction === TTB; 1195 style(root, "maxWidth", unit(options.width)); 1196 style(track, resolve("paddingLeft"), cssPadding(false)); 1197 style(track, resolve("paddingRight"), cssPadding(true)); 1198 resize(true); 1199 } 1200 1201 function resize(force) { 1202 var newRect = rect(root); 1203 1204 if (force || rootRect.width !== newRect.width || rootRect.height !== newRect.height) { 1205 style(track, "height", cssTrackHeight()); 1206 styleSlides(resolve("marginRight"), unit(options.gap)); 1207 styleSlides("width", cssSlideWidth()); 1208 styleSlides("height", cssSlideHeight(), true); 1209 rootRect = newRect; 1210 emit(EVENT_RESIZED); 1211 1212 if (overflow !== (overflow = isOverflow())) { 1213 toggleClass(root, CLASS_OVERFLOW, overflow); 1214 emit(EVENT_OVERFLOW, overflow); 1215 } 1216 } 1217 } 1218 1219 function cssPadding(right) { 1220 var padding = options.padding; 1221 var prop = resolve(right ? "right" : "left"); 1222 return padding && unit(padding[prop] || (isObject(padding) ? 0 : padding)) || "0px"; 1223 } 1224 1225 function cssTrackHeight() { 1226 var height = ""; 1227 1228 if (vertical) { 1229 height = cssHeight(); 1230 assert(height, "height or heightRatio is missing."); 1231 height = "calc(" + height + " - " + cssPadding(false) + " - " + cssPadding(true) + ")"; 1232 } 1233 1234 return height; 1235 } 1236 1237 function cssHeight() { 1238 return unit(options.height || rect(list).width * options.heightRatio); 1239 } 1240 1241 function cssSlideWidth() { 1242 return options.autoWidth ? null : unit(options.fixedWidth) || (vertical ? "" : cssSlideSize()); 1243 } 1244 1245 function cssSlideHeight() { 1246 return unit(options.fixedHeight) || (vertical ? options.autoHeight ? null : cssSlideSize() : cssHeight()); 1247 } 1248 1249 function cssSlideSize() { 1250 var gap = unit(options.gap); 1251 return "calc((100%" + (gap && " + " + gap) + ")/" + (options.perPage || 1) + (gap && " - " + gap) + ")"; 1252 } 1253 1254 function listSize() { 1255 return rect(list)[resolve("width")]; 1256 } 1257 1258 function slideSize(index, withoutGap) { 1259 var Slide = getAt(index || 0); 1260 return Slide ? rect(Slide.slide)[resolve("width")] + (withoutGap ? 0 : getGap()) : 0; 1261 } 1262 1263 function totalSize(index, withoutGap) { 1264 var Slide = getAt(index); 1265 1266 if (Slide) { 1267 var right = rect(Slide.slide)[resolve("right")]; 1268 var left = rect(list)[resolve("left")]; 1269 return abs(right - left) + (withoutGap ? 0 : getGap()); 1270 } 1271 1272 return 0; 1273 } 1274 1275 function sliderSize(withoutGap) { 1276 return totalSize(Splide2.length - 1) - totalSize(0) + slideSize(0, withoutGap); 1277 } 1278 1279 function getGap() { 1280 var Slide = getAt(0); 1281 return Slide && parseFloat(style(Slide.slide, resolve("marginRight"))) || 0; 1282 } 1283 1284 function getPadding(right) { 1285 return parseFloat(style(track, resolve("padding" + (right ? "Right" : "Left")))) || 0; 1286 } 1287 1288 function isOverflow() { 1289 return Splide2.is(FADE) || sliderSize(true) > listSize(); 1290 } 1291 1292 return { 1293 mount: mount, 1294 resize: resize, 1295 listSize: listSize, 1296 slideSize: slideSize, 1297 sliderSize: sliderSize, 1298 totalSize: totalSize, 1299 getPadding: getPadding, 1300 isOverflow: isOverflow 1301 }; 1302 } 1303 1304 var MULTIPLIER = 2; 1305 1306 function Clones(Splide2, Components2, options) { 1307 var event = EventInterface(Splide2); 1308 var on = event.on; 1309 var Elements = Components2.Elements, 1310 Slides = Components2.Slides; 1311 var resolve = Components2.Direction.resolve; 1312 var clones = []; 1313 var cloneCount; 1314 1315 function mount() { 1316 on(EVENT_REFRESH, remount); 1317 on([EVENT_UPDATED, EVENT_RESIZE], observe); 1318 1319 if (cloneCount = computeCloneCount()) { 1320 generate(cloneCount); 1321 Components2.Layout.resize(true); 1322 } 1323 } 1324 1325 function remount() { 1326 destroy(); 1327 mount(); 1328 } 1329 1330 function destroy() { 1331 remove(clones); 1332 empty(clones); 1333 event.destroy(); 1334 } 1335 1336 function observe() { 1337 var count = computeCloneCount(); 1338 1339 if (cloneCount !== count) { 1340 if (cloneCount < count || !count) { 1341 event.emit(EVENT_REFRESH); 1342 } 1343 } 1344 } 1345 1346 function generate(count) { 1347 var slides = Slides.get().slice(); 1348 var length = slides.length; 1349 1350 if (length) { 1351 while (slides.length < count) { 1352 push(slides, slides); 1353 } 1354 1355 push(slides.slice(-count), slides.slice(0, count)).forEach(function (Slide, index) { 1356 var isHead = index < count; 1357 var clone = cloneDeep(Slide.slide, index); 1358 isHead ? before(clone, slides[0].slide) : append(Elements.list, clone); 1359 push(clones, clone); 1360 Slides.register(clone, index - count + (isHead ? 0 : length), Slide.index); 1361 }); 1362 } 1363 } 1364 1365 function cloneDeep(elm, index) { 1366 var clone = elm.cloneNode(true); 1367 addClass(clone, options.classes.clone); 1368 clone.id = Splide2.root.id + "-clone" + pad(index + 1); 1369 return clone; 1370 } 1371 1372 function computeCloneCount() { 1373 var clones2 = options.clones; 1374 1375 if (!Splide2.is(LOOP)) { 1376 clones2 = 0; 1377 } else if (isUndefined(clones2)) { 1378 var fixedSize = options[resolve("fixedWidth")] && Components2.Layout.slideSize(0); 1379 var fixedCount = fixedSize && ceil(rect(Elements.track)[resolve("width")] / fixedSize); 1380 clones2 = fixedCount || options[resolve("autoWidth")] && Splide2.length || options.perPage * MULTIPLIER; 1381 } 1382 1383 return clones2; 1384 } 1385 1386 return { 1387 mount: mount, 1388 destroy: destroy 1389 }; 1390 } 1391 1392 function Move(Splide2, Components2, options) { 1393 var _EventInterface4 = EventInterface(Splide2), 1394 on = _EventInterface4.on, 1395 emit = _EventInterface4.emit; 1396 1397 var set = Splide2.state.set; 1398 var _Components2$Layout = Components2.Layout, 1399 slideSize = _Components2$Layout.slideSize, 1400 getPadding = _Components2$Layout.getPadding, 1401 totalSize = _Components2$Layout.totalSize, 1402 listSize = _Components2$Layout.listSize, 1403 sliderSize = _Components2$Layout.sliderSize; 1404 var _Components2$Directio = Components2.Direction, 1405 resolve = _Components2$Directio.resolve, 1406 orient = _Components2$Directio.orient; 1407 var _Components2$Elements3 = Components2.Elements, 1408 list = _Components2$Elements3.list, 1409 track = _Components2$Elements3.track; 1410 var Transition; 1411 1412 function mount() { 1413 Transition = Components2.Transition; 1414 on([EVENT_MOUNTED, EVENT_RESIZED, EVENT_UPDATED, EVENT_REFRESH], reposition); 1415 } 1416 1417 function reposition() { 1418 if (!Components2.Controller.isBusy()) { 1419 Components2.Scroll.cancel(); 1420 jump(Splide2.index); 1421 Components2.Slides.update(); 1422 } 1423 } 1424 1425 function move(dest, index, prev, callback) { 1426 if (dest !== index && canShift(dest > prev)) { 1427 cancel(); 1428 translate(shift(getPosition(), dest > prev), true); 1429 } 1430 1431 set(MOVING); 1432 emit(EVENT_MOVE, index, prev, dest); 1433 Transition.start(index, function () { 1434 set(IDLE); 1435 emit(EVENT_MOVED, index, prev, dest); 1436 callback && callback(); 1437 }); 1438 } 1439 1440 function jump(index) { 1441 translate(toPosition(index, true)); 1442 } 1443 1444 function translate(position, preventLoop) { 1445 if (!Splide2.is(FADE)) { 1446 var destination = preventLoop ? position : loop(position); 1447 style(list, "transform", "translate" + resolve("X") + "(" + destination + "px)"); 1448 position !== destination && emit(EVENT_SHIFTED); 1449 } 1450 } 1451 1452 function loop(position) { 1453 if (Splide2.is(LOOP)) { 1454 var index = toIndex(position); 1455 var exceededMax = index > Components2.Controller.getEnd(); 1456 var exceededMin = index < 0; 1457 1458 if (exceededMin || exceededMax) { 1459 position = shift(position, exceededMax); 1460 } 1461 } 1462 1463 return position; 1464 } 1465 1466 function shift(position, backwards) { 1467 var excess = position - getLimit(backwards); 1468 var size = sliderSize(); 1469 position -= orient(size * (ceil(abs(excess) / size) || 1)) * (backwards ? 1 : -1); 1470 return position; 1471 } 1472 1473 function cancel() { 1474 translate(getPosition(), true); 1475 Transition.cancel(); 1476 } 1477 1478 function toIndex(position) { 1479 var Slides = Components2.Slides.get(); 1480 var index = 0; 1481 var minDistance = Infinity; 1482 1483 for (var i = 0; i < Slides.length; i++) { 1484 var slideIndex = Slides[i].index; 1485 var distance = abs(toPosition(slideIndex, true) - position); 1486 1487 if (distance <= minDistance) { 1488 minDistance = distance; 1489 index = slideIndex; 1490 } else { 1491 break; 1492 } 1493 } 1494 1495 return index; 1496 } 1497 1498 function toPosition(index, trimming) { 1499 var position = orient(totalSize(index - 1) - offset(index)); 1500 return trimming ? trim(position) : position; 1501 } 1502 1503 function getPosition() { 1504 var left = resolve("left"); 1505 return rect(list)[left] - rect(track)[left] + orient(getPadding(false)); 1506 } 1507 1508 function trim(position) { 1509 if (options.trimSpace && Splide2.is(SLIDE)) { 1510 position = clamp(position, 0, orient(sliderSize(true) - listSize())); 1511 } 1512 1513 return position; 1514 } 1515 1516 function offset(index) { 1517 var focus = options.focus; 1518 return focus === "center" ? (listSize() - slideSize(index, true)) / 2 : +focus * slideSize(index) || 0; 1519 } 1520 1521 function getLimit(max) { 1522 return toPosition(max ? Components2.Controller.getEnd() : 0, !!options.trimSpace); 1523 } 1524 1525 function canShift(backwards) { 1526 var shifted = orient(shift(getPosition(), backwards)); 1527 return backwards ? shifted >= 0 : shifted <= list[resolve("scrollWidth")] - rect(track)[resolve("width")]; 1528 } 1529 1530 function exceededLimit(max, position) { 1531 position = isUndefined(position) ? getPosition() : position; 1532 var exceededMin = max !== true && orient(position) < orient(getLimit(false)); 1533 var exceededMax = max !== false && orient(position) > orient(getLimit(true)); 1534 return exceededMin || exceededMax; 1535 } 1536 1537 return { 1538 mount: mount, 1539 move: move, 1540 jump: jump, 1541 translate: translate, 1542 shift: shift, 1543 cancel: cancel, 1544 toIndex: toIndex, 1545 toPosition: toPosition, 1546 getPosition: getPosition, 1547 getLimit: getLimit, 1548 exceededLimit: exceededLimit, 1549 reposition: reposition 1550 }; 1551 } 1552 1553 function Controller(Splide2, Components2, options) { 1554 var _EventInterface5 = EventInterface(Splide2), 1555 on = _EventInterface5.on, 1556 emit = _EventInterface5.emit; 1557 1558 var Move = Components2.Move; 1559 var getPosition = Move.getPosition, 1560 getLimit = Move.getLimit, 1561 toPosition = Move.toPosition; 1562 var _Components2$Slides = Components2.Slides, 1563 isEnough = _Components2$Slides.isEnough, 1564 getLength = _Components2$Slides.getLength; 1565 var omitEnd = options.omitEnd; 1566 var isLoop = Splide2.is(LOOP); 1567 var isSlide = Splide2.is(SLIDE); 1568 var getNext = apply(getAdjacent, false); 1569 var getPrev = apply(getAdjacent, true); 1570 var currIndex = options.start || 0; 1571 var endIndex; 1572 var prevIndex = currIndex; 1573 var slideCount; 1574 var perMove; 1575 var perPage; 1576 1577 function mount() { 1578 init(); 1579 on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], init); 1580 on(EVENT_RESIZED, onResized); 1581 } 1582 1583 function init() { 1584 slideCount = getLength(true); 1585 perMove = options.perMove; 1586 perPage = options.perPage; 1587 endIndex = getEnd(); 1588 var index = clamp(currIndex, 0, omitEnd ? endIndex : slideCount - 1); 1589 1590 if (index !== currIndex) { 1591 currIndex = index; 1592 Move.reposition(); 1593 } 1594 } 1595 1596 function onResized() { 1597 if (endIndex !== getEnd()) { 1598 emit(EVENT_END_INDEX_CHANGED); 1599 } 1600 } 1601 1602 function go(control, allowSameIndex, callback) { 1603 if (!isBusy()) { 1604 var dest = parse(control); 1605 var index = loop(dest); 1606 1607 if (index > -1 && (allowSameIndex || index !== currIndex)) { 1608 setIndex(index); 1609 Move.move(dest, index, prevIndex, callback); 1610 } 1611 } 1612 } 1613 1614 function scroll(destination, duration, snap, callback) { 1615 Components2.Scroll.scroll(destination, duration, snap, function () { 1616 var index = loop(Move.toIndex(getPosition())); 1617 setIndex(omitEnd ? min(index, endIndex) : index); 1618 callback && callback(); 1619 }); 1620 } 1621 1622 function parse(control) { 1623 var index = currIndex; 1624 1625 if (isString(control)) { 1626 var _ref = control.match(/([+\-<>])(\d+)?/) || [], 1627 indicator = _ref[1], 1628 number = _ref[2]; 1629 1630 if (indicator === "+" || indicator === "-") { 1631 index = computeDestIndex(currIndex + +("" + indicator + (+number || 1)), currIndex); 1632 } else if (indicator === ">") { 1633 index = number ? toIndex(+number) : getNext(true); 1634 } else if (indicator === "<") { 1635 index = getPrev(true); 1636 } 1637 } else { 1638 index = isLoop ? control : clamp(control, 0, endIndex); 1639 } 1640 1641 return index; 1642 } 1643 1644 function getAdjacent(prev, destination) { 1645 var number = perMove || (hasFocus() ? 1 : perPage); 1646 var dest = computeDestIndex(currIndex + number * (prev ? -1 : 1), currIndex, !(perMove || hasFocus())); 1647 1648 if (dest === -1 && isSlide) { 1649 if (!approximatelyEqual(getPosition(), getLimit(!prev), 1)) { 1650 return prev ? 0 : endIndex; 1651 } 1652 } 1653 1654 return destination ? dest : loop(dest); 1655 } 1656 1657 function computeDestIndex(dest, from, snapPage) { 1658 if (isEnough() || hasFocus()) { 1659 var index = computeMovableDestIndex(dest); 1660 1661 if (index !== dest) { 1662 from = dest; 1663 dest = index; 1664 snapPage = false; 1665 } 1666 1667 if (dest < 0 || dest > endIndex) { 1668 if (!perMove && (between(0, dest, from, true) || between(endIndex, from, dest, true))) { 1669 dest = toIndex(toPage(dest)); 1670 } else { 1671 if (isLoop) { 1672 dest = snapPage ? dest < 0 ? -(slideCount % perPage || perPage) : slideCount : dest; 1673 } else if (options.rewind) { 1674 dest = dest < 0 ? endIndex : 0; 1675 } else { 1676 dest = -1; 1677 } 1678 } 1679 } else { 1680 if (snapPage && dest !== from) { 1681 dest = toIndex(toPage(from) + (dest < from ? -1 : 1)); 1682 } 1683 } 1684 } else { 1685 dest = -1; 1686 } 1687 1688 return dest; 1689 } 1690 1691 function computeMovableDestIndex(dest) { 1692 if (isSlide && options.trimSpace === "move" && dest !== currIndex) { 1693 var position = getPosition(); 1694 1695 while (position === toPosition(dest, true) && between(dest, 0, Splide2.length - 1, !options.rewind)) { 1696 dest < currIndex ? --dest : ++dest; 1697 } 1698 } 1699 1700 return dest; 1701 } 1702 1703 function loop(index) { 1704 return isLoop ? (index + slideCount) % slideCount || 0 : index; 1705 } 1706 1707 function getEnd() { 1708 var end = slideCount - (hasFocus() || isLoop && perMove ? 1 : perPage); 1709 1710 while (omitEnd && end-- > 0) { 1711 if (toPosition(slideCount - 1, true) !== toPosition(end, true)) { 1712 end++; 1713 break; 1714 } 1715 } 1716 1717 return clamp(end, 0, slideCount - 1); 1718 } 1719 1720 function toIndex(page) { 1721 return clamp(hasFocus() ? page : perPage * page, 0, endIndex); 1722 } 1723 1724 function toPage(index) { 1725 return hasFocus() ? min(index, endIndex) : floor((index >= endIndex ? slideCount - 1 : index) / perPage); 1726 } 1727 1728 function toDest(destination) { 1729 var closest = Move.toIndex(destination); 1730 return isSlide ? clamp(closest, 0, endIndex) : closest; 1731 } 1732 1733 function setIndex(index) { 1734 if (index !== currIndex) { 1735 prevIndex = currIndex; 1736 currIndex = index; 1737 } 1738 } 1739 1740 function getIndex(prev) { 1741 return prev ? prevIndex : currIndex; 1742 } 1743 1744 function hasFocus() { 1745 return !isUndefined(options.focus) || options.isNavigation; 1746 } 1747 1748 function isBusy() { 1749 return Splide2.state.is([MOVING, SCROLLING]) && !!options.waitForTransition; 1750 } 1751 1752 return { 1753 mount: mount, 1754 go: go, 1755 scroll: scroll, 1756 getNext: getNext, 1757 getPrev: getPrev, 1758 getAdjacent: getAdjacent, 1759 getEnd: getEnd, 1760 setIndex: setIndex, 1761 getIndex: getIndex, 1762 toIndex: toIndex, 1763 toPage: toPage, 1764 toDest: toDest, 1765 hasFocus: hasFocus, 1766 isBusy: isBusy 1767 }; 1768 } 1769 1770 var XML_NAME_SPACE = "http://www.w3.org/2000/svg"; 1771 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"; 1772 var SIZE = 40; 1773 1774 function Arrows(Splide2, Components2, options) { 1775 var event = EventInterface(Splide2); 1776 var on = event.on, 1777 bind = event.bind, 1778 emit = event.emit; 1779 var classes = options.classes, 1780 i18n = options.i18n; 1781 var Elements = Components2.Elements, 1782 Controller = Components2.Controller; 1783 var placeholder = Elements.arrows, 1784 track = Elements.track; 1785 var wrapper = placeholder; 1786 var prev = Elements.prev; 1787 var next = Elements.next; 1788 var created; 1789 var wrapperClasses; 1790 var arrows = {}; 1791 1792 function mount() { 1793 init(); 1794 on(EVENT_UPDATED, remount); 1795 } 1796 1797 function remount() { 1798 destroy(); 1799 mount(); 1800 } 1801 1802 function init() { 1803 var enabled = options.arrows; 1804 1805 if (enabled && !(prev && next)) { 1806 createArrows(); 1807 } 1808 1809 if (prev && next) { 1810 assign(arrows, { 1811 prev: prev, 1812 next: next 1813 }); 1814 display(wrapper, enabled ? "" : "none"); 1815 addClass(wrapper, wrapperClasses = CLASS_ARROWS + "--" + options.direction); 1816 1817 if (enabled) { 1818 listen(); 1819 update(); 1820 setAttribute([prev, next], ARIA_CONTROLS, track.id); 1821 emit(EVENT_ARROWS_MOUNTED, prev, next); 1822 } 1823 } 1824 } 1825 1826 function destroy() { 1827 event.destroy(); 1828 removeClass(wrapper, wrapperClasses); 1829 1830 if (created) { 1831 remove(placeholder ? [prev, next] : wrapper); 1832 prev = next = null; 1833 } else { 1834 removeAttribute([prev, next], ALL_ATTRIBUTES); 1835 } 1836 } 1837 1838 function listen() { 1839 on([EVENT_MOUNTED, EVENT_MOVED, EVENT_REFRESH, EVENT_SCROLLED, EVENT_END_INDEX_CHANGED], update); 1840 bind(next, "click", apply(go, ">")); 1841 bind(prev, "click", apply(go, "<")); 1842 } 1843 1844 function go(control) { 1845 Controller.go(control, true); 1846 } 1847 1848 function createArrows() { 1849 wrapper = placeholder || create("div", classes.arrows); 1850 prev = createArrow(true); 1851 next = createArrow(false); 1852 created = true; 1853 append(wrapper, [prev, next]); 1854 !placeholder && before(wrapper, track); 1855 }
1856 1857 /*function createArrow(prev2) { 1858 var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><span class=\"splide__arrow__bg\" data-elem-type=\"container\" data-lp-selector=\".splide__arrow__bg\" data-has-event=\"1\"></span><span class=\"splide__arrow__lines "+ (prev2 ? '' : 'reverse__arrows') +"\" data-elem-type=\"generate\" data-lp-controls-list=\"background\" data-lp-selector=\".splide__arrow__line\"><span class=\"splide__arrow__line\"></span><span class=\"splide__arrow__line\"></span></span>"; 1859 return parseHtml(arrow); 1860 }*/ 1861 1862 function createArrow(prev2) { 1863 var arrow = "<button class=\"" + classes.arrow + " " + (prev2 ? classes.prev : classes.next) + "\" type=\"button\"><span class=\"splide__arrow__bg\" data-elem-type=\"container\" data-lp-selector=\".splide__arrow__bg\" data-has-event=\"1\"><span class=\"splide__arrow__icon "+ (!prev2 ? '' : 'splide__arrow__icon--prev') +"\" data-elem-type=\"generate\" data-lp-controls-list=\"background\" data-lp-selector=\".splide__arrow__icon\"></span></span>"; 1864 return parseHtml(arrow); 1865 } /*Ðбновление ÑÑÑелок https://megagroup.fibery.io/S3/Task/2041 */ 1866
vendor: 19,573 bytes, lines 1867-2579
1867 function update() { 1868 if (prev && next) { 1869 var index = Splide2.index; 1870 var prevIndex = Controller.getPrev(); 1871 var nextIndex = Controller.getNext(); 1872 var prevLabel = prevIndex > -1 && index < prevIndex ? i18n.last : i18n.prev; 1873 var nextLabel = nextIndex > -1 && index > nextIndex ? i18n.first : i18n.next; 1874 prev.disabled = prevIndex < 0; 1875 next.disabled = nextIndex < 0; 1876 setAttribute(prev, ARIA_LABEL, prevLabel); 1877 setAttribute(next, ARIA_LABEL, nextLabel); 1878 emit(EVENT_ARROWS_UPDATED, prev, next, prevIndex, nextIndex); 1879 } 1880 } 1881 1882 return { 1883 arrows: arrows, 1884 mount: mount, 1885 destroy: destroy, 1886 update: update 1887 }; 1888 } 1889 1890 var INTERVAL_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-interval"; 1891 1892 function Autoplay(Splide2, Components2, options) { 1893 var _EventInterface6 = EventInterface(Splide2), 1894 on = _EventInterface6.on, 1895 bind = _EventInterface6.bind, 1896 emit = _EventInterface6.emit; 1897 1898 var interval = RequestInterval(options.interval, Splide2.go.bind(Splide2, ">"), onAnimationFrame); 1899 var isPaused = interval.isPaused; 1900 var Elements = Components2.Elements, 1901 _Components2$Elements4 = Components2.Elements, 1902 root = _Components2$Elements4.root, 1903 toggle = _Components2$Elements4.toggle; 1904 var autoplay = options.autoplay; 1905 var hovered; 1906 var focused; 1907 var stopped = autoplay === "pause"; 1908 1909 function mount() { 1910 if (autoplay) { 1911 listen(); 1912 toggle && setAttribute(toggle, ARIA_CONTROLS, Elements.track.id); 1913 stopped || play(); 1914 update(); 1915 } 1916 } 1917 1918 function listen() { 1919 if (options.pauseOnHover) { 1920 bind(root, "mouseenter mouseleave", function (e) { 1921 hovered = e.type === "mouseenter"; 1922 autoToggle(); 1923 }); 1924 } 1925 1926 if (options.pauseOnFocus) { 1927 bind(root, "focusin focusout", function (e) { 1928 focused = e.type === "focusin"; 1929 autoToggle(); 1930 }); 1931 } 1932 1933 if (toggle) { 1934 bind(toggle, "click", function () { 1935 stopped ? play() : pause(true); 1936 }); 1937 } 1938 1939 on([EVENT_MOVE, EVENT_SCROLL, EVENT_REFRESH], interval.rewind); 1940 on(EVENT_MOVE, onMove); 1941 } 1942 1943 function play() { 1944 if (isPaused() && Components2.Slides.isEnough()) { 1945 interval.start(!options.resetProgress); 1946 focused = hovered = stopped = false; 1947 update(); 1948 emit(EVENT_AUTOPLAY_PLAY); 1949 } 1950 } 1951 1952 function pause(stop) { 1953 if (stop === void 0) { 1954 stop = true; 1955 } 1956 1957 stopped = !!stop; 1958 update(); 1959 1960 if (!isPaused()) { 1961 interval.pause(); 1962 emit(EVENT_AUTOPLAY_PAUSE); 1963 } 1964 } 1965 1966 function autoToggle() { 1967 if (!stopped) { 1968 hovered || focused ? pause(false) : play(); 1969 } 1970 } 1971 1972 function update() { 1973 if (toggle) { 1974 toggleClass(toggle, CLASS_ACTIVE, !stopped); 1975 setAttribute(toggle, ARIA_LABEL, options.i18n[stopped ? "play" : "pause"]); 1976 } 1977 } 1978 1979 function onAnimationFrame(rate) { 1980 var bar = Elements.bar; 1981 bar && style(bar, "width", rate * 100 + "%"); 1982 emit(EVENT_AUTOPLAY_PLAYING, rate); 1983 } 1984 1985 function onMove(index) { 1986 var Slide = Components2.Slides.getAt(index); 1987 interval.set(Slide && +getAttribute(Slide.slide, INTERVAL_DATA_ATTRIBUTE) || options.interval); 1988 } 1989 1990 return { 1991 mount: mount, 1992 destroy: interval.cancel, 1993 play: play, 1994 pause: pause, 1995 isPaused: isPaused 1996 }; 1997 } 1998 1999 function Cover(Splide2, Components2, options) { 2000 var _EventInterface7 = EventInterface(Splide2), 2001 on = _EventInterface7.on; 2002 2003 function mount() { 2004 if (options.cover) { 2005 on(EVENT_LAZYLOAD_LOADED, apply(toggle, true)); 2006 on([EVENT_MOUNTED, EVENT_UPDATED, EVENT_REFRESH], apply(cover, true)); 2007 } 2008 } 2009 2010 function cover(cover2) { 2011 Components2.Slides.forEach(function (Slide) { 2012 var img = child(Slide.container || Slide.slide, "img"); 2013 2014 if (img && img.src) { 2015 toggle(cover2, img, Slide); 2016 } 2017 }); 2018 } 2019 2020 function toggle(cover2, img, Slide) { 2021 Slide.style("background", cover2 ? "center/cover no-repeat url(\"" + img.src + "\")" : "", true); 2022 display(img, cover2 ? "none" : ""); 2023 } 2024 2025 return { 2026 mount: mount, 2027 destroy: apply(cover, false) 2028 }; 2029 } 2030 2031 var BOUNCE_DIFF_THRESHOLD = 10; 2032 var BOUNCE_DURATION = 600; 2033 var FRICTION_FACTOR = 0.6; 2034 var BASE_VELOCITY = 1.5; 2035 var MIN_DURATION = 800; 2036 2037 function Scroll(Splide2, Components2, options) { 2038 var _EventInterface8 = EventInterface(Splide2), 2039 on = _EventInterface8.on, 2040 emit = _EventInterface8.emit; 2041 2042 var set = Splide2.state.set; 2043 var Move = Components2.Move; 2044 var getPosition = Move.getPosition, 2045 getLimit = Move.getLimit, 2046 exceededLimit = Move.exceededLimit, 2047 translate = Move.translate; 2048 var isSlide = Splide2.is(SLIDE); 2049 var interval; 2050 var callback; 2051 var friction = 1; 2052 2053 function mount() { 2054 on(EVENT_MOVE, clear); 2055 on([EVENT_UPDATED, EVENT_REFRESH], cancel); 2056 } 2057 2058 function scroll(destination, duration, snap, onScrolled, noConstrain) { 2059 var from = getPosition(); 2060 clear(); 2061 2062 if (snap && (!isSlide || !exceededLimit())) { 2063 var size = Components2.Layout.sliderSize(); 2064 var offset = sign(destination) * size * floor(abs(destination) / size) || 0; 2065 destination = Move.toPosition(Components2.Controller.toDest(destination % size)) + offset; 2066 } 2067 2068 var noDistance = approximatelyEqual(from, destination, 1); 2069 friction = 1; 2070 duration = noDistance ? 0 : duration || max(abs(destination - from) / BASE_VELOCITY, MIN_DURATION); 2071 callback = onScrolled; 2072 interval = RequestInterval(duration, onEnd, apply(update, from, destination, noConstrain), 1); 2073 set(SCROLLING); 2074 emit(EVENT_SCROLL); 2075 interval.start(); 2076 } 2077 2078 function onEnd() { 2079 set(IDLE); 2080 callback && callback(); 2081 emit(EVENT_SCROLLED); 2082 } 2083 2084 function update(from, to, noConstrain, rate) { 2085 var position = getPosition(); 2086 var target = from + (to - from) * easing(rate); 2087 var diff = (target - position) * friction; 2088 translate(position + diff); 2089 2090 if (isSlide && !noConstrain && exceededLimit()) { 2091 friction *= FRICTION_FACTOR; 2092 2093 if (abs(diff) < BOUNCE_DIFF_THRESHOLD) { 2094 scroll(getLimit(exceededLimit(true)), BOUNCE_DURATION, false, callback, true); 2095 } 2096 } 2097 } 2098 2099 function clear() { 2100 if (interval) { 2101 interval.cancel(); 2102 } 2103 } 2104 2105 function cancel() { 2106 if (interval && !interval.isPaused()) { 2107 clear(); 2108 onEnd(); 2109 } 2110 } 2111 2112 function easing(t) { 2113 var easingFunc = options.easingFunc; 2114 return easingFunc ? easingFunc(t) : 1 - Math.pow(1 - t, 4); 2115 } 2116 2117 return { 2118 mount: mount, 2119 destroy: clear, 2120 scroll: scroll, 2121 cancel: cancel 2122 }; 2123 } 2124 2125 var SCROLL_LISTENER_OPTIONS = { 2126 passive: false, 2127 capture: true 2128 }; 2129 2130 function Drag(Splide2, Components2, options) { 2131 var _EventInterface9 = EventInterface(Splide2), 2132 on = _EventInterface9.on, 2133 emit = _EventInterface9.emit, 2134 bind = _EventInterface9.bind, 2135 unbind = _EventInterface9.unbind; 2136 2137 var state = Splide2.state; 2138 var Move = Components2.Move, 2139 Scroll = Components2.Scroll, 2140 Controller = Components2.Controller, 2141 track = Components2.Elements.track, 2142 reduce = Components2.Media.reduce; 2143 var _Components2$Directio2 = Components2.Direction, 2144 resolve = _Components2$Directio2.resolve, 2145 orient = _Components2$Directio2.orient; 2146 var getPosition = Move.getPosition, 2147 exceededLimit = Move.exceededLimit; 2148 var basePosition; 2149 var baseEvent; 2150 var prevBaseEvent; 2151 var isFree; 2152 var dragging; 2153 var exceeded = false; 2154 var clickPrevented; 2155 var disabled; 2156 var target; 2157 2158 function mount() { 2159 bind(track, POINTER_MOVE_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 2160 bind(track, POINTER_UP_EVENTS, noop, SCROLL_LISTENER_OPTIONS); 2161 bind(track, POINTER_DOWN_EVENTS, onPointerDown, SCROLL_LISTENER_OPTIONS); 2162 bind(track, "click", onClick, { 2163 capture: true 2164 }); 2165 bind(track, "dragstart", prevent); 2166 on([EVENT_MOUNTED, EVENT_UPDATED], init); 2167 } 2168 2169 function init() { 2170 var drag = options.drag; 2171 disable(!drag); 2172 isFree = drag === "free"; 2173 } 2174 2175 function onPointerDown(e) { 2176 clickPrevented = false; 2177 2178 if (!disabled) { 2179 var isTouch = isTouchEvent(e); 2180 2181 if (isDraggable(e.target) && (isTouch || !e.button)) { 2182 if (!Controller.isBusy()) { 2183 target = isTouch ? track : window; 2184 dragging = state.is([MOVING, SCROLLING]); 2185 prevBaseEvent = null; 2186 bind(target, POINTER_MOVE_EVENTS, onPointerMove, SCROLL_LISTENER_OPTIONS); 2187 bind(target, POINTER_UP_EVENTS, onPointerUp, SCROLL_LISTENER_OPTIONS); 2188 Move.cancel(); 2189 Scroll.cancel(); 2190 save(e); 2191 } else { 2192 prevent(e, true); 2193 } 2194 } 2195 } 2196 } 2197 2198 function onPointerMove(e) { 2199 if (!state.is(DRAGGING)) { 2200 state.set(DRAGGING); 2201 emit(EVENT_DRAG); 2202 } 2203 2204 if (e.cancelable) { 2205 if (dragging) { 2206 Move.translate(basePosition + constrain(diffCoord(e))); 2207 var expired = diffTime(e) > LOG_INTERVAL; 2208 var hasExceeded = exceeded !== (exceeded = exceededLimit()); 2209 2210 if (expired || hasExceeded) { 2211 save(e); 2212 } 2213 2214 clickPrevented = true; 2215 emit(EVENT_DRAGGING); 2216 prevent(e); 2217 } else if (isSliderDirection(e)) { 2218 dragging = shouldStart(e); 2219 prevent(e); 2220 } 2221 } 2222 } 2223 2224 function onPointerUp(e) { 2225 if (state.is(DRAGGING)) { 2226 state.set(IDLE); 2227 emit(EVENT_DRAGGED); 2228 } 2229 2230 if (dragging) { 2231 move(e); 2232 prevent(e); 2233 } 2234 2235 unbind(target, POINTER_MOVE_EVENTS, onPointerMove); 2236 unbind(target, POINTER_UP_EVENTS, onPointerUp); 2237 dragging = false; 2238 } 2239 2240 function onClick(e) { 2241 if (!disabled && clickPrevented) { 2242 prevent(e, true); 2243 } 2244 } 2245 2246 function save(e) { 2247 prevBaseEvent = baseEvent; 2248 baseEvent = e; 2249 basePosition = getPosition(); 2250 } 2251 2252 function move(e) { 2253 var velocity = computeVelocity(e); 2254 var destination = computeDestination(velocity); 2255 var rewind = options.rewind && options.rewindByDrag; 2256 reduce(false); 2257 2258 if (isFree) { 2259 Controller.scroll(destination, 0, options.snap); 2260 } else if (Splide2.is(FADE)) { 2261 Controller.go(orient(sign(velocity)) < 0 ? rewind ? "<" : "-" : rewind ? ">" : "+"); 2262 } else if (Splide2.is(SLIDE) && exceeded && rewind) { 2263 Controller.go(exceededLimit(true) ? ">" : "<"); 2264 } else { 2265 Controller.go(Controller.toDest(destination), true); 2266 } 2267 2268 reduce(true); 2269 } 2270 2271 function shouldStart(e) { 2272 var thresholds = options.dragMinThreshold; 2273 var isObj = isObject(thresholds); 2274 var mouse = isObj && thresholds.mouse || 0; 2275 var touch = (isObj ? thresholds.touch : +thresholds) || 10; 2276 return abs(diffCoord(e)) > (isTouchEvent(e) ? touch : mouse); 2277 } 2278 2279 function isSliderDirection(e) { 2280 return abs(diffCoord(e)) > abs(diffCoord(e, true)); 2281 } 2282 2283 function computeVelocity(e) { 2284 if (Splide2.is(LOOP) || !exceeded) { 2285 var time = diffTime(e); 2286 2287 if (time && time < LOG_INTERVAL) { 2288 return diffCoord(e) / time; 2289 } 2290 } 2291 2292 return 0; 2293 } 2294 2295 function computeDestination(velocity) { 2296 return getPosition() + sign(velocity) * min(abs(velocity) * (options.flickPower || 600), isFree ? Infinity : Components2.Layout.listSize() * (options.flickMaxPages || 1)); 2297 } 2298 2299 function diffCoord(e, orthogonal) { 2300 return coordOf(e, orthogonal) - coordOf(getBaseEvent(e), orthogonal); 2301 } 2302 2303 function diffTime(e) { 2304 return timeOf(e) - timeOf(getBaseEvent(e)); 2305 } 2306 2307 function getBaseEvent(e) { 2308 return baseEvent === e && prevBaseEvent || baseEvent; 2309 } 2310 2311 function coordOf(e, orthogonal) { 2312 return (isTouchEvent(e) ? e.changedTouches[0] : e)["page" + resolve(orthogonal ? "Y" : "X")]; 2313 } 2314 2315 function constrain(diff) { 2316 return diff / (exceeded && Splide2.is(SLIDE) ? FRICTION : 1); 2317 } 2318 2319 function isDraggable(target2) { 2320 var noDrag = options.noDrag; 2321 return !matches(target2, "." + CLASS_PAGINATION_PAGE + ", ." + CLASS_ARROW) && (!noDrag || !matches(target2, noDrag)); 2322 } 2323 2324 function isTouchEvent(e) { 2325 return typeof TouchEvent !== "undefined" && e instanceof TouchEvent; 2326 } 2327 2328 function isDragging() { 2329 return dragging; 2330 } 2331 2332 function disable(value) { 2333 disabled = value; 2334 } 2335 2336 return { 2337 mount: mount, 2338 disable: disable, 2339 isDragging: isDragging 2340 }; 2341 } 2342 2343 var NORMALIZATION_MAP = { 2344 Spacebar: " ", 2345 Right: ARROW_RIGHT, 2346 Left: ARROW_LEFT, 2347 Up: ARROW_UP, 2348 Down: ARROW_DOWN 2349 }; 2350 2351 function normalizeKey(key) { 2352 key = isString(key) ? key : key.key; 2353 return NORMALIZATION_MAP[key] || key; 2354 } 2355 2356 var KEYBOARD_EVENT = "keydown"; 2357 2358 function Keyboard(Splide2, Components2, options) { 2359 var _EventInterface10 = EventInterface(Splide2), 2360 on = _EventInterface10.on, 2361 bind = _EventInterface10.bind, 2362 unbind = _EventInterface10.unbind; 2363 2364 var root = Splide2.root; 2365 var resolve = Components2.Direction.resolve; 2366 var target; 2367 var disabled; 2368 2369 function mount() { 2370 init(); 2371 on(EVENT_UPDATED, destroy); 2372 on(EVENT_UPDATED, init); 2373 on(EVENT_MOVE, onMove); 2374 } 2375 2376 function init() { 2377 var keyboard = options.keyboard; 2378 2379 if (keyboard) { 2380 target = keyboard === "global" ? window : root; 2381 bind(target, KEYBOARD_EVENT, onKeydown); 2382 } 2383 } 2384 2385 function destroy() { 2386 unbind(target, KEYBOARD_EVENT); 2387 } 2388 2389 function disable(value) { 2390 disabled = value; 2391 } 2392 2393 function onMove() { 2394 var _disabled = disabled; 2395 disabled = true; 2396 nextTick(function () { 2397 disabled = _disabled; 2398 }); 2399 } 2400 2401 function onKeydown(e) { 2402 if (!disabled) { 2403 var key = normalizeKey(e); 2404 2405 if (key === resolve(ARROW_LEFT)) { 2406 Splide2.go("<"); 2407 } else if (key === resolve(ARROW_RIGHT)) { 2408 Splide2.go(">"); 2409 } 2410 } 2411 } 2412 2413 return { 2414 mount: mount, 2415 destroy: destroy, 2416 disable: disable 2417 }; 2418 } 2419 2420 var SRC_DATA_ATTRIBUTE = DATA_ATTRIBUTE + "-lazy"; 2421 var SRCSET_DATA_ATTRIBUTE = SRC_DATA_ATTRIBUTE + "-srcset"; 2422 var IMAGE_SELECTOR = "[" + SRC_DATA_ATTRIBUTE + "], [" + SRCSET_DATA_ATTRIBUTE + "]"; 2423 2424 function LazyLoad(Splide2, Components2, options) { 2425 var _EventInterface11 = EventInterface(Splide2), 2426 on = _EventInterface11.on, 2427 off = _EventInterface11.off, 2428 bind = _EventInterface11.bind, 2429 emit = _EventInterface11.emit; 2430 2431 var isSequential = options.lazyLoad === "sequential"; 2432 var events = [EVENT_MOVED, EVENT_SCROLLED]; 2433 var entries = []; 2434 2435 function mount() { 2436 if (options.lazyLoad) { 2437 init(); 2438 on(EVENT_REFRESH, init); 2439 } 2440 } 2441 2442 function init() { 2443 empty(entries); 2444 register(); 2445 2446 if (isSequential) { 2447 loadNext(); 2448 } else { 2449 off(events); 2450 on(events, check); 2451 check(); 2452 } 2453 } 2454 2455 function register() { 2456 Components2.Slides.forEach(function (Slide) { 2457 queryAll(Slide.slide, IMAGE_SELECTOR).forEach(function (img) { 2458 var src = getAttribute(img, SRC_DATA_ATTRIBUTE); 2459 var srcset = getAttribute(img, SRCSET_DATA_ATTRIBUTE); 2460 2461 if (src !== img.src || srcset !== img.srcset) { 2462 var className = options.classes.spinner; 2463 var parent = img.parentElement; 2464 var spinner = child(parent, "." + className) || create("span", className, parent); 2465 entries.push([img, Slide, spinner]); 2466 img.src || display(img, "none"); 2467 } 2468 }); 2469 }); 2470 } 2471 2472 function check() { 2473 entries = entries.filter(function (data) { 2474 var distance = options.perPage * ((options.preloadPages || 1) + 1) - 1; 2475 return data[1].isWithin(Splide2.index, distance) ? load(data) : true; 2476 }); 2477 entries.length || off(events); 2478 } 2479 2480 function load(data) { 2481 var img = data[0]; 2482 addClass(data[1].slide, CLASS_LOADING); 2483 bind(img, "load error", apply(onLoad, data)); 2484 setAttribute(img, "src", getAttribute(img, SRC_DATA_ATTRIBUTE)); 2485 setAttribute(img, "srcset", getAttribute(img, SRCSET_DATA_ATTRIBUTE)); 2486 removeAttribute(img, SRC_DATA_ATTRIBUTE); 2487 removeAttribute(img, SRCSET_DATA_ATTRIBUTE); 2488 } 2489 2490 function onLoad(data, e) { 2491 var img = data[0], 2492 Slide = data[1]; 2493 removeClass(Slide.slide, CLASS_LOADING); 2494 2495 if (e.type !== "error") { 2496 remove(data[2]); 2497 display(img, ""); 2498 emit(EVENT_LAZYLOAD_LOADED, img, Slide); 2499 emit(EVENT_RESIZE); 2500 } 2501 2502 isSequential && loadNext(); 2503 } 2504 2505 function loadNext() { 2506 entries.length && load(entries.shift()); 2507 } 2508 2509 return { 2510 mount: mount, 2511 destroy: apply(empty, entries), 2512 check: check 2513 }; 2514 } 2515 2516 function Pagination(Splide2, Components2, options) { 2517 var event = EventInterface(Splide2); 2518 var on = event.on, 2519 emit = event.emit, 2520 bind = event.bind; 2521 var Slides = Components2.Slides, 2522 Elements = Components2.Elements, 2523 Controller = Components2.Controller; 2524 var hasFocus = Controller.hasFocus, 2525 getIndex = Controller.getIndex, 2526 go = Controller.go; 2527 var resolve = Components2.Direction.resolve; 2528 var placeholder = Elements.pagination; 2529 var items = []; 2530 var list; 2531 var paginationClasses; 2532 2533 function mount() { 2534 destroy(); 2535 on([EVENT_UPDATED, EVENT_REFRESH, EVENT_END_INDEX_CHANGED], mount); 2536 var enabled = options.pagination; 2537 placeholder && display(placeholder, enabled ? "" : "none"); 2538 2539 if (enabled) { 2540 on([EVENT_MOVE, EVENT_SCROLL, EVENT_SCROLLED], update); 2541 createPagination(); 2542 update(); 2543 emit(EVENT_PAGINATION_MOUNTED, { 2544 list: list, 2545 items: items 2546 }, getAt(Splide2.index)); 2547 } 2548 } 2549 2550 function destroy() { 2551 if (list) { 2552 remove(placeholder ? slice(list.children) : list); 2553 removeClass(list, paginationClasses); 2554 empty(items); 2555 list = null; 2556 } 2557 2558 event.destroy(); 2559 } 2560 2561 function createPagination() { 2562 var length = Splide2.length; 2563 var classes = options.classes, 2564 i18n = options.i18n, 2565 perPage = options.perPage; 2566 var max = hasFocus() ? Controller.getEnd() + 1 : ceil(length / perPage); 2567 list = placeholder || create("ul", classes.pagination, Elements.track.parentElement); 2568 addClass(list, paginationClasses = CLASS_PAGINATION + "--" + getDirection()); 2569 setAttribute(list, ROLE, "tablist"); 2570 setAttribute(list, ARIA_LABEL, i18n.select); 2571 setAttribute(list, ARIA_ORIENTATION, getDirection() === TTB ? "vertical" : ""); 2572 2573 for (var i = 0; i < max; i++) { 2574 var li = create("li", null, list); 2575 var button = create("button", { 2576 class: classes.page, 2577 type: "button", 2578 'data-elem-type':"container", 2579 'data-lp-selector':'.splide__pagination__page'
vendor: 14,262 bytes, lines 2579-3161
2579 2580 }, li); 2581 var controls = Slides.getIn(i).map(function (Slide) { 2582 return Slide.slide.id; 2583 }); 2584 var text = !hasFocus() && perPage > 1 ? i18n.pageX : i18n.slideX; 2585 bind(button, "click", apply(onClick, i)); 2586 2587 if (options.paginationKeyboard) { 2588 bind(button, "keydown", apply(onKeydown, i)); 2589 } 2590 2591 setAttribute(li, ROLE, "presentation"); 2592 setAttribute(button, ROLE, "tab"); 2593 setAttribute(button, ARIA_CONTROLS, controls.join(" ")); 2594 setAttribute(button, ARIA_LABEL, format(text, i + 1)); 2595 setAttribute(button, TAB_INDEX, -1); 2596 items.push({ 2597 li: li, 2598 button: button, 2599 page: i 2600 }); 2601 } 2602 } 2603 2604 function onClick(page) { 2605 go(">" + page, true); 2606 } 2607 2608 function onKeydown(page, e) { 2609 var length = items.length; 2610 var key = normalizeKey(e); 2611 var dir = getDirection(); 2612 var nextPage = -1; 2613 2614 if (key === resolve(ARROW_RIGHT, false, dir)) { 2615 nextPage = ++page % length; 2616 } else if (key === resolve(ARROW_LEFT, false, dir)) { 2617 nextPage = (--page + length) % length; 2618 } else if (key === "Home") { 2619 nextPage = 0; 2620 } else if (key === "End") { 2621 nextPage = length - 1; 2622 } 2623 2624 var item = items[nextPage]; 2625 2626 if (item) { 2627 focus(item.button); 2628 go(">" + nextPage); 2629 prevent(e, true); 2630 } 2631 } 2632 2633 function getDirection() { 2634 return options.paginationDirection || options.direction; 2635 } 2636 2637 function getAt(index) { 2638 return items[Controller.toPage(index)]; 2639 } 2640 2641 function update() { 2642 var prev = getAt(getIndex(true)); 2643 var curr = getAt(getIndex()); 2644 2645 if (prev) { 2646 var button = prev.button; 2647 removeClass(button, CLASS_ACTIVE); 2648 removeAttribute(button, ARIA_SELECTED); 2649 setAttribute(button, TAB_INDEX, -1); 2650 } 2651 2652 if (curr) { 2653 var _button = curr.button; 2654 addClass(_button, CLASS_ACTIVE); 2655 setAttribute(_button, ARIA_SELECTED, true); 2656 setAttribute(_button, TAB_INDEX, ""); 2657 } 2658 2659 emit(EVENT_PAGINATION_UPDATED, { 2660 list: list, 2661 items: items 2662 }, prev, curr); 2663 } 2664 2665 return { 2666 items: items, 2667 mount: mount, 2668 destroy: destroy, 2669 getAt: getAt, 2670 update: update 2671 }; 2672 } 2673 2674 var TRIGGER_KEYS = [" ", "Enter"]; 2675 2676 function Sync(Splide2, Components2, options) { 2677 var isNavigation = options.isNavigation, 2678 slideFocus = options.slideFocus; 2679 var events = []; 2680 2681 function mount() { 2682 Splide2.splides.forEach(function (target) { 2683 if (!target.isParent) { 2684 sync(Splide2, target.splide); 2685 sync(target.splide, Splide2); 2686 } 2687 }); 2688 2689 if (isNavigation) { 2690 navigate(); 2691 } 2692 } 2693 2694 function destroy() { 2695 events.forEach(function (event) { 2696 event.destroy(); 2697 }); 2698 empty(events); 2699 } 2700 2701 function remount() { 2702 destroy(); 2703 mount(); 2704 } 2705 2706 function sync(splide, target) { 2707 var event = EventInterface(splide); 2708 event.on(EVENT_MOVE, function (index, prev, dest) { 2709 target.go(target.is(LOOP) ? dest : index); 2710 }); 2711 events.push(event); 2712 } 2713 2714 function navigate() { 2715 var event = EventInterface(Splide2); 2716 var on = event.on; 2717 on(EVENT_CLICK, onClick); 2718 on(EVENT_SLIDE_KEYDOWN, onKeydown); 2719 on([EVENT_MOUNTED, EVENT_UPDATED], update); 2720 events.push(event); 2721 event.emit(EVENT_NAVIGATION_MOUNTED, Splide2.splides); 2722 } 2723 2724 function update() { 2725 setAttribute(Components2.Elements.list, ARIA_ORIENTATION, options.direction === TTB ? "vertical" : ""); 2726 } 2727 2728 function onClick(Slide) { 2729 Splide2.go(Slide.index); 2730 } 2731 2732 function onKeydown(Slide, e) { 2733 if (includes(TRIGGER_KEYS, normalizeKey(e))) { 2734 onClick(Slide); 2735 prevent(e); 2736 } 2737 } 2738 2739 return { 2740 setup: apply(Components2.Media.set, { 2741 slideFocus: isUndefined(slideFocus) ? isNavigation : slideFocus 2742 }, true), 2743 mount: mount, 2744 destroy: destroy, 2745 remount: remount 2746 }; 2747 } 2748 2749 function Wheel(Splide2, Components2, options) { 2750 var _EventInterface12 = EventInterface(Splide2), 2751 bind = _EventInterface12.bind; 2752 2753 var lastTime = 0; 2754 2755 function mount() { 2756 if (options.wheel) { 2757 bind(Components2.Elements.track, "wheel", onWheel, SCROLL_LISTENER_OPTIONS); 2758 } 2759 } 2760 2761 function onWheel(e) { 2762 if (e.cancelable) { 2763 var deltaY = e.deltaY; 2764 var backwards = deltaY < 0; 2765 var timeStamp = timeOf(e); 2766 2767 var _min = options.wheelMinThreshold || 0; 2768 2769 var sleep = options.wheelSleep || 0; 2770 2771 if (abs(deltaY) > _min && timeStamp - lastTime > sleep) { 2772 Splide2.go(backwards ? "<" : ">"); 2773 lastTime = timeStamp; 2774 } 2775 2776 shouldPrevent(backwards) && prevent(e); 2777 } 2778 } 2779 2780 function shouldPrevent(backwards) { 2781 return !options.releaseWheel || Splide2.state.is(MOVING) || Components2.Controller.getAdjacent(backwards) !== -1; 2782 } 2783 2784 return { 2785 mount: mount 2786 }; 2787 } 2788 2789 var SR_REMOVAL_DELAY = 90; 2790 2791 function Live(Splide2, Components2, options) { 2792 var _EventInterface13 = EventInterface(Splide2), 2793 on = _EventInterface13.on; 2794 2795 var track = Components2.Elements.track; 2796 var enabled = options.live && !options.isNavigation; 2797 var sr = create("span", CLASS_SR); 2798 var interval = RequestInterval(SR_REMOVAL_DELAY, apply(toggle, false)); 2799 2800 function mount() { 2801 if (enabled) { 2802 disable(!Components2.Autoplay.isPaused()); 2803 setAttribute(track, ARIA_ATOMIC, true); 2804 sr.textContent = "\u2026"; 2805 on(EVENT_AUTOPLAY_PLAY, apply(disable, true)); 2806 on(EVENT_AUTOPLAY_PAUSE, apply(disable, false)); 2807 on([EVENT_MOVED, EVENT_SCROLLED], apply(toggle, true)); 2808 } 2809 } 2810 2811 function toggle(active) { 2812 setAttribute(track, ARIA_BUSY, active); 2813 2814 if (active) { 2815 append(track, sr); 2816 interval.start(); 2817 } else { 2818 remove(sr); 2819 interval.cancel(); 2820 } 2821 } 2822 2823 function destroy() { 2824 removeAttribute(track, [ARIA_LIVE, ARIA_ATOMIC, ARIA_BUSY]); 2825 remove(sr); 2826 } 2827 2828 function disable(disabled) { 2829 if (enabled) { 2830 setAttribute(track, ARIA_LIVE, disabled ? "off" : "polite"); 2831 } 2832 } 2833 2834 return { 2835 mount: mount, 2836 disable: disable, 2837 destroy: destroy 2838 }; 2839 } 2840 2841 var ComponentConstructors = /*#__PURE__*/Object.freeze({ 2842 __proto__: null, 2843 Media: Media, 2844 Direction: Direction, 2845 Elements: Elements, 2846 Slides: Slides, 2847 Layout: Layout, 2848 Clones: Clones, 2849 Move: Move, 2850 Controller: Controller, 2851 Arrows: Arrows, 2852 Autoplay: Autoplay, 2853 Cover: Cover, 2854 Scroll: Scroll, 2855 Drag: Drag, 2856 Keyboard: Keyboard, 2857 LazyLoad: LazyLoad, 2858 Pagination: Pagination, 2859 Sync: Sync, 2860 Wheel: Wheel, 2861 Live: Live 2862 }); 2863 var I18N = { 2864 prev: "Previous slide", 2865 next: "Next slide", 2866 first: "Go to first slide", 2867 last: "Go to last slide", 2868 slideX: "Go to slide %s", 2869 pageX: "Go to page %s", 2870 play: "Start autoplay", 2871 pause: "Pause autoplay", 2872 carousel: "carousel", 2873 slide: "slide", 2874 select: "Select a slide to show", 2875 slideLabel: "%s of %s" 2876 }; 2877 var DEFAULTS = { 2878 type: "slide", 2879 role: "region", 2880 speed: 400, 2881 perPage: 1, 2882 cloneStatus: true, 2883 arrows: true, 2884 pagination: true, 2885 paginationKeyboard: true, 2886 interval: 5e3, 2887 pauseOnHover: true, 2888 pauseOnFocus: true, 2889 resetProgress: true, 2890 easing: "cubic-bezier(0.25, 1, 0.5, 1)", 2891 drag: true, 2892 direction: "ltr", 2893 trimSpace: true, 2894 focusableNodes: "a, button, textarea, input, select, iframe", 2895 live: true, 2896 classes: CLASSES, 2897 i18n: I18N, 2898 reducedMotion: { 2899 speed: 0, 2900 rewindSpeed: 0, 2901 autoplay: "pause" 2902 } 2903 }; 2904 2905 function Fade(Splide2, Components2, options) { 2906 var Slides = Components2.Slides; 2907 2908 function mount() { 2909 EventInterface(Splide2).on([EVENT_MOUNTED, EVENT_REFRESH], init); 2910 } 2911 2912 function init() { 2913 Slides.forEach(function (Slide) { 2914 Slide.style("transform", "translateX(-" + 100 * Slide.index + "%)"); 2915 }); 2916 } 2917 2918 function start(index, done) { 2919 Slides.style("transition", "opacity " + options.speed + "ms " + options.easing); 2920 nextTick(done); 2921 } 2922 2923 return { 2924 mount: mount, 2925 start: start, 2926 cancel: noop 2927 }; 2928 } 2929 2930 function Slide(Splide2, Components2, options) { 2931 var Move = Components2.Move, 2932 Controller = Components2.Controller, 2933 Scroll = Components2.Scroll; 2934 var list = Components2.Elements.list; 2935 var transition = apply(style, list, "transition"); 2936 var endCallback; 2937 2938 function mount() { 2939 EventInterface(Splide2).bind(list, "transitionend", function (e) { 2940 if (e.target === list && endCallback) { 2941 cancel(); 2942 endCallback(); 2943 } 2944 }); 2945 } 2946 2947 function start(index, done) { 2948 var destination = Move.toPosition(index, true); 2949 var position = Move.getPosition(); 2950 var speed = getSpeed(index); 2951 2952 if (abs(destination - position) >= 1 && speed >= 1) { 2953 if (options.useScroll) { 2954 Scroll.scroll(destination, speed, false, done); 2955 } else { 2956 transition("transform " + speed + "ms " + options.easing); 2957 Move.translate(destination, true); 2958 endCallback = done; 2959 } 2960 } else { 2961 Move.jump(index); 2962 done(); 2963 } 2964 } 2965 2966 function cancel() { 2967 transition(""); 2968 Scroll.cancel(); 2969 } 2970 2971 function getSpeed(index) { 2972 var rewindSpeed = options.rewindSpeed; 2973 2974 if (Splide2.is(SLIDE) && rewindSpeed) { 2975 var prev = Controller.getIndex(true); 2976 var end = Controller.getEnd(); 2977 2978 if (prev === 0 && index >= end || prev >= end && index === 0) { 2979 return rewindSpeed; 2980 } 2981 } 2982 2983 return options.speed; 2984 } 2985 2986 return { 2987 mount: mount, 2988 start: start, 2989 cancel: cancel 2990 }; 2991 } 2992 2993 var _Splide = /*#__PURE__*/function () { 2994 function _Splide(target, options) { 2995 this.event = EventInterface(); 2996 this.Components = {}; 2997 this.state = State(CREATED); 2998 this.splides = []; 2999 this._o = {}; 3000 this._E = {}; 3001 var root = isString(target) ? query(document, target) : target; 3002 assert(root, root + " is invalid."); 3003 this.root = root; 3004 options = merge({ 3005 label: getAttribute(root, ARIA_LABEL) || "", 3006 labelledby: getAttribute(root, ARIA_LABELLEDBY) || "" 3007 }, DEFAULTS, _Splide.defaults, options || {}); 3008 3009 try { 3010 merge(options, JSON.parse(getAttribute(root, DATA_ATTRIBUTE))); 3011 } catch (e) { 3012 assert(false, "Invalid JSON"); 3013 } 3014 3015 this._o = Object.create(merge({}, options)); 3016 } 3017 3018 var _proto = _Splide.prototype; 3019 3020 _proto.mount = function mount(Extensions, Transition) { 3021 var _this = this; 3022 3023 var state = this.state, 3024 Components2 = this.Components; 3025 assert(state.is([CREATED, DESTROYED]), "Already mounted!"); 3026 state.set(CREATED); 3027 this._C = Components2; 3028 this._T = Transition || this._T || (this.is(FADE) ? Fade : Slide); 3029 this._E = Extensions || this._E; 3030 var Constructors = assign({}, ComponentConstructors, this._E, { 3031 Transition: this._T 3032 }); 3033 forOwn(Constructors, function (Component, key) { 3034 var component = Component(_this, Components2, _this._o); 3035 Components2[key] = component; 3036 component.setup && component.setup(); 3037 }); 3038 forOwn(Components2, function (component) { 3039 component.mount && component.mount(); 3040 }); 3041 this.emit(EVENT_MOUNTED); 3042 addClass(this.root, CLASS_INITIALIZED); 3043 state.set(IDLE); 3044 this.emit(EVENT_READY); 3045 return this; 3046 }; 3047 3048 _proto.sync = function sync(splide) { 3049 this.splides.push({ 3050 splide: splide 3051 }); 3052 splide.splides.push({ 3053 splide: this, 3054 isParent: true 3055 }); 3056 3057 if (this.state.is(IDLE)) { 3058 this._C.Sync.remount(); 3059 3060 splide.Components.Sync.remount(); 3061 } 3062 3063 return this; 3064 }; 3065 3066 _proto.go = function go(control) { 3067 this._C.Controller.go(control); 3068 3069 return this; 3070 }; 3071 3072 _proto.on = function on(events, callback) { 3073 this.event.on(events, callback); 3074 return this; 3075 }; 3076 3077 _proto.off = function off(events) { 3078 this.event.off(events); 3079 return this; 3080 }; 3081 3082 _proto.emit = function emit(event) { 3083 var _this$event; 3084 3085 (_this$event = this.event).emit.apply(_this$event, [event].concat(slice(arguments, 1))); 3086 3087 return this; 3088 }; 3089 3090 _proto.add = function add(slides, index) { 3091 this._C.Slides.add(slides, index); 3092 3093 return this; 3094 }; 3095 3096 _proto.remove = function remove(matcher) { 3097 this._C.Slides.remove(matcher); 3098 3099 return this; 3100 }; 3101 3102 _proto.is = function is(type) { 3103 return this._o.type === type; 3104 }; 3105 3106 _proto.refresh = function refresh() { 3107 this.emit(EVENT_REFRESH); 3108 return this; 3109 }; 3110 3111 _proto.destroy = function destroy(completely) { 3112 if (completely === void 0) { 3113 completely = true; 3114 } 3115 3116 var event = this.event, 3117 state = this.state; 3118 3119 if (state.is(CREATED)) { 3120 EventInterface(this).on(EVENT_READY, this.destroy.bind(this, completely)); 3121 } else { 3122 forOwn(this._C, function (component) { 3123 component.destroy && component.destroy(completely); 3124 }, true); 3125 event.emit(EVENT_DESTROY); 3126 event.destroy(); 3127 completely && empty(this.splides); 3128 state.set(DESTROYED); 3129 } 3130 3131 return this; 3132 }; 3133 3134 _createClass(_Splide, [{ 3135 key: "options", 3136 get: function get() { 3137 return this._o; 3138 }, 3139 set: function set(options) { 3140 this._C.Media.set(options, true, true); 3141 } 3142 }, { 3143 key: "length", 3144 get: function get() { 3145 return this._C.Slides.getLength(true); 3146 } 3147 }, { 3148 key: "index", 3149 get: function get() { 3150 return this._C.Controller.getIndex(); 3151 } 3152 }]); 3153 3154 return _Splide; 3155 }(); 3156 3157 var Splide = _Splide; 3158 Splide.defaults = {}; 3159 Splide.STATES = STATES; 3160 return Splide; 3161});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.