vendor: 4,645 bytes, lines 1-208
1function isObject$1(obj) { 2 return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object; 3} 4function extend$1(target = {}, src = {}) { 5 const noExtend = ["__proto__", "constructor", "prototype"]; 6 Object.keys(src).filter((key) => noExtend.indexOf(key) < 0).forEach((key) => { 7 if (typeof target[key] === "undefined") target[key] = src[key]; 8 else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) { 9 extend$1(target[key], src[key]); 10 } 11 }); 12} 13const ssrDocument = { 14 body: {}, 15 addEventListener() { 16 }, 17 removeEventListener() { 18 }, 19 activeElement: { 20 blur() { 21 }, 22 nodeName: "" 23 }, 24 querySelector() { 25 return null; 26 }, 27 querySelectorAll() { 28 return []; 29 }, 30 getElementById() { 31 return null; 32 }, 33 createEvent() { 34 return { 35 initEvent() { 36 } 37 }; 38 }, 39 createElement() { 40 return { 41 children: [], 42 childNodes: [], 43 style: {}, 44 setAttribute() { 45 }, 46 getElementsByTagName() { 47 return []; 48 } 49 }; 50 }, 51 createElementNS() { 52 return {}; 53 }, 54 importNode() { 55 return null; 56 }, 57 location: { 58 hash: "", 59 host: "", 60 hostname: "", 61 href: "", 62 origin: "", 63 pathname: "", 64 protocol: "", 65 search: "" 66 } 67}; 68function getDocument() { 69 const doc = typeof document !== "undefined" ? document : {}; 70 extend$1(doc, ssrDocument); 71 return doc; 72} 73const ssrWindow = { 74 document: ssrDocument, 75 navigator: { 76 userAgent: "" 77 }, 78 location: { 79 hash: "", 80 host: "", 81 hostname: "", 82 href: "", 83 origin: "", 84 pathname: "", 85 protocol: "", 86 search: "" 87 }, 88 history: { 89 replaceState() { 90 }, 91 pushState() { 92 }, 93 go() { 94 }, 95 back() { 96 } 97 }, 98 CustomEvent: function CustomEvent() { 99 return this; 100 }, 101 addEventListener() { 102 }, 103 removeEventListener() { 104 }, 105 getComputedStyle() { 106 return { 107 getPropertyValue() { 108 return ""; 109 } 110 }; 111 }, 112 Image() { 113 }, 114 Date() { 115 }, 116 screen: {}, 117 setTimeout() { 118 }, 119 clearTimeout() { 120 }, 121 matchMedia() { 122 return {}; 123 }, 124 requestAnimationFrame(callback) { 125 if (typeof setTimeout === "undefined") { 126 callback(); 127 return null; 128 } 129 return setTimeout(callback, 0); 130 }, 131 cancelAnimationFrame(id) { 132 if (typeof setTimeout === "undefined") { 133 return; 134 } 135 clearTimeout(id); 136 } 137}; 138function getWindow() { 139 const win = typeof window !== "undefined" ? window : {}; 140 extend$1(win, ssrWindow); 141 return win; 142} 143function classesToTokens(classes2 = "") { 144 return classes2.trim().split(" ").filter((c) => !!c.trim()); 145} 146function deleteProps(obj) { 147 const object = obj; 148 Object.keys(object).forEach((key) => { 149 try { 150 object[key] = null; 151 } catch (e) { 152 } 153 try { 154 delete object[key]; 155 } catch (e) { 156 } 157 }); 158} 159function nextTick(callback, delay = 0) { 160 return setTimeout(callback, delay); 161} 162function now() { 163 return Date.now(); 164} 165function getComputedStyle$1(el) { 166 const window2 = getWindow(); 167 let style; 168 if (window2.getComputedStyle) { 169 style = window2.getComputedStyle(el, null); 170 } 171 if (!style && el.currentStyle) { 172 style = el.currentStyle; 173 } 174 if (!style) { 175 style = el.style; 176 } 177 return style; 178} 179function getTranslate(el, axis = "x") { 180 const window2 = getWindow(); 181 let matrix; 182 let curTransform; 183 let transformMatrix; 184 const curStyle = getComputedStyle$1(el); 185 if (window2.WebKitCSSMatrix) { 186 curTransform = curStyle.transform || curStyle.webkitTransform; 187 if (curTransform.split(",").length > 6) { 188 curTransform = curTransform.split(", ").map((a) => a.replace(",", ".")).join(", "); 189 } 190 transformMatrix = new window2.WebKitCSSMatrix(curTransform === "none" ? "" : curTransform); 191 } else { 192 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue("transform").replace("translate(", "matrix(1, 0, 0, 1,"); 193 matrix = transformMatrix.toString().split(","); 194 } 195 if (axis === "x") { 196 if (window2.WebKitCSSMatrix) curTransform = transformMatrix.m41; 197 else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); 198 else curTransform = parseFloat(matrix[4]); 199 } 200 if (axis === "y") { 201 if (window2.WebKitCSSMatrix) curTransform = transformMatrix.m42; 202 else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); 203 else curTransform = parseFloat(matrix[5]); 204 } 205 return curTransform || 0; 206} 207function isObject(o) { 208 return typeof o === "object" && o !== null && o.constructor && Ob
vendor: 4,789 bytes, lines 208-342
208ject.prototype.toString.call(o).slice(8, -1) === "Object"; 209} 210function isNode(node) { 211 if (typeof window !== "undefined" && typeof window.HTMLElement !== "undefined") { 212 return node instanceof HTMLElement; 213 } 214 return node && (node.nodeType === 1 || node.nodeType === 11); 215} 216function extend(...args) { 217 const to = Object(args[0]); 218 const noExtend = ["__proto__", "constructor", "prototype"]; 219 for (let i = 1; i < args.length; i += 1) { 220 const nextSource = args[i]; 221 if (nextSource !== void 0 && nextSource !== null && !isNode(nextSource)) { 222 const keysArray = Object.keys(Object(nextSource)).filter((key) => noExtend.indexOf(key) < 0); 223 for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { 224 const nextKey = keysArray[nextIndex]; 225 const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 226 if (desc !== void 0 && desc.enumerable) { 227 if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 228 if (nextSource[nextKey].__swiper__) { 229 to[nextKey] = nextSource[nextKey]; 230 } else { 231 extend(to[nextKey], nextSource[nextKey]); 232 } 233 } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 234 to[nextKey] = {}; 235 if (nextSource[nextKey].__swiper__) { 236 to[nextKey] = nextSource[nextKey]; 237 } else { 238 extend(to[nextKey], nextSource[nextKey]); 239 } 240 } else { 241 to[nextKey] = nextSource[nextKey]; 242 } 243 } 244 } 245 } 246 } 247 return to; 248} 249function setCSSProperty(el, varName, varValue) { 250 el.style.setProperty(varName, varValue); 251} 252function animateCSSModeScroll({ 253 swiper, 254 targetPosition, 255 side 256}) { 257 const window2 = getWindow(); 258 const startPosition = -swiper.translate; 259 let startTime = null; 260 let time; 261 const duration = swiper.params.speed; 262 swiper.wrapperEl.style.scrollSnapType = "none"; 263 window2.cancelAnimationFrame(swiper.cssModeFrameID); 264 const dir = targetPosition > startPosition ? "next" : "prev"; 265 const isOutOfBound = (current, target) => { 266 return dir === "next" && current >= target || dir === "prev" && current <= target; 267 }; 268 const animate = () => { 269 time = (/* @__PURE__ */ new Date()).getTime(); 270 if (startTime === null) { 271 startTime = time; 272 } 273 const progress = Math.max(Math.min((time - startTime) / duration, 1), 0); 274 const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2; 275 let currentPosition = startPosition + easeProgress * (targetPosition - startPosition); 276 if (isOutOfBound(currentPosition, targetPosition)) { 277 currentPosition = targetPosition; 278 } 279 swiper.wrapperEl.scrollTo({ 280 [side]: currentPosition 281 }); 282 if (isOutOfBound(currentPosition, targetPosition)) { 283 swiper.wrapperEl.style.overflow = "hidden"; 284 swiper.wrapperEl.style.scrollSnapType = ""; 285 setTimeout(() => { 286 swiper.wrapperEl.style.overflow = ""; 287 swiper.wrapperEl.scrollTo({ 288 [side]: currentPosition 289 }); 290 }); 291 window2.cancelAnimationFrame(swiper.cssModeFrameID); 292 return; 293 } 294 swiper.cssModeFrameID = window2.requestAnimationFrame(animate); 295 }; 296 animate(); 297} 298function getSlideTransformEl(slideEl) { 299 return slideEl.querySelector(".swiper-slide-transform") || slideEl.shadowRoot && slideEl.shadowRoot.querySelector(".swiper-slide-transform") || slideEl; 300} 301function elementChildren(element, selector = "") { 302 const window2 = getWindow(); 303 const children = [...element.children]; 304 if (window2.HTMLSlotElement && element instanceof HTMLSlotElement) { 305 children.push(...element.assignedElements()); 306 } 307 if (!selector) { 308 return children; 309 } 310 return children.filter((el) => el.matches(selector)); 311} 312function elementIsChildOfSlot(el, slot) { 313 const elementsQueue = [slot]; 314 while (elementsQueue.length > 0) { 315 const elementToCheck = elementsQueue.shift(); 316 if (el === elementToCheck) { 317 return true; 318 } 319 elementsQueue.push(...elementToCheck.children, ...elementToCheck.shadowRoot ? elementToCheck.shadowRoot.children : [], ...elementToCheck.assignedElements ? elementToCheck.assignedElements() : []); 320 } 321} 322function elementIsChildOf(el, parent) { 323 const window2 = getWindow(); 324 let isChild = parent.contains(el); 325 if (!isChild && window2.HTMLSlotElement && parent instanceof HTMLSlotElement) { 326 const children = [...parent.assignedElements()]; 327 isChild = children.includes(el); 328 if (!isChild) { 329 isChild = elementIsChildOfSlot(el, parent); 330 } 331 } 332 return isChild; 333} 334function showWarning(text) { 335 try { 336 console.warn(text); 337 return; 338 } catch (err) { 339 } 340} 341function createElement(tag, classes2 = []) { 342 const el = document.createElement(tag);
vendor: 8,807 bytes, lines 343-627
343 el.classList.add(...Array.isArray(classes2) ? classes2 : classesToTokens(classes2)); 344 return el; 345} 346function elementPrevAll(el, selector) { 347 const prevEls = []; 348 while (el.previousElementSibling) { 349 const prev = el.previousElementSibling; 350 if (selector) { 351 if (prev.matches(selector)) prevEls.push(prev); 352 } else prevEls.push(prev); 353 el = prev; 354 } 355 return prevEls; 356} 357function elementNextAll(el, selector) { 358 const nextEls = []; 359 while (el.nextElementSibling) { 360 const next = el.nextElementSibling; 361 if (selector) { 362 if (next.matches(selector)) nextEls.push(next); 363 } else nextEls.push(next); 364 el = next; 365 } 366 return nextEls; 367} 368function elementStyle(el, prop) { 369 const window2 = getWindow(); 370 return window2.getComputedStyle(el, null).getPropertyValue(prop); 371} 372function elementIndex(el) { 373 let child = el; 374 let i; 375 if (child) { 376 i = 0; 377 while ((child = child.previousSibling) !== null) { 378 if (child.nodeType === 1) i += 1; 379 } 380 return i; 381 } 382 return void 0; 383} 384function elementParents(el, selector) { 385 const parents = []; 386 let parent = el.parentElement; 387 while (parent) { 388 if (selector) { 389 if (parent.matches(selector)) parents.push(parent); 390 } else { 391 parents.push(parent); 392 } 393 parent = parent.parentElement; 394 } 395 return parents; 396} 397function elementTransitionEnd(el, callback) { 398 function fireCallBack(e) { 399 if (e.target !== el) return; 400 callback.call(el, e); 401 el.removeEventListener("transitionend", fireCallBack); 402 } 403 if (callback) { 404 el.addEventListener("transitionend", fireCallBack); 405 } 406} 407function elementOuterSize(el, size, includeMargins) { 408 const window2 = getWindow(); 409 { 410 return el[size === "width" ? "offsetWidth" : "offsetHeight"] + parseFloat(window2.getComputedStyle(el, null).getPropertyValue(size === "width" ? "margin-right" : "margin-top")) + parseFloat(window2.getComputedStyle(el, null).getPropertyValue(size === "width" ? "margin-left" : "margin-bottom")); 411 } 412} 413function makeElementsArray(el) { 414 return (Array.isArray(el) ? el : [el]).filter((e) => !!e); 415} 416function setInnerHTML(el, html = "") { 417 if (typeof trustedTypes !== "undefined") { 418 el.innerHTML = trustedTypes.createPolicy("html", { 419 createHTML: (s) => s 420 }).createHTML(html); 421 } else { 422 el.innerHTML = html; 423 } 424} 425let support; 426function calcSupport() { 427 const window2 = getWindow(); 428 const document2 = getDocument(); 429 return { 430 smoothScroll: document2.documentElement && document2.documentElement.style && "scrollBehavior" in document2.documentElement.style, 431 touch: !!("ontouchstart" in window2 || window2.DocumentTouch && document2 instanceof window2.DocumentTouch) 432 }; 433} 434function getSupport() { 435 if (!support) { 436 support = calcSupport(); 437 } 438 return support; 439} 440let deviceCached; 441function calcDevice({ 442 userAgent 443} = {}) { 444 const support2 = getSupport(); 445 const window2 = getWindow(); 446 const platform = window2.navigator.platform; 447 const ua = userAgent || window2.navigator.userAgent; 448 const device = { 449 ios: false, 450 android: false 451 }; 452 const screenWidth = window2.screen.width; 453 const screenHeight = window2.screen.height; 454 const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); 455 let ipad = ua.match(/(iPad)(?!\1).*OS\s([\d_]+)/); 456 const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); 457 const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); 458 const windows = platform === "Win32"; 459 let macos = platform === "MacIntel"; 460 const iPadScreens = ["1024x1366", "1366x1024", "834x1194", "1194x834", "834x1112", "1112x834", "768x1024", "1024x768", "820x1180", "1180x820", "810x1080", "1080x810"]; 461 if (!ipad && macos && support2.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) { 462 ipad = ua.match(/(Version)\/([\d.]+)/); 463 if (!ipad) ipad = [0, 1, "13_0_0"]; 464 macos = false; 465 } 466 if (android && !windows) { 467 device.os = "android"; 468 device.android = true; 469 } 470 if (ipad || iphone || ipod) { 471 device.os = "ios"; 472 device.ios = true; 473 } 474 return device; 475} 476function getDevice(overrides = {}) { 477 if (!deviceCached) { 478 deviceCached = calcDevice(overrides); 479 } 480 return deviceCached; 481} 482let browser; 483function calcBrowser() { 484 const window2 = getWindow(); 485 const device = getDevice(); 486 let needPerspectiveFix = false; 487 function isSafari() { 488 const ua = window2.navigator.userAgent.toLowerCase(); 489 return ua.indexOf("safari") >= 0 && ua.indexOf("chrome") < 0 && ua.indexOf("android") < 0; 490 } 491 if (isSafari()) { 492 const ua = String(window2.navigator.userAgent); 493 if (ua.includes("Version/")) { 494 const [major, minor] = ua.split("Version/")[1].split(" ")[0].split(".").map((num) => Number(num)); 495 needPerspectiveFix = major < 16 || major === 16 && minor < 2; 496 } 497 } 498 const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window2.navigator.userAgent); 499 const isSafariBrowser = isSafari(); 500 const need3dFix = isSafariBrowser || isWebView && device.ios; 501 return { 502 isSafari: needPerspectiveFix || isSafariBrowser, 503 needPerspectiveFix, 504 need3dFix, 505 isWebView 506 }; 507} 508function getBrowser() { 509 if (!browser) { 510 browser = calcBrowser(); 511 } 512 return browser; 513} 514function Resize({ 515 swiper, 516 on, 517 emit 518}) { 519 const window2 = getWindow(); 520 let observer = null; 521 let animationFrame = null; 522 const resizeHandler = () => { 523 if (!swiper || swiper.destroyed || !swiper.initialized) return; 524 emit("beforeResize"); 525 emit("resize"); 526 }; 527 const createObserver = () => { 528 if (!swiper || swiper.destroyed || !swiper.initialized) return; 529 observer = new ResizeObserver((entries) => { 530 animationFrame = window2.requestAnimationFrame(() => { 531 const { 532 width, 533 height 534 } = swiper; 535 let newWidth = width; 536 let newHeight = height; 537 entries.forEach(({ 538 contentBoxSize, 539 contentRect, 540 target 541 }) => { 542 if (target && target !== swiper.el) return; 543 newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize; 544 newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize; 545 }); 546 if (newWidth !== width || newHeight !== height) { 547 resizeHandler(); 548 } 549 }); 550 }); 551 observer.observe(swiper.el); 552 }; 553 const removeObserver = () => { 554 if (animationFrame) { 555 window2.cancelAnimationFrame(animationFrame); 556 } 557 if (observer && observer.unobserve && swiper.el) { 558 observer.unobserve(swiper.el); 559 observer = null; 560 } 561 }; 562 const orientationChangeHandler = () => { 563 if (!swiper || swiper.destroyed || !swiper.initialized) return; 564 emit("orientationchange"); 565 }; 566 on("init", () => { 567 if (swiper.params.resizeObserver && typeof window2.ResizeObserver !== "undefined") { 568 createObserver(); 569 return; 570 } 571 window2.addEventListener("resize", resizeHandler); 572 window2.addEventListener("orientationchange", orientationChangeHandler); 573 }); 574 on("destroy", () => { 575 removeObserver(); 576 window2.removeEventListener("resize", resizeHandler); 577 window2.removeEventListener("orientationchange", orientationChangeHandler); 578 }); 579} 580function Observer({ 581 swiper, 582 extendParams, 583 on, 584 emit 585}) { 586 const observers = []; 587 const window2 = getWindow(); 588 const attach = (target, options = {}) => { 589 const ObserverFunc = window2.MutationObserver || window2.WebkitMutationObserver; 590 const observer = new ObserverFunc((mutations) => { 591 if (swiper.__preventObserver__) return; 592 if (mutations.length === 1) { 593 emit("observerUpdate", mutations[0]); 594 return; 595 } 596 const observerUpdate = function observerUpdate2() { 597 emit("observerUpdate", mutations[0]); 598 }; 599 if (window2.requestAnimationFrame) { 600 window2.requestAnimationFrame(observerUpdate); 601 } else { 602 window2.setTimeout(observerUpdate, 0); 603 } 604 }); 605 observer.observe(target, { 606 attributes: typeof options.attributes === "undefined" ? true : options.attributes, 607 childList: swiper.isElement || (typeof options.childList === "undefined" ? true : options).childList, 608 characterData: typeof options.characterData === "undefined" ? true : options.characterData 609 }); 610 observers.push(observer); 611 }; 612 const init = () => { 613 if (!swiper.params.observer) return; 614 if (swiper.params.observeParents) { 615 const containerParents = elementParents(swiper.hostEl); 616 for (let i = 0; i < containerParents.length; i += 1) { 617 attach(containerParents[i]); 618 } 619 } 620 attach(swiper.hostEl, { 621 childList: swiper.params.observeSlideChildren 622 }); 623 attach(swiper.wrapperEl, { 624 attributes: false 625 }); 626 }; 627 const destroy = () => {
vendor: 5,307 bytes, lines 628-785
628 observers.forEach((observer) => { 629 observer.disconnect(); 630 }); 631 observers.splice(0, observers.length); 632 }; 633 extendParams({ 634 observer: false, 635 observeParents: false, 636 observeSlideChildren: false 637 }); 638 on("init", init); 639 on("destroy", destroy); 640} 641var eventsEmitter = { 642 on(events2, handler, priority) { 643 const self = this; 644 if (!self.eventsListeners || self.destroyed) return self; 645 if (typeof handler !== "function") return self; 646 const method = priority ? "unshift" : "push"; 647 events2.split(" ").forEach((event) => { 648 if (!self.eventsListeners[event]) self.eventsListeners[event] = []; 649 self.eventsListeners[event][method](handler); 650 }); 651 return self; 652 }, 653 once(events2, handler, priority) { 654 const self = this; 655 if (!self.eventsListeners || self.destroyed) return self; 656 if (typeof handler !== "function") return self; 657 function onceHandler(...args) { 658 self.off(events2, onceHandler); 659 if (onceHandler.__emitterProxy) { 660 delete onceHandler.__emitterProxy; 661 } 662 handler.apply(self, args); 663 } 664 onceHandler.__emitterProxy = handler; 665 return self.on(events2, onceHandler, priority); 666 }, 667 onAny(handler, priority) { 668 const self = this; 669 if (!self.eventsListeners || self.destroyed) return self; 670 if (typeof handler !== "function") return self; 671 const method = priority ? "unshift" : "push"; 672 if (self.eventsAnyListeners.indexOf(handler) < 0) { 673 self.eventsAnyListeners[method](handler); 674 } 675 return self; 676 }, 677 offAny(handler) { 678 const self = this; 679 if (!self.eventsListeners || self.destroyed) return self; 680 if (!self.eventsAnyListeners) return self; 681 const index = self.eventsAnyListeners.indexOf(handler); 682 if (index >= 0) { 683 self.eventsAnyListeners.splice(index, 1); 684 } 685 return self; 686 }, 687 off(events2, handler) { 688 const self = this; 689 if (!self.eventsListeners || self.destroyed) return self; 690 if (!self.eventsListeners) return self; 691 events2.split(" ").forEach((event) => { 692 if (typeof handler === "undefined") { 693 self.eventsListeners[event] = []; 694 } else if (self.eventsListeners[event]) { 695 self.eventsListeners[event].forEach((eventHandler, index) => { 696 if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) { 697 self.eventsListeners[event].splice(index, 1); 698 } 699 }); 700 } 701 }); 702 return self; 703 }, 704 emit(...args) { 705 const self = this; 706 if (!self.eventsListeners || self.destroyed) return self; 707 if (!self.eventsListeners) return self; 708 let events2; 709 let data; 710 let context; 711 if (typeof args[0] === "string" || Array.isArray(args[0])) { 712 events2 = args[0]; 713 data = args.slice(1, args.length); 714 context = self; 715 } else { 716 events2 = args[0].events; 717 data = args[0].data; 718 context = args[0].context || self; 719 } 720 data.unshift(context); 721 const eventsArray = Array.isArray(events2) ? events2 : events2.split(" "); 722 eventsArray.forEach((event) => { 723 if (self.eventsAnyListeners && self.eventsAnyListeners.length) { 724 self.eventsAnyListeners.forEach((eventHandler) => { 725 eventHandler.apply(context, [event, ...data]); 726 }); 727 } 728 if (self.eventsListeners && self.eventsListeners[event]) { 729 self.eventsListeners[event].forEach((eventHandler) => { 730 eventHandler.apply(context, data); 731 }); 732 } 733 }); 734 return self; 735 } 736}; 737function updateSize() { 738 const swiper = this; 739 let width; 740 let height; 741 const el = swiper.el; 742 if (typeof swiper.params.width !== "undefined" && swiper.params.width !== null) { 743 width = swiper.params.width; 744 } else { 745 width = el.clientWidth; 746 } 747 if (typeof swiper.params.height !== "undefined" && swiper.params.height !== null) { 748 height = swiper.params.height; 749 } else { 750 height = el.clientHeight; 751 } 752 if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) { 753 return; 754 } 755 width = width - parseInt(elementStyle(el, "padding-left") || 0, 10) - parseInt(elementStyle(el, "padding-right") || 0, 10); 756 height = height - parseInt(elementStyle(el, "padding-top") || 0, 10) - parseInt(elementStyle(el, "padding-bottom") || 0, 10); 757 if (Number.isNaN(width)) width = 0; 758 if (Number.isNaN(height)) height = 0; 759 Object.assign(swiper, { 760 width, 761 height, 762 size: swiper.isHorizontal() ? width : height 763 }); 764} 765function updateSlides() { 766 const swiper = this; 767 function getDirectionPropertyValue(node, label) { 768 return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0); 769 } 770 const params = swiper.params; 771 const { 772 wrapperEl, 773 slidesEl, 774 rtlTranslate: rtl, 775 wrongRTL 776 } = swiper; 777 const isVirtual = swiper.virtual && params.virtual.enabled; 778 const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; 779 const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`); 780 const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; 781 let snapGrid = []; 782 const slidesGrid = []; 783 const slidesSizesGrid = []; 784 let offsetBefore = params.slidesOffsetBefore; 785 if (typeof offsetBefore === "function") {
vendor: 6,205 bytes, lines 786-930
786 offsetBefore = params.slidesOffsetBefore.call(swiper); 787 } 788 let offsetAfter = params.slidesOffsetAfter; 789 if (typeof offsetAfter === "function") { 790 offsetAfter = params.slidesOffsetAfter.call(swiper); 791 } 792 const previousSnapGridLength = swiper.snapGrid.length; 793 const previousSlidesGridLength = swiper.slidesGrid.length; 794 const swiperSize = swiper.size - offsetBefore - offsetAfter; 795 let spaceBetween = params.spaceBetween; 796 let slidePosition = -offsetBefore; 797 let prevSlideSize = 0; 798 let index = 0; 799 if (typeof swiperSize === "undefined") { 800 return; 801 } 802 if (typeof spaceBetween === "string" && spaceBetween.indexOf("%") >= 0) { 803 spaceBetween = parseFloat(spaceBetween.replace("%", "")) / 100 * swiperSize; 804 } else if (typeof spaceBetween === "string") { 805 spaceBetween = parseFloat(spaceBetween); 806 } 807 swiper.virtualSize = -spaceBetween - offsetBefore - offsetAfter; 808 slides.forEach((slideEl) => { 809 if (rtl) { 810 slideEl.style.marginLeft = ""; 811 } else { 812 slideEl.style.marginRight = ""; 813 } 814 slideEl.style.marginBottom = ""; 815 slideEl.style.marginTop = ""; 816 }); 817 if (params.centeredSlides && params.cssMode) { 818 setCSSProperty(wrapperEl, "--swiper-centered-offset-before", ""); 819 setCSSProperty(wrapperEl, "--swiper-centered-offset-after", ""); 820 } 821 const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid; 822 if (gridEnabled) { 823 swiper.grid.initSlides(slides); 824 } else if (swiper.grid) { 825 swiper.grid.unsetSlides(); 826 } 827 let slideSize; 828 const shouldResetSlideSize = params.slidesPerView === "auto" && params.breakpoints && Object.keys(params.breakpoints).filter((key) => { 829 return typeof params.breakpoints[key].slidesPerView !== "undefined"; 830 }).length > 0; 831 for (let i = 0; i < slidesLength; i += 1) { 832 slideSize = 0; 833 const slide2 = slides[i]; 834 if (slide2) { 835 if (gridEnabled) { 836 swiper.grid.updateSlide(i, slide2, slides); 837 } 838 if (elementStyle(slide2, "display") === "none") continue; 839 } 840 if (isVirtual && params.slidesPerView === "auto") { 841 if (params.virtual.slidesPerViewAutoSlideSize) { 842 slideSize = params.virtual.slidesPerViewAutoSlideSize; 843 } 844 if (slideSize && slide2) { 845 if (params.roundLengths) slideSize = Math.floor(slideSize); 846 slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`; 847 } 848 } else if (params.slidesPerView === "auto") { 849 if (shouldResetSlideSize) { 850 slide2.style[swiper.getDirectionLabel("width")] = ``; 851 } 852 const slideStyles = getComputedStyle(slide2); 853 const currentTransform = slide2.style.transform; 854 const currentWebKitTransform = slide2.style.webkitTransform; 855 if (currentTransform) { 856 slide2.style.transform = "none"; 857 } 858 if (currentWebKitTransform) { 859 slide2.style.webkitTransform = "none"; 860 } 861 if (params.roundLengths) { 862 slideSize = swiper.isHorizontal() ? elementOuterSize(slide2, "width") : elementOuterSize(slide2, "height"); 863 } else { 864 const width = getDirectionPropertyValue(slideStyles, "width"); 865 const paddingLeft = getDirectionPropertyValue(slideStyles, "padding-left"); 866 const paddingRight = getDirectionPropertyValue(slideStyles, "padding-right"); 867 const marginLeft = getDirectionPropertyValue(slideStyles, "margin-left"); 868 const marginRight = getDirectionPropertyValue(slideStyles, "margin-right"); 869 const boxSizing = slideStyles.getPropertyValue("box-sizing"); 870 if (boxSizing && boxSizing === "border-box") { 871 slideSize = width + marginLeft + marginRight; 872 } else { 873 const { 874 clientWidth, 875 offsetWidth 876 } = slide2; 877 slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth); 878 } 879 } 880 if (currentTransform) { 881 slide2.style.transform = currentTransform; 882 } 883 if (currentWebKitTransform) { 884 slide2.style.webkitTransform = currentWebKitTransform; 885 } 886 if (params.roundLengths) slideSize = Math.floor(slideSize); 887 } else { 888 slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView; 889 if (params.roundLengths) slideSize = Math.floor(slideSize); 890 if (slide2) { 891 slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`; 892 } 893 } 894 if (slide2) { 895 slide2.swiperSlideSize = slideSize; 896 } 897 slidesSizesGrid.push(slideSize); 898 if (params.centeredSlides) { 899 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; 900 if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 901 if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 902 if (Math.abs(slidePosition) < 1 / 1e3) slidePosition = 0; 903 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 904 if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition); 905 slidesGrid.push(slidePosition); 906 } else { 907 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 908 if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition); 909 slidesGrid.push(slidePosition); 910 slidePosition = slidePosition + slideSize + spaceBetween; 911 } 912 swiper.virtualSize += slideSize + spaceBetween; 913 prevSlideSize = slideSize; 914 index += 1; 915 } 916 swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; 917 if (rtl && wrongRTL && (params.effect === "slide" || params.effect === "coverflow")) { 918 wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`; 919 } 920 if (params.setWrapperSize) { 921 wrapperEl.style[swiper.getDirectionLabel("width")] = `${swiper.virtualSize + spaceBetween}px`; 922 } 923 if (gridEnabled) { 924 swiper.grid.updateWrapperSize(slideSize, snapGrid); 925 } 926 if (!params.centeredSlides) { 927 const newSlidesGrid = []; 928 for (let i = 0; i < snapGrid.length; i += 1) { 929 let slidesGridItem = snapGrid[i]; 930 if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
vendor: 6,007 bytes, lines 931-1083
931 if (snapGrid[i] <= swiper.virtualSize - swiperSize) { 932 newSlidesGrid.push(slidesGridItem); 933 } 934 } 935 snapGrid = newSlidesGrid; 936 if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { 937 snapGrid.push(swiper.virtualSize - swiperSize); 938 } 939 } 940 if (isVirtual && params.loop) { 941 const size = slidesSizesGrid[0] + spaceBetween; 942 if (params.slidesPerGroup > 1) { 943 const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup); 944 const groupSize = size * params.slidesPerGroup; 945 for (let i = 0; i < groups; i += 1) { 946 snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize); 947 } 948 } 949 for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) { 950 if (params.slidesPerGroup === 1) { 951 snapGrid.push(snapGrid[snapGrid.length - 1] + size); 952 } 953 slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size); 954 swiper.virtualSize += size; 955 } 956 } 957 if (snapGrid.length === 0) snapGrid = [0]; 958 if (spaceBetween !== 0) { 959 const key = swiper.isHorizontal() && rtl ? "marginLeft" : swiper.getDirectionLabel("marginRight"); 960 slides.filter((_, slideIndex) => { 961 if (!params.cssMode || params.loop) return true; 962 if (slideIndex === slides.length - 1) { 963 return false; 964 } 965 return true; 966 }).forEach((slideEl) => { 967 slideEl.style[key] = `${spaceBetween}px`; 968 }); 969 } 970 if (params.centeredSlides && params.centeredSlidesBounds) { 971 let allSlidesSize = 0; 972 slidesSizesGrid.forEach((slideSizeValue) => { 973 allSlidesSize += slideSizeValue + (spaceBetween || 0); 974 }); 975 allSlidesSize -= spaceBetween; 976 const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0; 977 snapGrid = snapGrid.map((snap) => { 978 if (snap <= 0) return -offsetBefore; 979 if (snap > maxSnap) return maxSnap + offsetAfter; 980 return snap; 981 }); 982 } 983 if (params.centerInsufficientSlides) { 984 let allSlidesSize = 0; 985 slidesSizesGrid.forEach((slideSizeValue) => { 986 allSlidesSize += slideSizeValue + (spaceBetween || 0); 987 }); 988 allSlidesSize -= spaceBetween; 989 const offsetSize = (offsetBefore || 0) + (offsetAfter || 0); 990 if (allSlidesSize + offsetSize < swiperSize) { 991 const allSlidesOffset = (swiperSize - allSlidesSize - offsetSize) / 2; 992 snapGrid.forEach((snap, snapIndex) => { 993 snapGrid[snapIndex] = snap - allSlidesOffset; 994 }); 995 slidesGrid.forEach((snap, snapIndex) => { 996 slidesGrid[snapIndex] = snap + allSlidesOffset; 997 }); 998 } 999 } 1000 Object.assign(swiper, { 1001 slides, 1002 snapGrid, 1003 slidesGrid, 1004 slidesSizesGrid 1005 }); 1006 if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) { 1007 setCSSProperty(wrapperEl, "--swiper-centered-offset-before", `${-snapGrid[0]}px`); 1008 setCSSProperty(wrapperEl, "--swiper-centered-offset-after", `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`); 1009 const addToSnapGrid = -swiper.snapGrid[0]; 1010 const addToSlidesGrid = -swiper.slidesGrid[0]; 1011 swiper.snapGrid = swiper.snapGrid.map((v) => v + addToSnapGrid); 1012 swiper.slidesGrid = swiper.slidesGrid.map((v) => v + addToSlidesGrid); 1013 } 1014 if (slidesLength !== previousSlidesLength) { 1015 swiper.emit("slidesLengthChange"); 1016 } 1017 if (snapGrid.length !== previousSnapGridLength) { 1018 if (swiper.params.watchOverflow) swiper.checkOverflow(); 1019 swiper.emit("snapGridLengthChange"); 1020 } 1021 if (slidesGrid.length !== previousSlidesGridLength) { 1022 swiper.emit("slidesGridLengthChange"); 1023 } 1024 if (params.watchSlidesProgress) { 1025 swiper.updateSlidesOffset(); 1026 } 1027 swiper.emit("slidesUpdated"); 1028 if (!isVirtual && !params.cssMode && (params.effect === "slide" || params.effect === "fade")) { 1029 const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`; 1030 const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass); 1031 if (slidesLength <= params.maxBackfaceHiddenSlides) { 1032 if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass); 1033 } else if (hasClassBackfaceClassAdded) { 1034 swiper.el.classList.remove(backFaceHiddenClass); 1035 } 1036 } 1037} 1038function updateAutoHeight(speed) { 1039 const swiper = this; 1040 const activeSlides = []; 1041 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 1042 let newHeight = 0; 1043 let i; 1044 if (typeof speed === "number") { 1045 swiper.setTransition(speed); 1046 } else if (speed === true) { 1047 swiper.setTransition(swiper.params.speed); 1048 } 1049 const getSlideByIndex = (index) => { 1050 if (isVirtual) { 1051 return swiper.slides[swiper.getSlideIndexByData(index)]; 1052 } 1053 return swiper.slides[index]; 1054 }; 1055 if (swiper.params.slidesPerView !== "auto" && swiper.params.slidesPerView > 1) { 1056 if (swiper.params.centeredSlides) { 1057 (swiper.visibleSlides || []).forEach((slide2) => { 1058 activeSlides.push(slide2); 1059 }); 1060 } else { 1061 for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { 1062 const index = swiper.activeIndex + i; 1063 if (index > swiper.slides.length && !isVirtual) break; 1064 activeSlides.push(getSlideByIndex(index)); 1065 } 1066 } 1067 } else { 1068 activeSlides.push(getSlideByIndex(swiper.activeIndex)); 1069 } 1070 for (i = 0; i < activeSlides.length; i += 1) { 1071 if (typeof activeSlides[i] !== "undefined") { 1072 const height = activeSlides[i].offsetHeight; 1073 newHeight = height > newHeight ? height : newHeight; 1074 } 1075 } 1076 if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`; 1077} 1078function updateSlidesOffset() { 1079 const swiper = this; 1080 const slides = swiper.slides; 1081 const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0; 1082 for (let i = 0; i < slides.length; i += 1) { 1083 slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minu
vendor: 2,147 bytes, lines 1083-1128
1083sOffset - swiper.cssOverflowAdjustment(); 1084 } 1085} 1086const toggleSlideClasses$1 = (slideEl, condition, className) => { 1087 if (condition && !slideEl.classList.contains(className)) { 1088 slideEl.classList.add(className); 1089 } else if (!condition && slideEl.classList.contains(className)) { 1090 slideEl.classList.remove(className); 1091 } 1092}; 1093function updateSlidesProgress(translate2 = this && this.translate || 0) { 1094 const swiper = this; 1095 const params = swiper.params; 1096 const { 1097 slides, 1098 rtlTranslate: rtl, 1099 snapGrid 1100 } = swiper; 1101 if (slides.length === 0) return; 1102 if (typeof slides[0].swiperSlideOffset === "undefined") swiper.updateSlidesOffset(); 1103 let offsetCenter = -translate2; 1104 if (rtl) offsetCenter = translate2; 1105 swiper.visibleSlidesIndexes = []; 1106 swiper.visibleSlides = []; 1107 let spaceBetween = params.spaceBetween; 1108 if (typeof spaceBetween === "string" && spaceBetween.indexOf("%") >= 0) { 1109 spaceBetween = parseFloat(spaceBetween.replace("%", "")) / 100 * swiper.size; 1110 } else if (typeof spaceBetween === "string") { 1111 spaceBetween = parseFloat(spaceBetween); 1112 } 1113 for (let i = 0; i < slides.length; i += 1) { 1114 const slide2 = slides[i]; 1115 let slideOffset = slide2.swiperSlideOffset; 1116 if (params.cssMode && params.centeredSlides) { 1117 slideOffset -= slides[0].swiperSlideOffset; 1118 } 1119 const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween); 1120 const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween); 1121 const slideBefore = -(offsetCenter - slideOffset); 1122 const slideAfter = slideBefore + swiper.slidesSizesGrid[i]; 1123 const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i]; 1124 const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size; 1125 if (isVisible) { 1126 swiper.visibleSlides.push(slide2); 1127 swiper.visibleSlidesIndexes.push(i); 1128 }
vendor: 4,456 bytes, lines 1129-1248
1129 toggleSlideClasses$1(slide2, isVisible, params.slideVisibleClass); 1130 toggleSlideClasses$1(slide2, isFullyVisible, params.slideFullyVisibleClass); 1131 slide2.progress = rtl ? -slideProgress : slideProgress; 1132 slide2.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress; 1133 } 1134} 1135function updateProgress(translate2) { 1136 const swiper = this; 1137 if (typeof translate2 === "undefined") { 1138 const multiplier = swiper.rtlTranslate ? -1 : 1; 1139 translate2 = swiper && swiper.translate && swiper.translate * multiplier || 0; 1140 } 1141 const params = swiper.params; 1142 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 1143 let { 1144 progress, 1145 isBeginning, 1146 isEnd, 1147 progressLoop 1148 } = swiper; 1149 const wasBeginning = isBeginning; 1150 const wasEnd = isEnd; 1151 if (translatesDiff === 0) { 1152 progress = 0; 1153 isBeginning = true; 1154 isEnd = true; 1155 } else { 1156 progress = (translate2 - swiper.minTranslate()) / translatesDiff; 1157 const isBeginningRounded = Math.abs(translate2 - swiper.minTranslate()) < 1; 1158 const isEndRounded = Math.abs(translate2 - swiper.maxTranslate()) < 1; 1159 isBeginning = isBeginningRounded || progress <= 0; 1160 isEnd = isEndRounded || progress >= 1; 1161 if (isBeginningRounded) progress = 0; 1162 if (isEndRounded) progress = 1; 1163 } 1164 if (params.loop) { 1165 const firstSlideIndex = swiper.getSlideIndexByData(0); 1166 const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1); 1167 const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex]; 1168 const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex]; 1169 const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1]; 1170 const translateAbs = Math.abs(translate2); 1171 if (translateAbs >= firstSlideTranslate) { 1172 progressLoop = (translateAbs - firstSlideTranslate) / translateMax; 1173 } else { 1174 progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax; 1175 } 1176 if (progressLoop > 1) progressLoop -= 1; 1177 } 1178 Object.assign(swiper, { 1179 progress, 1180 progressLoop, 1181 isBeginning, 1182 isEnd 1183 }); 1184 if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate2); 1185 if (isBeginning && !wasBeginning) { 1186 swiper.emit("reachBeginning toEdge"); 1187 } 1188 if (isEnd && !wasEnd) { 1189 swiper.emit("reachEnd toEdge"); 1190 } 1191 if (wasBeginning && !isBeginning || wasEnd && !isEnd) { 1192 swiper.emit("fromEdge"); 1193 } 1194 swiper.emit("progress", progress); 1195} 1196const toggleSlideClasses = (slideEl, condition, className) => { 1197 if (condition && !slideEl.classList.contains(className)) { 1198 slideEl.classList.add(className); 1199 } else if (!condition && slideEl.classList.contains(className)) { 1200 slideEl.classList.remove(className); 1201 } 1202}; 1203function updateSlidesClasses() { 1204 const swiper = this; 1205 const { 1206 slides, 1207 params, 1208 slidesEl, 1209 activeIndex 1210 } = swiper; 1211 const isVirtual = swiper.virtual && params.virtual.enabled; 1212 const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1; 1213 const getFilteredSlide = (selector) => { 1214 return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0]; 1215 }; 1216 let activeSlide; 1217 let prevSlide; 1218 let nextSlide; 1219 if (isVirtual) { 1220 if (params.loop) { 1221 let slideIndex = activeIndex - swiper.virtual.slidesBefore; 1222 if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex; 1223 if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length; 1224 activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`); 1225 } else { 1226 activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`); 1227 } 1228 } else { 1229 if (gridEnabled) { 1230 activeSlide = slides.find((slideEl) => slideEl.column === activeIndex); 1231 nextSlide = slides.find((slideEl) => slideEl.column === activeIndex + 1); 1232 prevSlide = slides.find((slideEl) => slideEl.column === activeIndex - 1); 1233 } else { 1234 activeSlide = slides[activeIndex]; 1235 } 1236 } 1237 if (activeSlide) { 1238 if (!gridEnabled) { 1239 nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0]; 1240 if (params.loop && !nextSlide) { 1241 nextSlide = slides[0]; 1242 } 1243 prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0]; 1244 if (params.loop && !prevSlide === 0) { 1245 prevSlide = slides[slides.length - 1]; 1246 } 1247 } 1248 }
vendor: 4,377 bytes, lines 1249-1364
1249 slides.forEach((slideEl) => { 1250 toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass); 1251 toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass); 1252 toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass); 1253 }); 1254 swiper.emitSlidesClasses(); 1255} 1256const processLazyPreloader = (swiper, imageEl) => { 1257 if (!swiper || swiper.destroyed || !swiper.params) return; 1258 const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`; 1259 const slideEl = imageEl.closest(slideSelector()); 1260 if (slideEl) { 1261 let lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`); 1262 if (!lazyEl && swiper.isElement) { 1263 if (slideEl.shadowRoot) { 1264 lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`); 1265 } else { 1266 requestAnimationFrame(() => { 1267 if (slideEl.shadowRoot) { 1268 lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`); 1269 if (lazyEl) lazyEl.remove(); 1270 } 1271 }); 1272 } 1273 } 1274 if (lazyEl) lazyEl.remove(); 1275 } 1276}; 1277const unlazy = (swiper, index) => { 1278 if (!swiper.slides[index]) return; 1279 const imageEl = swiper.slides[index].querySelector('[loading="lazy"]'); 1280 if (imageEl) imageEl.removeAttribute("loading"); 1281}; 1282const preload = (swiper) => { 1283 if (!swiper || swiper.destroyed || !swiper.params) return; 1284 let amount = swiper.params.lazyPreloadPrevNext; 1285 const len = swiper.slides.length; 1286 if (!len || !amount || amount < 0) return; 1287 amount = Math.min(amount, len); 1288 const slidesPerView = swiper.params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView); 1289 const activeIndex = swiper.activeIndex; 1290 if (swiper.params.grid && swiper.params.grid.rows > 1) { 1291 const activeColumn = activeIndex; 1292 const preloadColumns = [activeColumn - amount]; 1293 preloadColumns.push(...Array.from({ 1294 length: amount 1295 }).map((_, i) => { 1296 return activeColumn + slidesPerView + i; 1297 })); 1298 swiper.slides.forEach((slideEl, i) => { 1299 if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i); 1300 }); 1301 return; 1302 } 1303 const slideIndexLastInView = activeIndex + slidesPerView - 1; 1304 if (swiper.params.rewind || swiper.params.loop) { 1305 for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) { 1306 const realIndex = (i % len + len) % len; 1307 if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex); 1308 } 1309 } else { 1310 for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) { 1311 if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) { 1312 unlazy(swiper, i); 1313 } 1314 } 1315 } 1316}; 1317function getActiveIndexByTranslate(swiper) { 1318 const { 1319 slidesGrid, 1320 params 1321 } = swiper; 1322 const translate2 = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 1323 let activeIndex; 1324 for (let i = 0; i < slidesGrid.length; i += 1) { 1325 if (typeof slidesGrid[i + 1] !== "undefined") { 1326 if (translate2 >= slidesGrid[i] && translate2 < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) { 1327 activeIndex = i; 1328 } else if (translate2 >= slidesGrid[i] && translate2 < slidesGrid[i + 1]) { 1329 activeIndex = i + 1; 1330 } 1331 } else if (translate2 >= slidesGrid[i]) { 1332 activeIndex = i; 1333 } 1334 } 1335 if (params.normalizeSlideIndex) { 1336 if (activeIndex < 0 || typeof activeIndex === "undefined") activeIndex = 0; 1337 } 1338 return activeIndex; 1339} 1340function updateActiveIndex(newActiveIndex) { 1341 const swiper = this; 1342 const translate2 = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 1343 const { 1344 snapGrid, 1345 params, 1346 activeIndex: previousIndex, 1347 realIndex: previousRealIndex, 1348 snapIndex: previousSnapIndex 1349 } = swiper; 1350 let activeIndex = newActiveIndex; 1351 let snapIndex; 1352 const getVirtualRealIndex = (aIndex) => { 1353 let realIndex2 = aIndex - swiper.virtual.slidesBefore; 1354 if (realIndex2 < 0) { 1355 realIndex2 = swiper.virtual.slides.length + realIndex2; 1356 } 1357 if (realIndex2 >= swiper.virtual.slides.length) { 1358 realIndex2 -= swiper.virtual.slides.length; 1359 } 1360 return realIndex2; 1361 }; 1362 if (typeof activeIndex === "undefined") { 1363 activeIndex = getActiveIndexByTranslate(swiper); 1364 }
vendor: 7,525 bytes, lines 1365-1601
1365 if (snapGrid.indexOf(translate2) >= 0) { 1366 snapIndex = snapGrid.indexOf(translate2); 1367 } else { 1368 const skip = Math.min(params.slidesPerGroupSkip, activeIndex); 1369 snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup); 1370 } 1371 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 1372 if (activeIndex === previousIndex && !swiper.params.loop) { 1373 if (snapIndex !== previousSnapIndex) { 1374 swiper.snapIndex = snapIndex; 1375 swiper.emit("snapIndexChange"); 1376 } 1377 return; 1378 } 1379 if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) { 1380 swiper.realIndex = getVirtualRealIndex(activeIndex); 1381 return; 1382 } 1383 const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1; 1384 let realIndex; 1385 if (swiper.virtual && params.virtual.enabled && params.loop) { 1386 realIndex = getVirtualRealIndex(activeIndex); 1387 } else if (gridEnabled) { 1388 const firstSlideInColumn = swiper.slides.find((slideEl) => slideEl.column === activeIndex); 1389 let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute("data-swiper-slide-index"), 10); 1390 if (Number.isNaN(activeSlideIndex)) { 1391 activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0); 1392 } 1393 realIndex = Math.floor(activeSlideIndex / params.grid.rows); 1394 } else if (swiper.slides[activeIndex]) { 1395 const slideIndex = swiper.slides[activeIndex].getAttribute("data-swiper-slide-index"); 1396 if (slideIndex) { 1397 realIndex = parseInt(slideIndex, 10); 1398 } else { 1399 realIndex = activeIndex; 1400 } 1401 } else { 1402 realIndex = activeIndex; 1403 } 1404 Object.assign(swiper, { 1405 previousSnapIndex, 1406 snapIndex, 1407 previousRealIndex, 1408 realIndex, 1409 previousIndex, 1410 activeIndex 1411 }); 1412 if (swiper.initialized) { 1413 preload(swiper); 1414 } 1415 swiper.emit("activeIndexChange"); 1416 swiper.emit("snapIndexChange"); 1417 if (swiper.initialized || swiper.params.runCallbacksOnInit) { 1418 if (previousRealIndex !== realIndex) { 1419 swiper.emit("realIndexChange"); 1420 } 1421 swiper.emit("slideChange"); 1422 } 1423} 1424function updateClickedSlide(el, path) { 1425 const swiper = this; 1426 const params = swiper.params; 1427 let slide2 = el.closest(`.${params.slideClass}, swiper-slide`); 1428 if (!slide2 && swiper.isElement && path && path.length > 1 && path.includes(el)) { 1429 [...path.slice(path.indexOf(el) + 1, path.length)].forEach((pathEl) => { 1430 if (!slide2 && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) { 1431 slide2 = pathEl; 1432 } 1433 }); 1434 } 1435 let slideFound = false; 1436 let slideIndex; 1437 if (slide2) { 1438 for (let i = 0; i < swiper.slides.length; i += 1) { 1439 if (swiper.slides[i] === slide2) { 1440 slideFound = true; 1441 slideIndex = i; 1442 break; 1443 } 1444 } 1445 } 1446 if (slide2 && slideFound) { 1447 swiper.clickedSlide = slide2; 1448 if (swiper.virtual && swiper.params.virtual.enabled) { 1449 swiper.clickedIndex = parseInt(slide2.getAttribute("data-swiper-slide-index"), 10); 1450 } else { 1451 swiper.clickedIndex = slideIndex; 1452 } 1453 } else { 1454 swiper.clickedSlide = void 0; 1455 swiper.clickedIndex = void 0; 1456 return; 1457 } 1458 if (params.slideToClickedSlide && swiper.clickedIndex !== void 0 && swiper.clickedIndex !== swiper.activeIndex) { 1459 swiper.slideToClickedSlide(); 1460 } 1461} 1462var update = { 1463 updateSize, 1464 updateSlides, 1465 updateAutoHeight, 1466 updateSlidesOffset, 1467 updateSlidesProgress, 1468 updateProgress, 1469 updateSlidesClasses, 1470 updateActiveIndex, 1471 updateClickedSlide 1472}; 1473function getSwiperTranslate(axis = this.isHorizontal() ? "x" : "y") { 1474 const swiper = this; 1475 const { 1476 params, 1477 rtlTranslate: rtl, 1478 translate: translate2, 1479 wrapperEl 1480 } = swiper; 1481 if (params.virtualTranslate) { 1482 return rtl ? -translate2 : translate2; 1483 } 1484 if (params.cssMode) { 1485 return translate2; 1486 } 1487 let currentTranslate = getTranslate(wrapperEl, axis); 1488 currentTranslate += swiper.cssOverflowAdjustment(); 1489 if (rtl) currentTranslate = -currentTranslate; 1490 return currentTranslate || 0; 1491} 1492function setTranslate(translate2, byController) { 1493 const swiper = this; 1494 const { 1495 rtlTranslate: rtl, 1496 params, 1497 wrapperEl, 1498 progress 1499 } = swiper; 1500 let x = 0; 1501 let y = 0; 1502 const z = 0; 1503 if (swiper.isHorizontal()) { 1504 x = rtl ? -translate2 : translate2; 1505 } else { 1506 y = translate2; 1507 } 1508 if (params.roundLengths) { 1509 x = Math.floor(x); 1510 y = Math.floor(y); 1511 } 1512 swiper.previousTranslate = swiper.translate; 1513 swiper.translate = swiper.isHorizontal() ? x : y; 1514 if (params.cssMode) { 1515 wrapperEl[swiper.isHorizontal() ? "scrollLeft" : "scrollTop"] = swiper.isHorizontal() ? -x : -y; 1516 } else if (!params.virtualTranslate) { 1517 if (swiper.isHorizontal()) { 1518 x -= swiper.cssOverflowAdjustment(); 1519 } else { 1520 y -= swiper.cssOverflowAdjustment(); 1521 } 1522 wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`; 1523 } 1524 let newProgress; 1525 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 1526 if (translatesDiff === 0) { 1527 newProgress = 0; 1528 } else { 1529 newProgress = (translate2 - swiper.minTranslate()) / translatesDiff; 1530 } 1531 if (newProgress !== progress) { 1532 swiper.updateProgress(translate2); 1533 } 1534 swiper.emit("setTranslate", swiper.translate, byController); 1535} 1536function minTranslate() { 1537 return -this.snapGrid[0]; 1538} 1539function maxTranslate() { 1540 return -this.snapGrid[this.snapGrid.length - 1]; 1541} 1542function translateTo(translate2 = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) { 1543 const swiper = this; 1544 const { 1545 params, 1546 wrapperEl 1547 } = swiper; 1548 if (swiper.animating && params.preventInteractionOnTransition) { 1549 return false; 1550 } 1551 const minTranslate2 = swiper.minTranslate(); 1552 const maxTranslate2 = swiper.maxTranslate(); 1553 let newTranslate; 1554 if (translateBounds && translate2 > minTranslate2) newTranslate = minTranslate2; 1555 else if (translateBounds && translate2 < maxTranslate2) newTranslate = maxTranslate2; 1556 else newTranslate = translate2; 1557 swiper.updateProgress(newTranslate); 1558 if (params.cssMode) { 1559 const isH = swiper.isHorizontal(); 1560 if (speed === 0) { 1561 wrapperEl[isH ? "scrollLeft" : "scrollTop"] = -newTranslate; 1562 } else { 1563 if (!swiper.support.smoothScroll) { 1564 animateCSSModeScroll({ 1565 swiper, 1566 targetPosition: -newTranslate, 1567 side: isH ? "left" : "top" 1568 }); 1569 return true; 1570 } 1571 wrapperEl.scrollTo({ 1572 [isH ? "left" : "top"]: -newTranslate, 1573 behavior: "smooth" 1574 }); 1575 } 1576 return true; 1577 } 1578 if (speed === 0) { 1579 swiper.setTransition(0); 1580 swiper.setTranslate(newTranslate); 1581 if (runCallbacks) { 1582 swiper.emit("beforeTransitionStart", speed, internal); 1583 swiper.emit("transitionEnd"); 1584 } 1585 } else { 1586 swiper.setTransition(speed); 1587 swiper.setTranslate(newTranslate); 1588 if (runCallbacks) { 1589 swiper.emit("beforeTransitionStart", speed, internal); 1590 swiper.emit("transitionStart"); 1591 } 1592 if (!swiper.animating) { 1593 swiper.animating = true; 1594 if (!swiper.onTranslateToWrapperTransitionEnd) { 1595 swiper.onTranslateToWrapperTransitionEnd = function transitionEnd2(e) { 1596 if (!swiper || swiper.destroyed) return; 1597 if (e.target !== this) return; 1598 swiper.wrapperEl.removeEventListener("transitionend", swiper.onTranslateToWrapperTransitionEnd); 1599 swiper.onTranslateToWrapperTransitionEnd = null; 1600 delete swiper.onTranslateToWrapperTransitionEnd; 1601 swiper.animating = false;
vendor: 22,967 bytes, lines 1602-2225
1602 if (runCallbacks) { 1603 swiper.emit("transitionEnd"); 1604 } 1605 }; 1606 } 1607 swiper.wrapperEl.addEventListener("transitionend", swiper.onTranslateToWrapperTransitionEnd); 1608 } 1609 } 1610 return true; 1611} 1612var translate = { 1613 getTranslate: getSwiperTranslate, 1614 setTranslate, 1615 minTranslate, 1616 maxTranslate, 1617 translateTo 1618}; 1619function setTransition(duration, byController) { 1620 const swiper = this; 1621 if (!swiper.params.cssMode) { 1622 swiper.wrapperEl.style.transitionDuration = `${duration}ms`; 1623 swiper.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : ""; 1624 } 1625 swiper.emit("setTransition", duration, byController); 1626} 1627function transitionEmit({ 1628 swiper, 1629 runCallbacks, 1630 direction, 1631 step 1632}) { 1633 const { 1634 activeIndex, 1635 previousIndex 1636 } = swiper; 1637 let dir = direction; 1638 if (!dir) { 1639 if (activeIndex > previousIndex) dir = "next"; 1640 else if (activeIndex < previousIndex) dir = "prev"; 1641 else dir = "reset"; 1642 } 1643 swiper.emit(`transition${step}`); 1644 if (runCallbacks && dir === "reset") { 1645 swiper.emit(`slideResetTransition${step}`); 1646 } else if (runCallbacks && activeIndex !== previousIndex) { 1647 swiper.emit(`slideChangeTransition${step}`); 1648 if (dir === "next") { 1649 swiper.emit(`slideNextTransition${step}`); 1650 } else { 1651 swiper.emit(`slidePrevTransition${step}`); 1652 } 1653 } 1654} 1655function transitionStart(runCallbacks = true, direction) { 1656 const swiper = this; 1657 const { 1658 params 1659 } = swiper; 1660 if (params.cssMode) return; 1661 if (params.autoHeight) { 1662 swiper.updateAutoHeight(); 1663 } 1664 transitionEmit({ 1665 swiper, 1666 runCallbacks, 1667 direction, 1668 step: "Start" 1669 }); 1670} 1671function transitionEnd(runCallbacks = true, direction) { 1672 const swiper = this; 1673 const { 1674 params 1675 } = swiper; 1676 swiper.animating = false; 1677 if (params.cssMode) return; 1678 swiper.setTransition(0); 1679 transitionEmit({ 1680 swiper, 1681 runCallbacks, 1682 direction, 1683 step: "End" 1684 }); 1685} 1686var transition = { 1687 setTransition, 1688 transitionStart, 1689 transitionEnd 1690}; 1691function slideTo(index = 0, speed, runCallbacks = true, internal, initial) { 1692 if (typeof index === "string") { 1693 index = parseInt(index, 10); 1694 } 1695 const swiper = this; 1696 let slideIndex = index; 1697 if (slideIndex < 0) slideIndex = 0; 1698 const { 1699 params, 1700 snapGrid, 1701 slidesGrid, 1702 previousIndex, 1703 activeIndex, 1704 rtlTranslate: rtl, 1705 wrapperEl, 1706 enabled 1707 } = swiper; 1708 if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) { 1709 return false; 1710 } 1711 if (typeof speed === "undefined") { 1712 speed = swiper.params.speed; 1713 } 1714 const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); 1715 let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); 1716 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 1717 const translate2 = -snapGrid[snapIndex]; 1718 if (params.normalizeSlideIndex) { 1719 for (let i = 0; i < slidesGrid.length; i += 1) { 1720 const normalizedTranslate = -Math.floor(translate2 * 100); 1721 const normalizedGrid = Math.floor(slidesGrid[i] * 100); 1722 const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100); 1723 if (typeof slidesGrid[i + 1] !== "undefined") { 1724 if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) { 1725 slideIndex = i; 1726 } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) { 1727 slideIndex = i + 1; 1728 } 1729 } else if (normalizedTranslate >= normalizedGrid) { 1730 slideIndex = i; 1731 } 1732 } 1733 } 1734 if (swiper.initialized && slideIndex !== activeIndex) { 1735 if (!swiper.allowSlideNext && (rtl ? translate2 > swiper.translate && translate2 > swiper.minTranslate() : translate2 < swiper.translate && translate2 < swiper.minTranslate())) { 1736 return false; 1737 } 1738 if (!swiper.allowSlidePrev && translate2 > swiper.translate && translate2 > swiper.maxTranslate()) { 1739 if ((activeIndex || 0) !== slideIndex) { 1740 return false; 1741 } 1742 } 1743 } 1744 if (slideIndex !== (previousIndex || 0) && runCallbacks) { 1745 swiper.emit("beforeSlideChangeStart"); 1746 } 1747 swiper.updateProgress(translate2); 1748 let direction; 1749 if (slideIndex > activeIndex) direction = "next"; 1750 else if (slideIndex < activeIndex) direction = "prev"; 1751 else direction = "reset"; 1752 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 1753 const isInitialVirtual = isVirtual && initial; 1754 if (!isInitialVirtual && (rtl && -translate2 === swiper.translate || !rtl && translate2 === swiper.translate)) { 1755 swiper.updateActiveIndex(slideIndex); 1756 if (params.autoHeight) { 1757 swiper.updateAutoHeight(); 1758 } 1759 swiper.updateSlidesClasses(); 1760 if (params.effect !== "slide") { 1761 swiper.setTranslate(translate2); 1762 } 1763 if (direction !== "reset") { 1764 swiper.transitionStart(runCallbacks, direction); 1765 swiper.transitionEnd(runCallbacks, direction); 1766 } 1767 return false; 1768 } 1769 if (params.cssMode) { 1770 const isH = swiper.isHorizontal(); 1771 const t = rtl ? translate2 : -translate2; 1772 if (speed === 0) { 1773 if (isVirtual) { 1774 swiper.wrapperEl.style.scrollSnapType = "none"; 1775 swiper._immediateVirtual = true; 1776 } 1777 if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) { 1778 swiper._cssModeVirtualInitialSet = true; 1779 requestAnimationFrame(() => { 1780 wrapperEl[isH ? "scrollLeft" : "scrollTop"] = t; 1781 }); 1782 } else { 1783 wrapperEl[isH ? "scrollLeft" : "scrollTop"] = t; 1784 } 1785 if (isVirtual) { 1786 requestAnimationFrame(() => { 1787 swiper.wrapperEl.style.scrollSnapType = ""; 1788 swiper._immediateVirtual = false; 1789 }); 1790 } 1791 } else { 1792 if (!swiper.support.smoothScroll) { 1793 animateCSSModeScroll({ 1794 swiper, 1795 targetPosition: t, 1796 side: isH ? "left" : "top" 1797 }); 1798 return true; 1799 } 1800 wrapperEl.scrollTo({ 1801 [isH ? "left" : "top"]: t, 1802 behavior: "smooth" 1803 }); 1804 } 1805 return true; 1806 } 1807 const browser2 = getBrowser(); 1808 const isSafari = browser2.isSafari; 1809 if (isVirtual && !initial && isSafari && swiper.isElement) { 1810 swiper.virtual.update(false, false, slideIndex); 1811 } 1812 swiper.setTransition(speed); 1813 swiper.setTranslate(translate2); 1814 swiper.updateActiveIndex(slideIndex); 1815 swiper.updateSlidesClasses(); 1816 swiper.emit("beforeTransitionStart", speed, internal); 1817 swiper.transitionStart(runCallbacks, direction); 1818 if (speed === 0) { 1819 swiper.transitionEnd(runCallbacks, direction); 1820 } else if (!swiper.animating) { 1821 swiper.animating = true; 1822 if (!swiper.onSlideToWrapperTransitionEnd) { 1823 swiper.onSlideToWrapperTransitionEnd = function transitionEnd2(e) { 1824 if (!swiper || swiper.destroyed) return; 1825 if (e.target !== this) return; 1826 swiper.wrapperEl.removeEventListener("transitionend", swiper.onSlideToWrapperTransitionEnd); 1827 swiper.onSlideToWrapperTransitionEnd = null; 1828 delete swiper.onSlideToWrapperTransitionEnd; 1829 swiper.transitionEnd(runCallbacks, direction); 1830 }; 1831 } 1832 swiper.wrapperEl.addEventListener("transitionend", swiper.onSlideToWrapperTransitionEnd); 1833 } 1834 return true; 1835} 1836function slideToLoop(index = 0, speed, runCallbacks = true, internal) { 1837 if (typeof index === "string") { 1838 const indexAsNumber = parseInt(index, 10); 1839 index = indexAsNumber; 1840 } 1841 const swiper = this; 1842 if (swiper.destroyed) return; 1843 if (typeof speed === "undefined") { 1844 speed = swiper.params.speed; 1845 } 1846 const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1; 1847 let newIndex = index; 1848 if (swiper.params.loop) { 1849 if (swiper.virtual && swiper.params.virtual.enabled) { 1850 newIndex = newIndex + swiper.virtual.slidesBefore; 1851 } else { 1852 let targetSlideIndex; 1853 if (gridEnabled) { 1854 const slideIndex = newIndex * swiper.params.grid.rows; 1855 targetSlideIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column; 1856 } else { 1857 targetSlideIndex = swiper.getSlideIndexByData(newIndex); 1858 } 1859 const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length; 1860 const { 1861 centeredSlides, 1862 slidesOffsetBefore, 1863 slidesOffsetAfter 1864 } = swiper.params; 1865 const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter; 1866 let slidesPerView = swiper.params.slidesPerView; 1867 if (slidesPerView === "auto") { 1868 slidesPerView = swiper.slidesPerViewDynamic(); 1869 } else { 1870 slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10)); 1871 if (bothDirections && slidesPerView % 2 === 0) { 1872 slidesPerView = slidesPerView + 1; 1873 } 1874 } 1875 let needLoopFix = cols - targetSlideIndex < slidesPerView; 1876 if (bothDirections) { 1877 needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2); 1878 } 1879 if (internal && bothDirections && swiper.params.slidesPerView !== "auto" && !gridEnabled) { 1880 needLoopFix = false; 1881 } 1882 if (needLoopFix) { 1883 const direction = bothDirections ? targetSlideIndex < swiper.activeIndex ? "prev" : "next" : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? "next" : "prev"; 1884 swiper.loopFix({ 1885 direction, 1886 slideTo: true, 1887 activeSlideIndex: direction === "next" ? targetSlideIndex + 1 : targetSlideIndex - cols + 1, 1888 slideRealIndex: direction === "next" ? swiper.realIndex : void 0 1889 }); 1890 } 1891 if (gridEnabled) { 1892 const slideIndex = newIndex * swiper.params.grid.rows; 1893 newIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column; 1894 } else { 1895 newIndex = swiper.getSlideIndexByData(newIndex); 1896 } 1897 } 1898 } 1899 requestAnimationFrame(() => { 1900 swiper.slideTo(newIndex, speed, runCallbacks, internal); 1901 }); 1902 return swiper; 1903} 1904function slideNext(speed, runCallbacks = true, internal) { 1905 const swiper = this; 1906 const { 1907 enabled, 1908 params, 1909 animating 1910 } = swiper; 1911 if (!enabled || swiper.destroyed) return swiper; 1912 if (typeof speed === "undefined") { 1913 speed = swiper.params.speed; 1914 } 1915 let perGroup = params.slidesPerGroup; 1916 if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 1917 perGroup = Math.max(swiper.slidesPerViewDynamic("current", true), 1); 1918 } 1919 const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup; 1920 const isVirtual = swiper.virtual && params.virtual.enabled; 1921 if (params.loop) { 1922 if (animating && !isVirtual && params.loopPreventsSliding) return false; 1923 swiper.loopFix({ 1924 direction: "next" 1925 }); 1926 swiper._clientLeft = swiper.wrapperEl.clientLeft; 1927 if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) { 1928 requestAnimationFrame(() => { 1929 swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); 1930 }); 1931 return true; 1932 } 1933 } 1934 if (params.rewind && swiper.isEnd) { 1935 return swiper.slideTo(0, speed, runCallbacks, internal); 1936 } 1937 return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); 1938} 1939function slidePrev(speed, runCallbacks = true, internal) { 1940 const swiper = this; 1941 const { 1942 params, 1943 snapGrid, 1944 slidesGrid, 1945 rtlTranslate, 1946 enabled, 1947 animating 1948 } = swiper; 1949 if (!enabled || swiper.destroyed) return swiper; 1950 if (typeof speed === "undefined") { 1951 speed = swiper.params.speed; 1952 } 1953 const isVirtual = swiper.virtual && params.virtual.enabled; 1954 if (params.loop) { 1955 if (animating && !isVirtual && params.loopPreventsSliding) return false; 1956 swiper.loopFix({ 1957 direction: "prev" 1958 }); 1959 swiper._clientLeft = swiper.wrapperEl.clientLeft; 1960 } 1961 const translate2 = rtlTranslate ? swiper.translate : -swiper.translate; 1962 function normalize(val) { 1963 if (val < 0) return -Math.floor(Math.abs(val)); 1964 return Math.floor(val); 1965 } 1966 const normalizedTranslate = normalize(translate2); 1967 const normalizedSnapGrid = snapGrid.map((val) => normalize(val)); 1968 const isFreeMode = params.freeMode && params.freeMode.enabled; 1969 let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; 1970 if (typeof prevSnap === "undefined" && (params.cssMode || isFreeMode)) { 1971 let prevSnapIndex; 1972 snapGrid.forEach((snap, snapIndex) => { 1973 if (normalizedTranslate >= snap) { 1974 prevSnapIndex = snapIndex; 1975 } 1976 }); 1977 if (typeof prevSnapIndex !== "undefined") { 1978 prevSnap = isFreeMode ? snapGrid[prevSnapIndex] : snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex]; 1979 } 1980 } 1981 let prevIndex = 0; 1982 if (typeof prevSnap !== "undefined") { 1983 prevIndex = slidesGrid.indexOf(prevSnap); 1984 if (prevIndex < 0) prevIndex = swiper.activeIndex - 1; 1985 if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 1986 prevIndex = prevIndex - swiper.slidesPerViewDynamic("previous", true) + 1; 1987 prevIndex = Math.max(prevIndex, 0); 1988 } 1989 } 1990 if (params.rewind && swiper.isBeginning) { 1991 const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 1992 return swiper.slideTo(lastIndex, speed, runCallbacks, internal); 1993 } else if (params.loop && swiper.activeIndex === 0 && params.cssMode) { 1994 requestAnimationFrame(() => { 1995 swiper.slideTo(prevIndex, speed, runCallbacks, internal); 1996 }); 1997 return true; 1998 } 1999 return swiper.slideTo(prevIndex, speed, runCallbacks, internal); 2000} 2001function slideReset(speed, runCallbacks = true, internal) { 2002 const swiper = this; 2003 if (swiper.destroyed) return; 2004 if (typeof speed === "undefined") { 2005 speed = swiper.params.speed; 2006 } 2007 return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); 2008} 2009function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) { 2010 const swiper = this; 2011 if (swiper.destroyed) return; 2012 if (typeof speed === "undefined") { 2013 speed = swiper.params.speed; 2014 } 2015 let index = swiper.activeIndex; 2016 const skip = Math.min(swiper.params.slidesPerGroupSkip, index); 2017 const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); 2018 const translate2 = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 2019 if (translate2 >= swiper.snapGrid[snapIndex]) { 2020 const currentSnap = swiper.snapGrid[snapIndex]; 2021 const nextSnap = swiper.snapGrid[snapIndex + 1]; 2022 if (translate2 - currentSnap > (nextSnap - currentSnap) * threshold) { 2023 index += swiper.params.slidesPerGroup; 2024 } 2025 } else { 2026 const prevSnap = swiper.snapGrid[snapIndex - 1]; 2027 const currentSnap = swiper.snapGrid[snapIndex]; 2028 if (translate2 - prevSnap <= (currentSnap - prevSnap) * threshold) { 2029 index -= swiper.params.slidesPerGroup; 2030 } 2031 } 2032 index = Math.max(index, 0); 2033 index = Math.min(index, swiper.slidesGrid.length - 1); 2034 return swiper.slideTo(index, speed, runCallbacks, internal); 2035} 2036function slideToClickedSlide() { 2037 const swiper = this; 2038 if (swiper.destroyed) return; 2039 const { 2040 params, 2041 slidesEl 2042 } = swiper; 2043 const slidesPerView = params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : params.slidesPerView; 2044 let slideToIndex = swiper.getSlideIndexWhenGrid(swiper.clickedIndex); 2045 let realIndex; 2046 const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`; 2047 const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1; 2048 if (params.loop) { 2049 if (swiper.animating) return; 2050 realIndex = parseInt(swiper.clickedSlide.getAttribute("data-swiper-slide-index"), 10); 2051 if (params.centeredSlides) { 2052 swiper.slideToLoop(realIndex); 2053 } else if (slideToIndex > (isGrid ? (swiper.slides.length - slidesPerView) / 2 - (swiper.params.grid.rows - 1) : swiper.slides.length - slidesPerView)) { 2054 swiper.loopFix(); 2055 slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]); 2056 nextTick(() => { 2057 swiper.slideTo(slideToIndex); 2058 }); 2059 } else { 2060 swiper.slideTo(slideToIndex); 2061 } 2062 } else { 2063 swiper.slideTo(slideToIndex); 2064 } 2065} 2066var slide = { 2067 slideTo, 2068 slideToLoop, 2069 slideNext, 2070 slidePrev, 2071 slideReset, 2072 slideToClosest, 2073 slideToClickedSlide 2074}; 2075function loopCreate(slideRealIndex, initial) { 2076 const swiper = this; 2077 const { 2078 params, 2079 slidesEl 2080 } = swiper; 2081 if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return; 2082 const initSlides = () => { 2083 const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`); 2084 slides.forEach((el, index) => { 2085 el.setAttribute("data-swiper-slide-index", index); 2086 }); 2087 }; 2088 const clearBlankSlides = () => { 2089 const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`); 2090 slides.forEach((el) => { 2091 el.remove(); 2092 }); 2093 if (slides.length > 0) { 2094 swiper.recalcSlides(); 2095 swiper.updateSlides(); 2096 } 2097 }; 2098 const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1; 2099 if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) { 2100 clearBlankSlides(); 2101 } 2102 const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1); 2103 const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0; 2104 const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0; 2105 const addBlankSlides = (amountOfSlides) => { 2106 for (let i = 0; i < amountOfSlides; i += 1) { 2107 const slideEl = swiper.isElement ? createElement("swiper-slide", [params.slideBlankClass]) : createElement("div", [params.slideClass, params.slideBlankClass]); 2108 swiper.slidesEl.append(slideEl); 2109 } 2110 }; 2111 if (shouldFillGroup) { 2112 if (params.loopAddBlankSlides) { 2113 const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup; 2114 addBlankSlides(slidesToAdd); 2115 swiper.recalcSlides(); 2116 swiper.updateSlides(); 2117 } else { 2118 showWarning("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)"); 2119 } 2120 initSlides(); 2121 } else if (shouldFillGrid) { 2122 if (params.loopAddBlankSlides) { 2123 const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows; 2124 addBlankSlides(slidesToAdd); 2125 swiper.recalcSlides(); 2126 swiper.updateSlides(); 2127 } else { 2128 showWarning("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)"); 2129 } 2130 initSlides(); 2131 } else { 2132 initSlides(); 2133 } 2134 const bothDirections = params.centeredSlides || !!params.slidesOffsetBefore || !!params.slidesOffsetAfter; 2135 swiper.loopFix({ 2136 slideRealIndex, 2137 direction: bothDirections ? void 0 : "next", 2138 initial 2139 }); 2140} 2141function loopFix({ 2142 slideRealIndex, 2143 slideTo: slideTo2 = true, 2144 direction, 2145 setTranslate: setTranslate2, 2146 activeSlideIndex, 2147 initial, 2148 byController, 2149 byMousewheel 2150} = {}) { 2151 const swiper = this; 2152 if (!swiper.params.loop) return; 2153 swiper.emit("beforeLoopFix"); 2154 const { 2155 slides, 2156 allowSlidePrev, 2157 allowSlideNext, 2158 slidesEl, 2159 params 2160 } = swiper; 2161 const { 2162 centeredSlides, 2163 slidesOffsetBefore, 2164 slidesOffsetAfter, 2165 initialSlide 2166 } = params; 2167 const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter; 2168 swiper.allowSlidePrev = true; 2169 swiper.allowSlideNext = true; 2170 if (swiper.virtual && params.virtual.enabled) { 2171 if (slideTo2) { 2172 if (!bothDirections && swiper.snapIndex === 0) { 2173 swiper.slideTo(swiper.virtual.slides.length, 0, false, true); 2174 } else if (bothDirections && swiper.snapIndex < params.slidesPerView) { 2175 swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true); 2176 } else if (swiper.snapIndex === swiper.snapGrid.length - 1) { 2177 swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true); 2178 } 2179 } 2180 swiper.allowSlidePrev = allowSlidePrev; 2181 swiper.allowSlideNext = allowSlideNext; 2182 swiper.emit("loopFix"); 2183 return; 2184 } 2185 let slidesPerView = params.slidesPerView; 2186 if (slidesPerView === "auto") { 2187 slidesPerView = swiper.slidesPerViewDynamic(); 2188 } else { 2189 slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10)); 2190 if (bothDirections && slidesPerView % 2 === 0) { 2191 slidesPerView = slidesPerView + 1; 2192 } 2193 } 2194 const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup; 2195 let loopedSlides = bothDirections ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup; 2196 if (loopedSlides % slidesPerGroup !== 0) { 2197 loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup; 2198 } 2199 loopedSlides += params.loopAdditionalSlides; 2200 swiper.loopedSlides = loopedSlides; 2201 const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1; 2202 if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) { 2203 showWarning("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"); 2204 } else if (gridEnabled && params.grid.fill === "row") { 2205 showWarning("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`"); 2206 } 2207 const prependSlidesIndexes = []; 2208 const appendSlidesIndexes = []; 2209 const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length; 2210 const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !bothDirections; 2211 let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex; 2212 if (typeof activeSlideIndex === "undefined") { 2213 activeSlideIndex = swiper.getSlideIndex(slides.find((el) => el.classList.contains(params.slideActiveClass))); 2214 } else { 2215 activeIndex = activeSlideIndex; 2216 } 2217 const isNext = direction === "next" || !direction; 2218 const isPrev = direction === "prev" || !direction; 2219 let slidesPrepended = 0; 2220 let slidesAppended = 0; 2221 const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex; 2222 const activeColIndexWithShift = activeColIndex + (bothDirections && typeof setTranslate2 === "undefined" ? -slidesPerView / 2 + 0.5 : 0); 2223 if (activeColIndexWithShift < loopedSlides) { 2224 slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup); 2225 for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
vendor: 14,520 bytes, lines 2226-2628
2226 const index = i - Math.floor(i / cols) * cols; 2227 if (gridEnabled) { 2228 const colIndexToPrepend = cols - index - 1; 2229 for (let i2 = slides.length - 1; i2 >= 0; i2 -= 1) { 2230 if (slides[i2].column === colIndexToPrepend) prependSlidesIndexes.push(i2); 2231 } 2232 } else { 2233 prependSlidesIndexes.push(cols - index - 1); 2234 } 2235 } 2236 } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) { 2237 slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup); 2238 if (isInitialOverflow) { 2239 slidesAppended = Math.max(slidesAppended, slidesPerView - cols + initialSlide + 1); 2240 } 2241 for (let i = 0; i < slidesAppended; i += 1) { 2242 const index = i - Math.floor(i / cols) * cols; 2243 if (gridEnabled) { 2244 slides.forEach((slide2, slideIndex) => { 2245 if (slide2.column === index) appendSlidesIndexes.push(slideIndex); 2246 }); 2247 } else { 2248 appendSlidesIndexes.push(index); 2249 } 2250 } 2251 } 2252 swiper.__preventObserver__ = true; 2253 requestAnimationFrame(() => { 2254 swiper.__preventObserver__ = false; 2255 }); 2256 if (swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) { 2257 if (appendSlidesIndexes.includes(activeSlideIndex)) { 2258 appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1); 2259 } 2260 if (prependSlidesIndexes.includes(activeSlideIndex)) { 2261 prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1); 2262 } 2263 } 2264 if (isPrev) { 2265 prependSlidesIndexes.forEach((index) => { 2266 slides[index].swiperLoopMoveDOM = true; 2267 slidesEl.prepend(slides[index]); 2268 slides[index].swiperLoopMoveDOM = false; 2269 }); 2270 } 2271 if (isNext) { 2272 appendSlidesIndexes.forEach((index) => { 2273 slides[index].swiperLoopMoveDOM = true; 2274 slidesEl.append(slides[index]); 2275 slides[index].swiperLoopMoveDOM = false; 2276 }); 2277 } 2278 swiper.recalcSlides(); 2279 if (params.slidesPerView === "auto") { 2280 swiper.updateSlides(); 2281 } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) { 2282 swiper.slides.forEach((slide2, slideIndex) => { 2283 swiper.grid.updateSlide(slideIndex, slide2, swiper.slides); 2284 }); 2285 } 2286 if (params.watchSlidesProgress) { 2287 swiper.updateSlidesOffset(); 2288 } 2289 if (slideTo2) { 2290 if (prependSlidesIndexes.length > 0 && isPrev) { 2291 if (typeof slideRealIndex === "undefined") { 2292 const currentSlideTranslate = swiper.slidesGrid[activeIndex]; 2293 const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended]; 2294 const diff = newSlideTranslate - currentSlideTranslate; 2295 if (byMousewheel) { 2296 swiper.setTranslate(swiper.translate - diff); 2297 } else { 2298 swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true); 2299 if (setTranslate2) { 2300 swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff; 2301 swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff; 2302 } 2303 } 2304 } else { 2305 if (setTranslate2) { 2306 const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length; 2307 swiper.slideTo(swiper.activeIndex + shift, 0, false, true); 2308 swiper.touchEventsData.currentTranslate = swiper.translate; 2309 } 2310 } 2311 } else if (appendSlidesIndexes.length > 0 && isNext) { 2312 if (typeof slideRealIndex === "undefined") { 2313 const currentSlideTranslate = swiper.slidesGrid[activeIndex]; 2314 const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended]; 2315 const diff = newSlideTranslate - currentSlideTranslate; 2316 if (byMousewheel) { 2317 swiper.setTranslate(swiper.translate - diff); 2318 } else { 2319 swiper.slideTo(activeIndex - slidesAppended, 0, false, true); 2320 if (setTranslate2) { 2321 swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff; 2322 swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff; 2323 } 2324 } 2325 } else { 2326 const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length; 2327 swiper.slideTo(swiper.activeIndex - shift, 0, false, true); 2328 } 2329 } 2330 } 2331 swiper.allowSlidePrev = allowSlidePrev; 2332 swiper.allowSlideNext = allowSlideNext; 2333 if (swiper.controller && swiper.controller.control && !byController) { 2334 const loopParams = { 2335 slideRealIndex, 2336 direction, 2337 setTranslate: setTranslate2, 2338 activeSlideIndex, 2339 byController: true 2340 }; 2341 if (Array.isArray(swiper.controller.control)) { 2342 swiper.controller.control.forEach((c) => { 2343 if (!c.destroyed && c.params.loop) c.loopFix({ 2344 ...loopParams, 2345 slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo2 : false 2346 }); 2347 }); 2348 } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) { 2349 swiper.controller.control.loopFix({ 2350 ...loopParams, 2351 slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo2 : false 2352 }); 2353 } 2354 } 2355 swiper.emit("loopFix"); 2356} 2357function loopDestroy() { 2358 const swiper = this; 2359 const { 2360 params, 2361 slidesEl 2362 } = swiper; 2363 if (!params.loop || !slidesEl || swiper.virtual && swiper.params.virtual.enabled) return; 2364 swiper.recalcSlides(); 2365 const newSlidesOrder = []; 2366 swiper.slides.forEach((slideEl) => { 2367 const index = typeof slideEl.swiperSlideIndex === "undefined" ? slideEl.getAttribute("data-swiper-slide-index") * 1 : slideEl.swiperSlideIndex; 2368 newSlidesOrder[index] = slideEl; 2369 }); 2370 swiper.slides.forEach((slideEl) => { 2371 slideEl.removeAttribute("data-swiper-slide-index"); 2372 }); 2373 newSlidesOrder.forEach((slideEl) => { 2374 slidesEl.append(slideEl); 2375 }); 2376 swiper.recalcSlides(); 2377 swiper.slideTo(swiper.realIndex, 0); 2378} 2379var loop = { 2380 loopCreate, 2381 loopFix, 2382 loopDestroy 2383}; 2384function setGrabCursor(moving) { 2385 const swiper = this; 2386 if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return; 2387 const el = swiper.params.touchEventsTarget === "container" ? swiper.el : swiper.wrapperEl; 2388 if (swiper.isElement) { 2389 swiper.__preventObserver__ = true; 2390 } 2391 el.style.cursor = "move"; 2392 el.style.cursor = moving ? "grabbing" : "grab"; 2393 if (swiper.isElement) { 2394 requestAnimationFrame(() => { 2395 swiper.__preventObserver__ = false; 2396 }); 2397 } 2398} 2399function unsetGrabCursor() { 2400 const swiper = this; 2401 if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) { 2402 return; 2403 } 2404 if (swiper.isElement) { 2405 swiper.__preventObserver__ = true; 2406 } 2407 swiper[swiper.params.touchEventsTarget === "container" ? "el" : "wrapperEl"].style.cursor = ""; 2408 if (swiper.isElement) { 2409 requestAnimationFrame(() => { 2410 swiper.__preventObserver__ = false; 2411 }); 2412 } 2413} 2414var grabCursor = { 2415 setGrabCursor, 2416 unsetGrabCursor 2417}; 2418function closestElement(selector, base = this) { 2419 function __closestFrom(el) { 2420 if (!el || el === getDocument() || el === getWindow()) return null; 2421 if (el.assignedSlot) el = el.assignedSlot; 2422 const found = el.closest(selector); 2423 if (!found && !el.getRootNode) { 2424 return null; 2425 } 2426 return found || __closestFrom(el.getRootNode().host); 2427 } 2428 return __closestFrom(base); 2429} 2430function preventEdgeSwipe(swiper, event, startX) { 2431 const window2 = getWindow(); 2432 const { 2433 params 2434 } = swiper; 2435 const edgeSwipeDetection = params.edgeSwipeDetection; 2436 const edgeSwipeThreshold = params.edgeSwipeThreshold; 2437 if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) { 2438 if (edgeSwipeDetection === "prevent") { 2439 event.preventDefault(); 2440 return true; 2441 } 2442 return false; 2443 } 2444 return true; 2445} 2446function onTouchStart(event) { 2447 const swiper = this; 2448 const document2 = getDocument(); 2449 let e = event; 2450 if (e.originalEvent) e = e.originalEvent; 2451 const data = swiper.touchEventsData; 2452 if (e.type === "pointerdown") { 2453 if (data.pointerId !== null && data.pointerId !== e.pointerId) { 2454 return; 2455 } 2456 data.pointerId = e.pointerId; 2457 } else if (e.type === "touchstart" && e.targetTouches.length === 1) { 2458 data.touchId = e.targetTouches[0].identifier; 2459 } 2460 if (e.type === "touchstart") { 2461 preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX); 2462 return; 2463 } 2464 const { 2465 params, 2466 touches, 2467 enabled 2468 } = swiper; 2469 if (!enabled) return; 2470 if (!params.simulateTouch && e.pointerType === "mouse") return; 2471 if (swiper.animating && params.preventInteractionOnTransition) { 2472 return; 2473 } 2474 if (!swiper.animating && params.cssMode && params.loop) { 2475 swiper.loopFix(); 2476 } 2477 let targetEl = e.target; 2478 if (params.touchEventsTarget === "wrapper") { 2479 if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return; 2480 } 2481 if ("which" in e && e.which === 3) return; 2482 if ("button" in e && e.button > 0) return; 2483 if (data.isTouched && data.isMoved) return; 2484 const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ""; 2485 const eventPath = e.composedPath ? e.composedPath() : e.path; 2486 if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) { 2487 targetEl = eventPath[0]; 2488 } 2489 const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`; 2490 const isTargetShadow = !!(e.target && e.target.shadowRoot); 2491 if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) { 2492 swiper.allowClick = true; 2493 return; 2494 } 2495 if (params.swipeHandler) { 2496 if (!targetEl.closest(params.swipeHandler)) return; 2497 } 2498 touches.currentX = e.pageX; 2499 touches.currentY = e.pageY; 2500 const startX = touches.currentX; 2501 const startY = touches.currentY; 2502 if (!preventEdgeSwipe(swiper, e, startX)) { 2503 return; 2504 } 2505 Object.assign(data, { 2506 isTouched: true, 2507 isMoved: false, 2508 allowTouchCallbacks: true, 2509 isScrolling: void 0, 2510 startMoving: void 0 2511 }); 2512 touches.startX = startX; 2513 touches.startY = startY; 2514 data.touchStartTime = now(); 2515 swiper.allowClick = true; 2516 swiper.updateSize(); 2517 swiper.swipeDirection = void 0; 2518 if (params.threshold > 0) data.allowThresholdMove = false; 2519 let preventDefault = true; 2520 if (targetEl.matches(data.focusableElements)) { 2521 preventDefault = false; 2522 if (targetEl.nodeName === "SELECT") { 2523 data.isTouched = false; 2524 } 2525 } 2526 if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl && (e.pointerType === "mouse" || e.pointerType !== "mouse" && !targetEl.matches(data.focusableElements))) { 2527 document2.activeElement.blur(); 2528 } 2529 const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; 2530 if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) { 2531 e.preventDefault(); 2532 } 2533 if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) { 2534 swiper.freeMode.onTouchStart(); 2535 } 2536 swiper.emit("touchStart", e); 2537} 2538function onTouchMove(event) { 2539 const document2 = getDocument(); 2540 const swiper = this; 2541 const data = swiper.touchEventsData; 2542 const { 2543 params, 2544 touches, 2545 rtlTranslate: rtl, 2546 enabled 2547 } = swiper; 2548 if (!enabled) return; 2549 if (!params.simulateTouch && event.pointerType === "mouse") return; 2550 let e = event; 2551 if (e.originalEvent) e = e.originalEvent; 2552 if (e.type === "pointermove") { 2553 if (data.touchId !== null) return; 2554 const id = e.pointerId; 2555 if (id !== data.pointerId) return; 2556 } 2557 let targetTouch; 2558 if (e.type === "touchmove") { 2559 targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId); 2560 if (!targetTouch || targetTouch.identifier !== data.touchId) return; 2561 } else { 2562 targetTouch = e; 2563 } 2564 if (!data.isTouched) { 2565 if (data.startMoving && data.isScrolling) { 2566 swiper.emit("touchMoveOpposite", e); 2567 } 2568 return; 2569 } 2570 const pageX = targetTouch.pageX; 2571 const pageY = targetTouch.pageY; 2572 if (e.preventedByNestedSwiper) { 2573 touches.startX = pageX; 2574 touches.startY = pageY; 2575 return; 2576 } 2577 if (!swiper.allowTouchMove) { 2578 if (!e.target.matches(data.focusableElements)) { 2579 swiper.allowClick = false; 2580 } 2581 if (data.isTouched) { 2582 Object.assign(touches, { 2583 startX: pageX, 2584 startY: pageY, 2585 currentX: pageX, 2586 currentY: pageY 2587 }); 2588 data.touchStartTime = now(); 2589 } 2590 return; 2591 } 2592 if (params.touchReleaseOnEdges && !params.loop) { 2593 if (swiper.isVertical()) { 2594 if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) { 2595 data.isTouched = false; 2596 data.isMoved = false; 2597 return; 2598 } 2599 } else if (rtl && (pageX > touches.startX && -swiper.translate <= swiper.maxTranslate() || pageX < touches.startX && -swiper.translate >= swiper.minTranslate())) { 2600 return; 2601 } else if (!rtl && (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate())) { 2602 return; 2603 } 2604 } 2605 if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== e.target && e.pointerType !== "mouse") { 2606 document2.activeElement.blur(); 2607 } 2608 if (document2.activeElement) { 2609 if (e.target === document2.activeElement && e.target.matches(data.focusableElements)) { 2610 data.isMoved = true; 2611 swiper.allowClick = false; 2612 return; 2613 } 2614 } 2615 if (data.allowTouchCallbacks) { 2616 swiper.emit("touchMove", e); 2617 } 2618 touches.previousX = touches.currentX; 2619 touches.previousY = touches.currentY; 2620 touches.currentX = pageX; 2621 touches.currentY = pageY; 2622 const diffX = touches.currentX - touches.startX; 2623 const diffY = touches.currentY - touches.startY; 2624 if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return; 2625 if (typeof data.isScrolling === "undefined") { 2626 let touchAngle; 2627 if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) { 2628 data.isScrolling = false;
vendor: 8,704 bytes, lines 2629-2849
2629 } else { 2630 if (diffX * diffX + diffY * diffY >= 25) { 2631 touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI; 2632 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle; 2633 } 2634 } 2635 } 2636 if (data.isScrolling) { 2637 swiper.emit("touchMoveOpposite", e); 2638 } 2639 if (typeof data.startMoving === "undefined") { 2640 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { 2641 data.startMoving = true; 2642 } 2643 } 2644 if (data.isScrolling || e.type === "touchmove" && data.preventTouchMoveFromPointerMove) { 2645 data.isTouched = false; 2646 return; 2647 } 2648 if (!data.startMoving) { 2649 return; 2650 } 2651 swiper.allowClick = false; 2652 if (!params.cssMode && e.cancelable) { 2653 e.preventDefault(); 2654 } 2655 if (params.touchMoveStopPropagation && !params.nested) { 2656 e.stopPropagation(); 2657 } 2658 let diff = swiper.isHorizontal() ? diffX : diffY; 2659 let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY; 2660 if (params.oneWayMovement) { 2661 diff = Math.abs(diff) * (rtl ? 1 : -1); 2662 touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1); 2663 } 2664 touches.diff = diff; 2665 diff *= params.touchRatio; 2666 if (rtl) { 2667 diff = -diff; 2668 touchesDiff = -touchesDiff; 2669 } 2670 const prevTouchesDirection = swiper.touchesDirection; 2671 swiper.swipeDirection = diff > 0 ? "prev" : "next"; 2672 swiper.touchesDirection = touchesDiff > 0 ? "prev" : "next"; 2673 const isLoop = swiper.params.loop && !params.cssMode; 2674 const allowLoopFix = swiper.touchesDirection === "next" && swiper.allowSlideNext || swiper.touchesDirection === "prev" && swiper.allowSlidePrev; 2675 if (!data.isMoved) { 2676 if (isLoop && allowLoopFix) { 2677 swiper.loopFix({ 2678 direction: swiper.swipeDirection 2679 }); 2680 } 2681 data.startTranslate = swiper.getTranslate(); 2682 swiper.setTransition(0); 2683 if (swiper.animating) { 2684 const evt = new window.CustomEvent("transitionend", { 2685 bubbles: true, 2686 cancelable: true, 2687 detail: { 2688 bySwiperTouchMove: true 2689 } 2690 }); 2691 swiper.wrapperEl.dispatchEvent(evt); 2692 } 2693 data.allowMomentumBounce = false; 2694 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 2695 swiper.setGrabCursor(true); 2696 } 2697 swiper.emit("sliderFirstMove", e); 2698 } 2699 (/* @__PURE__ */ new Date()).getTime(); 2700 if (params._loopSwapReset !== false && data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) { 2701 Object.assign(touches, { 2702 startX: pageX, 2703 startY: pageY, 2704 currentX: pageX, 2705 currentY: pageY, 2706 startTranslate: data.currentTranslate 2707 }); 2708 data.loopSwapReset = true; 2709 data.startTranslate = data.currentTranslate; 2710 return; 2711 } 2712 swiper.emit("sliderMove", e); 2713 data.isMoved = true; 2714 data.currentTranslate = diff + data.startTranslate; 2715 let disableParentSwiper = true; 2716 let resistanceRatio = params.resistanceRatio; 2717 if (params.touchReleaseOnEdges) { 2718 resistanceRatio = 0; 2719 } 2720 if (diff > 0) { 2721 if (isLoop && allowLoopFix && true && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) { 2722 swiper.loopFix({ 2723 direction: "prev", 2724 setTranslate: true, 2725 activeSlideIndex: 0 2726 }); 2727 } 2728 if (data.currentTranslate > swiper.minTranslate()) { 2729 disableParentSwiper = false; 2730 if (params.resistance) { 2731 data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio; 2732 } 2733 } 2734 } else if (diff < 0) { 2735 if (isLoop && allowLoopFix && true && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) { 2736 swiper.loopFix({ 2737 direction: "next", 2738 setTranslate: true, 2739 activeSlideIndex: swiper.slides.length - (params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10))) 2740 }); 2741 } 2742 if (data.currentTranslate < swiper.maxTranslate()) { 2743 disableParentSwiper = false; 2744 if (params.resistance) { 2745 data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio; 2746 } 2747 } 2748 } 2749 if (disableParentSwiper) { 2750 e.preventedByNestedSwiper = true; 2751 } 2752 if (!swiper.allowSlideNext && swiper.swipeDirection === "next" && data.currentTranslate < data.startTranslate) { 2753 data.currentTranslate = data.startTranslate; 2754 } 2755 if (!swiper.allowSlidePrev && swiper.swipeDirection === "prev" && data.currentTranslate > data.startTranslate) { 2756 data.currentTranslate = data.startTranslate; 2757 } 2758 if (!swiper.allowSlidePrev && !swiper.allowSlideNext) { 2759 data.currentTranslate = data.startTranslate; 2760 } 2761 if (params.threshold > 0) { 2762 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { 2763 if (!data.allowThresholdMove) { 2764 data.allowThresholdMove = true; 2765 touches.startX = touches.currentX; 2766 touches.startY = touches.currentY; 2767 data.currentTranslate = data.startTranslate; 2768 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; 2769 return; 2770 } 2771 } else { 2772 data.currentTranslate = data.startTranslate; 2773 return; 2774 } 2775 } 2776 if (!params.followFinger || params.cssMode) return; 2777 if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) { 2778 swiper.updateActiveIndex(); 2779 swiper.updateSlidesClasses(); 2780 } 2781 if (params.freeMode && params.freeMode.enabled && swiper.freeMode) { 2782 swiper.freeMode.onTouchMove(); 2783 } 2784 swiper.updateProgress(data.currentTranslate); 2785 swiper.setTranslate(data.currentTranslate); 2786} 2787function onTouchEnd(event) { 2788 const swiper = this; 2789 const data = swiper.touchEventsData; 2790 let e = event; 2791 if (e.originalEvent) e = e.originalEvent; 2792 let targetTouch; 2793 const isTouchEvent = e.type === "touchend" || e.type === "touchcancel"; 2794 if (!isTouchEvent) { 2795 if (data.touchId !== null) return; 2796 if (e.pointerId !== data.pointerId) return; 2797 targetTouch = e; 2798 } else { 2799 targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId); 2800 if (!targetTouch || targetTouch.identifier !== data.touchId) return; 2801 } 2802 if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(e.type)) { 2803 const proceed = ["pointercancel", "contextmenu"].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView); 2804 if (!proceed) { 2805 return; 2806 } 2807 } 2808 data.pointerId = null; 2809 data.touchId = null; 2810 const { 2811 params, 2812 touches, 2813 rtlTranslate: rtl, 2814 slidesGrid, 2815 enabled 2816 } = swiper; 2817 if (!enabled) return; 2818 if (!params.simulateTouch && e.pointerType === "mouse") return; 2819 if (data.allowTouchCallbacks) { 2820 swiper.emit("touchEnd", e); 2821 } 2822 data.allowTouchCallbacks = false; 2823 if (!data.isTouched) { 2824 if (data.isMoved && params.grabCursor) { 2825 swiper.setGrabCursor(false); 2826 } 2827 data.isMoved = false; 2828 data.startMoving = false; 2829 return; 2830 } 2831 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 2832 swiper.setGrabCursor(false); 2833 } 2834 const touchEndTime = now(); 2835 const timeDiff = touchEndTime - data.touchStartTime; 2836 if (swiper.allowClick) { 2837 const pathTree = e.path || e.composedPath && e.composedPath(); 2838 swiper.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree); 2839 swiper.emit("tap click", e); 2840 if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) { 2841 swiper.emit("doubleTap doubleClick", e); 2842 } 2843 } 2844 data.lastClickTime = now(); 2845 nextTick(() => { 2846 if (!swiper.destroyed) swiper.allowClick = true; 2847 }); 2848 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) { 2849 data.isTouched = false;
vendor: 5,975 bytes, lines 2850-3026
2850 data.isMoved = false; 2851 data.startMoving = false; 2852 return; 2853 } 2854 data.isTouched = false; 2855 data.isMoved = false; 2856 data.startMoving = false; 2857 let currentPos; 2858 if (params.followFinger) { 2859 currentPos = rtl ? swiper.translate : -swiper.translate; 2860 } else { 2861 currentPos = -data.currentTranslate; 2862 } 2863 if (params.cssMode) { 2864 return; 2865 } 2866 if (params.freeMode && params.freeMode.enabled) { 2867 swiper.freeMode.onTouchEnd({ 2868 currentPos 2869 }); 2870 return; 2871 } 2872 const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop; 2873 let stopIndex = 0; 2874 let groupSize = swiper.slidesSizesGrid[0]; 2875 for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) { 2876 const increment2 = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 2877 if (typeof slidesGrid[i + increment2] !== "undefined") { 2878 if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) { 2879 stopIndex = i; 2880 groupSize = slidesGrid[i + increment2] - slidesGrid[i]; 2881 } 2882 } else if (swipeToLast || currentPos >= slidesGrid[i]) { 2883 stopIndex = i; 2884 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; 2885 } 2886 } 2887 let rewindFirstIndex = null; 2888 let rewindLastIndex = null; 2889 if (params.rewind) { 2890 if (swiper.isBeginning) { 2891 rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 2892 } else if (swiper.isEnd) { 2893 rewindFirstIndex = 0; 2894 } 2895 } 2896 const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; 2897 const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 2898 if (timeDiff > params.longSwipesMs) { 2899 if (!params.longSwipes) { 2900 swiper.slideTo(swiper.activeIndex); 2901 return; 2902 } 2903 if (swiper.swipeDirection === "next") { 2904 if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment); 2905 else swiper.slideTo(stopIndex); 2906 } 2907 if (swiper.swipeDirection === "prev") { 2908 if (ratio > 1 - params.longSwipesRatio) { 2909 swiper.slideTo(stopIndex + increment); 2910 } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) { 2911 swiper.slideTo(rewindLastIndex); 2912 } else { 2913 swiper.slideTo(stopIndex); 2914 } 2915 } 2916 } else { 2917 if (!params.shortSwipes) { 2918 swiper.slideTo(swiper.activeIndex); 2919 return; 2920 } 2921 const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl); 2922 if (!isNavButtonTarget) { 2923 if (swiper.swipeDirection === "next") { 2924 swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment); 2925 } 2926 if (swiper.swipeDirection === "prev") { 2927 swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex); 2928 } 2929 } else if (e.target === swiper.navigation.nextEl) { 2930 swiper.slideTo(stopIndex + increment); 2931 } else { 2932 swiper.slideTo(stopIndex); 2933 } 2934 } 2935} 2936function onResize() { 2937 const swiper = this; 2938 const { 2939 params, 2940 el 2941 } = swiper; 2942 if (el && el.offsetWidth === 0) return; 2943 if (params.breakpoints) { 2944 swiper.setBreakpoint(); 2945 } 2946 const { 2947 allowSlideNext, 2948 allowSlidePrev, 2949 snapGrid 2950 } = swiper; 2951 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 2952 swiper.allowSlideNext = true; 2953 swiper.allowSlidePrev = true; 2954 swiper.updateSize(); 2955 swiper.updateSlides(); 2956 swiper.updateSlidesClasses(); 2957 const isVirtualLoop = isVirtual && params.loop; 2958 if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) { 2959 swiper.slideTo(swiper.slides.length - 1, 0, false, true); 2960 } else { 2961 if (swiper.params.loop && !isVirtual) { 2962 swiper.slideToLoop(swiper.realIndex, 0, false, true); 2963 } else { 2964 swiper.slideTo(swiper.activeIndex, 0, false, true); 2965 } 2966 } 2967 if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { 2968 clearTimeout(swiper.autoplay.resizeTimeout); 2969 swiper.autoplay.resizeTimeout = setTimeout(() => { 2970 if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { 2971 swiper.autoplay.resume(); 2972 } 2973 }, 500); 2974 } 2975 swiper.allowSlidePrev = allowSlidePrev; 2976 swiper.allowSlideNext = allowSlideNext; 2977 if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { 2978 swiper.checkOverflow(); 2979 } 2980} 2981function onClick(e) { 2982 const swiper = this; 2983 if (!swiper.enabled) return; 2984 if (!swiper.allowClick) { 2985 if (swiper.params.preventClicks) e.preventDefault(); 2986 if (swiper.params.preventClicksPropagation && swiper.animating) { 2987 e.stopPropagation(); 2988 e.stopImmediatePropagation(); 2989 } 2990 } 2991} 2992function onScroll() { 2993 const swiper = this; 2994 const { 2995 wrapperEl, 2996 rtlTranslate, 2997 enabled 2998 } = swiper; 2999 if (!enabled) return; 3000 swiper.previousTranslate = swiper.translate; 3001 if (swiper.isHorizontal()) { 3002 swiper.translate = -wrapperEl.scrollLeft; 3003 } else { 3004 swiper.translate = -wrapperEl.scrollTop; 3005 } 3006 if (swiper.translate === 0) swiper.translate = 0; 3007 swiper.updateActiveIndex(); 3008 swiper.updateSlidesClasses(); 3009 let newProgress; 3010 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 3011 if (translatesDiff === 0) { 3012 newProgress = 0; 3013 } else { 3014 newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff; 3015 } 3016 if (newProgress !== swiper.progress) { 3017 swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate); 3018 } 3019 swiper.emit("setTranslate", swiper.translate, false); 3020} 3021function onLoad(e) { 3022 const swiper = this; 3023 processLazyPreloader(swiper, e.target); 3024 if (swiper.params.cssMode || swiper.params.slidesPerView !== "auto" && !swiper.params.autoHeight) { 3025 return; 3026 }
vendor: 4,645 bytes, lines 3027-3162
3027 swiper.update(); 3028} 3029function onDocumentTouchStart() { 3030 const swiper = this; 3031 if (swiper.documentTouchHandlerProceeded) return; 3032 swiper.documentTouchHandlerProceeded = true; 3033 if (swiper.params.touchReleaseOnEdges) { 3034 swiper.el.style.touchAction = "auto"; 3035 } 3036} 3037const events = (swiper, method) => { 3038 const document2 = getDocument(); 3039 const { 3040 params, 3041 el, 3042 wrapperEl, 3043 device 3044 } = swiper; 3045 const capture = !!params.nested; 3046 const domMethod = method === "on" ? "addEventListener" : "removeEventListener"; 3047 const swiperMethod = method; 3048 if (!el || typeof el === "string") return; 3049 document2[domMethod]("touchstart", swiper.onDocumentTouchStart, { 3050 passive: false, 3051 capture 3052 }); 3053 el[domMethod]("touchstart", swiper.onTouchStart, { 3054 passive: false 3055 }); 3056 el[domMethod]("pointerdown", swiper.onTouchStart, { 3057 passive: false 3058 }); 3059 document2[domMethod]("touchmove", swiper.onTouchMove, { 3060 passive: false, 3061 capture 3062 }); 3063 document2[domMethod]("pointermove", swiper.onTouchMove, { 3064 passive: false, 3065 capture 3066 }); 3067 document2[domMethod]("touchend", swiper.onTouchEnd, { 3068 passive: true 3069 }); 3070 document2[domMethod]("pointerup", swiper.onTouchEnd, { 3071 passive: true 3072 }); 3073 document2[domMethod]("pointercancel", swiper.onTouchEnd, { 3074 passive: true 3075 }); 3076 document2[domMethod]("touchcancel", swiper.onTouchEnd, { 3077 passive: true 3078 }); 3079 document2[domMethod]("pointerout", swiper.onTouchEnd, { 3080 passive: true 3081 }); 3082 document2[domMethod]("pointerleave", swiper.onTouchEnd, { 3083 passive: true 3084 }); 3085 document2[domMethod]("contextmenu", swiper.onTouchEnd, { 3086 passive: true 3087 }); 3088 if (params.preventClicks || params.preventClicksPropagation) { 3089 el[domMethod]("click", swiper.onClick, true); 3090 } 3091 if (params.cssMode) { 3092 wrapperEl[domMethod]("scroll", swiper.onScroll); 3093 } 3094 if (params.updateOnWindowResize) { 3095 swiper[swiperMethod](device.ios || device.android ? "resize orientationchange observerUpdate" : "resize observerUpdate", onResize, true); 3096 } else { 3097 swiper[swiperMethod]("observerUpdate", onResize, true); 3098 } 3099 el[domMethod]("load", swiper.onLoad, { 3100 capture: true 3101 }); 3102}; 3103function attachEvents() { 3104 const swiper = this; 3105 const { 3106 params 3107 } = swiper; 3108 swiper.onTouchStart = onTouchStart.bind(swiper); 3109 swiper.onTouchMove = onTouchMove.bind(swiper); 3110 swiper.onTouchEnd = onTouchEnd.bind(swiper); 3111 swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper); 3112 if (params.cssMode) { 3113 swiper.onScroll = onScroll.bind(swiper); 3114 } 3115 swiper.onClick = onClick.bind(swiper); 3116 swiper.onLoad = onLoad.bind(swiper); 3117 events(swiper, "on"); 3118} 3119function detachEvents() { 3120 const swiper = this; 3121 events(swiper, "off"); 3122} 3123var events$1 = { 3124 attachEvents, 3125 detachEvents 3126}; 3127const isGridEnabled = (swiper, params) => { 3128 return swiper.grid && params.grid && params.grid.rows > 1; 3129}; 3130function setBreakpoint() { 3131 const swiper = this; 3132 const { 3133 realIndex, 3134 initialized, 3135 params, 3136 el 3137 } = swiper; 3138 const breakpoints2 = params.breakpoints; 3139 if (!breakpoints2 || breakpoints2 && Object.keys(breakpoints2).length === 0) return; 3140 const document2 = getDocument(); 3141 const breakpointsBase = params.breakpointsBase === "window" || !params.breakpointsBase ? params.breakpointsBase : "container"; 3142 const breakpointContainer = ["window", "container"].includes(params.breakpointsBase) || !params.breakpointsBase ? swiper.el : document2.querySelector(params.breakpointsBase); 3143 const breakpoint = swiper.getBreakpoint(breakpoints2, breakpointsBase, breakpointContainer); 3144 if (!breakpoint || swiper.currentBreakpoint === breakpoint) return; 3145 const breakpointOnlyParams = breakpoint in breakpoints2 ? breakpoints2[breakpoint] : void 0; 3146 const breakpointParams = breakpointOnlyParams || swiper.originalParams; 3147 const wasMultiRow = isGridEnabled(swiper, params); 3148 const isMultiRow = isGridEnabled(swiper, breakpointParams); 3149 const wasGrabCursor = swiper.params.grabCursor; 3150 const isGrabCursor = breakpointParams.grabCursor; 3151 const wasEnabled = params.enabled; 3152 if (wasMultiRow && !isMultiRow) { 3153 el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`); 3154 swiper.emitContainerClasses(); 3155 } else if (!wasMultiRow && isMultiRow) { 3156 el.classList.add(`${params.containerModifierClass}grid`); 3157 if (breakpointParams.grid.fill && breakpointParams.grid.fill === "column" || !breakpointParams.grid.fill && params.grid.fill === "column") { 3158 el.classList.add(`${params.containerModifierClass}grid-column`); 3159 } 3160 swiper.emitContainerClasses(); 3161 } 3162 if (wasGrabCursor && !isGrabCursor) {
vendor: 4,781 bytes, lines 3163-3326
3163 swiper.unsetGrabCursor(); 3164 } else if (!wasGrabCursor && isGrabCursor) { 3165 swiper.setGrabCursor(); 3166 } 3167 ["navigation", "pagination", "scrollbar"].forEach((prop) => { 3168 if (typeof breakpointParams[prop] === "undefined") return; 3169 const wasModuleEnabled = params[prop] && params[prop].enabled; 3170 const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled; 3171 if (wasModuleEnabled && !isModuleEnabled) { 3172 swiper[prop].disable(); 3173 } 3174 if (!wasModuleEnabled && isModuleEnabled) { 3175 swiper[prop].enable(); 3176 } 3177 }); 3178 const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction; 3179 const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged); 3180 const wasLoop = params.loop; 3181 if (directionChanged && initialized) { 3182 swiper.changeDirection(); 3183 } 3184 extend(swiper.params, breakpointParams); 3185 const isEnabled = swiper.params.enabled; 3186 const hasLoop = swiper.params.loop; 3187 Object.assign(swiper, { 3188 allowTouchMove: swiper.params.allowTouchMove, 3189 allowSlideNext: swiper.params.allowSlideNext, 3190 allowSlidePrev: swiper.params.allowSlidePrev 3191 }); 3192 if (wasEnabled && !isEnabled) { 3193 swiper.disable(); 3194 } else if (!wasEnabled && isEnabled) { 3195 swiper.enable(); 3196 } 3197 swiper.currentBreakpoint = breakpoint; 3198 swiper.emit("_beforeBreakpoint", breakpointParams); 3199 if (initialized) { 3200 if (needsReLoop) { 3201 swiper.loopDestroy(); 3202 swiper.loopCreate(realIndex); 3203 swiper.updateSlides(); 3204 } else if (!wasLoop && hasLoop) { 3205 swiper.loopCreate(realIndex); 3206 swiper.updateSlides(); 3207 } else if (wasLoop && !hasLoop) { 3208 swiper.loopDestroy(); 3209 } 3210 } 3211 swiper.emit("breakpoint", breakpointParams); 3212} 3213function getBreakpoint(breakpoints2, base = "window", containerEl) { 3214 if (!breakpoints2 || base === "container" && !containerEl) return void 0; 3215 let breakpoint = false; 3216 const window2 = getWindow(); 3217 const currentHeight = base === "window" ? window2.innerHeight : containerEl.clientHeight; 3218 const points = Object.keys(breakpoints2).map((point) => { 3219 if (typeof point === "string" && point.indexOf("@") === 0) { 3220 const minRatio = parseFloat(point.substr(1)); 3221 const value = currentHeight * minRatio; 3222 return { 3223 value, 3224 point 3225 }; 3226 } 3227 return { 3228 value: point, 3229 point 3230 }; 3231 }); 3232 points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10)); 3233 for (let i = 0; i < points.length; i += 1) { 3234 const { 3235 point, 3236 value 3237 } = points[i]; 3238 if (base === "window") { 3239 if (window2.matchMedia(`(min-width: ${value}px)`).matches) { 3240 breakpoint = point; 3241 } 3242 } else if (value <= containerEl.clientWidth) { 3243 breakpoint = point; 3244 } 3245 } 3246 return breakpoint || "max"; 3247} 3248var breakpoints = { 3249 setBreakpoint, 3250 getBreakpoint 3251}; 3252function prepareClasses(entries, prefix) { 3253 const resultClasses = []; 3254 entries.forEach((item) => { 3255 if (typeof item === "object") { 3256 Object.keys(item).forEach((classNames) => { 3257 if (item[classNames]) { 3258 resultClasses.push(prefix + classNames); 3259 } 3260 }); 3261 } else if (typeof item === "string") { 3262 resultClasses.push(prefix + item); 3263 } 3264 }); 3265 return resultClasses; 3266} 3267function addClasses() { 3268 const swiper = this; 3269 const { 3270 classNames, 3271 params, 3272 rtl, 3273 el, 3274 device 3275 } = swiper; 3276 const suffixes = prepareClasses(["initialized", params.direction, { 3277 "free-mode": swiper.params.freeMode && params.freeMode.enabled 3278 }, { 3279 "autoheight": params.autoHeight 3280 }, { 3281 "rtl": rtl 3282 }, { 3283 "grid": params.grid && params.grid.rows > 1 3284 }, { 3285 "grid-column": params.grid && params.grid.rows > 1 && params.grid.fill === "column" 3286 }, { 3287 "android": device.android 3288 }, { 3289 "ios": device.ios 3290 }, { 3291 "css-mode": params.cssMode 3292 }, { 3293 "centered": params.cssMode && params.centeredSlides 3294 }, { 3295 "watch-progress": params.watchSlidesProgress 3296 }], params.containerModifierClass); 3297 classNames.push(...suffixes); 3298 el.classList.add(...classNames); 3299 swiper.emitContainerClasses(); 3300} 3301function removeClasses() { 3302 const swiper = this; 3303 const { 3304 el, 3305 classNames 3306 } = swiper; 3307 if (!el || typeof el === "string") return; 3308 el.classList.remove(...classNames); 3309 swiper.emitContainerClasses(); 3310} 3311var classes = { 3312 addClasses, 3313 removeClasses 3314}; 3315function checkOverflow() { 3316 const swiper = this; 3317 const { 3318 isLocked: wasLocked, 3319 params 3320 } = swiper; 3321 const { 3322 slidesOffsetBefore 3323 } = params; 3324 if (slidesOffsetBefore) { 3325 const lastSlideIndex = swiper.slides.length - 1; 3326 const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
vendor: 5,140 bytes, lines 3327-3517
3327 swiper.isLocked = swiper.size > lastSlideRightEdge; 3328 } else { 3329 swiper.isLocked = swiper.snapGrid.length === 1; 3330 } 3331 if (params.allowSlideNext === true) { 3332 swiper.allowSlideNext = !swiper.isLocked; 3333 } 3334 if (params.allowSlidePrev === true) { 3335 swiper.allowSlidePrev = !swiper.isLocked; 3336 } 3337 if (wasLocked && wasLocked !== swiper.isLocked) { 3338 swiper.isEnd = false; 3339 } 3340 if (wasLocked !== swiper.isLocked) { 3341 swiper.emit(swiper.isLocked ? "lock" : "unlock"); 3342 } 3343} 3344var checkOverflow$1 = { 3345 checkOverflow 3346}; 3347var defaults = { 3348 init: true, 3349 direction: "horizontal", 3350 oneWayMovement: false, 3351 swiperElementNodeName: "SWIPER-CONTAINER", 3352 touchEventsTarget: "wrapper", 3353 initialSlide: 0, 3354 speed: 300, 3355 cssMode: false, 3356 updateOnWindowResize: true, 3357 resizeObserver: true, 3358 nested: false, 3359 createElements: false, 3360 eventsPrefix: "swiper", 3361 enabled: true, 3362 focusableElements: "input, select, option, textarea, button, video, label", 3363 // Overrides 3364 width: null, 3365 height: null, 3366 // 3367 preventInteractionOnTransition: false, 3368 // ssr 3369 userAgent: null, 3370 url: null, 3371 // To support iOS's swipe-to-go-back gesture (when being used in-app). 3372 edgeSwipeDetection: false, 3373 edgeSwipeThreshold: 20, 3374 // Autoheight 3375 autoHeight: false, 3376 // Set wrapper width 3377 setWrapperSize: false, 3378 // Virtual Translate 3379 virtualTranslate: false, 3380 // Effects 3381 effect: "slide", 3382 // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' 3383 // Breakpoints 3384 breakpoints: void 0, 3385 breakpointsBase: "window", 3386 // Slides grid 3387 spaceBetween: 0, 3388 slidesPerView: 1, 3389 slidesPerGroup: 1, 3390 slidesPerGroupSkip: 0, 3391 slidesPerGroupAuto: false, 3392 centeredSlides: false, 3393 centeredSlidesBounds: false, 3394 slidesOffsetBefore: 0, 3395 // in px 3396 slidesOffsetAfter: 0, 3397 // in px 3398 normalizeSlideIndex: true, 3399 centerInsufficientSlides: false, 3400 // Disable swiper and hide navigation when container not overflow 3401 watchOverflow: true, 3402 // Round length 3403 roundLengths: false, 3404 // Touches 3405 touchRatio: 1, 3406 touchAngle: 45, 3407 simulateTouch: true, 3408 shortSwipes: true, 3409 longSwipes: true, 3410 longSwipesRatio: 0.5, 3411 longSwipesMs: 300, 3412 followFinger: true, 3413 allowTouchMove: true, 3414 threshold: 5, 3415 touchMoveStopPropagation: false, 3416 touchStartPreventDefault: true, 3417 touchStartForcePreventDefault: false, 3418 touchReleaseOnEdges: false, 3419 // Unique Navigation Elements 3420 uniqueNavElements: true, 3421 // Resistance 3422 resistance: true, 3423 resistanceRatio: 0.85, 3424 // Progress 3425 watchSlidesProgress: false, 3426 // Cursor 3427 grabCursor: false, 3428 // Clicks 3429 preventClicks: true, 3430 preventClicksPropagation: true, 3431 slideToClickedSlide: false, 3432 // loop 3433 loop: false, 3434 loopAddBlankSlides: true, 3435 loopAdditionalSlides: 0, 3436 loopPreventsSliding: true, 3437 // rewind 3438 rewind: false, 3439 // Swiping/no swiping 3440 allowSlidePrev: true, 3441 allowSlideNext: true, 3442 swipeHandler: null, 3443 // '.swipe-handler', 3444 noSwiping: true, 3445 noSwipingClass: "swiper-no-swiping", 3446 noSwipingSelector: null, 3447 // Passive Listeners 3448 passiveListeners: true, 3449 maxBackfaceHiddenSlides: 10, 3450 // NS 3451 containerModifierClass: "swiper-", 3452 // NEW 3453 slideClass: "swiper-slide", 3454 slideBlankClass: "swiper-slide-blank", 3455 slideActiveClass: "swiper-slide-active", 3456 slideVisibleClass: "swiper-slide-visible", 3457 slideFullyVisibleClass: "swiper-slide-fully-visible", 3458 slideNextClass: "swiper-slide-next", 3459 slidePrevClass: "swiper-slide-prev", 3460 wrapperClass: "swiper-wrapper", 3461 lazyPreloaderClass: "swiper-lazy-preloader", 3462 lazyPreloadPrevNext: 0, 3463 // Callbacks 3464 runCallbacksOnInit: true, 3465 // Internals 3466 _emitClasses: false 3467}; 3468function moduleExtendParams(params, allModulesParams) { 3469 return function extendParams(obj = {}) { 3470 const moduleParamName = Object.keys(obj)[0]; 3471 const moduleParams = obj[moduleParamName]; 3472 if (typeof moduleParams !== "object" || moduleParams === null) { 3473 extend(allModulesParams, obj); 3474 return; 3475 } 3476 if (params[moduleParamName] === true) { 3477 params[moduleParamName] = { 3478 enabled: true 3479 }; 3480 } 3481 if (moduleParamName === "navigation" && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) { 3482 params[moduleParamName].auto = true; 3483 } 3484 if (["pagination", "scrollbar"].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) { 3485 params[moduleParamName].auto = true; 3486 } 3487 if (!(moduleParamName in params && "enabled" in moduleParams)) { 3488 extend(allModulesParams, obj); 3489 return; 3490 } 3491 if (typeof params[moduleParamName] === "object" && !("enabled" in params[moduleParamName])) { 3492 params[moduleParamName].enabled = true; 3493 } 3494 if (!params[moduleParamName]) params[moduleParamName] = { 3495 enabled: false 3496 }; 3497 extend(allModulesParams, obj); 3498 }; 3499} 3500const prototypes = { 3501 eventsEmitter, 3502 update, 3503 translate, 3504 transition, 3505 slide, 3506 loop, 3507 grabCursor, 3508 events: events$1, 3509 breakpoints, 3510 checkOverflow: checkOverflow$1, 3511 classes 3512}; 3513const extendedDefaults = {}; 3514class Swiper { 3515 constructor(...args) { 3516 let el; 3517 let params;
vendor: 5,036 bytes, lines 3518-3683
3518 if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === "Object") { 3519 params = args[0]; 3520 } else { 3521 [el, params] = args; 3522 } 3523 if (!params) params = {}; 3524 params = extend({}, params); 3525 if (el && !params.el) params.el = el; 3526 const document2 = getDocument(); 3527 if (params.el && typeof params.el === "string" && document2.querySelectorAll(params.el).length > 1) { 3528 const swipers = []; 3529 document2.querySelectorAll(params.el).forEach((containerEl) => { 3530 const newParams = extend({}, params, { 3531 el: containerEl 3532 }); 3533 swipers.push(new Swiper(newParams)); 3534 }); 3535 return swipers; 3536 } 3537 const swiper = this; 3538 swiper.__swiper__ = true; 3539 swiper.support = getSupport(); 3540 swiper.device = getDevice({ 3541 userAgent: params.userAgent 3542 }); 3543 swiper.browser = getBrowser(); 3544 swiper.eventsListeners = {}; 3545 swiper.eventsAnyListeners = []; 3546 swiper.modules = [...swiper.__modules__]; 3547 if (params.modules && Array.isArray(params.modules)) { 3548 swiper.modules.push(...params.modules); 3549 } 3550 const allModulesParams = {}; 3551 swiper.modules.forEach((mod) => { 3552 mod({ 3553 params, 3554 swiper, 3555 extendParams: moduleExtendParams(params, allModulesParams), 3556 on: swiper.on.bind(swiper), 3557 once: swiper.once.bind(swiper), 3558 off: swiper.off.bind(swiper), 3559 emit: swiper.emit.bind(swiper) 3560 }); 3561 }); 3562 const swiperParams = extend({}, defaults, allModulesParams); 3563 swiper.params = extend({}, swiperParams, extendedDefaults, params); 3564 swiper.originalParams = extend({}, swiper.params); 3565 swiper.passedParams = extend({}, params); 3566 if (swiper.params && swiper.params.on) { 3567 Object.keys(swiper.params.on).forEach((eventName) => { 3568 swiper.on(eventName, swiper.params.on[eventName]); 3569 }); 3570 } 3571 if (swiper.params && swiper.params.onAny) { 3572 swiper.onAny(swiper.params.onAny); 3573 } 3574 Object.assign(swiper, { 3575 enabled: swiper.params.enabled, 3576 el, 3577 // Classes 3578 classNames: [], 3579 // Slides 3580 slides: [], 3581 slidesGrid: [], 3582 snapGrid: [], 3583 slidesSizesGrid: [], 3584 // isDirection 3585 isHorizontal() { 3586 return swiper.params.direction === "horizontal"; 3587 }, 3588 isVertical() { 3589 return swiper.params.direction === "vertical"; 3590 }, 3591 // Indexes 3592 activeIndex: 0, 3593 realIndex: 0, 3594 // 3595 isBeginning: true, 3596 isEnd: false, 3597 // Props 3598 translate: 0, 3599 previousTranslate: 0, 3600 progress: 0, 3601 velocity: 0, 3602 animating: false, 3603 cssOverflowAdjustment() { 3604 return Math.trunc(this.translate / 2 ** 23) * 2 ** 23; 3605 }, 3606 // Locks 3607 allowSlideNext: swiper.params.allowSlideNext, 3608 allowSlidePrev: swiper.params.allowSlidePrev, 3609 // Touch Events 3610 touchEventsData: { 3611 isTouched: void 0, 3612 isMoved: void 0, 3613 allowTouchCallbacks: void 0, 3614 touchStartTime: void 0, 3615 isScrolling: void 0, 3616 currentTranslate: void 0, 3617 startTranslate: void 0, 3618 allowThresholdMove: void 0, 3619 // Form elements to match 3620 focusableElements: swiper.params.focusableElements, 3621 // Last click time 3622 lastClickTime: 0, 3623 clickTimeout: void 0, 3624 // Velocities 3625 velocities: [], 3626 allowMomentumBounce: void 0, 3627 startMoving: void 0, 3628 pointerId: null, 3629 touchId: null 3630 }, 3631 // Clicks 3632 allowClick: true, 3633 // Touches 3634 allowTouchMove: swiper.params.allowTouchMove, 3635 touches: { 3636 startX: 0, 3637 startY: 0, 3638 currentX: 0, 3639 currentY: 0, 3640 diff: 0 3641 }, 3642 // Images 3643 imagesToLoad: [], 3644 imagesLoaded: 0 3645 }); 3646 swiper.emit("_swiper"); 3647 if (swiper.params.init) { 3648 swiper.init(); 3649 } 3650 return swiper; 3651 } 3652 getDirectionLabel(property) { 3653 if (this.isHorizontal()) { 3654 return property; 3655 } 3656 return { 3657 "width": "height", 3658 "margin-top": "margin-left", 3659 "margin-bottom ": "margin-right", 3660 "margin-left": "margin-top", 3661 "margin-right": "margin-bottom", 3662 "padding-left": "padding-top", 3663 "padding-right": "padding-bottom", 3664 "marginRight": "marginBottom" 3665 }[property]; 3666 } 3667 getSlideIndex(slideEl) { 3668 const { 3669 slidesEl, 3670 params 3671 } = this; 3672 const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`); 3673 const firstSlideIndex = elementIndex(slides[0]); 3674 return elementIndex(slideEl) - firstSlideIndex; 3675 } 3676 getSlideIndexByData(index) { 3677 return this.getSlideIndex(this.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === index)); 3678 } 3679 getSlideIndexWhenGrid(index) { 3680 if (this.grid && this.params.grid && this.params.grid.rows > 1) { 3681 if (this.params.grid.fill === "column") { 3682 index = Math.floor(index / this.params.grid.rows); 3683 } else if (this.params.grid.fill === "row") {
vendor: 5,999 bytes, lines 3684-3862
3684 index = index % Math.ceil(this.slides.length / this.params.grid.rows); 3685 } 3686 } 3687 return index; 3688 } 3689 recalcSlides() { 3690 const swiper = this; 3691 const { 3692 slidesEl, 3693 params 3694 } = swiper; 3695 swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`); 3696 } 3697 enable() { 3698 const swiper = this; 3699 if (swiper.enabled) return; 3700 swiper.enabled = true; 3701 if (swiper.params.grabCursor) { 3702 swiper.setGrabCursor(); 3703 } 3704 swiper.emit("enable"); 3705 } 3706 disable() { 3707 const swiper = this; 3708 if (!swiper.enabled) return; 3709 swiper.enabled = false; 3710 if (swiper.params.grabCursor) { 3711 swiper.unsetGrabCursor(); 3712 } 3713 swiper.emit("disable"); 3714 } 3715 setProgress(progress, speed) { 3716 const swiper = this; 3717 progress = Math.min(Math.max(progress, 0), 1); 3718 const min = swiper.minTranslate(); 3719 const max = swiper.maxTranslate(); 3720 const current = (max - min) * progress + min; 3721 swiper.translateTo(current, typeof speed === "undefined" ? 0 : speed); 3722 swiper.updateActiveIndex(); 3723 swiper.updateSlidesClasses(); 3724 } 3725 emitContainerClasses() { 3726 const swiper = this; 3727 if (!swiper.params._emitClasses || !swiper.el) return; 3728 const cls = swiper.el.className.split(" ").filter((className) => { 3729 return className.indexOf("swiper") === 0 || className.indexOf(swiper.params.containerModifierClass) === 0; 3730 }); 3731 swiper.emit("_containerClasses", cls.join(" ")); 3732 } 3733 getSlideClasses(slideEl) { 3734 const swiper = this; 3735 if (swiper.destroyed) return ""; 3736 return slideEl.className.split(" ").filter((className) => { 3737 return className.indexOf("swiper-slide") === 0 || className.indexOf(swiper.params.slideClass) === 0; 3738 }).join(" "); 3739 } 3740 emitSlidesClasses() { 3741 const swiper = this; 3742 if (!swiper.params._emitClasses || !swiper.el) return; 3743 const updates = []; 3744 swiper.slides.forEach((slideEl) => { 3745 const classNames = swiper.getSlideClasses(slideEl); 3746 updates.push({ 3747 slideEl, 3748 classNames 3749 }); 3750 swiper.emit("_slideClass", slideEl, classNames); 3751 }); 3752 swiper.emit("_slideClasses", updates); 3753 } 3754 slidesPerViewDynamic(view = "current", exact = false) { 3755 const swiper = this; 3756 const { 3757 params, 3758 slides, 3759 slidesGrid, 3760 slidesSizesGrid, 3761 size: swiperSize, 3762 activeIndex 3763 } = swiper; 3764 let spv = 1; 3765 if (typeof params.slidesPerView === "number") return params.slidesPerView; 3766 if (params.centeredSlides) { 3767 let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0; 3768 let breakLoop; 3769 for (let i = activeIndex + 1; i < slides.length; i += 1) { 3770 if (slides[i] && !breakLoop) { 3771 slideSize += Math.ceil(slides[i].swiperSlideSize); 3772 spv += 1; 3773 if (slideSize > swiperSize) breakLoop = true; 3774 } 3775 } 3776 for (let i = activeIndex - 1; i >= 0; i -= 1) { 3777 if (slides[i] && !breakLoop) { 3778 slideSize += slides[i].swiperSlideSize; 3779 spv += 1; 3780 if (slideSize > swiperSize) breakLoop = true; 3781 } 3782 } 3783 } else { 3784 if (view === "current") { 3785 for (let i = activeIndex + 1; i < slides.length; i += 1) { 3786 const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize; 3787 if (slideInView) { 3788 spv += 1; 3789 } 3790 } 3791 } else { 3792 for (let i = activeIndex - 1; i >= 0; i -= 1) { 3793 const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize; 3794 if (slideInView) { 3795 spv += 1; 3796 } 3797 } 3798 } 3799 } 3800 return spv; 3801 } 3802 update() { 3803 const swiper = this; 3804 if (!swiper || swiper.destroyed) return; 3805 const { 3806 snapGrid, 3807 params 3808 } = swiper; 3809 if (params.breakpoints) { 3810 swiper.setBreakpoint(); 3811 } 3812 [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach((imageEl) => { 3813 if (imageEl.complete) { 3814 processLazyPreloader(swiper, imageEl); 3815 } 3816 }); 3817 swiper.updateSize(); 3818 swiper.updateSlides(); 3819 swiper.updateProgress(); 3820 swiper.updateSlidesClasses(); 3821 function setTranslate2() { 3822 const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; 3823 const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); 3824 swiper.setTranslate(newTranslate); 3825 swiper.updateActiveIndex(); 3826 swiper.updateSlidesClasses(); 3827 } 3828 let translated; 3829 if (params.freeMode && params.freeMode.enabled && !params.cssMode) { 3830 setTranslate2(); 3831 if (params.autoHeight) { 3832 swiper.updateAutoHeight(); 3833 } 3834 } else { 3835 if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) { 3836 const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides; 3837 translated = swiper.slideTo(slides.length - 1, 0, false, true); 3838 } else { 3839 translated = swiper.slideTo(swiper.activeIndex, 0, false, true); 3840 } 3841 if (!translated) { 3842 setTranslate2(); 3843 } 3844 } 3845 if (params.watchOverflow && snapGrid !== swiper.snapGrid) { 3846 swiper.checkOverflow(); 3847 } 3848 swiper.emit("update"); 3849 } 3850 changeDirection(newDirection, needUpdate = true) { 3851 const swiper = this; 3852 const currentDirection = swiper.params.direction; 3853 if (!newDirection) { 3854 newDirection = currentDirection === "horizontal" ? "vertical" : "horizontal"; 3855 } 3856 if (newDirection === currentDirection || newDirection !== "horizontal" && newDirection !== "vertical") { 3857 return swiper; 3858 } 3859 swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`); 3860 swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`); 3861 swiper.emitContainerClasses(); 3862 swiper.params.direction = newDirection;
vendor: 6,566 bytes, lines 3863-4068
3863 swiper.slides.forEach((slideEl) => { 3864 if (newDirection === "vertical") { 3865 slideEl.style.width = ""; 3866 } else { 3867 slideEl.style.height = ""; 3868 } 3869 }); 3870 swiper.emit("changeDirection"); 3871 if (needUpdate) swiper.update(); 3872 return swiper; 3873 } 3874 changeLanguageDirection(direction) { 3875 const swiper = this; 3876 if (swiper.rtl && direction === "rtl" || !swiper.rtl && direction === "ltr") return; 3877 swiper.rtl = direction === "rtl"; 3878 swiper.rtlTranslate = swiper.params.direction === "horizontal" && swiper.rtl; 3879 if (swiper.rtl) { 3880 swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`); 3881 swiper.el.dir = "rtl"; 3882 } else { 3883 swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`); 3884 swiper.el.dir = "ltr"; 3885 } 3886 swiper.update(); 3887 } 3888 mount(element) { 3889 const swiper = this; 3890 if (swiper.mounted) return true; 3891 let el = element || swiper.params.el; 3892 if (typeof el === "string") { 3893 el = document.querySelector(el); 3894 } 3895 if (!el) { 3896 return false; 3897 } 3898 el.swiper = swiper; 3899 if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) { 3900 swiper.isElement = true; 3901 } 3902 const getWrapperSelector = () => { 3903 return `.${(swiper.params.wrapperClass || "").trim().split(" ").join(".")}`; 3904 }; 3905 const getWrapper = () => { 3906 if (el && el.shadowRoot && el.shadowRoot.querySelector) { 3907 const res = el.shadowRoot.querySelector(getWrapperSelector()); 3908 return res; 3909 } 3910 return elementChildren(el, getWrapperSelector())[0]; 3911 }; 3912 let wrapperEl = getWrapper(); 3913 if (!wrapperEl && swiper.params.createElements) { 3914 wrapperEl = createElement("div", swiper.params.wrapperClass); 3915 el.append(wrapperEl); 3916 elementChildren(el, `.${swiper.params.slideClass}`).forEach((slideEl) => { 3917 wrapperEl.append(slideEl); 3918 }); 3919 } 3920 Object.assign(swiper, { 3921 el, 3922 wrapperEl, 3923 slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl, 3924 hostEl: swiper.isElement ? el.parentNode.host : el, 3925 mounted: true, 3926 // RTL 3927 rtl: el.dir.toLowerCase() === "rtl" || elementStyle(el, "direction") === "rtl", 3928 rtlTranslate: swiper.params.direction === "horizontal" && (el.dir.toLowerCase() === "rtl" || elementStyle(el, "direction") === "rtl"), 3929 wrongRTL: elementStyle(wrapperEl, "display") === "-webkit-box" 3930 }); 3931 return true; 3932 } 3933 init(el) { 3934 const swiper = this; 3935 if (swiper.initialized) return swiper; 3936 const mounted = swiper.mount(el); 3937 if (mounted === false) return swiper; 3938 swiper.emit("beforeInit"); 3939 if (swiper.params.breakpoints) { 3940 swiper.setBreakpoint(); 3941 } 3942 swiper.addClasses(); 3943 swiper.updateSize(); 3944 swiper.updateSlides(); 3945 if (swiper.params.watchOverflow) { 3946 swiper.checkOverflow(); 3947 } 3948 if (swiper.params.grabCursor && swiper.enabled) { 3949 swiper.setGrabCursor(); 3950 } 3951 if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) { 3952 swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true); 3953 } else { 3954 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true); 3955 } 3956 if (swiper.params.loop) { 3957 swiper.loopCreate(void 0, true); 3958 } 3959 swiper.attachEvents(); 3960 const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')]; 3961 if (swiper.isElement) { 3962 lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]')); 3963 } 3964 lazyElements.forEach((imageEl) => { 3965 if (imageEl.complete) { 3966 processLazyPreloader(swiper, imageEl); 3967 } else { 3968 imageEl.addEventListener("load", (e) => { 3969 processLazyPreloader(swiper, e.target); 3970 }); 3971 } 3972 }); 3973 preload(swiper); 3974 swiper.initialized = true; 3975 preload(swiper); 3976 swiper.emit("init"); 3977 swiper.emit("afterInit"); 3978 return swiper; 3979 } 3980 destroy(deleteInstance = true, cleanStyles = true) { 3981 const swiper = this; 3982 const { 3983 params, 3984 el, 3985 wrapperEl, 3986 slides 3987 } = swiper; 3988 if (typeof swiper.params === "undefined" || swiper.destroyed) { 3989 return null; 3990 } 3991 swiper.emit("beforeDestroy"); 3992 swiper.initialized = false; 3993 swiper.detachEvents(); 3994 if (params.loop) { 3995 swiper.loopDestroy(); 3996 } 3997 if (cleanStyles) { 3998 swiper.removeClasses(); 3999 if (el && typeof el !== "string") { 4000 el.removeAttribute("style"); 4001 } 4002 if (wrapperEl) { 4003 wrapperEl.removeAttribute("style"); 4004 } 4005 if (slides && slides.length) { 4006 slides.forEach((slideEl) => { 4007 slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass); 4008 slideEl.removeAttribute("style"); 4009 slideEl.removeAttribute("data-swiper-slide-index"); 4010 }); 4011 } 4012 } 4013 swiper.emit("destroy"); 4014 Object.keys(swiper.eventsListeners).forEach((eventName) => { 4015 swiper.off(eventName); 4016 }); 4017 if (deleteInstance !== false) { 4018 if (swiper.el && typeof swiper.el !== "string") { 4019 swiper.el.swiper = null; 4020 } 4021 deleteProps(swiper); 4022 } 4023 swiper.destroyed = true; 4024 return null; 4025 } 4026 static extendDefaults(newDefaults) { 4027 extend(extendedDefaults, newDefaults); 4028 } 4029 static get extendedDefaults() { 4030 return extendedDefaults; 4031 } 4032 static get defaults() { 4033 return defaults; 4034 } 4035 static installModule(mod) { 4036 if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = []; 4037 const modules = Swiper.prototype.__modules__; 4038 if (typeof mod === "function" && modules.indexOf(mod) < 0) { 4039 modules.push(mod); 4040 } 4041 } 4042 static use(module) { 4043 if (Array.isArray(module)) { 4044 module.forEach((m) => Swiper.installModule(m)); 4045 return Swiper; 4046 } 4047 Swiper.installModule(module); 4048 return Swiper; 4049 } 4050} 4051Object.keys(prototypes).forEach((prototypeGroup) => { 4052 Object.keys(prototypes[prototypeGroup]).forEach((protoMethod) => { 4053 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; 4054 }); 4055}); 4056Swiper.use([Resize, Observer]); 4057export { 4058 Swiper as S, 4059 elementChildren as a, 4060 elementParents as b, 4061 createElement as c, 4062 elementOuterSize as d, 4063 elementTransitionEnd as e, 4064 elementIndex as f, 4065 getSlideTransformEl as g, 4066 makeElementsArray as m, 4067 setInnerHTML as s 4068};
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.