vendor: 4,139 bytes, lines 1-262
1/** 2 * Swiper 8.3.1 3 * Most modern mobile touch slider and framework with hardware accelerated transitions 4 * https://swiperjs.com 5 * 6 * Copyright 2014-2022 Vladimir Kharlampidi 7 * 8 * Released under the MIT License 9 * 10 * Released on: July 21, 2022 11 */ 12 13/** 14 * SSR Window 4.0.2 15 * Better handling for window object in SSR environment 16 * https://github.com/nolimits4web/ssr-window 17 * 18 * Copyright 2021, Vladimir Kharlampidi 19 * 20 * Licensed under MIT 21 * 22 * Released on: December 13, 2021 23 */ 24 25/* eslint-disable no-param-reassign */ 26function isObject$1(obj) { 27 return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object; 28} 29 30function extend$1(target, src) { 31 if (target === void 0) { 32 target = {}; 33 } 34 35 if (src === void 0) { 36 src = {}; 37 } 38 39 Object.keys(src).forEach(key => { 40 if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) { 41 extend$1(target[key], src[key]); 42 } 43 }); 44} 45 46const ssrDocument = { 47 body: {}, 48 49 addEventListener() {}, 50 51 removeEventListener() {}, 52 53 activeElement: { 54 blur() {}, 55 56 nodeName: '' 57 }, 58 59 querySelector() { 60 return null; 61 }, 62 63 querySelectorAll() { 64 return []; 65 }, 66 67 getElementById() { 68 return null; 69 }, 70 71 createEvent() { 72 return { 73 initEvent() {} 74 75 }; 76 }, 77 78 createElement() { 79 return { 80 children: [], 81 childNodes: [], 82 style: {}, 83 84 setAttribute() {}, 85 86 getElementsByTagName() { 87 return []; 88 } 89 90 }; 91 }, 92 93 createElementNS() { 94 return {}; 95 }, 96 97 importNode() { 98 return null; 99 }, 100 101 location: { 102 hash: '', 103 host: '', 104 hostname: '', 105 href: '', 106 origin: '', 107 pathname: '', 108 protocol: '', 109 search: '' 110 } 111}; 112 113function getDocument() { 114 const doc = typeof document !== 'undefined' ? document : {}; 115 extend$1(doc, ssrDocument); 116 return doc; 117} 118 119const ssrWindow = { 120 document: ssrDocument, 121 navigator: { 122 userAgent: '' 123 }, 124 location: { 125 hash: '', 126 host: '', 127 hostname: '', 128 href: '', 129 origin: '', 130 pathname: '', 131 protocol: '', 132 search: '' 133 }, 134 history: { 135 replaceState() {}, 136 137 pushState() {}, 138 139 go() {}, 140 141 back() {} 142 143 }, 144 CustomEvent: function CustomEvent() { 145 return this; 146 }, 147 148 addEventListener() {}, 149 150 removeEventListener() {}, 151 152 getComputedStyle() { 153 return { 154 getPropertyValue() { 155 return ''; 156 } 157 158 }; 159 }, 160 161 Image() {}, 162 163 Date() {}, 164 165 screen: {}, 166 167 setTimeout() {}, 168 169 clearTimeout() {}, 170 171 matchMedia() { 172 return {}; 173 }, 174 175 requestAnimationFrame(callback) { 176 if (typeof setTimeout === 'undefined') { 177 callback(); 178 return null; 179 } 180 181 return setTimeout(callback, 0); 182 }, 183 184 cancelAnimationFrame(id) { 185 if (typeof setTimeout === 'undefined') { 186 return; 187 } 188 189 clearTimeout(id); 190 } 191 192}; 193 194function getWindow() { 195 const win = typeof window !== 'undefined' ? window : {}; 196 extend$1(win, ssrWindow); 197 return win; 198} 199 200/** 201 * Dom7 4.0.4 202 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API 203 * https://framework7.io/docs/dom7.html 204 * 205 * Copyright 2022, Vladimir Kharlampidi 206 * 207 * Licensed under MIT 208 * 209 * Released on: January 11, 2022 210 */ 211/* eslint-disable no-proto */ 212 213function makeReactive(obj) { 214 const proto = obj.__proto__; 215 Object.defineProperty(obj, '__proto__', { 216 get() { 217 return proto; 218 }, 219 220 set(value) { 221 proto.__proto__ = value; 222 } 223 224 }); 225} 226 227class Dom7 extends Array { 228 constructor(items) { 229 if (typeof items === 'number') { 230 super(items); 231 } else { 232 super(...(items || [])); 233 makeReactive(this); 234 } 235 } 236 237} 238 239function arrayFlat(arr) { 240 if (arr === void 0) { 241 arr = []; 242 } 243 244 const res = []; 245 arr.forEach(el => { 246 if (Array.isArray(el)) { 247 res.push(...arrayFlat(el)); 248 } else { 249 res.push(el); 250 } 251 }); 252 return res; 253} 254 255function arrayFilter(arr, callback) { 256 return Array.prototype.filter.call(arr, callback); 257} 258 259function arrayUnique(arr) { 260 const uniqueArray = []; 261 262 for (let i = 0; i < arr.length; i += 1) {
vendor: 11,735 bytes, lines 263-729
263 if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]); 264 } 265 266 return uniqueArray; 267} 268 269 270function qsa(selector, context) { 271 if (typeof selector !== 'string') { 272 return [selector]; 273 } 274 275 const a = []; 276 const res = context.querySelectorAll(selector); 277 278 for (let i = 0; i < res.length; i += 1) { 279 a.push(res[i]); 280 } 281 282 return a; 283} 284 285function $(selector, context) { 286 const window = getWindow(); 287 const document = getDocument(); 288 let arr = []; 289 290 if (!context && selector instanceof Dom7) { 291 return selector; 292 } 293 294 if (!selector) { 295 return new Dom7(arr); 296 } 297 298 if (typeof selector === 'string') { 299 const html = selector.trim(); 300 301 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { 302 let toCreate = 'div'; 303 if (html.indexOf('<li') === 0) toCreate = 'ul'; 304 if (html.indexOf('<tr') === 0) toCreate = 'tbody'; 305 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; 306 if (html.indexOf('<tbody') === 0) toCreate = 'table'; 307 if (html.indexOf('<option') === 0) toCreate = 'select'; 308 const tempParent = document.createElement(toCreate); 309 tempParent.innerHTML = html; 310 311 for (let i = 0; i < tempParent.childNodes.length; i += 1) { 312 arr.push(tempParent.childNodes[i]); 313 } 314 } else { 315 arr = qsa(selector.trim(), context || document); 316 } // arr = qsa(selector, document); 317 318 } else if (selector.nodeType || selector === window || selector === document) { 319 arr.push(selector); 320 } else if (Array.isArray(selector)) { 321 if (selector instanceof Dom7) return selector; 322 arr = selector; 323 } 324 325 return new Dom7(arrayUnique(arr)); 326} 327 328$.fn = Dom7.prototype; // eslint-disable-next-line 329 330function addClass() { 331 for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { 332 classes[_key] = arguments[_key]; 333 } 334 335 const classNames = arrayFlat(classes.map(c => c.split(' '))); 336 this.forEach(el => { 337 el.classList.add(...classNames); 338 }); 339 return this; 340} 341 342function removeClass() { 343 for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 344 classes[_key2] = arguments[_key2]; 345 } 346 347 const classNames = arrayFlat(classes.map(c => c.split(' '))); 348 this.forEach(el => { 349 el.classList.remove(...classNames); 350 }); 351 return this; 352} 353 354function toggleClass() { 355 for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 356 classes[_key3] = arguments[_key3]; 357 } 358 359 const classNames = arrayFlat(classes.map(c => c.split(' '))); 360 this.forEach(el => { 361 classNames.forEach(className => { 362 el.classList.toggle(className); 363 }); 364 }); 365} 366 367function hasClass() { 368 for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 369 classes[_key4] = arguments[_key4]; 370 } 371 372 const classNames = arrayFlat(classes.map(c => c.split(' '))); 373 return arrayFilter(this, el => { 374 return classNames.filter(className => el.classList.contains(className)).length > 0; 375 }).length > 0; 376} 377 378function attr(attrs, value) { 379 if (arguments.length === 1 && typeof attrs === 'string') { 380 // Get attr 381 if (this[0]) return this[0].getAttribute(attrs); 382 return undefined; 383 } // Set attrs 384 385 386 for (let i = 0; i < this.length; i += 1) { 387 if (arguments.length === 2) { 388 // String 389 this[i].setAttribute(attrs, value); 390 } else { 391 // Object 392 for (const attrName in attrs) { 393 this[i][attrName] = attrs[attrName]; 394 this[i].setAttribute(attrName, attrs[attrName]); 395 } 396 } 397 } 398 399 return this; 400} 401 402function removeAttr(attr) { 403 for (let i = 0; i < this.length; i += 1) { 404 this[i].removeAttribute(attr); 405 } 406 407 return this; 408} 409 410function transform(transform) { 411 for (let i = 0; i < this.length; i += 1) { 412 this[i].style.transform = transform; 413 } 414 415 return this; 416} 417 418function transition$1(duration) { 419 for (let i = 0; i < this.length; i += 1) { 420 this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration; 421 } 422 423 return this; 424} 425 426function on() { 427 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { 428 args[_key5] = arguments[_key5]; 429 } 430 431 let [eventType, targetSelector, listener, capture] = args; 432 433 if (typeof args[1] === 'function') { 434 [eventType, listener, capture] = args; 435 targetSelector = undefined; 436 } 437 438 if (!capture) capture = false; 439 440 function handleLiveEvent(e) { 441 const target = e.target; 442 if (!target) return; 443 const eventData = e.target.dom7EventData || []; 444 445 if (eventData.indexOf(e) < 0) { 446 eventData.unshift(e); 447 } 448 449 if ($(target).is(targetSelector)) listener.apply(target, eventData);else { 450 const parents = $(target).parents(); // eslint-disable-line 451 452 for (let k = 0; k < parents.length; k += 1) { 453 if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData); 454 } 455 } 456 } 457 458 function handleEvent(e) { 459 const eventData = e && e.target ? e.target.dom7EventData || [] : []; 460 461 if (eventData.indexOf(e) < 0) { 462 eventData.unshift(e); 463 } 464 465 listener.apply(this, eventData); 466 } 467 468 const events = eventType.split(' '); 469 let j; 470 471 for (let i = 0; i < this.length; i += 1) { 472 const el = this[i]; 473 474 if (!targetSelector) { 475 for (j = 0; j < events.length; j += 1) { 476 const event = events[j]; 477 if (!el.dom7Listeners) el.dom7Listeners = {}; 478 if (!el.dom7Listeners[event]) el.dom7Listeners[event] = []; 479 el.dom7Listeners[event].push({ 480 listener, 481 proxyListener: handleEvent 482 }); 483 el.addEventListener(event, handleEvent, capture); 484 } 485 } else { 486 // Live events 487 for (j = 0; j < events.length; j += 1) { 488 const event = events[j]; 489 if (!el.dom7LiveListeners) el.dom7LiveListeners = {}; 490 if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = []; 491 el.dom7LiveListeners[event].push({ 492 listener, 493 proxyListener: handleLiveEvent 494 }); 495 el.addEventListener(event, handleLiveEvent, capture); 496 } 497 } 498 } 499 500 return this; 501} 502 503function off() { 504 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { 505 args[_key6] = arguments[_key6]; 506 } 507 508 let [eventType, targetSelector, listener, capture] = args; 509 510 if (typeof args[1] === 'function') { 511 [eventType, listener, capture] = args; 512 targetSelector = undefined; 513 } 514 515 if (!capture) capture = false; 516 const events = eventType.split(' '); 517 518 for (let i = 0; i < events.length; i += 1) { 519 const event = events[i]; 520 521 for (let j = 0; j < this.length; j += 1) { 522 const el = this[j]; 523 let handlers; 524 525 if (!targetSelector && el.dom7Listeners) { 526 handlers = el.dom7Listeners[event]; 527 } else if (targetSelector && el.dom7LiveListeners) { 528 handlers = el.dom7LiveListeners[event]; 529 } 530 531 if (handlers && handlers.length) { 532 for (let k = handlers.length - 1; k >= 0; k -= 1) { 533 const handler = handlers[k]; 534 535 if (listener && handler.listener === listener) { 536 el.removeEventListener(event, handler.proxyListener, capture); 537 handlers.splice(k, 1); 538 } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) { 539 el.removeEventListener(event, handler.proxyListener, capture); 540 handlers.splice(k, 1); 541 } else if (!listener) { 542 el.removeEventListener(event, handler.proxyListener, capture); 543 handlers.splice(k, 1); 544 } 545 } 546 } 547 } 548 } 549 550 return this; 551} 552 553function trigger() { 554 const window = getWindow(); 555 556 for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { 557 args[_key9] = arguments[_key9]; 558 } 559 560 const events = args[0].split(' '); 561 const eventData = args[1]; 562 563 for (let i = 0; i < events.length; i += 1) { 564 const event = events[i]; 565 566 for (let j = 0; j < this.length; j += 1) { 567 const el = this[j]; 568 569 if (window.CustomEvent) { 570 const evt = new window.CustomEvent(event, { 571 detail: eventData, 572 bubbles: true, 573 cancelable: true 574 }); 575 el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0); 576 el.dispatchEvent(evt); 577 el.dom7EventData = []; 578 delete el.dom7EventData; 579 } 580 } 581 } 582 583 return this; 584} 585 586function transitionEnd$1(callback) { 587 const dom = this; 588 589 function fireCallBack(e) { 590 if (e.target !== this) return; 591 callback.call(this, e); 592 dom.off('transitionend', fireCallBack); 593 } 594 595 if (callback) { 596 dom.on('transitionend', fireCallBack); 597 } 598 599 return this; 600} 601 602function outerWidth(includeMargins) { 603 if (this.length > 0) { 604 if (includeMargins) { 605 const styles = this.styles(); 606 return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left')); 607 } 608 609 return this[0].offsetWidth; 610 } 611 612 return null; 613} 614 615function outerHeight(includeMargins) { 616 if (this.length > 0) { 617 if (includeMargins) { 618 const styles = this.styles(); 619 return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom')); 620 } 621 622 return this[0].offsetHeight; 623 } 624 625 return null; 626} 627 628function offset() { 629 if (this.length > 0) { 630 const window = getWindow(); 631 const document = getDocument(); 632 const el = this[0]; 633 const box = el.getBoundingClientRect(); 634 const body = document.body; 635 const clientTop = el.clientTop || body.clientTop || 0; 636 const clientLeft = el.clientLeft || body.clientLeft || 0; 637 const scrollTop = el === window ? window.scrollY : el.scrollTop; 638 const scrollLeft = el === window ? window.scrollX : el.scrollLeft; 639 return { 640 top: box.top + scrollTop - clientTop, 641 left: box.left + scrollLeft - clientLeft 642 }; 643 } 644 645 return null; 646} 647 648function styles() { 649 const window = getWindow(); 650 if (this[0]) return window.getComputedStyle(this[0], null); 651 return {}; 652} 653 654function css(props, value) { 655 const window = getWindow(); 656 let i; 657 658 if (arguments.length === 1) { 659 if (typeof props === 'string') { 660 // .css('width') 661 if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); 662 } else { 663 // .css({ width: '100px' }) 664 for (i = 0; i < this.length; i += 1) { 665 for (const prop in props) { 666 this[i].style[prop] = props[prop]; 667 } 668 } 669 670 return this; 671 } 672 } 673 674 if (arguments.length === 2 && typeof props === 'string') { 675 // .css('width', '100px') 676 for (i = 0; i < this.length; i += 1) { 677 this[i].style[props] = value; 678 } 679 680 return this; 681 } 682 683 return this; 684} 685 686function each(callback) { 687 if (!callback) return this; 688 this.forEach((el, index) => { 689 callback.apply(el, [el, index]); 690 }); 691 return this; 692} 693 694function filter(callback) { 695 const result = arrayFilter(this, callback); 696 return $(result); 697} 698 699function html(html) { 700 if (typeof html === 'undefined') { 701 return this[0] ? this[0].innerHTML : null; 702 } 703 704 for (let i = 0; i < this.length; i += 1) { 705 this[i].innerHTML = html; 706 } 707 708 return this; 709} 710 711function text(text) { 712 if (typeof text === 'undefined') { 713 return this[0] ? this[0].textContent.trim() : null; 714 } 715 716 for (let i = 0; i < this.length; i += 1) { 717 this[i].textContent = text; 718 } 719 720 return this; 721} 722 723function is(selector) { 724 const window = getWindow(); 725 const document = getDocument(); 726 const el = this[0]; 727 let compareWith; 728 let i; 729 if (!el || typeof selector === 'undefined') return false;
vendor: 5,079 bytes, lines 730-966
730 731 if (typeof selector === 'string') { 732 if (el.matches) return el.matches(selector); 733 if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); 734 if (el.msMatchesSelector) return el.msMatchesSelector(selector); 735 compareWith = $(selector); 736 737 for (i = 0; i < compareWith.length; i += 1) { 738 if (compareWith[i] === el) return true; 739 } 740 741 return false; 742 } 743 744 if (selector === document) { 745 return el === document; 746 } 747 748 if (selector === window) { 749 return el === window; 750 } 751 752 if (selector.nodeType || selector instanceof Dom7) { 753 compareWith = selector.nodeType ? [selector] : selector; 754 755 for (i = 0; i < compareWith.length; i += 1) { 756 if (compareWith[i] === el) return true; 757 } 758 759 return false; 760 } 761 762 return false; 763} 764 765function index() { 766 let child = this[0]; 767 let i; 768 769 if (child) { 770 i = 0; // eslint-disable-next-line 771 772 while ((child = child.previousSibling) !== null) { 773 if (child.nodeType === 1) i += 1; 774 } 775 776 return i; 777 } 778 779 return undefined; 780} 781 782function eq(index) { 783 if (typeof index === 'undefined') return this; 784 const length = this.length; 785 786 if (index > length - 1) { 787 return $([]); 788 } 789 790 if (index < 0) { 791 const returnIndex = length + index; 792 if (returnIndex < 0) return $([]); 793 return $([this[returnIndex]]); 794 } 795 796 return $([this[index]]); 797} 798 799function append() { 800 let newChild; 801 const document = getDocument(); 802 803 for (let k = 0; k < arguments.length; k += 1) { 804 newChild = k < 0 || arguments.length <= k ? undefined : arguments[k]; 805 806 for (let i = 0; i < this.length; i += 1) { 807 if (typeof newChild === 'string') { 808 const tempDiv = document.createElement('div'); 809 tempDiv.innerHTML = newChild; 810 811 while (tempDiv.firstChild) { 812 this[i].appendChild(tempDiv.firstChild); 813 } 814 } else if (newChild instanceof Dom7) { 815 for (let j = 0; j < newChild.length; j += 1) { 816 this[i].appendChild(newChild[j]); 817 } 818 } else { 819 this[i].appendChild(newChild); 820 } 821 } 822 } 823 824 return this; 825} 826 827function prepend(newChild) { 828 const document = getDocument(); 829 let i; 830 let j; 831 832 for (i = 0; i < this.length; i += 1) { 833 if (typeof newChild === 'string') { 834 const tempDiv = document.createElement('div'); 835 tempDiv.innerHTML = newChild; 836 837 for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { 838 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); 839 } 840 } else if (newChild instanceof Dom7) { 841 for (j = 0; j < newChild.length; j += 1) { 842 this[i].insertBefore(newChild[j], this[i].childNodes[0]); 843 } 844 } else { 845 this[i].insertBefore(newChild, this[i].childNodes[0]); 846 } 847 } 848 849 return this; 850} 851 852function next(selector) { 853 if (this.length > 0) { 854 if (selector) { 855 if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { 856 return $([this[0].nextElementSibling]); 857 } 858 859 return $([]); 860 } 861 862 if (this[0].nextElementSibling) return $([this[0].nextElementSibling]); 863 return $([]); 864 } 865 866 return $([]); 867} 868 869function nextAll(selector) { 870 const nextEls = []; 871 let el = this[0]; 872 if (!el) return $([]); 873 874 while (el.nextElementSibling) { 875 const next = el.nextElementSibling; // eslint-disable-line 876 877 if (selector) { 878 if ($(next).is(selector)) nextEls.push(next); 879 } else nextEls.push(next); 880 881 el = next; 882 } 883 884 return $(nextEls); 885} 886 887function prev(selector) { 888 if (this.length > 0) { 889 const el = this[0]; 890 891 if (selector) { 892 if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { 893 return $([el.previousElementSibling]); 894 } 895 896 return $([]); 897 } 898 899 if (el.previousElementSibling) return $([el.previousElementSibling]); 900 return $([]); 901 } 902 903 return $([]); 904} 905 906function prevAll(selector) { 907 const prevEls = []; 908 let el = this[0]; 909 if (!el) return $([]); 910 911 while (el.previousElementSibling) { 912 const prev = el.previousElementSibling; // eslint-disable-line 913 914 if (selector) { 915 if ($(prev).is(selector)) prevEls.push(prev); 916 } else prevEls.push(prev); 917 918 el = prev; 919 } 920 921 return $(prevEls); 922} 923 924function parent(selector) { 925 const parents = []; // eslint-disable-line 926 927 for (let i = 0; i < this.length; i += 1) { 928 if (this[i].parentNode !== null) { 929 if (selector) { 930 if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); 931 } else { 932 parents.push(this[i].parentNode); 933 } 934 } 935 } 936 937 return $(parents); 938} 939 940function parents(selector) { 941 const parents = []; // eslint-disable-line 942 943 for (let i = 0; i < this.length; i += 1) { 944 let parent = this[i].parentNode; // eslint-disable-line 945 946 while (parent) { 947 if (selector) { 948 if ($(parent).is(selector)) parents.push(parent); 949 } else { 950 parents.push(parent); 951 } 952 953 parent = parent.parentNode; 954 } 955 } 956 957 return $(parents); 958} 959 960function closest(selector) { 961 let closest = this; // eslint-disable-line 962 963 if (typeof selector === 'undefined') { 964 return $([]); 965 } 966
vendor: 1,801 bytes, lines 967-1073
967 if (!closest.is(selector)) { 968 closest = closest.parents(selector).eq(0); 969 } 970 971 return closest; 972} 973 974function find(selector) { 975 const foundElements = []; 976 977 for (let i = 0; i < this.length; i += 1) { 978 const found = this[i].querySelectorAll(selector); 979 980 for (let j = 0; j < found.length; j += 1) { 981 foundElements.push(found[j]); 982 } 983 } 984 985 return $(foundElements); 986} 987 988function children(selector) { 989 const children = []; // eslint-disable-line 990 991 for (let i = 0; i < this.length; i += 1) { 992 const childNodes = this[i].children; 993 994 for (let j = 0; j < childNodes.length; j += 1) { 995 if (!selector || $(childNodes[j]).is(selector)) { 996 children.push(childNodes[j]); 997 } 998 } 999 } 1000 1001 return $(children); 1002} 1003 1004function remove() { 1005 for (let i = 0; i < this.length; i += 1) { 1006 if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); 1007 } 1008 1009 return this; 1010} 1011 1012const Methods = { 1013 addClass, 1014 removeClass, 1015 hasClass, 1016 toggleClass, 1017 attr, 1018 removeAttr, 1019 transform, 1020 transition: transition$1, 1021 on, 1022 off, 1023 trigger, 1024 transitionEnd: transitionEnd$1, 1025 outerWidth, 1026 outerHeight, 1027 styles, 1028 offset, 1029 css, 1030 each, 1031 html, 1032 text, 1033 is, 1034 index, 1035 eq, 1036 append, 1037 prepend, 1038 next, 1039 nextAll, 1040 prev, 1041 prevAll, 1042 parent, 1043 parents, 1044 closest, 1045 find, 1046 children, 1047 filter, 1048 remove 1049}; 1050Object.keys(Methods).forEach(methodName => { 1051 Object.defineProperty($.fn, methodName, { 1052 value: Methods[methodName], 1053 writable: true 1054 }); 1055}); 1056 1057function deleteProps(obj) { 1058 const object = obj; 1059 Object.keys(object).forEach(key => { 1060 try { 1061 object[key] = null; 1062 } catch (e) {// no getter for object 1063 } 1064 1065 try { 1066 delete object[key]; 1067 } catch (e) {// something got wrong 1068 } 1069 }); 1070} 1071 1072function nextTick(callback, delay) { 1073 if (delay === void 0) {
vendor: 4,694 bytes, lines 1074-1230
1074 delay = 0; 1075 } 1076 1077 return setTimeout(callback, delay); 1078} 1079 1080function now() { 1081 return Date.now(); 1082} 1083 1084function getComputedStyle$1(el) { 1085 const window = getWindow(); 1086 let style; 1087 1088 if (window.getComputedStyle) { 1089 style = window.getComputedStyle(el, null); 1090 } 1091 1092 if (!style && el.currentStyle) { 1093 style = el.currentStyle; 1094 } 1095 1096 if (!style) { 1097 style = el.style; 1098 } 1099 1100 return style; 1101} 1102 1103function getTranslate(el, axis) { 1104 if (axis === void 0) { 1105 axis = 'x'; 1106 } 1107 1108 const window = getWindow(); 1109 let matrix; 1110 let curTransform; 1111 let transformMatrix; 1112 const curStyle = getComputedStyle$1(el); 1113 1114 if (window.WebKitCSSMatrix) { 1115 curTransform = curStyle.transform || curStyle.webkitTransform; 1116 1117 if (curTransform.split(',').length > 6) { 1118 curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', '); 1119 } // Some old versions of Webkit choke when 'none' is passed; pass 1120 // empty string instead in this case 1121 1122 1123 transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); 1124 } else { 1125 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); 1126 matrix = transformMatrix.toString().split(','); 1127 } 1128 1129 if (axis === 'x') { 1130 // Latest Chrome and webkits Fix 1131 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix 1132 else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers 1133 else curTransform = parseFloat(matrix[4]); 1134 } 1135 1136 if (axis === 'y') { 1137 // Latest Chrome and webkits Fix 1138 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix 1139 else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers 1140 else curTransform = parseFloat(matrix[5]); 1141 } 1142 1143 return curTransform || 0; 1144} 1145 1146function isObject(o) { 1147 return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object'; 1148} 1149 1150function isNode(node) { 1151 // eslint-disable-next-line 1152 if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') { 1153 return node instanceof HTMLElement; 1154 } 1155 1156 return node && (node.nodeType === 1 || node.nodeType === 11); 1157} 1158 1159function extend() { 1160 const to = Object(arguments.length <= 0 ? undefined : arguments[0]); 1161 const noExtend = ['__proto__', 'constructor', 'prototype']; 1162 1163 for (let i = 1; i < arguments.length; i += 1) { 1164 const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; 1165 1166 if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) { 1167 const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0); 1168 1169 for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { 1170 const nextKey = keysArray[nextIndex]; 1171 const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 1172 1173 if (desc !== undefined && desc.enumerable) { 1174 if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 1175 if (nextSource[nextKey].__swiper__) { 1176 to[nextKey] = nextSource[nextKey]; 1177 } else { 1178 extend(to[nextKey], nextSource[nextKey]); 1179 } 1180 } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { 1181 to[nextKey] = {}; 1182 1183 if (nextSource[nextKey].__swiper__) { 1184 to[nextKey] = nextSource[nextKey]; 1185 } else { 1186 extend(to[nextKey], nextSource[nextKey]); 1187 } 1188 } else { 1189 to[nextKey] = nextSource[nextKey]; 1190 } 1191 } 1192 } 1193 } 1194 } 1195 1196 return to; 1197} 1198 1199function setCSSProperty(el, varName, varValue) { 1200 el.style.setProperty(varName, varValue); 1201} 1202 1203function animateCSSModeScroll(_ref) { 1204 let { 1205 swiper, 1206 targetPosition, 1207 side 1208 } = _ref; 1209 const window = getWindow(); 1210 const startPosition = -swiper.translate; 1211 let startTime = null; 1212 let time; 1213 const duration = swiper.params.speed; 1214 swiper.wrapperEl.style.scrollSnapType = 'none'; 1215 window.cancelAnimationFrame(swiper.cssModeFrameID); 1216 const dir = targetPosition > startPosition ? 'next' : 'prev'; 1217 1218 const isOutOfBound = (current, target) => { 1219 return dir === 'next' && current >= target || dir === 'prev' && current <= target; 1220 }; 1221 1222 const animate = () => { 1223 time = new Date().getTime(); 1224 1225 if (startTime === null) { 1226 startTime = time; 1227 } 1228 1229 const progress = Math.max(Math.min((time - startTime) / duration, 1), 0); 1230 const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
vendor: 1,807 bytes, lines 1231-1304
1231 let currentPosition = startPosition + easeProgress * (targetPosition - startPosition); 1232 1233 if (isOutOfBound(currentPosition, targetPosition)) { 1234 currentPosition = targetPosition; 1235 } 1236 1237 swiper.wrapperEl.scrollTo({ 1238 [side]: currentPosition 1239 }); 1240 1241 if (isOutOfBound(currentPosition, targetPosition)) { 1242 swiper.wrapperEl.style.overflow = 'hidden'; 1243 swiper.wrapperEl.style.scrollSnapType = ''; 1244 setTimeout(() => { 1245 swiper.wrapperEl.style.overflow = ''; 1246 swiper.wrapperEl.scrollTo({ 1247 [side]: currentPosition 1248 }); 1249 }); 1250 window.cancelAnimationFrame(swiper.cssModeFrameID); 1251 return; 1252 } 1253 1254 swiper.cssModeFrameID = window.requestAnimationFrame(animate); 1255 }; 1256 1257 animate(); 1258} 1259 1260let support; 1261 1262function calcSupport() { 1263 const window = getWindow(); 1264 const document = getDocument(); 1265 return { 1266 smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style, 1267 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch), 1268 passiveListener: function checkPassiveListener() { 1269 let supportsPassive = false; 1270 1271 try { 1272 const opts = Object.defineProperty({}, 'passive', { 1273 // eslint-disable-next-line 1274 get() { 1275 supportsPassive = true; 1276 } 1277 1278 }); 1279 window.addEventListener('testPassiveListener', null, opts); 1280 } catch (e) {// No support 1281 } 1282 1283 return supportsPassive; 1284 }(), 1285 gestures: function checkGestures() { 1286 return 'ongesturestart' in window; 1287 }() 1288 }; 1289} 1290 1291function getSupport() { 1292 if (!support) { 1293 support = calcSupport(); 1294 } 1295 1296 return support; 1297} 1298 1299let deviceCached; 1300 1301function calcDevice(_temp) { 1302 let { 1303 userAgent 1304 } = _temp === void 0 ? {} : _temp;
vendor: 8,827 bytes, lines 1305-1630
1305 const support = getSupport(); 1306 const window = getWindow(); 1307 const platform = window.navigator.platform; 1308 const ua = userAgent || window.navigator.userAgent; 1309 const device = { 1310 ios: false, 1311 android: false 1312 }; 1313 const screenWidth = window.screen.width; 1314 const screenHeight = window.screen.height; 1315 const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line 1316 1317 let ipad = ua.match(/(iPad).*OS\s([\d_]+)/); 1318 const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); 1319 const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); 1320 const windows = platform === 'Win32'; 1321 let macos = platform === 'MacIntel'; // iPadOs 13 fix 1322 1323 const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810']; 1324 1325 if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) { 1326 ipad = ua.match(/(Version)\/([\d.]+)/); 1327 if (!ipad) ipad = [0, 1, '13_0_0']; 1328 macos = false; 1329 } // Android 1330 1331 1332 if (android && !windows) { 1333 device.os = 'android'; 1334 device.android = true; 1335 } 1336 1337 if (ipad || iphone || ipod) { 1338 device.os = 'ios'; 1339 device.ios = true; 1340 } // Export object 1341 1342 1343 return device; 1344} 1345 1346function getDevice(overrides) { 1347 if (overrides === void 0) { 1348 overrides = {}; 1349 } 1350 1351 if (!deviceCached) { 1352 deviceCached = calcDevice(overrides); 1353 } 1354 1355 return deviceCached; 1356} 1357 1358let browser; 1359 1360function calcBrowser() { 1361 const window = getWindow(); 1362 1363 function isSafari() { 1364 const ua = window.navigator.userAgent.toLowerCase(); 1365 return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0; 1366 } 1367 1368 return { 1369 isSafari: isSafari(), 1370 isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent) 1371 }; 1372} 1373 1374function getBrowser() { 1375 if (!browser) { 1376 browser = calcBrowser(); 1377 } 1378 1379 return browser; 1380} 1381 1382function Resize(_ref) { 1383 let { 1384 swiper, 1385 on, 1386 emit 1387 } = _ref; 1388 const window = getWindow(); 1389 let observer = null; 1390 let animationFrame = null; 1391 1392 const resizeHandler = () => { 1393 if (!swiper || swiper.destroyed || !swiper.initialized) return; 1394 emit('beforeResize'); 1395 emit('resize'); 1396 }; 1397 1398 const createObserver = () => { 1399 if (!swiper || swiper.destroyed || !swiper.initialized) return; 1400 observer = new ResizeObserver(entries => { 1401 animationFrame = window.requestAnimationFrame(() => { 1402 const { 1403 width, 1404 height 1405 } = swiper; 1406 let newWidth = width; 1407 let newHeight = height; 1408 entries.forEach(_ref2 => { 1409 let { 1410 contentBoxSize, 1411 contentRect, 1412 target 1413 } = _ref2; 1414 if (target && target !== swiper.el) return; 1415 newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize; 1416 newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize; 1417 }); 1418 1419 if (newWidth !== width || newHeight !== height) { 1420 resizeHandler(); 1421 } 1422 }); 1423 }); 1424 observer.observe(swiper.el); 1425 }; 1426 1427 const removeObserver = () => { 1428 if (animationFrame) { 1429 window.cancelAnimationFrame(animationFrame); 1430 } 1431 1432 if (observer && observer.unobserve && swiper.el) { 1433 observer.unobserve(swiper.el); 1434 observer = null; 1435 } 1436 }; 1437 1438 const orientationChangeHandler = () => { 1439 if (!swiper || swiper.destroyed || !swiper.initialized) return; 1440 emit('orientationchange'); 1441 }; 1442 1443 on('init', () => { 1444 if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') { 1445 createObserver(); 1446 return; 1447 } 1448 1449 window.addEventListener('resize', resizeHandler); 1450 window.addEventListener('orientationchange', orientationChangeHandler); 1451 }); 1452 on('destroy', () => { 1453 removeObserver(); 1454 window.removeEventListener('resize', resizeHandler); 1455 window.removeEventListener('orientationchange', orientationChangeHandler); 1456 }); 1457} 1458 1459function Observer(_ref) { 1460 let { 1461 swiper, 1462 extendParams, 1463 on, 1464 emit 1465 } = _ref; 1466 const observers = []; 1467 const window = getWindow(); 1468 1469 const attach = function (target, options) { 1470 if (options === void 0) { 1471 options = {}; 1472 } 1473 1474 const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver; 1475 const observer = new ObserverFunc(mutations => { 1476 // The observerUpdate event should only be triggered 1477 // once despite the number of mutations. Additional 1478 // triggers are redundant and are very costly 1479 if (mutations.length === 1) { 1480 emit('observerUpdate', mutations[0]); 1481 return; 1482 } 1483 1484 const observerUpdate = function observerUpdate() { 1485 emit('observerUpdate', mutations[0]); 1486 }; 1487 1488 if (window.requestAnimationFrame) { 1489 window.requestAnimationFrame(observerUpdate); 1490 } else { 1491 window.setTimeout(observerUpdate, 0); 1492 } 1493 }); 1494 observer.observe(target, { 1495 attributes: typeof options.attributes === 'undefined' ? true : options.attributes, 1496 childList: typeof options.childList === 'undefined' ? true : options.childList, 1497 characterData: typeof options.characterData === 'undefined' ? true : options.characterData 1498 }); 1499 observers.push(observer); 1500 }; 1501 1502 const init = () => { 1503 if (!swiper.params.observer) return; 1504 1505 if (swiper.params.observeParents) { 1506 const containerParents = swiper.$el.parents(); 1507 1508 for (let i = 0; i < containerParents.length; i += 1) { 1509 attach(containerParents[i]); 1510 } 1511 } // Observe container 1512 1513 1514 attach(swiper.$el[0], { 1515 childList: swiper.params.observeSlideChildren 1516 }); // Observe wrapper 1517 1518 attach(swiper.$wrapperEl[0], { 1519 attributes: false 1520 }); 1521 }; 1522 1523 const destroy = () => { 1524 observers.forEach(observer => { 1525 observer.disconnect(); 1526 }); 1527 observers.splice(0, observers.length); 1528 }; 1529 1530 extendParams({ 1531 observer: false, 1532 observeParents: false, 1533 observeSlideChildren: false 1534 }); 1535 on('init', init); 1536 on('destroy', destroy); 1537} 1538 1539/* eslint-disable no-underscore-dangle */ 1540var eventsEmitter = { 1541 on(events, handler, priority) { 1542 const self = this; 1543 if (!self.eventsListeners || self.destroyed) return self; 1544 if (typeof handler !== 'function') return self; 1545 const method = priority ? 'unshift' : 'push'; 1546 events.split(' ').forEach(event => { 1547 if (!self.eventsListeners[event]) self.eventsListeners[event] = []; 1548 self.eventsListeners[event][method](handler); 1549 }); 1550 return self; 1551 }, 1552 1553 once(events, handler, priority) { 1554 const self = this; 1555 if (!self.eventsListeners || self.destroyed) return self; 1556 if (typeof handler !== 'function') return self; 1557 1558 function onceHandler() { 1559 self.off(events, onceHandler); 1560 1561 if (onceHandler.__emitterProxy) { 1562 delete onceHandler.__emitterProxy; 1563 } 1564 1565 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 1566 args[_key] = arguments[_key]; 1567 } 1568 1569 handler.apply(self, args); 1570 } 1571 1572 onceHandler.__emitterProxy = handler; 1573 return self.on(events, onceHandler, priority); 1574 }, 1575 1576 onAny(handler, priority) { 1577 const self = this; 1578 if (!self.eventsListeners || self.destroyed) return self; 1579 if (typeof handler !== 'function') return self; 1580 const method = priority ? 'unshift' : 'push'; 1581 1582 if (self.eventsAnyListeners.indexOf(handler) < 0) { 1583 self.eventsAnyListeners[method](handler); 1584 } 1585 1586 return self; 1587 }, 1588 1589 offAny(handler) { 1590 const self = this; 1591 if (!self.eventsListeners || self.destroyed) return self; 1592 if (!self.eventsAnyListeners) return self; 1593 const index = self.eventsAnyListeners.indexOf(handler); 1594 1595 if (index >= 0) { 1596 self.eventsAnyListeners.splice(index, 1); 1597 } 1598 1599 return self; 1600 }, 1601 1602 off(events, handler) { 1603 const self = this; 1604 if (!self.eventsListeners || self.destroyed) return self; 1605 if (!self.eventsListeners) return self; 1606 events.split(' ').forEach(event => { 1607 if (typeof handler === 'undefined') { 1608 self.eventsListeners[event] = []; 1609 } else if (self.eventsListeners[event]) { 1610 self.eventsListeners[event].forEach((eventHandler, index) => { 1611 if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) { 1612 self.eventsListeners[event].splice(index, 1); 1613 } 1614 }); 1615 } 1616 }); 1617 return self; 1618 }, 1619 1620 emit() { 1621 const self = this; 1622 if (!self.eventsListeners || self.destroyed) return self; 1623 if (!self.eventsListeners) return self; 1624 let events; 1625 let data; 1626 let context; 1627 1628 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 1629 args[_key2] = arguments[_key2]; 1630 }
vendor: 11,741 bytes, lines 1630-2002
1630 1631 1632 if (typeof args[0] === 'string' || Array.isArray(args[0])) { 1633 events = args[0]; 1634 data = args.slice(1, args.length); 1635 context = self; 1636 } else { 1637 events = args[0].events; 1638 data = args[0].data; 1639 context = args[0].context || self; 1640 } 1641 1642 data.unshift(context); 1643 const eventsArray = Array.isArray(events) ? events : events.split(' '); 1644 eventsArray.forEach(event => { 1645 if (self.eventsAnyListeners && self.eventsAnyListeners.length) { 1646 self.eventsAnyListeners.forEach(eventHandler => { 1647 eventHandler.apply(context, [event, ...data]); 1648 }); 1649 } 1650 1651 if (self.eventsListeners && self.eventsListeners[event]) { 1652 self.eventsListeners[event].forEach(eventHandler => { 1653 eventHandler.apply(context, data); 1654 }); 1655 } 1656 }); 1657 return self; 1658 } 1659 1660}; 1661 1662function updateSize() { 1663 const swiper = this; 1664 let width; 1665 let height; 1666 const $el = swiper.$el; 1667 1668 if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) { 1669 width = swiper.params.width; 1670 } else { 1671 width = $el[0].clientWidth; 1672 } 1673 1674 if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) { 1675 height = swiper.params.height; 1676 } else { 1677 height = $el[0].clientHeight; 1678 } 1679 1680 if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) { 1681 return; 1682 } // Subtract paddings 1683 1684 1685 width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10); 1686 height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10); 1687 if (Number.isNaN(width)) width = 0; 1688 if (Number.isNaN(height)) height = 0; 1689 Object.assign(swiper, { 1690 width, 1691 height, 1692 size: swiper.isHorizontal() ? width : height 1693 }); 1694} 1695 1696function updateSlides() { 1697 const swiper = this; 1698 1699 function getDirectionLabel(property) { 1700 if (swiper.isHorizontal()) { 1701 return property; 1702 } // prettier-ignore 1703 1704 1705 return { 1706 'width': 'height', 1707 'margin-top': 'margin-left', 1708 'margin-bottom ': 'margin-right', 1709 'margin-left': 'margin-top', 1710 'margin-right': 'margin-bottom', 1711 'padding-left': 'padding-top', 1712 'padding-right': 'padding-bottom', 1713 'marginRight': 'marginBottom' 1714 }[property]; 1715 } 1716 1717 function getDirectionPropertyValue(node, label) { 1718 return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0); 1719 } 1720 1721 const params = swiper.params; 1722 const { 1723 $wrapperEl, 1724 size: swiperSize, 1725 rtlTranslate: rtl, 1726 wrongRTL 1727 } = swiper; 1728 const isVirtual = swiper.virtual && params.virtual.enabled; 1729 const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; 1730 const slides = $wrapperEl.children(`.${swiper.params.slideClass}`); 1731 const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; 1732 let snapGrid = []; 1733 const slidesGrid = []; 1734 const slidesSizesGrid = []; 1735 let offsetBefore = params.slidesOffsetBefore; 1736 1737 if (typeof offsetBefore === 'function') { 1738 offsetBefore = params.slidesOffsetBefore.call(swiper); 1739 } 1740 1741 let offsetAfter = params.slidesOffsetAfter; 1742 1743 if (typeof offsetAfter === 'function') { 1744 offsetAfter = params.slidesOffsetAfter.call(swiper); 1745 } 1746 1747 const previousSnapGridLength = swiper.snapGrid.length; 1748 const previousSlidesGridLength = swiper.slidesGrid.length; 1749 let spaceBetween = params.spaceBetween; 1750 let slidePosition = -offsetBefore; 1751 let prevSlideSize = 0; 1752 let index = 0; 1753 1754 if (typeof swiperSize === 'undefined') { 1755 return; 1756 } 1757 1758 if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { 1759 spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize; 1760 } 1761 1762 swiper.virtualSize = -spaceBetween; // reset margins 1763 1764 if (rtl) slides.css({ 1765 marginLeft: '', 1766 marginBottom: '', 1767 marginTop: '' 1768 });else slides.css({ 1769 marginRight: '', 1770 marginBottom: '', 1771 marginTop: '' 1772 }); // reset cssMode offsets 1773 1774 if (params.centeredSlides && params.cssMode) { 1775 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', ''); 1776 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', ''); 1777 } 1778 1779 const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid; 1780 1781 if (gridEnabled) { 1782 swiper.grid.initSlides(slidesLength); 1783 } // Calc slides 1784 1785 1786 let slideSize; 1787 const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => { 1788 return typeof params.breakpoints[key].slidesPerView !== 'undefined'; 1789 }).length > 0; 1790 1791 for (let i = 0; i < slidesLength; i += 1) { 1792 slideSize = 0; 1793 const slide = slides.eq(i); 1794 1795 if (gridEnabled) { 1796 swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel); 1797 } 1798 1799 if (slide.css('display') === 'none') continue; // eslint-disable-line 1800 1801 if (params.slidesPerView === 'auto') { 1802 if (shouldResetSlideSize) { 1803 slides[i].style[getDirectionLabel('width')] = ``; 1804 } 1805 1806 const slideStyles = getComputedStyle(slide[0]); 1807 const currentTransform = slide[0].style.transform; 1808 const currentWebKitTransform = slide[0].style.webkitTransform; 1809 1810 if (currentTransform) { 1811 slide[0].style.transform = 'none'; 1812 } 1813 1814 if (currentWebKitTransform) { 1815 slide[0].style.webkitTransform = 'none'; 1816 } 1817 1818 if (params.roundLengths) { 1819 slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true); 1820 } else { 1821 // eslint-disable-next-line 1822 const width = getDirectionPropertyValue(slideStyles, 'width'); 1823 const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left'); 1824 const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right'); 1825 const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left'); 1826 const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right'); 1827 const boxSizing = slideStyles.getPropertyValue('box-sizing'); 1828 1829 if (boxSizing && boxSizing === 'border-box') { 1830 slideSize = width + marginLeft + marginRight; 1831 } else { 1832 const { 1833 clientWidth, 1834 offsetWidth 1835 } = slide[0]; 1836 slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth); 1837 } 1838 } 1839 1840 if (currentTransform) { 1841 slide[0].style.transform = currentTransform; 1842 } 1843 1844 if (currentWebKitTransform) { 1845 slide[0].style.webkitTransform = currentWebKitTransform; 1846 } 1847 1848 if (params.roundLengths) slideSize = Math.floor(slideSize); 1849 } else { 1850 slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView; 1851 if (params.roundLengths) slideSize = Math.floor(slideSize); 1852 1853 if (slides[i]) { 1854 slides[i].style[getDirectionLabel('width')] = `${slideSize}px`; 1855 } 1856 } 1857 1858 if (slides[i]) { 1859 slides[i].swiperSlideSize = slideSize; 1860 } 1861 1862 slidesSizesGrid.push(slideSize); 1863 1864 if (params.centeredSlides) { 1865 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween; 1866 if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 1867 if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween; 1868 if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0; 1869 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 1870 if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition); 1871 slidesGrid.push(slidePosition); 1872 } else { 1873 if (params.roundLengths) slidePosition = Math.floor(slidePosition); 1874 if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition); 1875 slidesGrid.push(slidePosition); 1876 slidePosition = slidePosition + slideSize + spaceBetween; 1877 } 1878 1879 swiper.virtualSize += slideSize + spaceBetween; 1880 prevSlideSize = slideSize; 1881 index += 1; 1882 } 1883 1884 swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; 1885 1886 if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { 1887 $wrapperEl.css({ 1888 width: `${swiper.virtualSize + params.spaceBetween}px` 1889 }); 1890 } 1891 1892 if (params.setWrapperSize) { 1893 $wrapperEl.css({ 1894 [getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px` 1895 }); 1896 } 1897 1898 if (gridEnabled) { 1899 swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel); 1900 } // Remove last grid elements depending on width 1901 1902 1903 if (!params.centeredSlides) { 1904 const newSlidesGrid = []; 1905 1906 for (let i = 0; i < snapGrid.length; i += 1) { 1907 let slidesGridItem = snapGrid[i]; 1908 if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem); 1909 1910 if (snapGrid[i] <= swiper.virtualSize - swiperSize) { 1911 newSlidesGrid.push(slidesGridItem); 1912 } 1913 } 1914 1915 snapGrid = newSlidesGrid; 1916 1917 if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { 1918 snapGrid.push(swiper.virtualSize - swiperSize); 1919 } 1920 } 1921 1922 if (snapGrid.length === 0) snapGrid = [0]; 1923 1924 if (params.spaceBetween !== 0) { 1925 const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight'); 1926 slides.filter((_, slideIndex) => { 1927 if (!params.cssMode) return true; 1928 1929 if (slideIndex === slides.length - 1) { 1930 return false; 1931 } 1932 1933 return true; 1934 }).css({ 1935 [key]: `${spaceBetween}px` 1936 }); 1937 } 1938 1939 if (params.centeredSlides && params.centeredSlidesBounds) { 1940 let allSlidesSize = 0; 1941 slidesSizesGrid.forEach(slideSizeValue => { 1942 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); 1943 }); 1944 allSlidesSize -= params.spaceBetween; 1945 const maxSnap = allSlidesSize - swiperSize; 1946 snapGrid = snapGrid.map(snap => { 1947 if (snap < 0) return -offsetBefore; 1948 if (snap > maxSnap) return maxSnap + offsetAfter; 1949 return snap; 1950 }); 1951 } 1952 1953 if (params.centerInsufficientSlides) { 1954 let allSlidesSize = 0; 1955 slidesSizesGrid.forEach(slideSizeValue => { 1956 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); 1957 }); 1958 allSlidesSize -= params.spaceBetween; 1959 1960 if (allSlidesSize < swiperSize) { 1961 const allSlidesOffset = (swiperSize - allSlidesSize) / 2; 1962 snapGrid.forEach((snap, snapIndex) => { 1963 snapGrid[snapIndex] = snap - allSlidesOffset; 1964 }); 1965 slidesGrid.forEach((snap, snapIndex) => { 1966 slidesGrid[snapIndex] = snap + allSlidesOffset; 1967 }); 1968 } 1969 } 1970 1971 Object.assign(swiper, { 1972 slides, 1973 snapGrid, 1974 slidesGrid, 1975 slidesSizesGrid 1976 }); 1977 1978 if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) { 1979 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`); 1980 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`); 1981 const addToSnapGrid = -swiper.snapGrid[0]; 1982 const addToSlidesGrid = -swiper.slidesGrid[0]; 1983 swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid); 1984 swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid); 1985 } 1986 1987 if (slidesLength !== previousSlidesLength) { 1988 swiper.emit('slidesLengthChange'); 1989 } 1990 1991 if (snapGrid.length !== previousSnapGridLength) { 1992 if (swiper.params.watchOverflow) swiper.checkOverflow(); 1993 swiper.emit('snapGridLengthChange'); 1994 } 1995 1996 if (slidesGrid.length !== previousSlidesGridLength) { 1997 swiper.emit('slidesGridLengthChange'); 1998 } 1999 2000 if (params.watchSlidesProgress) { 2001 swiper.updateSlidesOffset(); 2002 }
vendor: 19,001 bytes, lines 2003-2699
2003 2004 if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) { 2005 const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`; 2006 const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass); 2007 2008 if (slidesLength <= params.maxBackfaceHiddenSlides) { 2009 if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass); 2010 } else if (hasClassBackfaceClassAdded) { 2011 swiper.$el.removeClass(backFaceHiddenClass); 2012 } 2013 } 2014} 2015 2016function updateAutoHeight(speed) { 2017 const swiper = this; 2018 const activeSlides = []; 2019 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 2020 let newHeight = 0; 2021 let i; 2022 2023 if (typeof speed === 'number') { 2024 swiper.setTransition(speed); 2025 } else if (speed === true) { 2026 swiper.setTransition(swiper.params.speed); 2027 } 2028 2029 const getSlideByIndex = index => { 2030 if (isVirtual) { 2031 return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) === index)[0]; 2032 } 2033 2034 return swiper.slides.eq(index)[0]; 2035 }; // Find slides currently in view 2036 2037 2038 if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { 2039 if (swiper.params.centeredSlides) { 2040 (swiper.visibleSlides || $([])).each(slide => { 2041 activeSlides.push(slide); 2042 }); 2043 } else { 2044 for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { 2045 const index = swiper.activeIndex + i; 2046 if (index > swiper.slides.length && !isVirtual) break; 2047 activeSlides.push(getSlideByIndex(index)); 2048 } 2049 } 2050 } else { 2051 activeSlides.push(getSlideByIndex(swiper.activeIndex)); 2052 } // Find new height from highest slide in view 2053 2054 2055 for (i = 0; i < activeSlides.length; i += 1) { 2056 if (typeof activeSlides[i] !== 'undefined') { 2057 const height = activeSlides[i].offsetHeight; 2058 newHeight = height > newHeight ? height : newHeight; 2059 } 2060 } // Update Height 2061 2062 2063 if (newHeight || newHeight === 0) swiper.$wrapperEl.css('height', `${newHeight}px`); 2064} 2065 2066function updateSlidesOffset() { 2067 const swiper = this; 2068 const slides = swiper.slides; 2069 2070 for (let i = 0; i < slides.length; i += 1) { 2071 slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; 2072 } 2073} 2074 2075function updateSlidesProgress(translate) { 2076 if (translate === void 0) { 2077 translate = this && this.translate || 0; 2078 } 2079 2080 const swiper = this; 2081 const params = swiper.params; 2082 const { 2083 slides, 2084 rtlTranslate: rtl, 2085 snapGrid 2086 } = swiper; 2087 if (slides.length === 0) return; 2088 if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset(); 2089 let offsetCenter = -translate; 2090 if (rtl) offsetCenter = translate; // Visible Slides 2091 2092 slides.removeClass(params.slideVisibleClass); 2093 swiper.visibleSlidesIndexes = []; 2094 swiper.visibleSlides = []; 2095 2096 for (let i = 0; i < slides.length; i += 1) { 2097 const slide = slides[i]; 2098 let slideOffset = slide.swiperSlideOffset; 2099 2100 if (params.cssMode && params.centeredSlides) { 2101 slideOffset -= slides[0].swiperSlideOffset; 2102 } 2103 2104 const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween); 2105 const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween); 2106 const slideBefore = -(offsetCenter - slideOffset); 2107 const slideAfter = slideBefore + swiper.slidesSizesGrid[i]; 2108 const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size; 2109 2110 if (isVisible) { 2111 swiper.visibleSlides.push(slide); 2112 swiper.visibleSlidesIndexes.push(i); 2113 slides.eq(i).addClass(params.slideVisibleClass); 2114 } 2115 2116 slide.progress = rtl ? -slideProgress : slideProgress; 2117 slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress; 2118 } 2119 2120 swiper.visibleSlides = $(swiper.visibleSlides); 2121} 2122 2123function updateProgress(translate) { 2124 const swiper = this; 2125 2126 if (typeof translate === 'undefined') { 2127 const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line 2128 2129 translate = swiper && swiper.translate && swiper.translate * multiplier || 0; 2130 } 2131 2132 const params = swiper.params; 2133 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 2134 let { 2135 progress, 2136 isBeginning, 2137 isEnd 2138 } = swiper; 2139 const wasBeginning = isBeginning; 2140 const wasEnd = isEnd; 2141 2142 if (translatesDiff === 0) { 2143 progress = 0; 2144 isBeginning = true; 2145 isEnd = true; 2146 } else { 2147 progress = (translate - swiper.minTranslate()) / translatesDiff; 2148 isBeginning = progress <= 0; 2149 isEnd = progress >= 1; 2150 } 2151 2152 Object.assign(swiper, { 2153 progress, 2154 isBeginning, 2155 isEnd 2156 }); 2157 if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate); 2158 2159 if (isBeginning && !wasBeginning) { 2160 swiper.emit('reachBeginning toEdge'); 2161 } 2162 2163 if (isEnd && !wasEnd) { 2164 swiper.emit('reachEnd toEdge'); 2165 } 2166 2167 if (wasBeginning && !isBeginning || wasEnd && !isEnd) { 2168 swiper.emit('fromEdge'); 2169 } 2170 2171 swiper.emit('progress', progress); 2172} 2173 2174function updateSlidesClasses() { 2175 const swiper = this; 2176 const { 2177 slides, 2178 params, 2179 $wrapperEl, 2180 activeIndex, 2181 realIndex 2182 } = swiper; 2183 const isVirtual = swiper.virtual && params.virtual.enabled; 2184 slides.removeClass(`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`); 2185 let activeSlide; 2186 2187 if (isVirtual) { 2188 activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`); 2189 } else { 2190 activeSlide = slides.eq(activeIndex); 2191 } // Active classes 2192 2193 2194 activeSlide.addClass(params.slideActiveClass); 2195 2196 if (params.loop) { 2197 // Duplicate to all looped slides 2198 if (activeSlide.hasClass(params.slideDuplicateClass)) { 2199 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass); 2200 } else { 2201 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass); 2202 } 2203 } // Next Slide 2204 2205 2206 let nextSlide = activeSlide.nextAll(`.${params.slideClass}`).eq(0).addClass(params.slideNextClass); 2207 2208 if (params.loop && nextSlide.length === 0) { 2209 nextSlide = slides.eq(0); 2210 nextSlide.addClass(params.slideNextClass); 2211 } // Prev Slide 2212 2213 2214 let prevSlide = activeSlide.prevAll(`.${params.slideClass}`).eq(0).addClass(params.slidePrevClass); 2215 2216 if (params.loop && prevSlide.length === 0) { 2217 prevSlide = slides.eq(-1); 2218 prevSlide.addClass(params.slidePrevClass); 2219 } 2220 2221 if (params.loop) { 2222 // Duplicate to all looped slides 2223 if (nextSlide.hasClass(params.slideDuplicateClass)) { 2224 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass); 2225 } else { 2226 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass); 2227 } 2228 2229 if (prevSlide.hasClass(params.slideDuplicateClass)) { 2230 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass); 2231 } else { 2232 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass); 2233 } 2234 } 2235 2236 swiper.emitSlidesClasses(); 2237} 2238 2239function updateActiveIndex(newActiveIndex) { 2240 const swiper = this; 2241 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 2242 const { 2243 slidesGrid, 2244 snapGrid, 2245 params, 2246 activeIndex: previousIndex, 2247 realIndex: previousRealIndex, 2248 snapIndex: previousSnapIndex 2249 } = swiper; 2250 let activeIndex = newActiveIndex; 2251 let snapIndex; 2252 2253 if (typeof activeIndex === 'undefined') { 2254 for (let i = 0; i < slidesGrid.length; i += 1) { 2255 if (typeof slidesGrid[i + 1] !== 'undefined') { 2256 if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) { 2257 activeIndex = i; 2258 } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { 2259 activeIndex = i + 1; 2260 } 2261 } else if (translate >= slidesGrid[i]) { 2262 activeIndex = i; 2263 } 2264 } // Normalize slideIndex 2265 2266 2267 if (params.normalizeSlideIndex) { 2268 if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0; 2269 } 2270 } 2271 2272 if (snapGrid.indexOf(translate) >= 0) { 2273 snapIndex = snapGrid.indexOf(translate); 2274 } else { 2275 const skip = Math.min(params.slidesPerGroupSkip, activeIndex); 2276 snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup); 2277 } 2278 2279 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 2280 2281 if (activeIndex === previousIndex) { 2282 if (snapIndex !== previousSnapIndex) { 2283 swiper.snapIndex = snapIndex; 2284 swiper.emit('snapIndexChange'); 2285 } 2286 2287 return; 2288 } // Get real index 2289 2290 2291 const realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); 2292 Object.assign(swiper, { 2293 snapIndex, 2294 realIndex, 2295 previousIndex, 2296 activeIndex 2297 }); 2298 swiper.emit('activeIndexChange'); 2299 swiper.emit('snapIndexChange'); 2300 2301 if (previousRealIndex !== realIndex) { 2302 swiper.emit('realIndexChange'); 2303 } 2304 2305 if (swiper.initialized || swiper.params.runCallbacksOnInit) { 2306 swiper.emit('slideChange'); 2307 } 2308} 2309 2310function updateClickedSlide(e) { 2311 const swiper = this; 2312 const params = swiper.params; 2313 const slide = $(e).closest(`.${params.slideClass}`)[0]; 2314 let slideFound = false; 2315 let slideIndex; 2316 2317 if (slide) { 2318 for (let i = 0; i < swiper.slides.length; i += 1) { 2319 if (swiper.slides[i] === slide) { 2320 slideFound = true; 2321 slideIndex = i; 2322 break; 2323 } 2324 } 2325 } 2326 2327 if (slide && slideFound) { 2328 swiper.clickedSlide = slide; 2329 2330 if (swiper.virtual && swiper.params.virtual.enabled) { 2331 swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); 2332 } else { 2333 swiper.clickedIndex = slideIndex; 2334 } 2335 } else { 2336 swiper.clickedSlide = undefined; 2337 swiper.clickedIndex = undefined; 2338 return; 2339 } 2340 2341 if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { 2342 swiper.slideToClickedSlide(); 2343 } 2344} 2345 2346var update = { 2347 updateSize, 2348 updateSlides, 2349 updateAutoHeight, 2350 updateSlidesOffset, 2351 updateSlidesProgress, 2352 updateProgress, 2353 updateSlidesClasses, 2354 updateActiveIndex, 2355 updateClickedSlide 2356}; 2357 2358function getSwiperTranslate(axis) { 2359 if (axis === void 0) { 2360 axis = this.isHorizontal() ? 'x' : 'y'; 2361 } 2362 2363 const swiper = this; 2364 const { 2365 params, 2366 rtlTranslate: rtl, 2367 translate, 2368 $wrapperEl 2369 } = swiper; 2370 2371 if (params.virtualTranslate) { 2372 return rtl ? -translate : translate; 2373 } 2374 2375 if (params.cssMode) { 2376 return translate; 2377 } 2378 2379 let currentTranslate = getTranslate($wrapperEl[0], axis); 2380 if (rtl) currentTranslate = -currentTranslate; 2381 return currentTranslate || 0; 2382} 2383 2384function setTranslate(translate, byController) { 2385 const swiper = this; 2386 const { 2387 rtlTranslate: rtl, 2388 params, 2389 $wrapperEl, 2390 wrapperEl, 2391 progress 2392 } = swiper; 2393 let x = 0; 2394 let y = 0; 2395 const z = 0; 2396 2397 if (swiper.isHorizontal()) { 2398 x = rtl ? -translate : translate; 2399 } else { 2400 y = translate; 2401 } 2402 2403 if (params.roundLengths) { 2404 x = Math.floor(x); 2405 y = Math.floor(y); 2406 } 2407 2408 if (params.cssMode) { 2409 wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y; 2410 } else if (!params.virtualTranslate) { 2411 $wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`); 2412 } 2413 2414 swiper.previousTranslate = swiper.translate; 2415 swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress 2416 2417 let newProgress; 2418 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 2419 2420 if (translatesDiff === 0) { 2421 newProgress = 0; 2422 } else { 2423 newProgress = (translate - swiper.minTranslate()) / translatesDiff; 2424 } 2425 2426 if (newProgress !== progress) { 2427 swiper.updateProgress(translate); 2428 } 2429 2430 swiper.emit('setTranslate', swiper.translate, byController); 2431} 2432 2433function minTranslate() { 2434 return -this.snapGrid[0]; 2435} 2436 2437function maxTranslate() { 2438 return -this.snapGrid[this.snapGrid.length - 1]; 2439} 2440 2441function translateTo(translate, speed, runCallbacks, translateBounds, internal) { 2442 if (translate === void 0) { 2443 translate = 0; 2444 } 2445 2446 if (speed === void 0) { 2447 speed = this.params.speed; 2448 } 2449 2450 if (runCallbacks === void 0) { 2451 runCallbacks = true; 2452 } 2453 2454 if (translateBounds === void 0) { 2455 translateBounds = true; 2456 } 2457 2458 const swiper = this; 2459 const { 2460 params, 2461 wrapperEl 2462 } = swiper; 2463 2464 if (swiper.animating && params.preventInteractionOnTransition) { 2465 return false; 2466 } 2467 2468 const minTranslate = swiper.minTranslate(); 2469 const maxTranslate = swiper.maxTranslate(); 2470 let newTranslate; 2471 if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress 2472 2473 swiper.updateProgress(newTranslate); 2474 2475 if (params.cssMode) { 2476 const isH = swiper.isHorizontal(); 2477 2478 if (speed === 0) { 2479 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate; 2480 } else { 2481 if (!swiper.support.smoothScroll) { 2482 animateCSSModeScroll({ 2483 swiper, 2484 targetPosition: -newTranslate, 2485 side: isH ? 'left' : 'top' 2486 }); 2487 return true; 2488 } 2489 2490 wrapperEl.scrollTo({ 2491 [isH ? 'left' : 'top']: -newTranslate, 2492 behavior: 'smooth' 2493 }); 2494 } 2495 2496 return true; 2497 } 2498 2499 if (speed === 0) { 2500 swiper.setTransition(0); 2501 swiper.setTranslate(newTranslate); 2502 2503 if (runCallbacks) { 2504 swiper.emit('beforeTransitionStart', speed, internal); 2505 swiper.emit('transitionEnd'); 2506 } 2507 } else { 2508 swiper.setTransition(speed); 2509 swiper.setTranslate(newTranslate); 2510 2511 if (runCallbacks) { 2512 swiper.emit('beforeTransitionStart', speed, internal); 2513 swiper.emit('transitionStart'); 2514 } 2515 2516 if (!swiper.animating) { 2517 swiper.animating = true; 2518 2519 if (!swiper.onTranslateToWrapperTransitionEnd) { 2520 swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) { 2521 if (!swiper || swiper.destroyed) return; 2522 if (e.target !== this) return; 2523 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); 2524 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); 2525 swiper.onTranslateToWrapperTransitionEnd = null; 2526 delete swiper.onTranslateToWrapperTransitionEnd; 2527 2528 if (runCallbacks) { 2529 swiper.emit('transitionEnd'); 2530 } 2531 }; 2532 } 2533 2534 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd); 2535 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd); 2536 } 2537 } 2538 2539 return true; 2540} 2541 2542var translate = { 2543 getTranslate: getSwiperTranslate, 2544 setTranslate, 2545 minTranslate, 2546 maxTranslate, 2547 translateTo 2548}; 2549 2550function setTransition(duration, byController) { 2551 const swiper = this; 2552 2553 if (!swiper.params.cssMode) { 2554 swiper.$wrapperEl.transition(duration); 2555 } 2556 2557 swiper.emit('setTransition', duration, byController); 2558} 2559 2560function transitionEmit(_ref) { 2561 let { 2562 swiper, 2563 runCallbacks, 2564 direction, 2565 step 2566 } = _ref; 2567 const { 2568 activeIndex, 2569 previousIndex 2570 } = swiper; 2571 let dir = direction; 2572 2573 if (!dir) { 2574 if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset'; 2575 } 2576 2577 swiper.emit(`transition${step}`); 2578 2579 if (runCallbacks && activeIndex !== previousIndex) { 2580 if (dir === 'reset') { 2581 swiper.emit(`slideResetTransition${step}`); 2582 return; 2583 } 2584 2585 swiper.emit(`slideChangeTransition${step}`); 2586 2587 if (dir === 'next') { 2588 swiper.emit(`slideNextTransition${step}`); 2589 } else { 2590 swiper.emit(`slidePrevTransition${step}`); 2591 } 2592 } 2593} 2594 2595function transitionStart(runCallbacks, direction) { 2596 if (runCallbacks === void 0) { 2597 runCallbacks = true; 2598 } 2599 2600 const swiper = this; 2601 const { 2602 params 2603 } = swiper; 2604 if (params.cssMode) return; 2605 2606 if (params.autoHeight) { 2607 swiper.updateAutoHeight(); 2608 } 2609 2610 transitionEmit({ 2611 swiper, 2612 runCallbacks, 2613 direction, 2614 step: 'Start' 2615 }); 2616} 2617 2618function transitionEnd(runCallbacks, direction) { 2619 if (runCallbacks === void 0) { 2620 runCallbacks = true; 2621 } 2622 2623 const swiper = this; 2624 const { 2625 params 2626 } = swiper; 2627 swiper.animating = false; 2628 if (params.cssMode) return; 2629 swiper.setTransition(0); 2630 transitionEmit({ 2631 swiper, 2632 runCallbacks, 2633 direction, 2634 step: 'End' 2635 }); 2636} 2637 2638var transition = { 2639 setTransition, 2640 transitionStart, 2641 transitionEnd 2642}; 2643 2644function slideTo(index, speed, runCallbacks, internal, initial) { 2645 if (index === void 0) { 2646 index = 0; 2647 } 2648 2649 if (speed === void 0) { 2650 speed = this.params.speed; 2651 } 2652 2653 if (runCallbacks === void 0) { 2654 runCallbacks = true; 2655 } 2656 2657 if (typeof index !== 'number' && typeof index !== 'string') { 2658 throw new Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`); 2659 } 2660 2661 if (typeof index === 'string') { 2662 /** 2663 * The `index` argument converted from `string` to `number`. 2664 * @type {number} 2665 */ 2666 const indexAsNumber = parseInt(index, 10); 2667 /** 2668 * Determines whether the `index` argument is a valid `number` 2669 * after being converted from the `string` type. 2670 * @type {boolean} 2671 */ 2672 2673 const isValidNumber = isFinite(indexAsNumber); 2674 2675 if (!isValidNumber) { 2676 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`); 2677 } // Knowing that the converted `index` is a valid number, 2678 // we can update the original argument's value. 2679 2680 2681 index = indexAsNumber; 2682 } 2683 2684 const swiper = this; 2685 let slideIndex = index; 2686 if (slideIndex < 0) slideIndex = 0; 2687 const { 2688 params, 2689 snapGrid, 2690 slidesGrid, 2691 previousIndex, 2692 activeIndex, 2693 rtlTranslate: rtl, 2694 wrapperEl, 2695 enabled 2696 } = swiper; 2697 2698 if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) { 2699 return false;
vendor: 6,246 bytes, lines 2700-2909
2700 } 2701 2702 const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); 2703 let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); 2704 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1; 2705 2706 if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) { 2707 swiper.emit('beforeSlideChangeStart'); 2708 } 2709 2710 const translate = -snapGrid[snapIndex]; // Update progress 2711 2712 swiper.updateProgress(translate); // Normalize slideIndex 2713 2714 if (params.normalizeSlideIndex) { 2715 for (let i = 0; i < slidesGrid.length; i += 1) { 2716 const normalizedTranslate = -Math.floor(translate * 100); 2717 const normalizedGrid = Math.floor(slidesGrid[i] * 100); 2718 const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100); 2719 2720 if (typeof slidesGrid[i + 1] !== 'undefined') { 2721 if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) { 2722 slideIndex = i; 2723 } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) { 2724 slideIndex = i + 1; 2725 } 2726 } else if (normalizedTranslate >= normalizedGrid) { 2727 slideIndex = i; 2728 } 2729 } 2730 } // Directions locks 2731 2732 2733 if (swiper.initialized && slideIndex !== activeIndex) { 2734 if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { 2735 return false; 2736 } 2737 2738 if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { 2739 if ((activeIndex || 0) !== slideIndex) return false; 2740 } 2741 } 2742 2743 let direction; 2744 if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index 2745 2746 if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) { 2747 swiper.updateActiveIndex(slideIndex); // Update Height 2748 2749 if (params.autoHeight) { 2750 swiper.updateAutoHeight(); 2751 } 2752 2753 swiper.updateSlidesClasses(); 2754 2755 if (params.effect !== 'slide') { 2756 swiper.setTranslate(translate); 2757 } 2758 2759 if (direction !== 'reset') { 2760 swiper.transitionStart(runCallbacks, direction); 2761 swiper.transitionEnd(runCallbacks, direction); 2762 } 2763 2764 return false; 2765 } 2766 2767 if (params.cssMode) { 2768 const isH = swiper.isHorizontal(); 2769 const t = rtl ? translate : -translate; 2770 2771 if (speed === 0) { 2772 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 2773 2774 if (isVirtual) { 2775 swiper.wrapperEl.style.scrollSnapType = 'none'; 2776 swiper._immediateVirtual = true; 2777 } 2778 2779 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t; 2780 2781 if (isVirtual) { 2782 requestAnimationFrame(() => { 2783 swiper.wrapperEl.style.scrollSnapType = ''; 2784 swiper._swiperImmediateVirtual = false; 2785 }); 2786 } 2787 } else { 2788 if (!swiper.support.smoothScroll) { 2789 animateCSSModeScroll({ 2790 swiper, 2791 targetPosition: t, 2792 side: isH ? 'left' : 'top' 2793 }); 2794 return true; 2795 } 2796 2797 wrapperEl.scrollTo({ 2798 [isH ? 'left' : 'top']: t, 2799 behavior: 'smooth' 2800 }); 2801 } 2802 2803 return true; 2804 } 2805 2806 swiper.setTransition(speed); 2807 swiper.setTranslate(translate); 2808 swiper.updateActiveIndex(slideIndex); 2809 swiper.updateSlidesClasses(); 2810 swiper.emit('beforeTransitionStart', speed, internal); 2811 swiper.transitionStart(runCallbacks, direction); 2812 2813 if (speed === 0) { 2814 swiper.transitionEnd(runCallbacks, direction); 2815 } else if (!swiper.animating) { 2816 swiper.animating = true; 2817 2818 if (!swiper.onSlideToWrapperTransitionEnd) { 2819 swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { 2820 if (!swiper || swiper.destroyed) return; 2821 if (e.target !== this) return; 2822 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 2823 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 2824 swiper.onSlideToWrapperTransitionEnd = null; 2825 delete swiper.onSlideToWrapperTransitionEnd; 2826 swiper.transitionEnd(runCallbacks, direction); 2827 }; 2828 } 2829 2830 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); 2831 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); 2832 } 2833 2834 return true; 2835} 2836 2837function slideToLoop(index, speed, runCallbacks, internal) { 2838 if (index === void 0) { 2839 index = 0; 2840 } 2841 2842 if (speed === void 0) { 2843 speed = this.params.speed; 2844 } 2845 2846 if (runCallbacks === void 0) { 2847 runCallbacks = true; 2848 } 2849 2850 if (typeof index === 'string') { 2851 /** 2852 * The `index` argument converted from `string` to `number`. 2853 * @type {number} 2854 */ 2855 const indexAsNumber = parseInt(index, 10); 2856 /** 2857 * Determines whether the `index` argument is a valid `number` 2858 * after being converted from the `string` type. 2859 * @type {boolean} 2860 */ 2861 2862 const isValidNumber = isFinite(indexAsNumber); 2863 2864 if (!isValidNumber) { 2865 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`); 2866 } // Knowing that the converted `index` is a valid number, 2867 // we can update the original argument's value. 2868 2869 2870 index = indexAsNumber; 2871 } 2872 2873 const swiper = this; 2874 let newIndex = index; 2875 2876 if (swiper.params.loop) { 2877 newIndex += swiper.loopedSlides; 2878 } 2879 2880 return swiper.slideTo(newIndex, speed, runCallbacks, internal); 2881} 2882 2883/* eslint no-unused-vars: "off" */ 2884function slideNext(speed, runCallbacks, internal) { 2885 if (speed === void 0) { 2886 speed = this.params.speed; 2887 } 2888 2889 if (runCallbacks === void 0) { 2890 runCallbacks = true; 2891 } 2892 2893 const swiper = this; 2894 const { 2895 animating, 2896 enabled, 2897 params 2898 } = swiper; 2899 if (!enabled) return swiper; 2900 let perGroup = params.slidesPerGroup; 2901 2902 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 2903 perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1); 2904 } 2905 2906 const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup; 2907 2908 if (params.loop) { 2909 if (animating && params.loopPreventsSlide) return false;
vendor: 4,350 bytes, lines 2910-3059
2910 swiper.loopFix(); // eslint-disable-next-line 2911 2912 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 2913 } 2914 2915 if (params.rewind && swiper.isEnd) { 2916 return swiper.slideTo(0, speed, runCallbacks, internal); 2917 } 2918 2919 return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal); 2920} 2921 2922/* eslint no-unused-vars: "off" */ 2923function slidePrev(speed, runCallbacks, internal) { 2924 if (speed === void 0) { 2925 speed = this.params.speed; 2926 } 2927 2928 if (runCallbacks === void 0) { 2929 runCallbacks = true; 2930 } 2931 2932 const swiper = this; 2933 const { 2934 params, 2935 animating, 2936 snapGrid, 2937 slidesGrid, 2938 rtlTranslate, 2939 enabled 2940 } = swiper; 2941 if (!enabled) return swiper; 2942 2943 if (params.loop) { 2944 if (animating && params.loopPreventsSlide) return false; 2945 swiper.loopFix(); // eslint-disable-next-line 2946 2947 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 2948 } 2949 2950 const translate = rtlTranslate ? swiper.translate : -swiper.translate; 2951 2952 function normalize(val) { 2953 if (val < 0) return -Math.floor(Math.abs(val)); 2954 return Math.floor(val); 2955 } 2956 2957 const normalizedTranslate = normalize(translate); 2958 const normalizedSnapGrid = snapGrid.map(val => normalize(val)); 2959 let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; 2960 2961 if (typeof prevSnap === 'undefined' && params.cssMode) { 2962 let prevSnapIndex; 2963 snapGrid.forEach((snap, snapIndex) => { 2964 if (normalizedTranslate >= snap) { 2965 // prevSnap = snap; 2966 prevSnapIndex = snapIndex; 2967 } 2968 }); 2969 2970 if (typeof prevSnapIndex !== 'undefined') { 2971 prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex]; 2972 } 2973 } 2974 2975 let prevIndex = 0; 2976 2977 if (typeof prevSnap !== 'undefined') { 2978 prevIndex = slidesGrid.indexOf(prevSnap); 2979 if (prevIndex < 0) prevIndex = swiper.activeIndex - 1; 2980 2981 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { 2982 prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1; 2983 prevIndex = Math.max(prevIndex, 0); 2984 } 2985 } 2986 2987 if (params.rewind && swiper.isBeginning) { 2988 const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 2989 return swiper.slideTo(lastIndex, speed, runCallbacks, internal); 2990 } 2991 2992 return swiper.slideTo(prevIndex, speed, runCallbacks, internal); 2993} 2994 2995/* eslint no-unused-vars: "off" */ 2996function slideReset(speed, runCallbacks, internal) { 2997 if (speed === void 0) { 2998 speed = this.params.speed; 2999 } 3000 3001 if (runCallbacks === void 0) { 3002 runCallbacks = true; 3003 } 3004 3005 const swiper = this; 3006 return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); 3007} 3008 3009/* eslint no-unused-vars: "off" */ 3010function slideToClosest(speed, runCallbacks, internal, threshold) { 3011 if (speed === void 0) { 3012 speed = this.params.speed; 3013 } 3014 3015 if (runCallbacks === void 0) { 3016 runCallbacks = true; 3017 } 3018 3019 if (threshold === void 0) { 3020 threshold = 0.5; 3021 } 3022 3023 const swiper = this; 3024 let index = swiper.activeIndex; 3025 const skip = Math.min(swiper.params.slidesPerGroupSkip, index); 3026 const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); 3027 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; 3028 3029 if (translate >= swiper.snapGrid[snapIndex]) { 3030 // The current translate is on or after the current snap index, so the choice 3031 // is between the current index and the one after it. 3032 const currentSnap = swiper.snapGrid[snapIndex]; 3033 const nextSnap = swiper.snapGrid[snapIndex + 1]; 3034 3035 if (translate - currentSnap > (nextSnap - currentSnap) * threshold) { 3036 index += swiper.params.slidesPerGroup; 3037 } 3038 } else { 3039 // The current translate is before the current snap index, so the choice 3040 // is between the current index and the one before it. 3041 const prevSnap = swiper.snapGrid[snapIndex - 1]; 3042 const currentSnap = swiper.snapGrid[snapIndex]; 3043 3044 if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) { 3045 index -= swiper.params.slidesPerGroup; 3046 } 3047 } 3048 3049 index = Math.max(index, 0); 3050 index = Math.min(index, swiper.slidesGrid.length - 1); 3051 return swiper.slideTo(index, speed, runCallbacks, internal); 3052} 3053 3054function slideToClickedSlide() { 3055 const swiper = this; 3056 const { 3057 params, 3058 $wrapperEl 3059 }
vendor: 5,270 bytes, lines 3059-3226
3059 = swiper; 3060 const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; 3061 let slideToIndex = swiper.clickedIndex; 3062 let realIndex; 3063 3064 if (params.loop) { 3065 if (swiper.animating) return; 3066 realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); 3067 3068 if (params.centeredSlides) { 3069 if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) { 3070 swiper.loopFix(); 3071 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index(); 3072 nextTick(() => { 3073 swiper.slideTo(slideToIndex); 3074 }); 3075 } else { 3076 swiper.slideTo(slideToIndex); 3077 } 3078 } else if (slideToIndex > swiper.slides.length - slidesPerView) { 3079 swiper.loopFix(); 3080 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index(); 3081 nextTick(() => { 3082 swiper.slideTo(slideToIndex); 3083 }); 3084 } else { 3085 swiper.slideTo(slideToIndex); 3086 } 3087 } else { 3088 swiper.slideTo(slideToIndex); 3089 } 3090} 3091 3092var slide = { 3093 slideTo, 3094 slideToLoop, 3095 slideNext, 3096 slidePrev, 3097 slideReset, 3098 slideToClosest, 3099 slideToClickedSlide 3100}; 3101 3102function loopCreate() { 3103 const swiper = this; 3104 const document = getDocument(); 3105 const { 3106 params, 3107 $wrapperEl 3108 } = swiper; // Remove duplicated slides 3109 3110 const $selector = $wrapperEl.children().length > 0 ? $($wrapperEl.children()[0].parentNode) : $wrapperEl; 3111 $selector.children(`.${params.slideClass}.${params.slideDuplicateClass}`).remove(); 3112 let slides = $selector.children(`.${params.slideClass}`); 3113 3114 if (params.loopFillGroupWithBlank) { 3115 const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup; 3116 3117 if (blankSlidesNum !== params.slidesPerGroup) { 3118 for (let i = 0; i < blankSlidesNum; i += 1) { 3119 const blankNode = $(document.createElement('div')).addClass(`${params.slideClass} ${params.slideBlankClass}`); 3120 $selector.append(blankNode); 3121 } 3122 3123 slides = $selector.children(`.${params.slideClass}`); 3124 } 3125 } 3126 3127 if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length; 3128 swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10)); 3129 swiper.loopedSlides += params.loopAdditionalSlides; 3130 3131 if (swiper.loopedSlides > slides.length) { 3132 swiper.loopedSlides = slides.length; 3133 } 3134 3135 const prependSlides = []; 3136 const appendSlides = []; 3137 slides.each((el, index) => { 3138 const slide = $(el); 3139 3140 if (index < swiper.loopedSlides) { 3141 appendSlides.push(el); 3142 } 3143 3144 if (index < slides.length && index >= slides.length - swiper.loopedSlides) { 3145 prependSlides.push(el); 3146 } 3147 3148 slide.attr('data-swiper-slide-index', index); 3149 }); 3150 3151 for (let i = 0; i < appendSlides.length; i += 1) { 3152 $selector.append($(appendSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass)); 3153 } 3154 3155 for (let i = prependSlides.length - 1; i >= 0; i -= 1) { 3156 $selector.prepend($(prependSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass)); 3157 } 3158} 3159 3160function loopFix() { 3161 const swiper = this; 3162 swiper.emit('beforeLoopFix'); 3163 const { 3164 activeIndex, 3165 slides, 3166 loopedSlides, 3167 allowSlidePrev, 3168 allowSlideNext, 3169 snapGrid, 3170 rtlTranslate: rtl 3171 } = swiper; 3172 let newIndex; 3173 swiper.allowSlidePrev = true; 3174 swiper.allowSlideNext = true; 3175 const snapTranslate = -snapGrid[activeIndex]; 3176 const diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding 3177 3178 if (activeIndex < loopedSlides) { 3179 newIndex = slides.length - loopedSlides * 3 + activeIndex; 3180 newIndex += loopedSlides; 3181 const slideChanged = swiper.slideTo(newIndex, 0, false, true); 3182 3183 if (slideChanged && diff !== 0) { 3184 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 3185 } 3186 } else if (activeIndex >= slides.length - loopedSlides) { 3187 // Fix For Positive Oversliding 3188 newIndex = -slides.length + activeIndex + loopedSlides; 3189 newIndex += loopedSlides; 3190 const slideChanged = swiper.slideTo(newIndex, 0, false, true); 3191 3192 if (slideChanged && diff !== 0) { 3193 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); 3194 } 3195 } 3196 3197 swiper.allowSlidePrev = allowSlidePrev; 3198 swiper.allowSlideNext = allowSlideNext; 3199 swiper.emit('loopFix'); 3200} 3201 3202function loopDestroy() { 3203 const swiper = this; 3204 const { 3205 $wrapperEl, 3206 params, 3207 slides 3208 } = swiper; 3209 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass},.${params.slideClass}.${params.slideBlankClass}`).remove(); 3210 slides.removeAttr('data-swiper-slide-index'); 3211} 3212 3213var loop = { 3214 loopCreate, 3215 loopFix, 3216 loopDestroy 3217}; 3218 3219function setGrabCursor(moving) { 3220 const swiper = this; 3221 if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return; 3222 const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl; 3223 el.style.cursor = 'move'; 3224 el.style.cursor = moving ? 'grabbing' : 'grab'; 3225} 3226
vendor: 29,242 bytes, lines 3227-4275
3227function unsetGrabCursor() { 3228 const swiper = this; 3229 3230 if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) { 3231 return; 3232 } 3233 3234 swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = ''; 3235} 3236 3237var grabCursor = { 3238 setGrabCursor, 3239 unsetGrabCursor 3240}; 3241 3242function closestElement(selector, base) { 3243 if (base === void 0) { 3244 base = this; 3245 } 3246 3247 function __closestFrom(el) { 3248 if (!el || el === getDocument() || el === getWindow()) return null; 3249 if (el.assignedSlot) el = el.assignedSlot; 3250 const found = el.closest(selector); 3251 3252 if (!found && !el.getRootNode) { 3253 return null; 3254 } 3255 3256 return found || __closestFrom(el.getRootNode().host); 3257 } 3258 3259 return __closestFrom(base); 3260} 3261 3262function onTouchStart(event) { 3263 const swiper = this; 3264 const document = getDocument(); 3265 const window = getWindow(); 3266 const data = swiper.touchEventsData; 3267 const { 3268 params, 3269 touches, 3270 enabled 3271 } = swiper; 3272 if (!enabled) return; 3273 3274 if (swiper.animating && params.preventInteractionOnTransition) { 3275 return; 3276 } 3277 3278 if (!swiper.animating && params.cssMode && params.loop) { 3279 swiper.loopFix(); 3280 } 3281 3282 let e = event; 3283 if (e.originalEvent) e = e.originalEvent; 3284 let $targetEl = $(e.target); 3285 3286 if (params.touchEventsTarget === 'wrapper') { 3287 if (!$targetEl.closest(swiper.wrapperEl).length) return; 3288 } 3289 3290 data.isTouchEvent = e.type === 'touchstart'; 3291 if (!data.isTouchEvent && 'which' in e && e.which === 3) return; 3292 if (!data.isTouchEvent && 'button' in e && e.button > 0) return; 3293 if (data.isTouched && data.isMoved) return; // change target el for shadow root component 3294 3295 const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ''; 3296 3297 if (swipingClassHasValue && e.target && e.target.shadowRoot && event.path && event.path[0]) { 3298 $targetEl = $(event.path[0]); 3299 } 3300 3301 const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`; 3302 const isTargetShadow = !!(e.target && e.target.shadowRoot); // use closestElement for shadow root element to get the actual closest for nested shadow root element 3303 3304 if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, $targetEl[0]) : $targetEl.closest(noSwipingSelector)[0])) { 3305 swiper.allowClick = true; 3306 return; 3307 } 3308 3309 if (params.swipeHandler) { 3310 if (!$targetEl.closest(params.swipeHandler)[0]) return; 3311 } 3312 3313 touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 3314 touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 3315 const startX = touches.currentX; 3316 const startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore 3317 3318 const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; 3319 const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; 3320 3321 if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) { 3322 if (edgeSwipeDetection === 'prevent') { 3323 event.preventDefault(); 3324 } else { 3325 return; 3326 } 3327 } 3328 3329 Object.assign(data, { 3330 isTouched: true, 3331 isMoved: false, 3332 allowTouchCallbacks: true, 3333 isScrolling: undefined, 3334 startMoving: undefined 3335 }); 3336 touches.startX = startX; 3337 touches.startY = startY; 3338 data.touchStartTime = now(); 3339 swiper.allowClick = true; 3340 swiper.updateSize(); 3341 swiper.swipeDirection = undefined; 3342 if (params.threshold > 0) data.allowThresholdMove = false; 3343 3344 if (e.type !== 'touchstart') { 3345 let preventDefault = true; 3346 3347 if ($targetEl.is(data.focusableElements)) { 3348 preventDefault = false; 3349 3350 if ($targetEl[0].nodeName === 'SELECT') { 3351 data.isTouched = false; 3352 } 3353 } 3354 3355 if (document.activeElement && $(document.activeElement).is(data.focusableElements) && document.activeElement !== $targetEl[0]) { 3356 document.activeElement.blur(); 3357 } 3358 3359 const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; 3360 3361 if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) { 3362 e.preventDefault(); 3363 } 3364 } 3365 3366 if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) { 3367 swiper.freeMode.onTouchStart(); 3368 } 3369 3370 swiper.emit('touchStart', e); 3371} 3372 3373function onTouchMove(event) { 3374 const document = getDocument(); 3375 const swiper = this; 3376 const data = swiper.touchEventsData; 3377 const { 3378 params, 3379 touches, 3380 rtlTranslate: rtl, 3381 enabled 3382 } = swiper; 3383 if (!enabled) return; 3384 let e = event; 3385 if (e.originalEvent) e = e.originalEvent; 3386 3387 if (!data.isTouched) { 3388 if (data.startMoving && data.isScrolling) { 3389 swiper.emit('touchMoveOpposite', e); 3390 } 3391 3392 return; 3393 } 3394 3395 if (data.isTouchEvent && e.type !== 'touchmove') return; 3396 const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]); 3397 const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX; 3398 const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY; 3399 3400 if (e.preventedByNestedSwiper) { 3401 touches.startX = pageX; 3402 touches.startY = pageY; 3403 return; 3404 } 3405 3406 if (!swiper.allowTouchMove) { 3407 if (!$(e.target).is(data.focusableElements)) { 3408 swiper.allowClick = false; 3409 } 3410 3411 if (data.isTouched) { 3412 Object.assign(touches, { 3413 startX: pageX, 3414 startY: pageY, 3415 currentX: pageX, 3416 currentY: pageY 3417 }); 3418 data.touchStartTime = now(); 3419 } 3420 3421 return; 3422 } 3423 3424 if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { 3425 if (swiper.isVertical()) { 3426 // Vertical 3427 if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) { 3428 data.isTouched = false; 3429 data.isMoved = false; 3430 return; 3431 } 3432 } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) { 3433 return; 3434 } 3435 } 3436 3437 if (data.isTouchEvent && document.activeElement) { 3438 if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) { 3439 data.isMoved = true; 3440 swiper.allowClick = false; 3441 return; 3442 } 3443 } 3444 3445 if (data.allowTouchCallbacks) { 3446 swiper.emit('touchMove', e); 3447 } 3448 3449 if (e.targetTouches && e.targetTouches.length > 1) return; 3450 touches.currentX = pageX; 3451 touches.currentY = pageY; 3452 const diffX = touches.currentX - touches.startX; 3453 const diffY = touches.currentY - touches.startY; 3454 if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return; 3455 3456 if (typeof data.isScrolling === 'undefined') { 3457 let touchAngle; 3458 3459 if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) { 3460 data.isScrolling = false; 3461 } else { 3462 // eslint-disable-next-line 3463 if (diffX * diffX + diffY * diffY >= 25) { 3464 touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI; 3465 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle; 3466 } 3467 } 3468 } 3469 3470 if (data.isScrolling) { 3471 swiper.emit('touchMoveOpposite', e); 3472 } 3473 3474 if (typeof data.startMoving === 'undefined') { 3475 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { 3476 data.startMoving = true; 3477 } 3478 } 3479 3480 if (data.isScrolling) { 3481 data.isTouched = false; 3482 return; 3483 } 3484 3485 if (!data.startMoving) { 3486 return; 3487 } 3488 3489 swiper.allowClick = false; 3490 3491 if (!params.cssMode && e.cancelable) { 3492 e.preventDefault(); 3493 } 3494 3495 if (params.touchMoveStopPropagation && !params.nested) { 3496 e.stopPropagation(); 3497 } 3498 3499 if (!data.isMoved) { 3500 if (params.loop && !params.cssMode) { 3501 swiper.loopFix(); 3502 } 3503 3504 data.startTranslate = swiper.getTranslate(); 3505 swiper.setTransition(0); 3506 3507 if (swiper.animating) { 3508 swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); 3509 } 3510 3511 data.allowMomentumBounce = false; // Grab Cursor 3512 3513 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 3514 swiper.setGrabCursor(true); 3515 } 3516 3517 swiper.emit('sliderFirstMove', e); 3518 } 3519 3520 swiper.emit('sliderMove', e); 3521 data.isMoved = true; 3522 let diff = swiper.isHorizontal() ? diffX : diffY; 3523 touches.diff = diff; 3524 diff *= params.touchRatio; 3525 if (rtl) diff = -diff; 3526 swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; 3527 data.currentTranslate = diff + data.startTranslate; 3528 let disableParentSwiper = true; 3529 let resistanceRatio = params.resistanceRatio; 3530 3531 if (params.touchReleaseOnEdges) { 3532 resistanceRatio = 0; 3533 } 3534 3535 if (diff > 0 && data.currentTranslate > swiper.minTranslate()) { 3536 disableParentSwiper = false; 3537 if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio; 3538 } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { 3539 disableParentSwiper = false; 3540 if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio; 3541 } 3542 3543 if (disableParentSwiper) { 3544 e.preventedByNestedSwiper = true; 3545 } // Directions locks 3546 3547 3548 if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { 3549 data.currentTranslate = data.startTranslate; 3550 } 3551 3552 if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { 3553 data.currentTranslate = data.startTranslate; 3554 } 3555 3556 if (!swiper.allowSlidePrev && !swiper.allowSlideNext) { 3557 data.currentTranslate = data.startTranslate; 3558 } // Threshold 3559 3560 3561 if (params.threshold > 0) { 3562 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { 3563 if (!data.allowThresholdMove) { 3564 data.allowThresholdMove = true; 3565 touches.startX = touches.currentX; 3566 touches.startY = touches.currentY; 3567 data.currentTranslate = data.startTranslate; 3568 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; 3569 return; 3570 } 3571 } else { 3572 data.currentTranslate = data.startTranslate; 3573 return; 3574 } 3575 } 3576 3577 if (!params.followFinger || params.cssMode) return; // Update active index in free mode 3578 3579 if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) { 3580 swiper.updateActiveIndex(); 3581 swiper.updateSlidesClasses(); 3582 } 3583 3584 if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) { 3585 swiper.freeMode.onTouchMove(); 3586 } // Update progress 3587 3588 3589 swiper.updateProgress(data.currentTranslate); // Update translate 3590 3591 swiper.setTranslate(data.currentTranslate); 3592} 3593 3594function onTouchEnd(event) { 3595 const swiper = this; 3596 const data = swiper.touchEventsData; 3597 const { 3598 params, 3599 touches, 3600 rtlTranslate: rtl, 3601 slidesGrid, 3602 enabled 3603 } = swiper; 3604 if (!enabled) return; 3605 let e = event; 3606 if (e.originalEvent) e = e.originalEvent; 3607 3608 if (data.allowTouchCallbacks) { 3609 swiper.emit('touchEnd', e); 3610 } 3611 3612 data.allowTouchCallbacks = false; 3613 3614 if (!data.isTouched) { 3615 if (data.isMoved && params.grabCursor) { 3616 swiper.setGrabCursor(false); 3617 } 3618 3619 data.isMoved = false; 3620 data.startMoving = false; 3621 return; 3622 } // Return Grab Cursor 3623 3624 3625 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 3626 swiper.setGrabCursor(false); 3627 } // Time diff 3628 3629 3630 const touchEndTime = now(); 3631 const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click 3632 3633 if (swiper.allowClick) { 3634 const pathTree = e.path || e.composedPath && e.composedPath(); 3635 swiper.updateClickedSlide(pathTree && pathTree[0] || e.target); 3636 swiper.emit('tap click', e); 3637 3638 if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) { 3639 swiper.emit('doubleTap doubleClick', e); 3640 } 3641 } 3642 3643 data.lastClickTime = now(); 3644 nextTick(() => { 3645 if (!swiper.destroyed) swiper.allowClick = true; 3646 }); 3647 3648 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { 3649 data.isTouched = false; 3650 data.isMoved = false; 3651 data.startMoving = false; 3652 return; 3653 } 3654 3655 data.isTouched = false; 3656 data.isMoved = false; 3657 data.startMoving = false; 3658 let currentPos; 3659 3660 if (params.followFinger) { 3661 currentPos = rtl ? swiper.translate : -swiper.translate; 3662 } else { 3663 currentPos = -data.currentTranslate; 3664 } 3665 3666 if (params.cssMode) { 3667 return; 3668 } 3669 3670 if (swiper.params.freeMode && params.freeMode.enabled) { 3671 swiper.freeMode.onTouchEnd({ 3672 currentPos 3673 }); 3674 return; 3675 } // Find current slide 3676 3677 3678 let stopIndex = 0; 3679 let groupSize = swiper.slidesSizesGrid[0]; 3680 3681 for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) { 3682 const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 3683 3684 if (typeof slidesGrid[i + increment] !== 'undefined') { 3685 if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) { 3686 stopIndex = i; 3687 groupSize = slidesGrid[i + increment] - slidesGrid[i]; 3688 } 3689 } else if (currentPos >= slidesGrid[i]) { 3690 stopIndex = i; 3691 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; 3692 } 3693 } 3694 3695 let rewindFirstIndex = null; 3696 let rewindLastIndex = null; 3697 3698 if (params.rewind) { 3699 if (swiper.isBeginning) { 3700 rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1; 3701 } else if (swiper.isEnd) { 3702 rewindFirstIndex = 0; 3703 } 3704 } // Find current slide size 3705 3706 3707 const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; 3708 const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup; 3709 3710 if (timeDiff > params.longSwipesMs) { 3711 // Long touches 3712 if (!params.longSwipes) { 3713 swiper.slideTo(swiper.activeIndex); 3714 return; 3715 } 3716 3717 if (swiper.swipeDirection === 'next') { 3718 if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex); 3719 } 3720 3721 if (swiper.swipeDirection === 'prev') { 3722 if (ratio > 1 - params.longSwipesRatio) { 3723 swiper.slideTo(stopIndex + increment); 3724 } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) { 3725 swiper.slideTo(rewindLastIndex); 3726 } else { 3727 swiper.slideTo(stopIndex); 3728 } 3729 } 3730 } else { 3731 // Short swipes 3732 if (!params.shortSwipes) { 3733 swiper.slideTo(swiper.activeIndex); 3734 return; 3735 } 3736 3737 const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl); 3738 3739 if (!isNavButtonTarget) { 3740 if (swiper.swipeDirection === 'next') { 3741 swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment); 3742 } 3743 3744 if (swiper.swipeDirection === 'prev') { 3745 swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex); 3746 } 3747 } else if (e.target === swiper.navigation.nextEl) { 3748 swiper.slideTo(stopIndex + increment); 3749 } else { 3750 swiper.slideTo(stopIndex); 3751 } 3752 } 3753} 3754 3755function onResize() { 3756 const swiper = this; 3757 const { 3758 params, 3759 el 3760 } = swiper; 3761 if (el && el.offsetWidth === 0) return; // Breakpoints 3762 3763 if (params.breakpoints) { 3764 swiper.setBreakpoint(); 3765 } // Save locks 3766 3767 3768 const { 3769 allowSlideNext, 3770 allowSlidePrev, 3771 snapGrid 3772 } = swiper; // Disable locks on resize 3773 3774 swiper.allowSlideNext = true; 3775 swiper.allowSlidePrev = true; 3776 swiper.updateSize(); 3777 swiper.updateSlides(); 3778 swiper.updateSlidesClasses(); 3779 3780 if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) { 3781 swiper.slideTo(swiper.slides.length - 1, 0, false, true); 3782 } else { 3783 swiper.slideTo(swiper.activeIndex, 0, false, true); 3784 } 3785 3786 if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) { 3787 swiper.autoplay.run(); 3788 } // Return locks after resize 3789 3790 3791 swiper.allowSlidePrev = allowSlidePrev; 3792 swiper.allowSlideNext = allowSlideNext; 3793 3794 if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { 3795 swiper.checkOverflow(); 3796 } 3797} 3798 3799function onClick(e) { 3800 const swiper = this; 3801 if (!swiper.enabled) return; 3802 3803 if (!swiper.allowClick) { 3804 if (swiper.params.preventClicks) e.preventDefault(); 3805 3806 if (swiper.params.preventClicksPropagation && swiper.animating) { 3807 e.stopPropagation(); 3808 e.stopImmediatePropagation(); 3809 } 3810 } 3811} 3812 3813function onScroll() { 3814 const swiper = this; 3815 const { 3816 wrapperEl, 3817 rtlTranslate, 3818 enabled 3819 } = swiper; 3820 if (!enabled) return; 3821 swiper.previousTranslate = swiper.translate; 3822 3823 if (swiper.isHorizontal()) { 3824 swiper.translate = -wrapperEl.scrollLeft; 3825 } else { 3826 swiper.translate = -wrapperEl.scrollTop; 3827 } // eslint-disable-next-line 3828 3829 3830 if (swiper.translate === 0) swiper.translate = 0; 3831 swiper.updateActiveIndex(); 3832 swiper.updateSlidesClasses(); 3833 let newProgress; 3834 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); 3835 3836 if (translatesDiff === 0) { 3837 newProgress = 0; 3838 } else { 3839 newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff; 3840 } 3841 3842 if (newProgress !== swiper.progress) { 3843 swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate); 3844 } 3845 3846 swiper.emit('setTranslate', swiper.translate, false); 3847} 3848 3849let dummyEventAttached = false; 3850 3851function dummyEventListener() {} 3852 3853const events = (swiper, method) => { 3854 const document = getDocument(); 3855 const { 3856 params, 3857 touchEvents, 3858 el, 3859 wrapperEl, 3860 device, 3861 support 3862 } = swiper; 3863 const capture = !!params.nested; 3864 const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener'; 3865 const swiperMethod = method; // Touch Events 3866 3867 if (!support.touch) { 3868 el[domMethod](touchEvents.start, swiper.onTouchStart, false); 3869 document[domMethod](touchEvents.move, swiper.onTouchMove, capture); 3870 document[domMethod](touchEvents.end, swiper.onTouchEnd, false); 3871 } else { 3872 const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? { 3873 passive: true, 3874 capture: false 3875 } : false; 3876 el[domMethod](touchEvents.start, swiper.onTouchStart, passiveListener); 3877 el[domMethod](touchEvents.move, swiper.onTouchMove, support.passiveListener ? { 3878 passive: false, 3879 capture 3880 } : capture); 3881 el[domMethod](touchEvents.end, swiper.onTouchEnd, passiveListener); 3882 3883 if (touchEvents.cancel) { 3884 el[domMethod](touchEvents.cancel, swiper.onTouchEnd, passiveListener); 3885 } 3886 } // Prevent Links Clicks 3887 3888 3889 if (params.preventClicks || params.preventClicksPropagation) { 3890 el[domMethod]('click', swiper.onClick, true); 3891 } 3892 3893 if (params.cssMode) { 3894 wrapperEl[domMethod]('scroll', swiper.onScroll); 3895 } // Resize handler 3896 3897 3898 if (params.updateOnWindowResize) { 3899 swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true); 3900 } else { 3901 swiper[swiperMethod]('observerUpdate', onResize, true); 3902 } 3903}; 3904 3905function attachEvents() { 3906 const swiper = this; 3907 const document = getDocument(); 3908 const { 3909 params, 3910 support 3911 } = swiper; 3912 swiper.onTouchStart = onTouchStart.bind(swiper); 3913 swiper.onTouchMove = onTouchMove.bind(swiper); 3914 swiper.onTouchEnd = onTouchEnd.bind(swiper); 3915 3916 if (params.cssMode) { 3917 swiper.onScroll = onScroll.bind(swiper); 3918 } 3919 3920 swiper.onClick = onClick.bind(swiper); 3921 3922 if (support.touch && !dummyEventAttached) { 3923 document.addEventListener('touchstart', dummyEventListener); 3924 dummyEventAttached = true; 3925 } 3926 3927 events(swiper, 'on'); 3928} 3929 3930function detachEvents() { 3931 const swiper = this; 3932 events(swiper, 'off'); 3933} 3934 3935var events$1 = { 3936 attachEvents, 3937 detachEvents 3938}; 3939 3940const isGridEnabled = (swiper, params) => { 3941 return swiper.grid && params.grid && params.grid.rows > 1; 3942}; 3943 3944function setBreakpoint() { 3945 const swiper = this; 3946 const { 3947 activeIndex, 3948 initialized, 3949 loopedSlides = 0, 3950 params, 3951 $el 3952 } = swiper; 3953 const breakpoints = params.breakpoints; 3954 if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters 3955 3956 const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el); 3957 if (!breakpoint || swiper.currentBreakpoint === breakpoint) return; 3958 const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; 3959 const breakpointParams = breakpointOnlyParams || swiper.originalParams; 3960 const wasMultiRow = isGridEnabled(swiper, params); 3961 const isMultiRow = isGridEnabled(swiper, breakpointParams); 3962 const wasEnabled = params.enabled; 3963 3964 if (wasMultiRow && !isMultiRow) { 3965 $el.removeClass(`${params.containerModifierClass}grid ${params.containerModifierClass}grid-column`); 3966 swiper.emitContainerClasses(); 3967 } else if (!wasMultiRow && isMultiRow) { 3968 $el.addClass(`${params.containerModifierClass}grid`); 3969 3970 if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') { 3971 $el.addClass(`${params.containerModifierClass}grid-column`); 3972 } 3973 3974 swiper.emitContainerClasses(); 3975 } // Toggle navigation, pagination, scrollbar 3976 3977 3978 ['navigation', 'pagination', 'scrollbar'].forEach(prop => { 3979 const wasModuleEnabled = params[prop] && params[prop].enabled; 3980 const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled; 3981 3982 if (wasModuleEnabled && !isModuleEnabled) { 3983 swiper[prop].disable(); 3984 } 3985 3986 if (!wasModuleEnabled && isModuleEnabled) { 3987 swiper[prop].enable(); 3988 } 3989 }); 3990 const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction; 3991 const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged); 3992 3993 if (directionChanged && initialized) { 3994 swiper.changeDirection(); 3995 } 3996 3997 extend(swiper.params, breakpointParams); 3998 const isEnabled = swiper.params.enabled; 3999 Object.assign(swiper, { 4000 allowTouchMove: swiper.params.allowTouchMove, 4001 allowSlideNext: swiper.params.allowSlideNext, 4002 allowSlidePrev: swiper.params.allowSlidePrev 4003 }); 4004 4005 if (wasEnabled && !isEnabled) { 4006 swiper.disable(); 4007 } else if (!wasEnabled && isEnabled) { 4008 swiper.enable(); 4009 } 4010 4011 swiper.currentBreakpoint = breakpoint; 4012 swiper.emit('_beforeBreakpoint', breakpointParams); 4013 4014 if (needsReLoop && initialized) { 4015 swiper.loopDestroy(); 4016 swiper.loopCreate(); 4017 swiper.updateSlides(); 4018 swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false); 4019 } 4020 4021 swiper.emit('breakpoint', breakpointParams); 4022} 4023 4024function getBreakpoint(breakpoints, base, containerEl) { 4025 if (base === void 0) { 4026 base = 'window'; 4027 } 4028 4029 if (!breakpoints || base === 'container' && !containerEl) return undefined; 4030 let breakpoint = false; 4031 const window = getWindow(); 4032 const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight; 4033 const points = Object.keys(breakpoints).map(point => { 4034 if (typeof point === 'string' && point.indexOf('@') === 0) { 4035 const minRatio = parseFloat(point.substr(1)); 4036 const value = currentHeight * minRatio; 4037 return { 4038 value, 4039 point 4040 }; 4041 } 4042 4043 return { 4044 value: point, 4045 point 4046 }; 4047 }); 4048 points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10)); 4049 4050 for (let i = 0; i < points.length; i += 1) { 4051 const { 4052 point, 4053 value 4054 } = points[i]; 4055 4056 if (base === 'window') { 4057 if (window.matchMedia(`(min-width: ${value}px)`).matches) { 4058 breakpoint = point; 4059 } 4060 } else if (value <= containerEl.clientWidth) { 4061 breakpoint = point; 4062 } 4063 } 4064 4065 return breakpoint || 'max'; 4066} 4067 4068var breakpoints = { 4069 setBreakpoint, 4070 getBreakpoint 4071}; 4072 4073function prepareClasses(entries, prefix) { 4074 const resultClasses = []; 4075 entries.forEach(item => { 4076 if (typeof item === 'object') { 4077 Object.keys(item).forEach(classNames => { 4078 if (item[classNames]) { 4079 resultClasses.push(prefix + classNames); 4080 } 4081 }); 4082 } else if (typeof item === 'string') { 4083 resultClasses.push(prefix + item); 4084 } 4085 }); 4086 return resultClasses; 4087} 4088 4089function addClasses() { 4090 const swiper = this; 4091 const { 4092 classNames, 4093 params, 4094 rtl, 4095 $el, 4096 device, 4097 support 4098 } = swiper; // prettier-ignore 4099 4100 const suffixes = prepareClasses(['initialized', params.direction, { 4101 'pointer-events': !support.touch 4102 }, { 4103 'free-mode': swiper.params.freeMode && params.freeMode.enabled 4104 }, { 4105 'autoheight': params.autoHeight 4106 }, { 4107 'rtl': rtl 4108 }, { 4109 'grid': params.grid && params.grid.rows > 1 4110 }, { 4111 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column' 4112 }, { 4113 'android': device.android 4114 }, { 4115 'ios': device.ios 4116 }, { 4117 'css-mode': params.cssMode 4118 }, { 4119 'centered': params.cssMode && params.centeredSlides 4120 }, { 4121 'watch-progress': params.watchSlidesProgress 4122 }], params.containerModifierClass); 4123 classNames.push(...suffixes); 4124 $el.addClass([...classNames].join(' ')); 4125 swiper.emitContainerClasses(); 4126} 4127 4128function removeClasses() { 4129 const swiper = this; 4130 const { 4131 $el, 4132 classNames 4133 } = swiper; 4134 $el.removeClass(classNames.join(' ')); 4135 swiper.emitContainerClasses(); 4136} 4137 4138var classes = { 4139 addClasses, 4140 removeClasses 4141}; 4142 4143function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) { 4144 const window = getWindow(); 4145 let image; 4146 4147 function onReady() { 4148 if (callback) callback(); 4149 } 4150 4151 const isPicture = $(imageEl).parent('picture')[0]; 4152 4153 if (!isPicture && (!imageEl.complete || !checkForComplete)) { 4154 if (src) { 4155 image = new window.Image(); 4156 image.onload = onReady; 4157 image.onerror = onReady; 4158 4159 if (sizes) { 4160 image.sizes = sizes; 4161 } 4162 4163 if (srcset) { 4164 image.srcset = srcset; 4165 } 4166 4167 if (src) { 4168 image.src = src; 4169 } 4170 } else { 4171 onReady(); 4172 } 4173 } else { 4174 // image already loaded... 4175 onReady(); 4176 } 4177} 4178 4179function preloadImages() { 4180 const swiper = this; 4181 swiper.imagesToLoad = swiper.$el.find('img'); 4182 4183 function onReady() { 4184 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return; 4185 if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1; 4186 4187 if (swiper.imagesLoaded === swiper.imagesToLoad.length) { 4188 if (swiper.params.updateOnImagesReady) swiper.update(); 4189 swiper.emit('imagesReady'); 4190 } 4191 } 4192 4193 for (let i = 0; i < swiper.imagesToLoad.length; i += 1) { 4194 const imageEl = swiper.imagesToLoad[i]; 4195 swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady); 4196 } 4197} 4198 4199var images = { 4200 loadImage, 4201 preloadImages 4202}; 4203 4204function checkOverflow() { 4205 const swiper = this; 4206 const { 4207 isLocked: wasLocked, 4208 params 4209 } = swiper; 4210 const { 4211 slidesOffsetBefore 4212 } = params; 4213 4214 if (slidesOffsetBefore) { 4215 const lastSlideIndex = swiper.slides.length - 1; 4216 const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2; 4217 swiper.isLocked = swiper.size > lastSlideRightEdge; 4218 } else { 4219 swiper.isLocked = swiper.snapGrid.length === 1; 4220 } 4221 4222 if (params.allowSlideNext === true) { 4223 swiper.allowSlideNext = !swiper.isLocked; 4224 } 4225 4226 if (params.allowSlidePrev === true) { 4227 swiper.allowSlidePrev = !swiper.isLocked; 4228 } 4229 4230 if (wasLocked && wasLocked !== swiper.isLocked) { 4231 swiper.isEnd = false; 4232 } 4233 4234 if (wasLocked !== swiper.isLocked) { 4235 swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); 4236 } 4237} 4238 4239var checkOverflow$1 = { 4240 checkOverflow 4241}; 4242 4243var defaults = { 4244 init: true, 4245 direction: 'horizontal', 4246 touchEventsTarget: 'wrapper', 4247 initialSlide: 0, 4248 speed: 300, 4249 cssMode: false, 4250 updateOnWindowResize: true, 4251 resizeObserver: true, 4252 nested: false, 4253 createElements: false, 4254 enabled: true, 4255 focusableElements: 'input, select, option, textarea, button, video, label', 4256 // Overrides 4257 width: null, 4258 height: null, 4259 // 4260 preventInteractionOnTransition: false, 4261 // ssr 4262 userAgent: null, 4263 url: null, 4264 // To support iOS's swipe-to-go-back gesture (when being used in-app). 4265 edgeSwipeDetection: false, 4266 edgeSwipeThreshold: 20, 4267 // Autoheight 4268 autoHeight: false, 4269 // Set wrapper width 4270 setWrapperSize: false, 4271 // Virtual Translate 4272 virtualTranslate: false, 4273 // Effects 4274 effect: 'slide', 4275 // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
vendor: 5,634 bytes, lines 4276-4490
4276 // Breakpoints 4277 breakpoints: undefined, 4278 breakpointsBase: 'window', 4279 // Slides grid 4280 spaceBetween: 0, 4281 slidesPerView: 1, 4282 slidesPerGroup: 1, 4283 slidesPerGroupSkip: 0, 4284 slidesPerGroupAuto: false, 4285 centeredSlides: false, 4286 centeredSlidesBounds: false, 4287 slidesOffsetBefore: 0, 4288 // in px 4289 slidesOffsetAfter: 0, 4290 // in px 4291 normalizeSlideIndex: true, 4292 centerInsufficientSlides: false, 4293 // Disable swiper and hide navigation when container not overflow 4294 watchOverflow: true, 4295 // Round length 4296 roundLengths: false, 4297 // Touches 4298 touchRatio: 1, 4299 touchAngle: 45, 4300 simulateTouch: true, 4301 shortSwipes: true, 4302 longSwipes: true, 4303 longSwipesRatio: 0.5, 4304 longSwipesMs: 300, 4305 followFinger: true, 4306 allowTouchMove: true, 4307 threshold: 0, 4308 touchMoveStopPropagation: false, 4309 touchStartPreventDefault: true, 4310 touchStartForcePreventDefault: false, 4311 touchReleaseOnEdges: false, 4312 // Unique Navigation Elements 4313 uniqueNavElements: true, 4314 // Resistance 4315 resistance: true, 4316 resistanceRatio: 0.85, 4317 // Progress 4318 watchSlidesProgress: false, 4319 // Cursor 4320 grabCursor: false, 4321 // Clicks 4322 preventClicks: true, 4323 preventClicksPropagation: true, 4324 slideToClickedSlide: false, 4325 // Images 4326 preloadImages: true, 4327 updateOnImagesReady: true, 4328 // loop 4329 loop: false, 4330 loopAdditionalSlides: 0, 4331 loopedSlides: null, 4332 loopFillGroupWithBlank: false, 4333 loopPreventsSlide: true, 4334 // rewind 4335 rewind: false, 4336 // Swiping/no swiping 4337 allowSlidePrev: true, 4338 allowSlideNext: true, 4339 swipeHandler: null, 4340 // '.swipe-handler', 4341 noSwiping: true, 4342 noSwipingClass: 'swiper-no-swiping', 4343 noSwipingSelector: null, 4344 // Passive Listeners 4345 passiveListeners: true, 4346 maxBackfaceHiddenSlides: 10, 4347 // NS 4348 containerModifierClass: 'swiper-', 4349 // NEW 4350 slideClass: 'swiper-slide', 4351 slideBlankClass: 'swiper-slide-invisible-blank', 4352 slideActiveClass: 'swiper-slide-active', 4353 slideDuplicateActiveClass: 'swiper-slide-duplicate-active', 4354 slideVisibleClass: 'swiper-slide-visible', 4355 slideDuplicateClass: 'swiper-slide-duplicate', 4356 slideNextClass: 'swiper-slide-next', 4357 slideDuplicateNextClass: 'swiper-slide-duplicate-next', 4358 slidePrevClass: 'swiper-slide-prev', 4359 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', 4360 wrapperClass: 'swiper-wrapper', 4361 // Callbacks 4362 runCallbacksOnInit: true, 4363 // Internals 4364 _emitClasses: false 4365}; 4366 4367function moduleExtendParams(params, allModulesParams) { 4368 return function extendParams(obj) { 4369 if (obj === void 0) { 4370 obj = {}; 4371 } 4372 4373 const moduleParamName = Object.keys(obj)[0]; 4374 const moduleParams = obj[moduleParamName]; 4375 4376 if (typeof moduleParams !== 'object' || moduleParams === null) { 4377 extend(allModulesParams, obj); 4378 return; 4379 } 4380 4381 if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) { 4382 params[moduleParamName] = { 4383 auto: true 4384 }; 4385 } 4386 4387 if (!(moduleParamName in params && 'enabled' in moduleParams)) { 4388 extend(allModulesParams, obj); 4389 return; 4390 } 4391 4392 if (params[moduleParamName] === true) { 4393 params[moduleParamName] = { 4394 enabled: true 4395 }; 4396 } 4397 4398 if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) { 4399 params[moduleParamName].enabled = true; 4400 } 4401 4402 if (!params[moduleParamName]) params[moduleParamName] = { 4403 enabled: false 4404 }; 4405 extend(allModulesParams, obj); 4406 }; 4407} 4408 4409/* eslint no-param-reassign: "off" */ 4410const prototypes = { 4411 eventsEmitter, 4412 update, 4413 translate, 4414 transition, 4415 slide, 4416 loop, 4417 grabCursor, 4418 events: events$1, 4419 breakpoints, 4420 checkOverflow: checkOverflow$1, 4421 classes, 4422 images 4423}; 4424const extendedDefaults = {}; 4425 4426class Swiper { 4427 constructor() { 4428 let el; 4429 let params; 4430 4431 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 4432 args[_key] = arguments[_key]; 4433 } 4434 4435 if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') { 4436 params = args[0]; 4437 } else { 4438 [el, params] = args; 4439 } 4440 4441 if (!params) params = {}; 4442 params = extend({}, params); 4443 if (el && !params.el) params.el = el; 4444 4445 if (params.el && $(params.el).length > 1) { 4446 const swipers = []; 4447 $(params.el).each(containerEl => { 4448 const newParams = extend({}, params, { 4449 el: containerEl 4450 }); 4451 swipers.push(new Swiper(newParams)); 4452 }); 4453 return swipers; 4454 } // Swiper Instance 4455 4456 4457 const swiper = this; 4458 swiper.__swiper__ = true; 4459 swiper.support = getSupport(); 4460 swiper.device = getDevice({ 4461 userAgent: params.userAgent 4462 }); 4463 swiper.browser = getBrowser(); 4464 swiper.eventsListeners = {}; 4465 swiper.eventsAnyListeners = []; 4466 swiper.modules = [...swiper.__modules__]; 4467 4468 if (params.modules && Array.isArray(params.modules)) { 4469 swiper.modules.push(...params.modules); 4470 } 4471 4472 const allModulesParams = {}; 4473 swiper.modules.forEach(mod => { 4474 mod({ 4475 swiper, 4476 extendParams: moduleExtendParams(params, allModulesParams), 4477 on: swiper.on.bind(swiper), 4478 once: swiper.once.bind(swiper), 4479 off: swiper.off.bind(swiper), 4480 emit: swiper.emit.bind(swiper) 4481 }); 4482 }); // Extend defaults with modules params 4483 4484 const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params 4485 4486 swiper.params = extend({}, swiperParams, extendedDefaults, params); 4487 swiper.originalParams = extend({}, swiper.params); 4488 swiper.passedParams = extend({}, params); // add event listeners 4489 4490 if (swiper.params && swiper.params.on) {
vendor: 13,095 bytes, lines 4491-4989
4491 Object.keys(swiper.params.on).forEach(eventName => { 4492 swiper.on(eventName, swiper.params.on[eventName]); 4493 }); 4494 } 4495 4496 if (swiper.params && swiper.params.onAny) { 4497 swiper.onAny(swiper.params.onAny); 4498 } // Save Dom lib 4499 4500 4501 swiper.$ = $; // Extend Swiper 4502 4503 Object.assign(swiper, { 4504 enabled: swiper.params.enabled, 4505 el, 4506 // Classes 4507 classNames: [], 4508 // Slides 4509 slides: $(), 4510 slidesGrid: [], 4511 snapGrid: [], 4512 slidesSizesGrid: [], 4513 4514 // isDirection 4515 isHorizontal() { 4516 return swiper.params.direction === 'horizontal'; 4517 }, 4518 4519 isVertical() { 4520 return swiper.params.direction === 'vertical'; 4521 }, 4522 4523 // Indexes 4524 activeIndex: 0, 4525 realIndex: 0, 4526 // 4527 isBeginning: true, 4528 isEnd: false, 4529 // Props 4530 translate: 0, 4531 previousTranslate: 0, 4532 progress: 0, 4533 velocity: 0, 4534 animating: false, 4535 // Locks 4536 allowSlideNext: swiper.params.allowSlideNext, 4537 allowSlidePrev: swiper.params.allowSlidePrev, 4538 // Touch Events 4539 touchEvents: function touchEvents() { 4540 const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel']; 4541 const desktop = ['pointerdown', 'pointermove', 'pointerup']; 4542 swiper.touchEventsTouch = { 4543 start: touch[0], 4544 move: touch[1], 4545 end: touch[2], 4546 cancel: touch[3] 4547 }; 4548 swiper.touchEventsDesktop = { 4549 start: desktop[0], 4550 move: desktop[1], 4551 end: desktop[2] 4552 }; 4553 return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; 4554 }(), 4555 touchEventsData: { 4556 isTouched: undefined, 4557 isMoved: undefined, 4558 allowTouchCallbacks: undefined, 4559 touchStartTime: undefined, 4560 isScrolling: undefined, 4561 currentTranslate: undefined, 4562 startTranslate: undefined, 4563 allowThresholdMove: undefined, 4564 // Form elements to match 4565 focusableElements: swiper.params.focusableElements, 4566 // Last click time 4567 lastClickTime: now(), 4568 clickTimeout: undefined, 4569 // Velocities 4570 velocities: [], 4571 allowMomentumBounce: undefined, 4572 isTouchEvent: undefined, 4573 startMoving: undefined 4574 }, 4575 // Clicks 4576 allowClick: true, 4577 // Touches 4578 allowTouchMove: swiper.params.allowTouchMove, 4579 touches: { 4580 startX: 0, 4581 startY: 0, 4582 currentX: 0, 4583 currentY: 0, 4584 diff: 0 4585 }, 4586 // Images 4587 imagesToLoad: [], 4588 imagesLoaded: 0 4589 }); 4590 swiper.emit('_swiper'); // Init 4591 4592 if (swiper.params.init) { 4593 swiper.init(); 4594 } // Return app instance 4595 4596 4597 return swiper; 4598 } 4599 4600 enable() { 4601 const swiper = this; 4602 if (swiper.enabled) return; 4603 swiper.enabled = true; 4604 4605 if (swiper.params.grabCursor) { 4606 swiper.setGrabCursor(); 4607 } 4608 4609 swiper.emit('enable'); 4610 } 4611 4612 disable() { 4613 const swiper = this; 4614 if (!swiper.enabled) return; 4615 swiper.enabled = false; 4616 4617 if (swiper.params.grabCursor) { 4618 swiper.unsetGrabCursor(); 4619 } 4620 4621 swiper.emit('disable'); 4622 } 4623 4624 setProgress(progress, speed) { 4625 const swiper = this; 4626 progress = Math.min(Math.max(progress, 0), 1); 4627 const min = swiper.minTranslate(); 4628 const max = swiper.maxTranslate(); 4629 const current = (max - min) * progress + min; 4630 swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed); 4631 swiper.updateActiveIndex(); 4632 swiper.updateSlidesClasses(); 4633 } 4634 4635 emitContainerClasses() { 4636 const swiper = this; 4637 if (!swiper.params._emitClasses || !swiper.el) return; 4638 const cls = swiper.el.className.split(' ').filter(className => { 4639 return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0; 4640 }); 4641 swiper.emit('_containerClasses', cls.join(' ')); 4642 } 4643 4644 getSlideClasses(slideEl) { 4645 const swiper = this; 4646 if (swiper.destroyed) return ''; 4647 return slideEl.className.split(' ').filter(className => { 4648 return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0; 4649 }).join(' '); 4650 } 4651 4652 emitSlidesClasses() { 4653 const swiper = this; 4654 if (!swiper.params._emitClasses || !swiper.el) return; 4655 const updates = []; 4656 swiper.slides.each(slideEl => { 4657 const classNames = swiper.getSlideClasses(slideEl); 4658 updates.push({ 4659 slideEl, 4660 classNames 4661 }); 4662 swiper.emit('_slideClass', slideEl, classNames); 4663 }); 4664 swiper.emit('_slideClasses', updates); 4665 } 4666 4667 slidesPerViewDynamic(view, exact) { 4668 if (view === void 0) { 4669 view = 'current'; 4670 } 4671 4672 if (exact === void 0) { 4673 exact = false; 4674 } 4675 4676 const swiper = this; 4677 const { 4678 params, 4679 slides, 4680 slidesGrid, 4681 slidesSizesGrid, 4682 size: swiperSize, 4683 activeIndex 4684 } = swiper; 4685 let spv = 1; 4686 4687 if (params.centeredSlides) { 4688 let slideSize = slides[activeIndex].swiperSlideSize; 4689 let breakLoop; 4690 4691 for (let i = activeIndex + 1; i < slides.length; i += 1) { 4692 if (slides[i] && !breakLoop) { 4693 slideSize += slides[i].swiperSlideSize; 4694 spv += 1; 4695 if (slideSize > swiperSize) breakLoop = true; 4696 } 4697 } 4698 4699 for (let i = activeIndex - 1; i >= 0; i -= 1) { 4700 if (slides[i] && !breakLoop) { 4701 slideSize += slides[i].swiperSlideSize; 4702 spv += 1; 4703 if (slideSize > swiperSize) breakLoop = true; 4704 } 4705 } 4706 } else { 4707 // eslint-disable-next-line 4708 if (view === 'current') { 4709 for (let i = activeIndex + 1; i < slides.length; i += 1) { 4710 const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize; 4711 4712 if (slideInView) { 4713 spv += 1; 4714 } 4715 } 4716 } else { 4717 // previous 4718 for (let i = activeIndex - 1; i >= 0; i -= 1) { 4719 const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize; 4720 4721 if (slideInView) { 4722 spv += 1; 4723 } 4724 } 4725 } 4726 } 4727 4728 return spv; 4729 } 4730 4731 update() { 4732 const swiper = this; 4733 if (!swiper || swiper.destroyed) return; 4734 const { 4735 snapGrid, 4736 params 4737 } = swiper; // Breakpoints 4738 4739 if (params.breakpoints) { 4740 swiper.setBreakpoint(); 4741 } 4742 4743 swiper.updateSize(); 4744 swiper.updateSlides(); 4745 swiper.updateProgress(); 4746 swiper.updateSlidesClasses(); 4747 4748 function setTranslate() { 4749 const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; 4750 const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); 4751 swiper.setTranslate(newTranslate); 4752 swiper.updateActiveIndex(); 4753 swiper.updateSlidesClasses(); 4754 } 4755 4756 let translated; 4757 4758 if (swiper.params.freeMode && swiper.params.freeMode.enabled) { 4759 setTranslate(); 4760 4761 if (swiper.params.autoHeight) { 4762 swiper.updateAutoHeight(); 4763 } 4764 } else { 4765 if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 4766 translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); 4767 } else { 4768 translated = swiper.slideTo(swiper.activeIndex, 0, false, true); 4769 } 4770 4771 if (!translated) { 4772 setTranslate(); 4773 } 4774 } 4775 4776 if (params.watchOverflow && snapGrid !== swiper.snapGrid) { 4777 swiper.checkOverflow(); 4778 } 4779 4780 swiper.emit('update'); 4781 } 4782 4783 changeDirection(newDirection, needUpdate) { 4784 if (needUpdate === void 0) { 4785 needUpdate = true; 4786 } 4787 4788 const swiper = this; 4789 const currentDirection = swiper.params.direction; 4790 4791 if (!newDirection) { 4792 // eslint-disable-next-line 4793 newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal'; 4794 } 4795 4796 if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') { 4797 return swiper; 4798 } 4799 4800 swiper.$el.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`).addClass(`${swiper.params.containerModifierClass}${newDirection}`); 4801 swiper.emitContainerClasses(); 4802 swiper.params.direction = newDirection; 4803 swiper.slides.each(slideEl => { 4804 if (newDirection === 'vertical') { 4805 slideEl.style.width = ''; 4806 } else { 4807 slideEl.style.height = ''; 4808 } 4809 }); 4810 swiper.emit('changeDirection'); 4811 if (needUpdate) swiper.update(); 4812 return swiper; 4813 } 4814 4815 changeLanguageDirection(direction) { 4816 const swiper = this; 4817 if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return; 4818 swiper.rtl = direction === 'rtl'; 4819 swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl; 4820 4821 if (swiper.rtl) { 4822 swiper.$el.addClass(`${swiper.params.containerModifierClass}rtl`); 4823 swiper.el.dir = 'rtl'; 4824 } else { 4825 swiper.$el.removeClass(`${swiper.params.containerModifierClass}rtl`); 4826 swiper.el.dir = 'ltr'; 4827 } 4828 4829 swiper.update(); 4830 } 4831 4832 mount(el) { 4833 const swiper = this; 4834 if (swiper.mounted) return true; // Find el 4835 4836 const $el = $(el || swiper.params.el); 4837 el = $el[0]; 4838 4839 if (!el) { 4840 return false; 4841 } 4842 4843 el.swiper = swiper; 4844 4845 const getWrapperSelector = () => { 4846 return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`; 4847 }; 4848 4849 const getWrapper = () => { 4850 if (el && el.shadowRoot && el.shadowRoot.querySelector) { 4851 const res = $(el.shadowRoot.querySelector(getWrapperSelector())); // Children needs to return slot items 4852 4853 res.children = options => $el.children(options); 4854 4855 return res; 4856 } 4857 4858 if (!$el.children) { 4859 return $($el).children(getWrapperSelector()); 4860 } 4861 4862 return $el.children(getWrapperSelector()); 4863 }; // Find Wrapper 4864 4865 4866 let $wrapperEl = getWrapper(); 4867 4868 if ($wrapperEl.length === 0 && swiper.params.createElements) { 4869 const document = getDocument(); 4870 const wrapper = document.createElement('div'); 4871 $wrapperEl = $(wrapper); 4872 wrapper.className = swiper.params.wrapperClass; 4873 $el.append(wrapper); 4874 $el.children(`.${swiper.params.slideClass}`).each(slideEl => { 4875 $wrapperEl.append(slideEl); 4876 }); 4877 } 4878 4879 Object.assign(swiper, { 4880 $el, 4881 el, 4882 $wrapperEl, 4883 wrapperEl: $wrapperEl[0], 4884 mounted: true, 4885 // RTL 4886 rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl', 4887 rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), 4888 wrongRTL: $wrapperEl.css('display') === '-webkit-box' 4889 }); 4890 return true; 4891 } 4892 4893 init(el) { 4894 const swiper = this; 4895 if (swiper.initialized) return swiper; 4896 const mounted = swiper.mount(el); 4897 if (mounted === false) return swiper; 4898 swiper.emit('beforeInit'); // Set breakpoint 4899 4900 if (swiper.params.breakpoints) { 4901 swiper.setBreakpoint(); 4902 } // Add Classes 4903 4904 4905 swiper.addClasses(); // Create loop 4906 4907 if (swiper.params.loop) { 4908 swiper.loopCreate(); 4909 } // Update size 4910 4911 4912 swiper.updateSize(); // Update slides 4913 4914 swiper.updateSlides(); 4915 4916 if (swiper.params.watchOverflow) { 4917 swiper.checkOverflow(); 4918 } // Set Grab Cursor 4919 4920 4921 if (swiper.params.grabCursor && swiper.enabled) { 4922 swiper.setGrabCursor(); 4923 } 4924 4925 if (swiper.params.preloadImages) { 4926 swiper.preloadImages(); 4927 } // Slide To Initial Slide 4928 4929 4930 if (swiper.params.loop) { 4931 swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit, false, true); 4932 } else { 4933 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true); 4934 } // Attach events 4935 4936 4937 swiper.attachEvents(); // Init Flag 4938 4939 swiper.initialized = true; // Emit 4940 4941 swiper.emit('init'); 4942 swiper.emit('afterInit'); 4943 return swiper; 4944 } 4945 4946 destroy(deleteInstance, cleanStyles) { 4947 if (deleteInstance === void 0) { 4948 deleteInstance = true; 4949 } 4950 4951 if (cleanStyles === void 0) { 4952 cleanStyles = true; 4953 } 4954 4955 const swiper = this; 4956 const { 4957 params, 4958 $el, 4959 $wrapperEl, 4960 slides 4961 } = swiper; 4962 4963 if (typeof swiper.params === 'undefined' || swiper.destroyed) { 4964 return null; 4965 } 4966 4967 swiper.emit('beforeDestroy'); // Init Flag 4968 4969 swiper.initialized = false; // Detach events 4970 4971 swiper.detachEvents(); // Destroy loop 4972 4973 if (params.loop) { 4974 swiper.loopDestroy(); 4975 } // Cleanup styles 4976 4977 4978 if (cleanStyles) { 4979 swiper.removeClasses(); 4980 $el.removeAttr('style'); 4981 $wrapperEl.removeAttr('style'); 4982 4983 if (slides && slides.length) { 4984 slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index'); 4985 } 4986 } 4987 4988 swiper.emit('destroy'); // Detach emitter events 4989
vendor: 1,642 bytes, lines 4990-5071
4990 Object.keys(swiper.eventsListeners).forEach(eventName => { 4991 swiper.off(eventName); 4992 }); 4993 4994 if (deleteInstance !== false) { 4995 swiper.$el[0].swiper = null; 4996 deleteProps(swiper); 4997 } 4998 4999 swiper.destroyed = true; 5000 return null; 5001 } 5002 5003 static extendDefaults(newDefaults) { 5004 extend(extendedDefaults, newDefaults); 5005 } 5006 5007 static get extendedDefaults() { 5008 return extendedDefaults; 5009 } 5010 5011 static get defaults() { 5012 return defaults; 5013 } 5014 5015 static installModule(mod) { 5016 if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = []; 5017 const modules = Swiper.prototype.__modules__; 5018 5019 if (typeof mod === 'function' && modules.indexOf(mod) < 0) { 5020 modules.push(mod); 5021 } 5022 } 5023 5024 static use(module) { 5025 if (Array.isArray(module)) { 5026 module.forEach(m => Swiper.installModule(m)); 5027 return Swiper; 5028 } 5029 5030 Swiper.installModule(module); 5031 return Swiper; 5032 } 5033 5034} 5035 5036Object.keys(prototypes).forEach(prototypeGroup => { 5037 Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => { 5038 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; 5039 }); 5040}); 5041Swiper.use([Resize, Observer]); 5042 5043function Virtual(_ref) { 5044 let { 5045 swiper, 5046 extendParams, 5047 on, 5048 emit 5049 } = _ref; 5050 extendParams({ 5051 virtual: { 5052 enabled: false, 5053 slides: [], 5054 cache: true, 5055 renderSlide: null, 5056 renderExternal: null, 5057 renderExternalUpdate: true, 5058 addSlidesBefore: 0, 5059 addSlidesAfter: 0 5060 } 5061 }); 5062 let cssModeTimeout; 5063 swiper.virtual = { 5064 cache: {}, 5065 from: undefined, 5066 to: undefined, 5067 slides: [], 5068 offset: 0, 5069 slidesGrid: [] 5070 }; 5071
vendor: 5,002 bytes, lines 5072-5243
5072 function renderSlide(slide, index) { 5073 const params = swiper.params.virtual; 5074 5075 if (params.cache && swiper.virtual.cache[index]) { 5076 return swiper.virtual.cache[index]; 5077 } 5078 5079 const $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $(`<div class="${swiper.params.slideClass}" data-swiper-slide-index="${index}">${slide}</div>`); 5080 if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index); 5081 if (params.cache) swiper.virtual.cache[index] = $slideEl; 5082 return $slideEl; 5083 } 5084 5085 function update(force) { 5086 const { 5087 slidesPerView, 5088 slidesPerGroup, 5089 centeredSlides 5090 } = swiper.params; 5091 const { 5092 addSlidesBefore, 5093 addSlidesAfter 5094 } = swiper.params.virtual; 5095 const { 5096 from: previousFrom, 5097 to: previousTo, 5098 slides, 5099 slidesGrid: previousSlidesGrid, 5100 offset: previousOffset 5101 } = swiper.virtual; 5102 5103 if (!swiper.params.cssMode) { 5104 swiper.updateActiveIndex(); 5105 } 5106 5107 const activeIndex = swiper.activeIndex || 0; 5108 let offsetProp; 5109 if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top'; 5110 let slidesAfter; 5111 let slidesBefore; 5112 5113 if (centeredSlides) { 5114 slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; 5115 slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; 5116 } else { 5117 slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter; 5118 slidesBefore = slidesPerGroup + addSlidesBefore; 5119 } 5120 5121 const from = Math.max((activeIndex || 0) - slidesBefore, 0); 5122 const to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); 5123 const offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); 5124 Object.assign(swiper.virtual, { 5125 from, 5126 to, 5127 offset, 5128 slidesGrid: swiper.slidesGrid 5129 }); 5130 5131 function onRendered() { 5132 swiper.updateSlides(); 5133 swiper.updateProgress(); 5134 swiper.updateSlidesClasses(); 5135 5136 if (swiper.lazy && swiper.params.lazy.enabled) { 5137 swiper.lazy.load(); 5138 } 5139 5140 emit('virtualUpdate'); 5141 } 5142 5143 if (previousFrom === from && previousTo === to && !force) { 5144 if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { 5145 swiper.slides.css(offsetProp, `${offset}px`); 5146 } 5147 5148 swiper.updateProgress(); 5149 emit('virtualUpdate'); 5150 return; 5151 } 5152 5153 if (swiper.params.virtual.renderExternal) { 5154 swiper.params.virtual.renderExternal.call(swiper, { 5155 offset, 5156 from, 5157 to, 5158 slides: function getSlides() { 5159 const slidesToRender = []; 5160 5161 for (let i = from; i <= to; i += 1) { 5162 slidesToRender.push(slides[i]); 5163 } 5164 5165 return slidesToRender; 5166 }() 5167 }); 5168 5169 if (swiper.params.virtual.renderExternalUpdate) { 5170 onRendered(); 5171 } else { 5172 emit('virtualUpdate'); 5173 } 5174 5175 return; 5176 } 5177 5178 const prependIndexes = []; 5179 const appendIndexes = []; 5180 5181 if (force) { 5182 swiper.$wrapperEl.find(`.${swiper.params.slideClass}`).remove(); 5183 } else { 5184 for (let i = previousFrom; i <= previousTo; i += 1) { 5185 if (i < from || i > to) { 5186 swiper.$wrapperEl.find(`.${swiper.params.slideClass}[data-swiper-slide-index="${i}"]`).remove(); 5187 } 5188 } 5189 } 5190 5191 for (let i = 0; i < slides.length; i += 1) { 5192 if (i >= from && i <= to) { 5193 if (typeof previousTo === 'undefined' || force) { 5194 appendIndexes.push(i); 5195 } else { 5196 if (i > previousTo) appendIndexes.push(i); 5197 if (i < previousFrom) prependIndexes.push(i); 5198 } 5199 } 5200 } 5201 5202 appendIndexes.forEach(index => { 5203 swiper.$wrapperEl.append(renderSlide(slides[index], index)); 5204 }); 5205 prependIndexes.sort((a, b) => b - a).forEach(index => { 5206 swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); 5207 }); 5208 swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, `${offset}px`); 5209 onRendered(); 5210 } 5211 5212 function appendSlide(slides) { 5213 if (typeof slides === 'object' && 'length' in slides) { 5214 for (let i = 0; i < slides.length; i += 1) { 5215 if (slides[i]) swiper.virtual.slides.push(slides[i]); 5216 } 5217 } else { 5218 swiper.virtual.slides.push(slides); 5219 } 5220 5221 update(true); 5222 } 5223 5224 function prependSlide(slides) { 5225 const activeIndex = swiper.activeIndex; 5226 let newActiveIndex = activeIndex + 1; 5227 let numberOfNewSlides = 1; 5228 5229 if (Array.isArray(slides)) { 5230 for (let i = 0; i < slides.length; i += 1) { 5231 if (slides[i]) swiper.virtual.slides.unshift(slides[i]); 5232 } 5233 5234 newActiveIndex = activeIndex + slides.length; 5235 numberOfNewSlides = slides.length; 5236 } else { 5237 swiper.virtual.slides.unshift(slides); 5238 } 5239 5240 if (swiper.params.virtual.cache) { 5241 const cache = swiper.virtual.cache; 5242 const newCache = {}; 5243 Object.keys(cache).forEach(cachedIndex => {
vendor: 5,614 bytes, lines 5244-5425
5244 const $cachedEl = cache[cachedIndex]; 5245 const cachedElIndex = $cachedEl.attr('data-swiper-slide-index'); 5246 5247 if (cachedElIndex) { 5248 $cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides); 5249 } 5250 5251 newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl; 5252 }); 5253 swiper.virtual.cache = newCache; 5254 } 5255 5256 update(true); 5257 swiper.slideTo(newActiveIndex, 0); 5258 } 5259 5260 function removeSlide(slidesIndexes) { 5261 if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return; 5262 let activeIndex = swiper.activeIndex; 5263 5264 if (Array.isArray(slidesIndexes)) { 5265 for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) { 5266 swiper.virtual.slides.splice(slidesIndexes[i], 1); 5267 5268 if (swiper.params.virtual.cache) { 5269 delete swiper.virtual.cache[slidesIndexes[i]]; 5270 } 5271 5272 if (slidesIndexes[i] < activeIndex) activeIndex -= 1; 5273 activeIndex = Math.max(activeIndex, 0); 5274 } 5275 } else { 5276 swiper.virtual.slides.splice(slidesIndexes, 1); 5277 5278 if (swiper.params.virtual.cache) { 5279 delete swiper.virtual.cache[slidesIndexes]; 5280 } 5281 5282 if (slidesIndexes < activeIndex) activeIndex -= 1; 5283 activeIndex = Math.max(activeIndex, 0); 5284 } 5285 5286 update(true); 5287 swiper.slideTo(activeIndex, 0); 5288 } 5289 5290 function removeAllSlides() { 5291 swiper.virtual.slides = []; 5292 5293 if (swiper.params.virtual.cache) { 5294 swiper.virtual.cache = {}; 5295 } 5296 5297 update(true); 5298 swiper.slideTo(0, 0); 5299 } 5300 5301 on('beforeInit', () => { 5302 if (!swiper.params.virtual.enabled) return; 5303 swiper.virtual.slides = swiper.params.virtual.slides; 5304 swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`); 5305 swiper.params.watchSlidesProgress = true; 5306 swiper.originalParams.watchSlidesProgress = true; 5307 5308 if (!swiper.params.initialSlide) { 5309 update(); 5310 } 5311 }); 5312 on('setTranslate', () => { 5313 if (!swiper.params.virtual.enabled) return; 5314 5315 if (swiper.params.cssMode && !swiper._immediateVirtual) { 5316 clearTimeout(cssModeTimeout); 5317 cssModeTimeout = setTimeout(() => { 5318 update(); 5319 }, 100); 5320 } else { 5321 update(); 5322 } 5323 }); 5324 on('init update resize', () => { 5325 if (!swiper.params.virtual.enabled) return; 5326 5327 if (swiper.params.cssMode) { 5328 setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`); 5329 } 5330 }); 5331 Object.assign(swiper.virtual, { 5332 appendSlide, 5333 prependSlide, 5334 removeSlide, 5335 removeAllSlides, 5336 update 5337 }); 5338} 5339 5340/* eslint-disable consistent-return */ 5341function Keyboard(_ref) { 5342 let { 5343 swiper, 5344 extendParams, 5345 on, 5346 emit 5347 } = _ref; 5348 const document = getDocument(); 5349 const window = getWindow(); 5350 swiper.keyboard = { 5351 enabled: false 5352 }; 5353 extendParams({ 5354 keyboard: { 5355 enabled: false, 5356 onlyInViewport: true, 5357 pageUpDown: true 5358 } 5359 }); 5360 5361 function handle(event) { 5362 if (!swiper.enabled) return; 5363 const { 5364 rtlTranslate: rtl 5365 } = swiper; 5366 let e = event; 5367 if (e.originalEvent) e = e.originalEvent; // jquery fix 5368 5369 const kc = e.keyCode || e.charCode; 5370 const pageUpDown = swiper.params.keyboard.pageUpDown; 5371 const isPageUp = pageUpDown && kc === 33; 5372 const isPageDown = pageUpDown && kc === 34; 5373 const isArrowLeft = kc === 37; 5374 const isArrowRight = kc === 39; 5375 const isArrowUp = kc === 38; 5376 const isArrowDown = kc === 40; // Directions locks 5377 5378 if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) { 5379 return false; 5380 } 5381 5382 if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) { 5383 return false; 5384 } 5385 5386 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { 5387 return undefined; 5388 } 5389 5390 if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) { 5391 return undefined; 5392 } 5393 5394 if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) { 5395 let inView = false; // Check that swiper should be inside of visible area of window 5396 5397 if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) { 5398 return undefined; 5399 } 5400 5401 const $el = swiper.$el; 5402 const swiperWidth = $el[0].clientWidth; 5403 const swiperHeight = $el[0].clientHeight; 5404 const windowWidth = window.innerWidth; 5405 const windowHeight = window.innerHeight; 5406 const swiperOffset = swiper.$el.offset(); 5407 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; 5408 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]]; 5409 5410 for (let i = 0; i < swiperCoord.length; i += 1) { 5411 const point = swiperCoord[i]; 5412 5413 if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) { 5414 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line 5415 5416 inView = true; 5417 } 5418 } 5419 5420 if (!inView) return undefined; 5421 } 5422 5423 if (swiper.isHorizontal()) { 5424 if (isPageUp || isPageDown || isArrowLeft || isArrowRight) { 5425 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
vendor: 1,358 bytes, lines 5426-5484
5426 } 5427 5428 if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext(); 5429 if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev(); 5430 } else { 5431 if (isPageUp || isPageDown || isArrowUp || isArrowDown) { 5432 if (e.preventDefault) e.preventDefault();else e.returnValue = false; 5433 } 5434 5435 if (isPageDown || isArrowDown) swiper.slideNext(); 5436 if (isPageUp || isArrowUp) swiper.slidePrev(); 5437 } 5438 5439 emit('keyPress', kc); 5440 return undefined; 5441 } 5442 5443 function enable() { 5444 if (swiper.keyboard.enabled) return; 5445 $(document).on('keydown', handle); 5446 swiper.keyboard.enabled = true; 5447 } 5448 5449 function disable() { 5450 if (!swiper.keyboard.enabled) return; 5451 $(document).off('keydown', handle); 5452 swiper.keyboard.enabled = false; 5453 } 5454 5455 on('init', () => { 5456 if (swiper.params.keyboard.enabled) { 5457 enable(); 5458 } 5459 }); 5460 on('destroy', () => { 5461 if (swiper.keyboard.enabled) { 5462 disable(); 5463 } 5464 }); 5465 Object.assign(swiper.keyboard, { 5466 enable, 5467 disable 5468 }); 5469} 5470 5471/* eslint-disable consistent-return */ 5472function Mousewheel(_ref) { 5473 let { 5474 swiper, 5475 extendParams, 5476 on, 5477 emit 5478 } = _ref; 5479 const window = getWindow(); 5480 extendParams({ 5481 mousewheel: { 5482 enabled: false, 5483 releaseOnEdges: false, 5484 invert: false,
vendor: 13,312 bytes, lines 5485-5866
5485 forceToAxis: false, 5486 sensitivity: 1, 5487 eventsTarget: 'container', 5488 thresholdDelta: null, 5489 thresholdTime: null 5490 } 5491 }); 5492 swiper.mousewheel = { 5493 enabled: false 5494 }; 5495 let timeout; 5496 let lastScrollTime = now(); 5497 let lastEventBeforeSnap; 5498 const recentWheelEvents = []; 5499 5500 function normalize(e) { 5501 // Reasonable defaults 5502 const PIXEL_STEP = 10; 5503 const LINE_HEIGHT = 40; 5504 const PAGE_HEIGHT = 800; 5505 let sX = 0; 5506 let sY = 0; // spinX, spinY 5507 5508 let pX = 0; 5509 let pY = 0; // pixelX, pixelY 5510 // Legacy 5511 5512 if ('detail' in e) { 5513 sY = e.detail; 5514 } 5515 5516 if ('wheelDelta' in e) { 5517 sY = -e.wheelDelta / 120; 5518 } 5519 5520 if ('wheelDeltaY' in e) { 5521 sY = -e.wheelDeltaY / 120; 5522 } 5523 5524 if ('wheelDeltaX' in e) { 5525 sX = -e.wheelDeltaX / 120; 5526 } // side scrolling on FF with DOMMouseScroll 5527 5528 5529 if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { 5530 sX = sY; 5531 sY = 0; 5532 } 5533 5534 pX = sX * PIXEL_STEP; 5535 pY = sY * PIXEL_STEP; 5536 5537 if ('deltaY' in e) { 5538 pY = e.deltaY; 5539 } 5540 5541 if ('deltaX' in e) { 5542 pX = e.deltaX; 5543 } 5544 5545 if (e.shiftKey && !pX) { 5546 // if user scrolls with shift he wants horizontal scroll 5547 pX = pY; 5548 pY = 0; 5549 } 5550 5551 if ((pX || pY) && e.deltaMode) { 5552 if (e.deltaMode === 1) { 5553 // delta in LINE units 5554 pX *= LINE_HEIGHT; 5555 pY *= LINE_HEIGHT; 5556 } else { 5557 // delta in PAGE units 5558 pX *= PAGE_HEIGHT; 5559 pY *= PAGE_HEIGHT; 5560 } 5561 } // Fall-back if spin cannot be determined 5562 5563 5564 if (pX && !sX) { 5565 sX = pX < 1 ? -1 : 1; 5566 } 5567 5568 if (pY && !sY) { 5569 sY = pY < 1 ? -1 : 1; 5570 } 5571 5572 return { 5573 spinX: sX, 5574 spinY: sY, 5575 pixelX: pX, 5576 pixelY: pY 5577 }; 5578 } 5579 5580 function handleMouseEnter() { 5581 if (!swiper.enabled) return; 5582 swiper.mouseEntered = true; 5583 } 5584 5585 function handleMouseLeave() { 5586 if (!swiper.enabled) return; 5587 swiper.mouseEntered = false; 5588 } 5589 5590 function animateSlider(newEvent) { 5591 if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) { 5592 // Prevent if delta of wheel scroll delta is below configured threshold 5593 return false; 5594 } 5595 5596 if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) { 5597 // Prevent if time between scrolls is below configured threshold 5598 return false; 5599 } // If the movement is NOT big enough and 5600 // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider): 5601 // Don't go any further (avoid insignificant scroll movement). 5602 5603 5604 if (newEvent.delta >= 6 && now() - lastScrollTime < 60) { 5605 // Return false as a default 5606 return true; 5607 } // If user is scrolling towards the end: 5608 // If the slider hasn't hit the latest slide or 5609 // if the slider is a loop and 5610 // if the slider isn't moving right now: 5611 // Go to next slide and 5612 // emit a scroll event. 5613 // Else (the user is scrolling towards the beginning) and 5614 // if the slider hasn't hit the first slide or 5615 // if the slider is a loop and 5616 // if the slider isn't moving right now: 5617 // Go to prev slide and 5618 // emit a scroll event. 5619 5620 5621 if (newEvent.direction < 0) { 5622 if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { 5623 swiper.slideNext(); 5624 emit('scroll', newEvent.raw); 5625 } 5626 } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { 5627 swiper.slidePrev(); 5628 emit('scroll', newEvent.raw); 5629 } // If you got here is because an animation has been triggered so store the current time 5630 5631 5632 lastScrollTime = new window.Date().getTime(); // Return false as a default 5633 5634 return false; 5635 } 5636 5637 function releaseScroll(newEvent) { 5638 const params = swiper.params.mousewheel; 5639 5640 if (newEvent.direction < 0) { 5641 if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) { 5642 // Return true to animate scroll on edges 5643 return true; 5644 } 5645 } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) { 5646 // Return true to animate scroll on edges 5647 return true; 5648 } 5649 5650 return false; 5651 } 5652 5653 function handle(event) { 5654 let e = event; 5655 let disableParentSwiper = true; 5656 if (!swiper.enabled) return; 5657 const params = swiper.params.mousewheel; 5658 5659 if (swiper.params.cssMode) { 5660 e.preventDefault(); 5661 } 5662 5663 let target = swiper.$el; 5664 5665 if (swiper.params.mousewheel.eventsTarget !== 'container') { 5666 target = $(swiper.params.mousewheel.eventsTarget); 5667 } 5668 5669 if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true; 5670 if (e.originalEvent) e = e.originalEvent; // jquery fix 5671 5672 let delta = 0; 5673 const rtlFactor = swiper.rtlTranslate ? -1 : 1; 5674 const data = normalize(e); 5675 5676 if (params.forceToAxis) { 5677 if (swiper.isHorizontal()) { 5678 if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true; 5679 } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true; 5680 } else { 5681 delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; 5682 } 5683 5684 if (delta === 0) return true; 5685 if (params.invert) delta = -delta; // Get the scroll positions 5686 5687 let positions = swiper.getTranslate() + delta * params.sensitivity; 5688 if (positions >= swiper.minTranslate()) positions = swiper.minTranslate(); 5689 if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate(); // When loop is true: 5690 // the disableParentSwiper will be true. 5691 // When loop is false: 5692 // if the scroll positions is not on edge, 5693 // then the disableParentSwiper will be true. 5694 // if the scroll on edge positions, 5695 // then the disableParentSwiper will be false. 5696 5697 disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate()); 5698 if (disableParentSwiper && swiper.params.nested) e.stopPropagation(); 5699 5700 if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) { 5701 // Register the new event in a variable which stores the relevant data 5702 const newEvent = { 5703 time: now(), 5704 delta: Math.abs(delta), 5705 direction: Math.sign(delta), 5706 raw: event 5707 }; // Keep the most recent events 5708 5709 if (recentWheelEvents.length >= 2) { 5710 recentWheelEvents.shift(); // only store the last N events 5711 } 5712 5713 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; 5714 recentWheelEvents.push(newEvent); // If there is at least one previous recorded event: 5715 // If direction has changed or 5716 // if the scroll is quicker than the previous one: 5717 // Animate the slider. 5718 // Else (this is the first time the wheel is moved): 5719 // Animate the slider. 5720 5721 if (prevEvent) { 5722 if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) { 5723 animateSlider(newEvent); 5724 } 5725 } else { 5726 animateSlider(newEvent); 5727 } // If it's time to release the scroll: 5728 // Return now so you don't hit the preventDefault. 5729 5730 5731 if (releaseScroll(newEvent)) { 5732 return true; 5733 } 5734 } else { 5735 // Freemode or scrollContainer: 5736 // If we recently snapped after a momentum scroll, then ignore wheel events 5737 // to give time for the deceleration to finish. Stop ignoring after 500 msecs 5738 // or if it's a new scroll (larger delta or inverse sign as last event before 5739 // an end-of-momentum snap). 5740 const newEvent = { 5741 time: now(), 5742 delta: Math.abs(delta), 5743 direction: Math.sign(delta) 5744 }; 5745 const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction; 5746 5747 if (!ignoreWheelEvents) { 5748 lastEventBeforeSnap = undefined; 5749 5750 if (swiper.params.loop) { 5751 swiper.loopFix(); 5752 } 5753 5754 let position = swiper.getTranslate() + delta * params.sensitivity; 5755 const wasBeginning = swiper.isBeginning; 5756 const wasEnd = swiper.isEnd; 5757 if (position >= swiper.minTranslate()) position = swiper.minTranslate(); 5758 if (position <= swiper.maxTranslate()) position = swiper.maxTranslate(); 5759 swiper.setTransition(0); 5760 swiper.setTranslate(position); 5761 swiper.updateProgress(); 5762 swiper.updateActiveIndex(); 5763 swiper.updateSlidesClasses(); 5764 5765 if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) { 5766 swiper.updateSlidesClasses(); 5767 } 5768 5769 if (swiper.params.freeMode.sticky) { 5770 // When wheel scrolling starts with sticky (aka snap) enabled, then detect 5771 // the end of a momentum scroll by storing recent (N=15?) wheel events. 5772 // 1. do all N events have decreasing or same (absolute value) delta? 5773 // 2. did all N events arrive in the last M (M=500?) msecs? 5774 // 3. does the earliest event have an (absolute value) delta that's 5775 // at least P (P=1?) larger than the most recent event's delta? 5776 // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels? 5777 // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration. 5778 // Snap immediately and ignore remaining wheel events in this scroll. 5779 // See comment above for "remaining wheel events in this scroll" determination. 5780 // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event. 5781 clearTimeout(timeout); 5782 timeout = undefined; 5783 5784 if (recentWheelEvents.length >= 15) { 5785 recentWheelEvents.shift(); // only store the last N events 5786 } 5787 5788 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined; 5789 const firstEvent = recentWheelEvents[0]; 5790 recentWheelEvents.push(newEvent); 5791 5792 if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) { 5793 // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log. 5794 recentWheelEvents.splice(0); 5795 } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) { 5796 // We're at the end of the deceleration of a momentum scroll, so there's no need 5797 // to wait for more events. Snap ASAP on the next tick. 5798 // Also, because there's some remaining momentum we'll bias the snap in the 5799 // direction of the ongoing scroll because it's better UX for the scroll to snap 5800 // in the same direction as the scroll instead of reversing to snap. Therefore, 5801 // if it's already scrolled more than 20% in the current direction, keep going. 5802 const snapToThreshold = delta > 0 ? 0.8 : 0.2; 5803 lastEventBeforeSnap = newEvent; 5804 recentWheelEvents.splice(0); 5805 timeout = nextTick(() => { 5806 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); 5807 }, 0); // no delay; move on next tick 5808 } 5809 5810 if (!timeout) { 5811 // if we get here, then we haven't detected the end of a momentum scroll, so 5812 // we'll consider a scroll "complete" when there haven't been any wheel events 5813 // for 500ms. 5814 timeout = nextTick(() => { 5815 const snapToThreshold = 0.5; 5816 lastEventBeforeSnap = newEvent; 5817 recentWheelEvents.splice(0); 5818 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold); 5819 }, 500); 5820 } 5821 } // Emit event 5822 5823 5824 if (!ignoreWheelEvents) emit('scroll', e); // Stop autoplay 5825 5826 if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop(); // Return page scroll on edge positions 5827 5828 if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true; 5829 } 5830 } 5831 5832 if (e.preventDefault) e.preventDefault();else e.returnValue = false; 5833 return false; 5834 } 5835 5836 function events(method) { 5837 let target = swiper.$el; 5838 5839 if (swiper.params.mousewheel.eventsTarget !== 'container') { 5840 target = $(swiper.params.mousewheel.eventsTarget); 5841 } 5842 5843 target[method]('mouseenter', handleMouseEnter); 5844 target[method]('mouseleave', handleMouseLeave); 5845 target[method]('wheel', handle); 5846 } 5847 5848 function enable() { 5849 if (swiper.params.cssMode) { 5850 swiper.wrapperEl.removeEventListener('wheel', handle); 5851 return true; 5852 } 5853 5854 if (swiper.mousewheel.enabled) return false; 5855 events('on'); 5856 swiper.mousewheel.enabled = true; 5857 return true; 5858 } 5859 5860 function disable() { 5861 if (swiper.params.cssMode) { 5862 swiper.wrapperEl.addEventListener(event, handle); 5863 return true; 5864 } 5865 5866 if (!swiper.mousewheel.enabled) return false;
vendor: 8,131 bytes, lines 5867-6189
5867 events('off'); 5868 swiper.mousewheel.enabled = false; 5869 return true; 5870 } 5871 5872 on('init', () => { 5873 if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) { 5874 disable(); 5875 } 5876 5877 if (swiper.params.mousewheel.enabled) enable(); 5878 }); 5879 on('destroy', () => { 5880 if (swiper.params.cssMode) { 5881 enable(); 5882 } 5883 5884 if (swiper.mousewheel.enabled) disable(); 5885 }); 5886 Object.assign(swiper.mousewheel, { 5887 enable, 5888 disable 5889 }); 5890} 5891 5892function createElementIfNotDefined(swiper, originalParams, params, checkProps) { 5893 const document = getDocument(); 5894 5895 if (swiper.params.createElements) { 5896 Object.keys(checkProps).forEach(key => { 5897 if (!params[key] && params.auto === true) { 5898 let element = swiper.$el.children(`.${checkProps[key]}`)[0]; 5899 5900 if (!element) { 5901 element = document.createElement('div'); 5902 element.className = checkProps[key]; 5903 swiper.$el.append(element); 5904 } 5905 5906 params[key] = element; 5907 originalParams[key] = element; 5908 } 5909 }); 5910 } 5911 5912 return params; 5913} 5914 5915function Navigation(_ref) { 5916 let { 5917 swiper, 5918 extendParams, 5919 on, 5920 emit 5921 } = _ref; 5922 extendParams({ 5923 navigation: { 5924 nextEl: null, 5925 prevEl: null, 5926 hideOnClick: false, 5927 disabledClass: 'swiper-button-disabled', 5928 hiddenClass: 'swiper-button-hidden', 5929 lockClass: 'swiper-button-lock', 5930 navigationDisabledClass: 'swiper-navigation-disabled' 5931 } 5932 }); 5933 swiper.navigation = { 5934 nextEl: null, 5935 $nextEl: null, 5936 prevEl: null, 5937 $prevEl: null 5938 }; 5939 5940 function getEl(el) { 5941 let $el; 5942 5943 if (el) { 5944 $el = $(el); 5945 5946 if (swiper.params.uniqueNavElements && typeof el === 'string' && $el.length > 1 && swiper.$el.find(el).length === 1) { 5947 $el = swiper.$el.find(el); 5948 } 5949 } 5950 5951 return $el; 5952 } 5953 5954 function toggleEl($el, disabled) { 5955 const params = swiper.params.navigation; 5956 5957 if ($el && $el.length > 0) { 5958 $el[disabled ? 'addClass' : 'removeClass'](params.disabledClass); 5959 if ($el[0] && $el[0].tagName === 'BUTTON') $el[0].disabled = disabled; 5960 5961 if (swiper.params.watchOverflow && swiper.enabled) { 5962 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 5963 } 5964 } 5965 } 5966 5967 function update() { 5968 // Update Navigation Buttons 5969 if (swiper.params.loop) return; 5970 const { 5971 $nextEl, 5972 $prevEl 5973 } = swiper.navigation; 5974 toggleEl($prevEl, swiper.isBeginning && !swiper.params.rewind); 5975 toggleEl($nextEl, swiper.isEnd && !swiper.params.rewind); 5976 } 5977 5978 function onPrevClick(e) { 5979 e.preventDefault(); 5980 if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return; 5981 swiper.slidePrev(); 5982 emit('navigationPrev'); 5983 } 5984 5985 function onNextClick(e) { 5986 e.preventDefault(); 5987 if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return; 5988 swiper.slideNext(); 5989 emit('navigationNext'); 5990 } 5991 5992 function init() { 5993 const params = swiper.params.navigation; 5994 swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, { 5995 nextEl: 'swiper-button-next', 5996 prevEl: 'swiper-button-prev' 5997 }); 5998 if (!(params.nextEl || params.prevEl)) return; 5999 const $nextEl = getEl(params.nextEl); 6000 const $prevEl = getEl(params.prevEl); 6001 6002 if ($nextEl && $nextEl.length > 0) { 6003 $nextEl.on('click', onNextClick); 6004 } 6005 6006 if ($prevEl && $prevEl.length > 0) { 6007 $prevEl.on('click', onPrevClick); 6008 } 6009 6010 Object.assign(swiper.navigation, { 6011 $nextEl, 6012 nextEl: $nextEl && $nextEl[0], 6013 $prevEl, 6014 prevEl: $prevEl && $prevEl[0] 6015 }); 6016 6017 if (!swiper.enabled) { 6018 if ($nextEl) $nextEl.addClass(params.lockClass); 6019 if ($prevEl) $prevEl.addClass(params.lockClass); 6020 } 6021 } 6022 6023 function destroy() { 6024 const { 6025 $nextEl, 6026 $prevEl 6027 } = swiper.navigation; 6028 6029 if ($nextEl && $nextEl.length) { 6030 $nextEl.off('click', onNextClick); 6031 $nextEl.removeClass(swiper.params.navigation.disabledClass); 6032 } 6033 6034 if ($prevEl && $prevEl.length) { 6035 $prevEl.off('click', onPrevClick); 6036 $prevEl.removeClass(swiper.params.navigation.disabledClass); 6037 } 6038 } 6039 6040 on('init', () => { 6041 if (swiper.params.navigation.enabled === false) { 6042 // eslint-disable-next-line 6043 disable(); 6044 } else { 6045 init(); 6046 update(); 6047 } 6048 }); 6049 on('toEdge fromEdge lock unlock', () => { 6050 update(); 6051 }); 6052 on('destroy', () => { 6053 destroy(); 6054 }); 6055 on('enable disable', () => { 6056 const { 6057 $nextEl, 6058 $prevEl 6059 } = swiper.navigation; 6060 6061 if ($nextEl) { 6062 $nextEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass); 6063 } 6064 6065 if ($prevEl) { 6066 $prevEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass); 6067 } 6068 }); 6069 on('click', (_s, e) => { 6070 const { 6071 $nextEl, 6072 $prevEl 6073 } = swiper.navigation; 6074 const targetEl = e.target; 6075 6076 if (swiper.params.navigation.hideOnClick && !$(targetEl).is($prevEl) && !$(targetEl).is($nextEl)) { 6077 if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return; 6078 let isHidden; 6079 6080 if ($nextEl) { 6081 isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass); 6082 } else if ($prevEl) { 6083 isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass); 6084 } 6085 6086 if (isHidden === true) { 6087 emit('navigationShow'); 6088 } else { 6089 emit('navigationHide'); 6090 } 6091 6092 if ($nextEl) { 6093 $nextEl.toggleClass(swiper.params.navigation.hiddenClass); 6094 } 6095 6096 if ($prevEl) { 6097 $prevEl.toggleClass(swiper.params.navigation.hiddenClass); 6098 } 6099 } 6100 }); 6101 6102 const enable = () => { 6103 swiper.$el.removeClass(swiper.params.navigation.navigationDisabledClass); 6104 init(); 6105 update(); 6106 }; 6107 6108 const disable = () => { 6109 swiper.$el.addClass(swiper.params.navigation.navigationDisabledClass); 6110 destroy(); 6111 }; 6112 6113 Object.assign(swiper.navigation, { 6114 enable, 6115 disable, 6116 update, 6117 init, 6118 destroy 6119 }); 6120} 6121 6122function classesToSelector(classes) { 6123 if (classes === void 0) { 6124 classes = ''; 6125 } 6126 6127 return `.${classes.trim().replace(/([\.:!\/])/g, '\\$1') // eslint-disable-line 6128 .replace(/ /g, '.')}`; 6129} 6130 6131function Pagination(_ref) { 6132 let { 6133 swiper, 6134 extendParams, 6135 on, 6136 emit 6137 } = _ref; 6138 const pfx = 'swiper-pagination'; 6139 extendParams({ 6140 pagination: { 6141 el: null, 6142 bulletElement: 'span', 6143 clickable: false, 6144 hideOnClick: false, 6145 renderBullet: null, 6146 renderProgressbar: null, 6147 renderFraction: null, 6148 renderCustom: null, 6149 progressbarOpposite: false, 6150 type: 'bullets', 6151 // 'bullets' or 'progressbar' or 'fraction' or 'custom' 6152 dynamicBullets: false, 6153 dynamicMainBullets: 1, 6154 formatFractionCurrent: number => number, 6155 formatFractionTotal: number => number, 6156 bulletClass: `${pfx}-bullet`, 6157 bulletActiveClass: `${pfx}-bullet-active`, 6158 modifierClass: `${pfx}-`, 6159 currentClass: `${pfx}-current`, 6160 totalClass: `${pfx}-total`, 6161 hiddenClass: `${pfx}-hidden`, 6162 progressbarFillClass: `${pfx}-progressbar-fill`, 6163 progressbarOppositeClass: `${pfx}-progressbar-opposite`, 6164 clickableClass: `${pfx}-clickable`, 6165 lockClass: `${pfx}-lock`, 6166 horizontalClass: `${pfx}-horizontal`, 6167 verticalClass: `${pfx}-vertical`, 6168 paginationDisabledClass: `${pfx}-disabled` 6169 } 6170 }); 6171 swiper.pagination = { 6172 el: null, 6173 $el: null, 6174 bullets: [] 6175 }; 6176 let bulletSize; 6177 let dynamicBulletIndex = 0; 6178 6179 function isPaginationDisabled() { 6180 return !swiper.params.pagination.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0; 6181 } 6182 6183 function setSideBullets($bulletEl, position) { 6184 const { 6185 bulletActiveClass 6186 } = swiper.params.pagination; 6187 $bulletEl[position]().addClass(`${bulletActiveClass}-${position}`)[position]().addClass(`${bulletActiveClass}-${position}-${position}`); 6188 } 6189
vendor: 17,918 bytes, lines 6190-6774
6190 function update() { 6191 // Render || Update Pagination bullets/items 6192 const rtl = swiper.rtl; 6193 const params = swiper.params.pagination; 6194 if (isPaginationDisabled()) return; 6195 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 6196 const $el = swiper.pagination.$el; // Current/Total 6197 6198 let current; 6199 const total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 6200 6201 if (swiper.params.loop) { 6202 current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); 6203 6204 if (current > slidesLength - 1 - swiper.loopedSlides * 2) { 6205 current -= slidesLength - swiper.loopedSlides * 2; 6206 } 6207 6208 if (current > total - 1) current -= total; 6209 if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current; 6210 } else if (typeof swiper.snapIndex !== 'undefined') { 6211 current = swiper.snapIndex; 6212 } else { 6213 current = swiper.activeIndex || 0; 6214 } // Types 6215 6216 6217 if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { 6218 const bullets = swiper.pagination.bullets; 6219 let firstIndex; 6220 let lastIndex; 6221 let midIndex; 6222 6223 if (params.dynamicBullets) { 6224 bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); 6225 $el.css(swiper.isHorizontal() ? 'width' : 'height', `${bulletSize * (params.dynamicMainBullets + 4)}px`); 6226 6227 if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { 6228 dynamicBulletIndex += current - (swiper.previousIndex - swiper.loopedSlides || 0); 6229 6230 if (dynamicBulletIndex > params.dynamicMainBullets - 1) { 6231 dynamicBulletIndex = params.dynamicMainBullets - 1; 6232 } else if (dynamicBulletIndex < 0) { 6233 dynamicBulletIndex = 0; 6234 } 6235 } 6236 6237 firstIndex = Math.max(current - dynamicBulletIndex, 0); 6238 lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); 6239 midIndex = (lastIndex + firstIndex) / 2; 6240 } 6241 6242 bullets.removeClass(['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletActiveClass}${suffix}`).join(' ')); 6243 6244 if ($el.length > 1) { 6245 bullets.each(bullet => { 6246 const $bullet = $(bullet); 6247 const bulletIndex = $bullet.index(); 6248 6249 if (bulletIndex === current) { 6250 $bullet.addClass(params.bulletActiveClass); 6251 } 6252 6253 if (params.dynamicBullets) { 6254 if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { 6255 $bullet.addClass(`${params.bulletActiveClass}-main`); 6256 } 6257 6258 if (bulletIndex === firstIndex) { 6259 setSideBullets($bullet, 'prev'); 6260 } 6261 6262 if (bulletIndex === lastIndex) { 6263 setSideBullets($bullet, 'next'); 6264 } 6265 } 6266 }); 6267 } else { 6268 const $bullet = bullets.eq(current); 6269 const bulletIndex = $bullet.index(); 6270 $bullet.addClass(params.bulletActiveClass); 6271 6272 if (params.dynamicBullets) { 6273 const $firstDisplayedBullet = bullets.eq(firstIndex); 6274 const $lastDisplayedBullet = bullets.eq(lastIndex); 6275 6276 for (let i = firstIndex; i <= lastIndex; i += 1) { 6277 bullets.eq(i).addClass(`${params.bulletActiveClass}-main`); 6278 } 6279 6280 if (swiper.params.loop) { 6281 if (bulletIndex >= bullets.length) { 6282 for (let i = params.dynamicMainBullets; i >= 0; i -= 1) { 6283 bullets.eq(bullets.length - i).addClass(`${params.bulletActiveClass}-main`); 6284 } 6285 6286 bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(`${params.bulletActiveClass}-prev`); 6287 } else { 6288 setSideBullets($firstDisplayedBullet, 'prev'); 6289 setSideBullets($lastDisplayedBullet, 'next'); 6290 } 6291 } else { 6292 setSideBullets($firstDisplayedBullet, 'prev'); 6293 setSideBullets($lastDisplayedBullet, 'next'); 6294 } 6295 } 6296 } 6297 6298 if (params.dynamicBullets) { 6299 const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); 6300 const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize; 6301 const offsetProp = rtl ? 'right' : 'left'; 6302 bullets.css(swiper.isHorizontal() ? offsetProp : 'top', `${bulletsOffset}px`); 6303 } 6304 } 6305 6306 if (params.type === 'fraction') { 6307 $el.find(classesToSelector(params.currentClass)).text(params.formatFractionCurrent(current + 1)); 6308 $el.find(classesToSelector(params.totalClass)).text(params.formatFractionTotal(total)); 6309 } 6310 6311 if (params.type === 'progressbar') { 6312 let progressbarDirection; 6313 6314 if (params.progressbarOpposite) { 6315 progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; 6316 } else { 6317 progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; 6318 } 6319 6320 const scale = (current + 1) / total; 6321 let scaleX = 1; 6322 let scaleY = 1; 6323 6324 if (progressbarDirection === 'horizontal') { 6325 scaleX = scale; 6326 } else { 6327 scaleY = scale; 6328 } 6329 6330 $el.find(classesToSelector(params.progressbarFillClass)).transform(`translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`).transition(swiper.params.speed); 6331 } 6332 6333 if (params.type === 'custom' && params.renderCustom) { 6334 $el.html(params.renderCustom(swiper, current + 1, total)); 6335 emit('paginationRender', $el[0]); 6336 } else { 6337 emit('paginationUpdate', $el[0]); 6338 } 6339 6340 if (swiper.params.watchOverflow && swiper.enabled) { 6341 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); 6342 } 6343 } 6344 6345 function render() { 6346 // Render Container 6347 const params = swiper.params.pagination; 6348 if (isPaginationDisabled()) return; 6349 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 6350 const $el = swiper.pagination.$el; 6351 let paginationHTML = ''; 6352 6353 if (params.type === 'bullets') { 6354 let numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 6355 6356 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.loop && numberOfBullets > slidesLength) { 6357 numberOfBullets = slidesLength; 6358 } 6359 6360 for (let i = 0; i < numberOfBullets; i += 1) { 6361 if (params.renderBullet) { 6362 paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); 6363 } else { 6364 paginationHTML += `<${params.bulletElement} class="${params.bulletClass}"></${params.bulletElement}>`; 6365 } 6366 } 6367 6368 $el.html(paginationHTML); 6369 swiper.pagination.bullets = $el.find(classesToSelector(params.bulletClass)); 6370 } 6371 6372 if (params.type === 'fraction') { 6373 if (params.renderFraction) { 6374 paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); 6375 } else { 6376 paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`; 6377 } 6378 6379 $el.html(paginationHTML); 6380 } 6381 6382 if (params.type === 'progressbar') { 6383 if (params.renderProgressbar) { 6384 paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); 6385 } else { 6386 paginationHTML = `<span class="${params.progressbarFillClass}"></span>`; 6387 } 6388 6389 $el.html(paginationHTML); 6390 } 6391 6392 if (params.type !== 'custom') { 6393 emit('paginationRender', swiper.pagination.$el[0]); 6394 } 6395 } 6396 6397 function init() { 6398 swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, { 6399 el: 'swiper-pagination' 6400 }); 6401 const params = swiper.params.pagination; 6402 if (!params.el) return; 6403 let $el = $(params.el); 6404 if ($el.length === 0) return; 6405 6406 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) { 6407 $el = swiper.$el.find(params.el); // check if it belongs to another nested Swiper 6408 6409 if ($el.length > 1) { 6410 $el = $el.filter(el => { 6411 if ($(el).parents('.swiper')[0] !== swiper.el) return false; 6412 return true; 6413 }); 6414 } 6415 } 6416 6417 if (params.type === 'bullets' && params.clickable) { 6418 $el.addClass(params.clickableClass); 6419 } 6420 6421 $el.addClass(params.modifierClass + params.type); 6422 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 6423 6424 if (params.type === 'bullets' && params.dynamicBullets) { 6425 $el.addClass(`${params.modifierClass}${params.type}-dynamic`); 6426 dynamicBulletIndex = 0; 6427 6428 if (params.dynamicMainBullets < 1) { 6429 params.dynamicMainBullets = 1; 6430 } 6431 } 6432 6433 if (params.type === 'progressbar' && params.progressbarOpposite) { 6434 $el.addClass(params.progressbarOppositeClass); 6435 } 6436 6437 if (params.clickable) { 6438 $el.on('click', classesToSelector(params.bulletClass), function onClick(e) { 6439 e.preventDefault(); 6440 let index = $(this).index() * swiper.params.slidesPerGroup; 6441 if (swiper.params.loop) index += swiper.loopedSlides; 6442 swiper.slideTo(index); 6443 }); 6444 } 6445 6446 Object.assign(swiper.pagination, { 6447 $el, 6448 el: $el[0] 6449 }); 6450 6451 if (!swiper.enabled) { 6452 $el.addClass(params.lockClass); 6453 } 6454 } 6455 6456 function destroy() { 6457 const params = swiper.params.pagination; 6458 if (isPaginationDisabled()) return; 6459 const $el = swiper.pagination.$el; 6460 $el.removeClass(params.hiddenClass); 6461 $el.removeClass(params.modifierClass + params.type); 6462 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 6463 if (swiper.pagination.bullets && swiper.pagination.bullets.removeClass) swiper.pagination.bullets.removeClass(params.bulletActiveClass); 6464 6465 if (params.clickable) { 6466 $el.off('click', classesToSelector(params.bulletClass)); 6467 } 6468 } 6469 6470 on('init', () => { 6471 if (swiper.params.pagination.enabled === false) { 6472 // eslint-disable-next-line 6473 disable(); 6474 } else { 6475 init(); 6476 render(); 6477 update(); 6478 } 6479 }); 6480 on('activeIndexChange', () => { 6481 if (swiper.params.loop) { 6482 update(); 6483 } else if (typeof swiper.snapIndex === 'undefined') { 6484 update(); 6485 } 6486 }); 6487 on('snapIndexChange', () => { 6488 if (!swiper.params.loop) { 6489 update(); 6490 } 6491 }); 6492 on('slidesLengthChange', () => { 6493 if (swiper.params.loop) { 6494 render(); 6495 update(); 6496 } 6497 }); 6498 on('snapGridLengthChange', () => { 6499 if (!swiper.params.loop) { 6500 render(); 6501 update(); 6502 } 6503 }); 6504 on('destroy', () => { 6505 destroy(); 6506 }); 6507 on('enable disable', () => { 6508 const { 6509 $el 6510 } = swiper.pagination; 6511 6512 if ($el) { 6513 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.pagination.lockClass); 6514 } 6515 }); 6516 on('lock unlock', () => { 6517 update(); 6518 }); 6519 on('click', (_s, e) => { 6520 const targetEl = e.target; 6521 const { 6522 $el 6523 } = swiper.pagination; 6524 6525 if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && $el && $el.length > 0 && !$(targetEl).hasClass(swiper.params.pagination.bulletClass)) { 6526 if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return; 6527 const isHidden = $el.hasClass(swiper.params.pagination.hiddenClass); 6528 6529 if (isHidden === true) { 6530 emit('paginationShow'); 6531 } else { 6532 emit('paginationHide'); 6533 } 6534 6535 $el.toggleClass(swiper.params.pagination.hiddenClass); 6536 } 6537 }); 6538 6539 const enable = () => { 6540 swiper.$el.removeClass(swiper.params.pagination.paginationDisabledClass); 6541 6542 if (swiper.pagination.$el) { 6543 swiper.pagination.$el.removeClass(swiper.params.pagination.paginationDisabledClass); 6544 } 6545 6546 init(); 6547 render(); 6548 update(); 6549 }; 6550 6551 const disable = () => { 6552 swiper.$el.addClass(swiper.params.pagination.paginationDisabledClass); 6553 6554 if (swiper.pagination.$el) { 6555 swiper.pagination.$el.addClass(swiper.params.pagination.paginationDisabledClass); 6556 } 6557 6558 destroy(); 6559 }; 6560 6561 Object.assign(swiper.pagination, { 6562 enable, 6563 disable, 6564 render, 6565 update, 6566 init, 6567 destroy 6568 }); 6569} 6570 6571function Scrollbar(_ref) { 6572 let { 6573 swiper, 6574 extendParams, 6575 on, 6576 emit 6577 } = _ref; 6578 const document = getDocument(); 6579 let isTouched = false; 6580 let timeout = null; 6581 let dragTimeout = null; 6582 let dragStartPos; 6583 let dragSize; 6584 let trackSize; 6585 let divider; 6586 extendParams({ 6587 scrollbar: { 6588 el: null, 6589 dragSize: 'auto', 6590 hide: false, 6591 draggable: false, 6592 snapOnRelease: true, 6593 lockClass: 'swiper-scrollbar-lock', 6594 dragClass: 'swiper-scrollbar-drag', 6595 scrollbarDisabledClass: 'swiper-scrollbar-disabled', 6596 horizontalClass: `swiper-scrollbar-horizontal`, 6597 verticalClass: `swiper-scrollbar-vertical` 6598 } 6599 }); 6600 swiper.scrollbar = { 6601 el: null, 6602 dragEl: null, 6603 $el: null, 6604 $dragEl: null 6605 }; 6606 6607 function setTranslate() { 6608 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 6609 const { 6610 scrollbar, 6611 rtlTranslate: rtl, 6612 progress 6613 } = swiper; 6614 const { 6615 $dragEl, 6616 $el 6617 } = scrollbar; 6618 const params = swiper.params.scrollbar; 6619 let newSize = dragSize; 6620 let newPos = (trackSize - dragSize) * progress; 6621 6622 if (rtl) { 6623 newPos = -newPos; 6624 6625 if (newPos > 0) { 6626 newSize = dragSize - newPos; 6627 newPos = 0; 6628 } else if (-newPos + dragSize > trackSize) { 6629 newSize = trackSize + newPos; 6630 } 6631 } else if (newPos < 0) { 6632 newSize = dragSize + newPos; 6633 newPos = 0; 6634 } else if (newPos + dragSize > trackSize) { 6635 newSize = trackSize - newPos; 6636 } 6637 6638 if (swiper.isHorizontal()) { 6639 $dragEl.transform(`translate3d(${newPos}px, 0, 0)`); 6640 $dragEl[0].style.width = `${newSize}px`; 6641 } else { 6642 $dragEl.transform(`translate3d(0px, ${newPos}px, 0)`); 6643 $dragEl[0].style.height = `${newSize}px`; 6644 } 6645 6646 if (params.hide) { 6647 clearTimeout(timeout); 6648 $el[0].style.opacity = 1; 6649 timeout = setTimeout(() => { 6650 $el[0].style.opacity = 0; 6651 $el.transition(400); 6652 }, 1000); 6653 } 6654 } 6655 6656 function setTransition(duration) { 6657 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 6658 swiper.scrollbar.$dragEl.transition(duration); 6659 } 6660 6661 function updateSize() { 6662 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 6663 const { 6664 scrollbar 6665 } = swiper; 6666 const { 6667 $dragEl, 6668 $el 6669 } = scrollbar; 6670 $dragEl[0].style.width = ''; 6671 $dragEl[0].style.height = ''; 6672 trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; 6673 divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0)); 6674 6675 if (swiper.params.scrollbar.dragSize === 'auto') { 6676 dragSize = trackSize * divider; 6677 } else { 6678 dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); 6679 } 6680 6681 if (swiper.isHorizontal()) { 6682 $dragEl[0].style.width = `${dragSize}px`; 6683 } else { 6684 $dragEl[0].style.height = `${dragSize}px`; 6685 } 6686 6687 if (divider >= 1) { 6688 $el[0].style.display = 'none'; 6689 } else { 6690 $el[0].style.display = ''; 6691 } 6692 6693 if (swiper.params.scrollbar.hide) { 6694 $el[0].style.opacity = 0; 6695 } 6696 6697 if (swiper.params.watchOverflow && swiper.enabled) { 6698 scrollbar.$el[swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); 6699 } 6700 } 6701 6702 function getPointerPosition(e) { 6703 if (swiper.isHorizontal()) { 6704 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX; 6705 } 6706 6707 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY; 6708 } 6709 6710 function setDragPosition(e) { 6711 const { 6712 scrollbar, 6713 rtlTranslate: rtl 6714 } = swiper; 6715 const { 6716 $el 6717 } = scrollbar; 6718 let positionRatio; 6719 positionRatio = (getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize); 6720 positionRatio = Math.max(Math.min(positionRatio, 1), 0); 6721 6722 if (rtl) { 6723 positionRatio = 1 - positionRatio; 6724 } 6725 6726 const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio; 6727 swiper.updateProgress(position); 6728 swiper.setTranslate(position); 6729 swiper.updateActiveIndex(); 6730 swiper.updateSlidesClasses(); 6731 } 6732 6733 function onDragStart(e) { 6734 const params = swiper.params.scrollbar; 6735 const { 6736 scrollbar, 6737 $wrapperEl 6738 } = swiper; 6739 const { 6740 $el, 6741 $dragEl 6742 } = scrollbar; 6743 isTouched = true; 6744 dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null; 6745 e.preventDefault(); 6746 e.stopPropagation(); 6747 $wrapperEl.transition(100); 6748 $dragEl.transition(100); 6749 setDragPosition(e); 6750 clearTimeout(dragTimeout); 6751 $el.transition(0); 6752 6753 if (params.hide) { 6754 $el.css('opacity', 1); 6755 } 6756 6757 if (swiper.params.cssMode) { 6758 swiper.$wrapperEl.css('scroll-snap-type', 'none'); 6759 } 6760 6761 emit('scrollbarDragStart', e); 6762 } 6763 6764 function onDragMove(e) { 6765 const { 6766 scrollbar, 6767 $wrapperEl 6768 } = swiper; 6769 const { 6770 $el, 6771 $dragEl 6772 } = scrollbar; 6773 if (!isTouched) return; 6774 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
6775 setDragPosition(e); 6776 $wrapperEl.transition(0); 6777 $el.transition(0); 6778 $dragEl.transition(0); 6779 emit('scrollbarDragMove', e); 6780 } 6781 6782 function onDragEnd(e) { 6783 const params = swiper.params.scrollbar; 6784 const { 6785 scrollbar, 6786 $wrapperEl 6787 } = swiper; 6788 const { 6789 $el 6790 } = scrollbar; 6791 if (!isTouched) return; 6792 isTouched = false; 6793 6794 if (swiper.params.cssMode) { 6795 swiper.$wrapperEl.css('scroll-snap-type', ''); 6796 $wrapperEl.transition(''); 6797 } 6798 6799 if (params.hide) { 6800 clearTimeout(dragTimeout); 6801 dragTimeout = nextTick(() => { 6802 $el.css('opacity', 0); 6803 $el.transition(400); 6804 }, 1000); 6805 } 6806 6807 emit('scrollbarDragEnd', e); 6808 6809 if (params.snapOnRelease) { 6810 swiper.slideToClosest(); 6811 } 6812 } 6813 6814 function events(method) { 6815 const { 6816 scrollbar, 6817 touchEventsTouch, 6818 touchEventsDesktop, 6819 params, 6820 support 6821 } = swiper; 6822 const $el = scrollbar.$el; 6823 if (!$el) return; 6824 const target = $el[0]; 6825 const activeListener = support.passiveListener && params.passiveListeners ? { 6826 passive: false, 6827 capture: false 6828 } : false; 6829 const passiveListener = support.passiveListener && params.passiveListeners ? { 6830 passive: true, 6831 capture: false 6832 } : false; 6833 if (!target) return; 6834 const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener'; 6835 6836 if (!support.touch) { 6837 target[eventMethod](touchEventsDesktop.start, onDragStart, activeListener); 6838 document[eventMethod](touchEventsDesktop.move, onDragMove, activeListener); 6839 document[eventMethod](touchEventsDesktop.end, onDragEnd, passiveListener); 6840 } else { 6841 target[eventMethod](touchEventsTouch.start, onDragStart, activeListener); 6842 target[eventMethod](touchEventsTouch.move, onDragMove, activeListener); 6843 target[eventMethod](touchEventsTouch.end, onDragEnd, passiveListener); 6844 } 6845 } 6846 6847 function enableDraggable() { 6848 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 6849 events('on'); 6850 } 6851 6852 function disableDraggable() { 6853 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return; 6854 events('off'); 6855 } 6856 6857 function init() { 6858 const { 6859 scrollbar, 6860 $el: $swiperEl 6861 } = swiper; 6862 swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, { 6863 el: 'swiper-scrollbar' 6864 }); 6865 const params = swiper.params.scrollbar; 6866 if (!params.el) return; 6867 let $el = $(params.el); 6868 6869 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { 6870 $el = $swiperEl.find(params.el); 6871 } 6872 6873 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 6874 let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`); 6875 6876 if ($dragEl.length === 0) { 6877 $dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`); 6878 $el.append($dragEl); 6879 } 6880 6881 Object.assign(scrollbar, { 6882 $el, 6883 el: $el[0], 6884 $dragEl, 6885 dragEl: $dragEl[0] 6886 }); 6887 6888 if (params.draggable) { 6889 enableDraggable(); 6890 } 6891 6892 if ($el) { 6893 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass); 6894 } 6895 } 6896 6897 function destroy() { 6898 const params = swiper.params.scrollbar; 6899 const $el = swiper.scrollbar.$el; 6900 6901 if ($el) { 6902 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass); 6903 } 6904 6905 disableDraggable(); 6906 } 6907 6908 on('init', () => { 6909 if (swiper.params.scrollbar.enabled === false) { 6910 // eslint-disable-next-line 6911 disable(); 6912 } else { 6913 init(); 6914 updateSize(); 6915 setTranslate(); 6916 } 6917 }); 6918 on('update resize observerUpdate lock unlock', () => { 6919 updateSize(); 6920 }); 6921 on('setTranslate', () => { 6922 setTranslate(); 6923 }); 6924 on('setTransition', (_s, duration) => { 6925 setTransition(duration); 6926 }); 6927 on('enable disable', () => { 6928 const { 6929 $el 6930 } = swiper.scrollbar; 6931 6932 if ($el) { 6933 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass); 6934 } 6935 }); 6936 on('destroy', () => { 6937 destroy(); 6938 }); 6939 6940 const enable = () => { 6941 swiper.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass); 6942 6943 if (swiper.scrollbar.$el) { 6944 swiper.scrollbar.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass); 6945 } 6946 6947 init(); 6948 updateSize(); 6949 setTranslate(); 6950 }; 6951 6952 const disable = () => { 6953 swiper.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass); 6954 6955 if (swiper.scrollbar.$el) { 6956 swiper.scrollbar.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass); 6957 } 6958 6959 destroy(); 6960 }; 6961 6962 Object.assign(swiper.scrollbar, { 6963 enable, 6964 disable, 6965 updateSize, 6966 setTranslate, 6967 init, 6968 destroy 6969 }); 6970} 6971 6972function Parallax(_ref) { 6973 let { 6974 swiper, 6975 extendParams, 6976 on 6977 } = _ref; 6978 extendParams({ 6979 parallax: { 6980 enabled: false 6981 } 6982 }); 6983 6984 const setTransform = (el, progress) => { 6985 const { 6986 rtl 6987 } = swiper; 6988 const $el = $(el); 6989 const rtlFactor = rtl ? -1 : 1; 6990 const p = $el.attr('data-swiper-parallax') || '0'; 6991 let x = $el.attr('data-swiper-parallax-x'); 6992 let y = $el.attr('data-swiper-parallax-y'); 6993 const scale = $el.attr('data-swiper-parallax-scale'); 6994 const opacity = $el.attr('data-swiper-parallax-opacity'); 6995 6996 if (x || y) { 6997 x = x || '0'; 6998 y = y || '0'; 6999 } else if (swiper.isHorizontal()) { 7000 x = p; 7001 y = '0'; 7002 } else { 7003 y = p; 7004 x = '0'; 7005 } 7006 7007 if (x.indexOf('%') >= 0) { 7008 x = `${parseInt(x, 10) * progress * rtlFactor}%`; 7009 } else { 7010 x = `${x * progress * rtlFactor}px`;
7011 } 7012 7013 if (y.indexOf('%') >= 0) { 7014 y = `${parseInt(y, 10) * progress}%`; 7015 } else { 7016 y = `${y * progress}px`; 7017 } 7018 7019 if (typeof opacity !== 'undefined' && opacity !== null) { 7020 const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress)); 7021 $el[0].style.opacity = currentOpacity; 7022 } 7023 7024 if (typeof scale === 'undefined' || scale === null) { 7025 $el.transform(`translate3d(${x}, ${y}, 0px)`); 7026 } else { 7027 const currentScale = scale - (scale - 1) * (1 - Math.abs(progress)); 7028 $el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`); 7029 } 7030 }; 7031 7032 const setTranslate = () => { 7033 const { 7034 $el, 7035 slides, 7036 progress, 7037 snapGrid 7038 } = swiper; 7039 $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => { 7040 setTransform(el, progress); 7041 }); 7042 slides.each((slideEl, slideIndex) => { 7043 let slideProgress = slideEl.progress; 7044 7045 if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { 7046 slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1); 7047 } 7048 7049 slideProgress = Math.min(Math.max(slideProgress, -1), 1); 7050 $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => { 7051 setTransform(el, slideProgress); 7052 }); 7053 }); 7054 }; 7055 7056 const setTransition = function (duration) { 7057 if (duration === void 0) { 7058 duration = swiper.params.speed; 7059 } 7060 7061 const { 7062 $el 7063 } = swiper; 7064 $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => { 7065 const $parallaxEl = $(parallaxEl); 7066 let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; 7067 if (duration === 0) parallaxDuration = 0; 7068 $parallaxEl.transition(parallaxDuration); 7069 }); 7070 }; 7071 7072 on('beforeInit', () => { 7073 if (!swiper.params.parallax.enabled) return; 7074 swiper.params.watchSlidesProgress = true; 7075 swiper.originalParams.watchSlidesProgress = true; 7076 }); 7077 on('init', () => { 7078 if (!swiper.params.parallax.enabled) return; 7079 setTranslate(); 7080 }); 7081 on('setTranslate', () => { 7082 if (!swiper.params.parallax.enabled) return; 7083 setTranslate(); 7084 }); 7085 on('setTransition', (_swiper, duration) => { 7086 if (!swiper.params.parallax.enabled) return; 7087 setTransition(duration); 7088 }); 7089} 7090 7091function Zoom(_ref) { 7092 let { 7093 swiper, 7094 extendParams, 7095 on, 7096 emit 7097 } = _ref; 7098 const window = getWindow(); 7099 extendParams({ 7100 zoom: { 7101 enabled: false, 7102 maxRatio: 3, 7103 minRatio: 1, 7104 toggle: true, 7105 containerClass: 'swiper-zoom-container', 7106 zoomedSlideClass: 'swiper-slide-zoomed' 7107 } 7108 }); 7109 swiper.zoom = { 7110 enabled: false 7111 }; 7112 let currentScale = 1; 7113 let isScaling = false; 7114 let gesturesEnabled; 7115 let fakeGestureTouched; 7116 let fakeGestureMoved; 7117 const gesture = { 7118 $slideEl: undefined, 7119 slideWidth: undefined, 7120 slideHeight: undefined, 7121 $imageEl: undefined, 7122 $imageWrapEl: undefined, 7123 maxRatio: 3 7124 }; 7125 const image = { 7126 isTouched: undefined, 7127 isMoved: undefined, 7128 currentX: undefined, 7129 currentY: undefined, 7130 minX: undefined, 7131 minY: undefined, 7132 maxX: undefined, 7133 maxY: undefined, 7134 width: undefined, 7135 height: undefined, 7136 startX: undefined, 7137 startY: undefined, 7138 touchesStart: {}, 7139 touchesCurrent: {} 7140 }; 7141 const velocity = { 7142 x: undefined, 7143 y: undefined, 7144 prevPositionX: undefined, 7145 prevPositionY: undefined, 7146 prevTime: undefined 7147 }; 7148 let scale = 1; 7149 Object.defineProperty(swiper.zoom, 'scale', { 7150 get() { 7151 return scale; 7152 }, 7153 7154 set(value) { 7155 if (scale !== value) { 7156 const imageEl = gesture.$imageEl ? gesture.$imageEl[0] : undefined; 7157 const slideEl = gesture.$slideEl ? gesture.$slideEl[0] : undefined; 7158 emit('zoomChange', value, imageEl, slideEl); 7159 } 7160 7161 scale = value; 7162 } 7163 7164 }); 7165 7166 function getDistanceBetweenTouches(e) { 7167 if (e.targetTouches.length < 2) return 1; 7168 const x1 = e.targetTouches[0].pageX; 7169 const y1 = e.targetTouches[0].pageY; 7170 const x2 = e.targetTouches[1].pageX; 7171 const y2 = e.targetTouches[1].pageY; 7172 const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2); 7173 return distance; 7174 } // Events 7175 7176 7177 function onGestureStart(e) { 7178 const support = swiper.support; 7179 const params = swiper.params.zoom; 7180 fakeGestureTouched = false;
vendor: 18,888 bytes, lines 7181-7724
7181 fakeGestureMoved = false; 7182 7183 if (!support.gestures) { 7184 if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) { 7185 return; 7186 } 7187 7188 fakeGestureTouched = true; 7189 gesture.scaleStart = getDistanceBetweenTouches(e); 7190 } 7191 7192 if (!gesture.$slideEl || !gesture.$slideEl.length) { 7193 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`); 7194 if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 7195 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 7196 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 7197 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 7198 7199 if (gesture.$imageWrapEl.length === 0) { 7200 gesture.$imageEl = undefined; 7201 return; 7202 } 7203 } 7204 7205 if (gesture.$imageEl) { 7206 gesture.$imageEl.transition(0); 7207 } 7208 7209 isScaling = true; 7210 } 7211 7212 function onGestureChange(e) { 7213 const support = swiper.support; 7214 const params = swiper.params.zoom; 7215 const zoom = swiper.zoom; 7216 7217 if (!support.gestures) { 7218 if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) { 7219 return; 7220 } 7221 7222 fakeGestureMoved = true; 7223 gesture.scaleMove = getDistanceBetweenTouches(e); 7224 } 7225 7226 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { 7227 if (e.type === 'gesturechange') onGestureStart(e); 7228 return; 7229 } 7230 7231 if (support.gestures) { 7232 zoom.scale = e.scale * currentScale; 7233 } else { 7234 zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale; 7235 } 7236 7237 if (zoom.scale > gesture.maxRatio) { 7238 zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5; 7239 } 7240 7241 if (zoom.scale < params.minRatio) { 7242 zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5; 7243 } 7244 7245 gesture.$imageEl.transform(`translate3d(0,0,0) scale(${zoom.scale})`); 7246 } 7247 7248 function onGestureEnd(e) { 7249 const device = swiper.device; 7250 const support = swiper.support; 7251 const params = swiper.params.zoom; 7252 const zoom = swiper.zoom; 7253 7254 if (!support.gestures) { 7255 if (!fakeGestureTouched || !fakeGestureMoved) { 7256 return; 7257 } 7258 7259 if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) { 7260 return; 7261 } 7262 7263 fakeGestureTouched = false; 7264 fakeGestureMoved = false; 7265 } 7266 7267 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 7268 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); 7269 gesture.$imageEl.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`); 7270 currentScale = zoom.scale; 7271 isScaling = false; 7272 if (zoom.scale === 1) gesture.$slideEl = undefined; 7273 } 7274 7275 function onTouchStart(e) { 7276 const device = swiper.device; 7277 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 7278 if (image.isTouched) return; 7279 if (device.android && e.cancelable) e.preventDefault(); 7280 image.isTouched = true; 7281 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 7282 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 7283 } 7284 7285 function onTouchMove(e) { 7286 const zoom = swiper.zoom; 7287 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 7288 swiper.allowClick = false; 7289 if (!image.isTouched || !gesture.$slideEl) return; 7290 7291 if (!image.isMoved) { 7292 image.width = gesture.$imageEl[0].offsetWidth; 7293 image.height = gesture.$imageEl[0].offsetHeight; 7294 image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0; 7295 image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0; 7296 gesture.slideWidth = gesture.$slideEl[0].offsetWidth; 7297 gesture.slideHeight = gesture.$slideEl[0].offsetHeight; 7298 gesture.$imageWrapEl.transition(0); 7299 } // Define if we need image drag 7300 7301 7302 const scaledWidth = image.width * zoom.scale; 7303 const scaledHeight = image.height * zoom.scale; 7304 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return; 7305 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); 7306 image.maxX = -image.minX; 7307 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); 7308 image.maxY = -image.minY; 7309 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 7310 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 7311 7312 if (!image.isMoved && !isScaling) { 7313 if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) { 7314 image.isTouched = false; 7315 return; 7316 } 7317 7318 if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) { 7319 image.isTouched = false; 7320 return; 7321 } 7322 } 7323 7324 if (e.cancelable) { 7325 e.preventDefault(); 7326 } 7327 7328 e.stopPropagation(); 7329 image.isMoved = true; 7330 image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX; 7331 image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY; 7332 7333 if (image.currentX < image.minX) { 7334 image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8; 7335 } 7336 7337 if (image.currentX > image.maxX) { 7338 image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8; 7339 } 7340 7341 if (image.currentY < image.minY) { 7342 image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8; 7343 } 7344 7345 if (image.currentY > image.maxY) { 7346 image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8; 7347 } // Velocity 7348 7349 7350 if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x; 7351 if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y; 7352 if (!velocity.prevTime) velocity.prevTime = Date.now(); 7353 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; 7354 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; 7355 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0; 7356 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0; 7357 velocity.prevPositionX = image.touchesCurrent.x; 7358 velocity.prevPositionY = image.touchesCurrent.y; 7359 velocity.prevTime = Date.now(); 7360 gesture.$imageWrapEl.transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`); 7361 } 7362 7363 function onTouchEnd() { 7364 const zoom = swiper.zoom; 7365 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return; 7366 7367 if (!image.isTouched || !image.isMoved) { 7368 image.isTouched = false; 7369 image.isMoved = false; 7370 return; 7371 } 7372 7373 image.isTouched = false; 7374 image.isMoved = false; 7375 let momentumDurationX = 300; 7376 let momentumDurationY = 300; 7377 const momentumDistanceX = velocity.x * momentumDurationX; 7378 const newPositionX = image.currentX + momentumDistanceX; 7379 const momentumDistanceY = velocity.y * momentumDurationY; 7380 const newPositionY = image.currentY + momentumDistanceY; // Fix duration 7381 7382 if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); 7383 if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); 7384 const momentumDuration = Math.max(momentumDurationX, momentumDurationY); 7385 image.currentX = newPositionX; 7386 image.currentY = newPositionY; // Define if we need image drag 7387 7388 const scaledWidth = image.width * zoom.scale; 7389 const scaledHeight = image.height * zoom.scale; 7390 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0); 7391 image.maxX = -image.minX; 7392 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0); 7393 image.maxY = -image.minY; 7394 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); 7395 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); 7396 gesture.$imageWrapEl.transition(momentumDuration).transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`); 7397 } 7398 7399 function onTransitionEnd() { 7400 const zoom = swiper.zoom; 7401 7402 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { 7403 if (gesture.$imageEl) { 7404 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); 7405 } 7406 7407 if (gesture.$imageWrapEl) { 7408 gesture.$imageWrapEl.transform('translate3d(0,0,0)'); 7409 } 7410 7411 zoom.scale = 1; 7412 currentScale = 1; 7413 gesture.$slideEl = undefined; 7414 gesture.$imageEl = undefined; 7415 gesture.$imageWrapEl = undefined; 7416 } 7417 } 7418 7419 function zoomIn(e) { 7420 const zoom = swiper.zoom; 7421 const params = swiper.params.zoom; 7422 7423 if (!gesture.$slideEl) { 7424 if (e && e.target) { 7425 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`); 7426 } 7427 7428 if (!gesture.$slideEl) { 7429 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { 7430 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`); 7431 } else { 7432 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 7433 } 7434 } 7435 7436 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 7437 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 7438 } 7439 7440 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return; 7441 7442 if (swiper.params.cssMode) { 7443 swiper.wrapperEl.style.overflow = 'hidden'; 7444 swiper.wrapperEl.style.touchAction = 'none'; 7445 } 7446 7447 gesture.$slideEl.addClass(`${params.zoomedSlideClass}`); 7448 let touchX; 7449 let touchY; 7450 let offsetX; 7451 let offsetY; 7452 let diffX; 7453 let diffY; 7454 let translateX; 7455 let translateY; 7456 let imageWidth; 7457 let imageHeight; 7458 let scaledWidth; 7459 let scaledHeight; 7460 let translateMinX; 7461 let translateMinY; 7462 let translateMaxX; 7463 let translateMaxY; 7464 let slideWidth; 7465 let slideHeight; 7466 7467 if (typeof image.touchesStart.x === 'undefined' && e) { 7468 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; 7469 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; 7470 } else { 7471 touchX = image.touchesStart.x; 7472 touchY = image.touchesStart.y; 7473 } 7474 7475 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 7476 currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 7477 7478 if (e) { 7479 slideWidth = gesture.$slideEl[0].offsetWidth; 7480 slideHeight = gesture.$slideEl[0].offsetHeight; 7481 offsetX = gesture.$slideEl.offset().left + window.scrollX; 7482 offsetY = gesture.$slideEl.offset().top + window.scrollY; 7483 diffX = offsetX + slideWidth / 2 - touchX; 7484 diffY = offsetY + slideHeight / 2 - touchY; 7485 imageWidth = gesture.$imageEl[0].offsetWidth; 7486 imageHeight = gesture.$imageEl[0].offsetHeight; 7487 scaledWidth = imageWidth * zoom.scale; 7488 scaledHeight = imageHeight * zoom.scale; 7489 translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0); 7490 translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0); 7491 translateMaxX = -translateMinX; 7492 translateMaxY = -translateMinY; 7493 translateX = diffX * zoom.scale; 7494 translateY = diffY * zoom.scale; 7495 7496 if (translateX < translateMinX) { 7497 translateX = translateMinX; 7498 } 7499 7500 if (translateX > translateMaxX) { 7501 translateX = translateMaxX; 7502 } 7503 7504 if (translateY < translateMinY) { 7505 translateY = translateMinY; 7506 } 7507 7508 if (translateY > translateMaxY) { 7509 translateY = translateMaxY; 7510 } 7511 } else { 7512 translateX = 0; 7513 translateY = 0; 7514 } 7515 7516 gesture.$imageWrapEl.transition(300).transform(`translate3d(${translateX}px, ${translateY}px,0)`); 7517 gesture.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${zoom.scale})`); 7518 } 7519 7520 function zoomOut() { 7521 const zoom = swiper.zoom; 7522 const params = swiper.params.zoom; 7523 7524 if (!gesture.$slideEl) { 7525 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) { 7526 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`); 7527 } else { 7528 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); 7529 } 7530 7531 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0); 7532 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`); 7533 } 7534 7535 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return; 7536 7537 if (swiper.params.cssMode) { 7538 swiper.wrapperEl.style.overflow = ''; 7539 swiper.wrapperEl.style.touchAction = ''; 7540 } 7541 7542 zoom.scale = 1; 7543 currentScale = 1; 7544 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); 7545 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); 7546 gesture.$slideEl.removeClass(`${params.zoomedSlideClass}`); 7547 gesture.$slideEl = undefined; 7548 } // Toggle Zoom 7549 7550 7551 function zoomToggle(e) { 7552 const zoom = swiper.zoom; 7553 7554 if (zoom.scale && zoom.scale !== 1) { 7555 // Zoom Out 7556 zoomOut(); 7557 } else { 7558 // Zoom In 7559 zoomIn(e); 7560 } 7561 } 7562 7563 function getListeners() { 7564 const support = swiper.support; 7565 const passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? { 7566 passive: true, 7567 capture: false 7568 } : false; 7569 const activeListenerWithCapture = support.passiveListener ? { 7570 passive: false, 7571 capture: true 7572 } : true; 7573 return { 7574 passiveListener, 7575 activeListenerWithCapture 7576 }; 7577 } 7578 7579 function getSlideSelector() { 7580 return `.${swiper.params.slideClass}`; 7581 } 7582 7583 function toggleGestures(method) { 7584 const { 7585 passiveListener 7586 } = getListeners(); 7587 const slideSelector = getSlideSelector(); 7588 swiper.$wrapperEl[method]('gesturestart', slideSelector, onGestureStart, passiveListener); 7589 swiper.$wrapperEl[method]('gesturechange', slideSelector, onGestureChange, passiveListener); 7590 swiper.$wrapperEl[method]('gestureend', slideSelector, onGestureEnd, passiveListener); 7591 } 7592 7593 function enableGestures() { 7594 if (gesturesEnabled) return; 7595 gesturesEnabled = true; 7596 toggleGestures('on'); 7597 } 7598 7599 function disableGestures() { 7600 if (!gesturesEnabled) return; 7601 gesturesEnabled = false; 7602 toggleGestures('off'); 7603 } // Attach/Detach Events 7604 7605 7606 function enable() { 7607 const zoom = swiper.zoom; 7608 if (zoom.enabled) return; 7609 zoom.enabled = true; 7610 const support = swiper.support; 7611 const { 7612 passiveListener, 7613 activeListenerWithCapture 7614 } = getListeners(); 7615 const slideSelector = getSlideSelector(); // Scale image 7616 7617 if (support.gestures) { 7618 swiper.$wrapperEl.on(swiper.touchEvents.start, enableGestures, passiveListener); 7619 swiper.$wrapperEl.on(swiper.touchEvents.end, disableGestures, passiveListener); 7620 } else if (swiper.touchEvents.start === 'touchstart') { 7621 swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener); 7622 swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture); 7623 swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener); 7624 7625 if (swiper.touchEvents.cancel) { 7626 swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener); 7627 } 7628 } // Move image 7629 7630 7631 swiper.$wrapperEl.on(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture); 7632 } 7633 7634 function disable() { 7635 const zoom = swiper.zoom; 7636 if (!zoom.enabled) return; 7637 const support = swiper.support; 7638 zoom.enabled = false; 7639 const { 7640 passiveListener, 7641 activeListenerWithCapture 7642 } = getListeners(); 7643 const slideSelector = getSlideSelector(); // Scale image 7644 7645 if (support.gestures) { 7646 swiper.$wrapperEl.off(swiper.touchEvents.start, enableGestures, passiveListener); 7647 swiper.$wrapperEl.off(swiper.touchEvents.end, disableGestures, passiveListener); 7648 } else if (swiper.touchEvents.start === 'touchstart') { 7649 swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener); 7650 swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture); 7651 swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener); 7652 7653 if (swiper.touchEvents.cancel) { 7654 swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener); 7655 } 7656 } // Move image 7657 7658 7659 swiper.$wrapperEl.off(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture); 7660 } 7661 7662 on('init', () => { 7663 if (swiper.params.zoom.enabled) { 7664 enable(); 7665 } 7666 }); 7667 on('destroy', () => { 7668 disable(); 7669 }); 7670 on('touchStart', (_s, e) => { 7671 if (!swiper.zoom.enabled) return; 7672 onTouchStart(e); 7673 }); 7674 on('touchEnd', (_s, e) => { 7675 if (!swiper.zoom.enabled) return; 7676 onTouchEnd(); 7677 }); 7678 on('doubleTap', (_s, e) => { 7679 if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { 7680 zoomToggle(e); 7681 } 7682 }); 7683 on('transitionEnd', () => { 7684 if (swiper.zoom.enabled && swiper.params.zoom.enabled) { 7685 onTransitionEnd(); 7686 } 7687 }); 7688 on('slideChange', () => { 7689 if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) { 7690 onTransitionEnd(); 7691 } 7692 }); 7693 Object.assign(swiper.zoom, { 7694 enable, 7695 disable, 7696 in: zoomIn, 7697 out: zoomOut, 7698 toggle: zoomToggle 7699 }); 7700} 7701 7702function Lazy(_ref) { 7703 let { 7704 swiper, 7705 extendParams, 7706 on, 7707 emit 7708 } = _ref; 7709 extendParams({ 7710 lazy: { 7711 checkInView: false, 7712 enabled: false, 7713 loadPrevNext: false, 7714 loadPrevNextAmount: 1, 7715 loadOnTransitionStart: false, 7716 scrollingElement: '', 7717 elementClass: 'swiper-lazy', 7718 loadingClass: 'swiper-lazy-loading', 7719 loadedClass: 'swiper-lazy-loaded', 7720 preloaderClass: 'swiper-lazy-preloader' 7721 } 7722 }); 7723 swiper.lazy = {}; 7724 let scrollHandlerAttached = false;
7725 let initialImageLoaded = false; 7726 7727 function loadInSlide(index, loadInDuplicate) { 7728 if (loadInDuplicate === void 0) { 7729 loadInDuplicate = true; 7730 } 7731 7732 const params = swiper.params.lazy; 7733 if (typeof index === 'undefined') return; 7734 if (swiper.slides.length === 0) return; 7735 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 7736 const $slideEl = isVirtual ? swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index); 7737 const $images = $slideEl.find(`.${params.elementClass}:not(.${params.loadedClass}):not(.${params.loadingClass})`); 7738 7739 if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { 7740 $images.push($slideEl[0]); 7741 } 7742 7743 if ($images.length === 0) return; 7744 $images.each(imageEl => { 7745 const $imageEl = $(imageEl); 7746 $imageEl.addClass(params.loadingClass); 7747 const background = $imageEl.attr('data-background'); 7748 const src = $imageEl.attr('data-src'); 7749 const srcset = $imageEl.attr('data-srcset'); 7750 const sizes = $imageEl.attr('data-sizes'); 7751 const $pictureEl = $imageEl.parent('picture'); 7752 swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, () => { 7753 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return; 7754 7755 if (background) { 7756 $imageEl.css('background-image', `url("${background}")`); 7757 $imageEl.removeAttr('data-background'); 7758 } else { 7759 if (srcset) { 7760 $imageEl.attr('srcset', srcset); 7761 $imageEl.removeAttr('data-srcset'); 7762 } 7763 7764 if (sizes) { 7765 $imageEl.attr('sizes', sizes); 7766 $imageEl.removeAttr('data-sizes'); 7767 } 7768 7769 if ($pictureEl.length) { 7770 $pictureEl.children('source').each(sourceEl => { 7771 const $source = $(sourceEl); 7772 7773 if ($source.attr('data-srcset')) { 7774 $source.attr('srcset', $source.attr('data-srcset')); 7775 $source.removeAttr('data-srcset'); 7776 } 7777 }); 7778 } 7779 7780 if (src) { 7781 $imageEl.attr('src', src); 7782 $imageEl.removeAttr('data-src'); 7783 } 7784 } 7785 7786 $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); 7787 $slideEl.find(`.${params.preloaderClass}`).remove(); 7788 7789 if (swiper.params.loop && loadInDuplicate) { 7790 const slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); 7791 7792 if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { 7793 const originalSlide = swiper.$wrapperEl.children(`[data-swiper-slide-index="${slideOriginalIndex}"]:not(.${swiper.params.slideDuplicateClass})`); 7794 loadInSlide(originalSlide.index(), false); 7795 } else { 7796 const duplicatedSlide = swiper.$wrapperEl.children(`.${swiper.params.slideDuplicateClass}[data-swiper-slide-index="${slideOriginalIndex}"]`); 7797 loadInSlide(duplicatedSlide.index(), false); 7798 } 7799 } 7800 7801 emit('lazyImageReady', $slideEl[0], $imageEl[0]); 7802 7803 if (swiper.params.autoHeight) { 7804 swiper.updateAutoHeight(); 7805 } 7806 }); 7807 emit('lazyImageLoad', $slideEl[0], $imageEl[0]); 7808 }); 7809 } 7810 7811 function load() { 7812 const { 7813 $wrapperEl, 7814 params: swiperParams, 7815 slides, 7816 activeIndex 7817 } = swiper; 7818 const isVirtual = swiper.virtual && swiperParams.virtual.enabled; 7819 const params = swiperParams.lazy; 7820 let slidesPerView = swiperParams.slidesPerView; 7821 7822 if (slidesPerView === 'auto') { 7823 slidesPerView = 0; 7824 } 7825 7826 function slideExist(index) { 7827 if (isVirtual) { 7828 if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) { 7829 return true; 7830 } 7831 } else if (slides[index]) return true; 7832 7833 return false; 7834 } 7835 7836 function slideIndex(slideEl) { 7837 if (isVirtual) { 7838 return $(slideEl).attr('data-swiper-slide-index'); 7839 } 7840 7841 return $(slideEl).index(); 7842 } 7843 7844 if (!initialImageLoaded) initialImageLoaded = true; 7845 7846 if (swiper.params.watchSlidesProgress) { 7847 $wrapperEl.children(`.${swiperParams.slideVisibleClass}`).each(slideEl => { 7848 const index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); 7849 loadInSlide(index); 7850 }); 7851 } else if (slidesPerView > 1) { 7852 for (let i = activeIndex; i < activeIndex + slidesPerView; i += 1) { 7853 if (slideExist(i)) loadInSlide(i); 7854 } 7855 } else { 7856 loadInSlide(activeIndex); 7857 } 7858 7859 if (params.loadPrevNext) { 7860 if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) { 7861 const amount = params.loadPrevNextAmount;
7862 const spv = Math.ceil(slidesPerView); 7863 const maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); 7864 const minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides 7865 7866 for (let i = activeIndex + spv; i < maxIndex; i += 1) { 7867 if (slideExist(i)) loadInSlide(i); 7868 } // Prev Slides 7869 7870 7871 for (let i = minIndex; i < activeIndex; i += 1) { 7872 if (slideExist(i)) loadInSlide(i); 7873 } 7874 } else { 7875 const nextSlide = $wrapperEl.children(`.${swiperParams.slideNextClass}`); 7876 if (nextSlide.length > 0) loadInSlide(slideIndex(nextSlide)); 7877 const prevSlide = $wrapperEl.children(`.${swiperParams.slidePrevClass}`); 7878 if (prevSlide.length > 0) loadInSlide(slideIndex(prevSlide)); 7879 } 7880 } 7881 } 7882 7883 function checkInViewOnLoad() { 7884 const window = getWindow(); 7885 if (!swiper || swiper.destroyed) return; 7886 const $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window); 7887 const isWindow = $scrollElement[0] === window; 7888 const scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth; 7889 const scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight; 7890 const swiperOffset = swiper.$el.offset(); 7891 const { 7892 rtlTranslate: rtl 7893 } = swiper; 7894 let inView = false; 7895 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft; 7896 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]]; 7897 7898 for (let i = 0; i < swiperCoord.length; i += 1) { 7899 const point = swiperCoord[i]; 7900 7901 if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) { 7902 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line 7903 7904 inView = true; 7905 } 7906 } 7907 7908 const passiveListener = swiper.touchEvents.start === 'touchstart' && swiper.support.passiveListener && swiper.params.passiveListeners ? { 7909 passive: true, 7910 capture: false 7911 } : false; 7912 7913 if (inView) { 7914 load(); 7915 $scrollElement.off('scroll', checkInViewOnLoad, passiveListener); 7916 } else if (!scrollHandlerAttached) { 7917 scrollHandlerAttached = true; 7918 $scrollElement.on('scroll', checkInViewOnLoad, passiveListener); 7919 } 7920 } 7921 7922 on('beforeInit', () => { 7923 if (swiper.params.lazy.enabled && swiper.params.preloadImages) { 7924 swiper.params.preloadImages = false; 7925 } 7926 }); 7927 on('init', () => { 7928 if (swiper.params.lazy.enabled) { 7929 if (swiper.params.lazy.checkInView) { 7930 checkInViewOnLoad(); 7931 } else { 7932 load(); 7933 } 7934 } 7935 }); 7936 on('scroll', () => { 7937 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.freeMode.sticky) { 7938 load(); 7939 } 7940 }); 7941 on('scrollbarDragMove resize _freeModeNoMomentumRelease', () => { 7942 if (swiper.params.lazy.enabled) { 7943 if (swiper.params.lazy.checkInView) { 7944 checkInViewOnLoad(); 7945 } else { 7946 load(); 7947 } 7948 } 7949 }); 7950 on('transitionStart', () => { 7951 if (swiper.params.lazy.enabled) { 7952 if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !initialImageLoaded) { 7953 if (swiper.params.lazy.checkInView) { 7954 checkInViewOnLoad(); 7955 } else { 7956 load(); 7957 } 7958 } 7959 } 7960 }); 7961 on('transitionEnd', () => { 7962 if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { 7963 if (swiper.params.lazy.checkInView) { 7964 checkInViewOnLoad(); 7965 } else { 7966 load(); 7967 } 7968 } 7969 }); 7970 on('slideChange', () => { 7971 const { 7972 lazy, 7973 cssMode, 7974 watchSlidesProgress, 7975 touchReleaseOnEdges, 7976 resistanceRatio 7977 } = swiper.params; 7978 7979 if (lazy.enabled && (cssMode || watchSlidesProgress && (touchReleaseOnEdges || resistanceRatio === 0))) { 7980 load(); 7981 } 7982 }); 7983 on('destroy', () => { 7984 if (!swiper.$el) return; 7985 swiper.$el.find(`.${swiper.params.lazy.loadingClass}`).removeClass(swiper.params.lazy.loadingClass); 7986 }); 7987 Object.assign(swiper.lazy, { 7988 load, 7989 loadInSlide 7990 }); 7991} 7992 7993/* eslint no-bitwise: ["error", { "allow": [">>"] }] */ 7994function Controller(_ref) { 7995 let { 7996 swiper, 7997 extendParams, 7998 on 7999 } = _ref; 8000 extendParams({ 8001 controller: { 8002 control: undefined, 8003 inverse: false, 8004 by: 'slide' // or 'container' 8005 8006 } 8007 }); 8008 swiper.controller = { 8009 control: undefined 8010 }; 8011 8012 function LinearSpline(x, y) { 8013 const binarySearch = function search() { 8014 let maxIndex; 8015 let minIndex; 8016 let guess; 8017 return (array, val) => { 8018 minIndex = -1; 8019 maxIndex = array.length; 8020 8021 while (maxIndex - minIndex > 1) {
vendor: 7,683 bytes, lines 8022-8295
8022 guess = maxIndex + minIndex >> 1; 8023 8024 if (array[guess] <= val) { 8025 minIndex = guess; 8026 } else { 8027 maxIndex = guess; 8028 } 8029 } 8030 8031 return maxIndex; 8032 }; 8033 }(); 8034 8035 this.x = x; 8036 this.y = y; 8037 this.lastIndex = x.length - 1; // Given an x value (x2), return the expected y2 value: 8038 // (x1,y1) is the known point before given value, 8039 // (x3,y3) is the known point after given value. 8040 8041 let i1; 8042 let i3; 8043 8044 this.interpolate = function interpolate(x2) { 8045 if (!x2) return 0; // Get the indexes of x1 and x3 (the array indexes before and after given x2): 8046 8047 i3 = binarySearch(this.x, x2); 8048 i1 = i3 - 1; // We have our indexes i1 & i3, so we can calculate already: 8049 // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 8050 8051 return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1]; 8052 }; 8053 8054 return this; 8055 } // xxx: for now i will just save one spline function to to 8056 8057 8058 function getInterpolateFunction(c) { 8059 if (!swiper.controller.spline) { 8060 swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid); 8061 } 8062 } 8063 8064 function setTranslate(_t, byController) { 8065 const controlled = swiper.controller.control; 8066 let multiplier; 8067 let controlledTranslate; 8068 const Swiper = swiper.constructor; 8069 8070 function setControlledTranslate(c) { 8071 // this will create an Interpolate function based on the snapGrids 8072 // x is the Grid of the scrolled scroller and y will be the controlled scroller 8073 // it makes sense to create this only once and recall it for the interpolation 8074 // the function does a lot of value caching for performance 8075 const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; 8076 8077 if (swiper.params.controller.by === 'slide') { 8078 getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid 8079 // but it did not work out 8080 8081 controlledTranslate = -swiper.controller.spline.interpolate(-translate); 8082 } 8083 8084 if (!controlledTranslate || swiper.params.controller.by === 'container') { 8085 multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); 8086 controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate(); 8087 } 8088 8089 if (swiper.params.controller.inverse) { 8090 controlledTranslate = c.maxTranslate() - controlledTranslate; 8091 } 8092 8093 c.updateProgress(controlledTranslate); 8094 c.setTranslate(controlledTranslate, swiper); 8095 c.updateActiveIndex(); 8096 c.updateSlidesClasses(); 8097 } 8098 8099 if (Array.isArray(controlled)) { 8100 for (let i = 0; i < controlled.length; i += 1) { 8101 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 8102 setControlledTranslate(controlled[i]); 8103 } 8104 } 8105 } else if (controlled instanceof Swiper && byController !== controlled) { 8106 setControlledTranslate(controlled); 8107 } 8108 } 8109 8110 function setTransition(duration, byController) { 8111 const Swiper = swiper.constructor; 8112 const controlled = swiper.controller.control; 8113 let i; 8114 8115 function setControlledTransition(c) { 8116 c.setTransition(duration, swiper); 8117 8118 if (duration !== 0) { 8119 c.transitionStart(); 8120 8121 if (c.params.autoHeight) { 8122 nextTick(() => { 8123 c.updateAutoHeight(); 8124 }); 8125 } 8126 8127 c.$wrapperEl.transitionEnd(() => { 8128 if (!controlled) return; 8129 8130 if (c.params.loop && swiper.params.controller.by === 'slide') { 8131 c.loopFix(); 8132 } 8133 8134 c.transitionEnd(); 8135 }); 8136 } 8137 } 8138 8139 if (Array.isArray(controlled)) { 8140 for (i = 0; i < controlled.length; i += 1) { 8141 if (controlled[i] !== byController && controlled[i] instanceof Swiper) { 8142 setControlledTransition(controlled[i]); 8143 } 8144 } 8145 } else if (controlled instanceof Swiper && byController !== controlled) { 8146 setControlledTransition(controlled); 8147 } 8148 } 8149 8150 function removeSpline() { 8151 if (!swiper.controller.control) return; 8152 8153 if (swiper.controller.spline) { 8154 swiper.controller.spline = undefined; 8155 delete swiper.controller.spline; 8156 } 8157 } 8158 8159 on('beforeInit', () => { 8160 swiper.controller.control = swiper.params.controller.control; 8161 }); 8162 on('update', () => { 8163 removeSpline(); 8164 }); 8165 on('resize', () => { 8166 removeSpline(); 8167 }); 8168 on('observerUpdate', () => { 8169 removeSpline(); 8170 }); 8171 on('setTranslate', (_s, translate, byController) => { 8172 if (!swiper.controller.control) return; 8173 swiper.controller.setTranslate(translate, byController); 8174 }); 8175 on('setTransition', (_s, duration, byController) => { 8176 if (!swiper.controller.control) return; 8177 swiper.controller.setTransition(duration, byController); 8178 }); 8179 Object.assign(swiper.controller, { 8180 setTranslate, 8181 setTransition 8182 }); 8183} 8184 8185function A11y(_ref) { 8186 let { 8187 swiper, 8188 extendParams, 8189 on 8190 } = _ref; 8191 extendParams({ 8192 a11y: { 8193 enabled: true, 8194 notificationClass: 'swiper-notification', 8195 prevSlideMessage: 'Previous slide', 8196 nextSlideMessage: 'Next slide', 8197 firstSlideMessage: 'This is the first slide', 8198 lastSlideMessage: 'This is the last slide', 8199 paginationBulletMessage: 'Go to slide {{index}}', 8200 slideLabelMessage: '{{index}} / {{slidesLength}}', 8201 containerMessage: null, 8202 containerRoleDescriptionMessage: null, 8203 itemRoleDescriptionMessage: null, 8204 slideRole: 'group', 8205 id: null 8206 } 8207 }); 8208 let liveRegion = null; 8209 8210 function notify(message) { 8211 const notification = liveRegion; 8212 if (notification.length === 0) return; 8213 notification.html(''); 8214 notification.html(message); 8215 } 8216 8217 function getRandomNumber(size) { 8218 if (size === void 0) { 8219 size = 16; 8220 } 8221 8222 const randomChar = () => Math.round(16 * Math.random()).toString(16); 8223 8224 return 'x'.repeat(size).replace(/x/g, randomChar); 8225 } 8226 8227 function makeElFocusable($el) { 8228 $el.attr('tabIndex', '0'); 8229 } 8230 8231 function makeElNotFocusable($el) { 8232 $el.attr('tabIndex', '-1'); 8233 } 8234 8235 function addElRole($el, role) { 8236 $el.attr('role', role); 8237 } 8238 8239 function addElRoleDescription($el, description) { 8240 $el.attr('aria-roledescription', description); 8241 } 8242 8243 function addElControls($el, controls) { 8244 $el.attr('aria-controls', controls); 8245 } 8246 8247 function addElLabel($el, label) { 8248 $el.attr('aria-label', label); 8249 } 8250 8251 function addElId($el, id) { 8252 $el.attr('id', id); 8253 } 8254 8255 function addElLive($el, live) { 8256 $el.attr('aria-live', live); 8257 } 8258 8259 function disableEl($el) { 8260 $el.attr('aria-disabled', true); 8261 } 8262 8263 function enableEl($el) { 8264 $el.attr('aria-disabled', false); 8265 } 8266 8267 function onEnterOrSpaceKey(e) { 8268 if (e.keyCode !== 13 && e.keyCode !== 32) return; 8269 const params = swiper.params.a11y; 8270 const $targetEl = $(e.target); 8271 8272 if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { 8273 if (!(swiper.isEnd && !swiper.params.loop)) { 8274 swiper.slideNext(); 8275 } 8276 8277 if (swiper.isEnd) { 8278 notify(params.lastSlideMessage); 8279 } else { 8280 notify(params.nextSlideMessage); 8281 } 8282 } 8283 8284 if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { 8285 if (!(swiper.isBeginning && !swiper.params.loop)) { 8286 swiper.slidePrev(); 8287 } 8288 8289 if (swiper.isBeginning) { 8290 notify(params.firstSlideMessage); 8291 } else { 8292 notify(params.prevSlideMessage); 8293 } 8294 } 8295
8296 if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) { 8297 $targetEl[0].click(); 8298 } 8299 } 8300 8301 function updateNavigation() { 8302 if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return; 8303 const { 8304 $nextEl, 8305 $prevEl 8306 } = swiper.navigation; 8307 8308 if ($prevEl && $prevEl.length > 0) { 8309 if (swiper.isBeginning) { 8310 disableEl($prevEl); 8311 makeElNotFocusable($prevEl); 8312 } else { 8313 enableEl($prevEl); 8314 makeElFocusable($prevEl); 8315 } 8316 } 8317 8318 if ($nextEl && $nextEl.length > 0) { 8319 if (swiper.isEnd) { 8320 disableEl($nextEl); 8321 makeElNotFocusable($nextEl); 8322 } else { 8323 enableEl($nextEl); 8324 makeElFocusable($nextEl); 8325 } 8326 } 8327 } 8328 8329 function hasPagination() { 8330 return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length; 8331 } 8332 8333 function hasClickablePagination() { 8334 return hasPagination() && swiper.params.pagination.clickable; 8335 } 8336 8337 function updatePagination() { 8338 const params = swiper.params.a11y; 8339 if (!hasPagination()) return; 8340 swiper.pagination.bullets.each(bulletEl => { 8341 const $bulletEl = $(bulletEl); 8342 8343 if (swiper.params.pagination.clickable) { 8344 makeElFocusable($bulletEl); 8345 8346 if (!swiper.params.pagination.renderBullet) { 8347 addElRole($bulletEl, 'button'); 8348 addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1)); 8349 } 8350 } 8351 8352 if ($bulletEl.is(`.${swiper.params.pagination.bulletActiveClass}`)) { 8353 $bulletEl.attr('aria-current', 'true'); 8354 } else { 8355 $bulletEl.removeAttr('aria-current'); 8356 } 8357 }); 8358 } 8359 8360 const initNavEl = ($el, wrapperId, message) => { 8361 makeElFocusable($el); 8362 8363 if ($el[0].tagName !== 'BUTTON') { 8364 addElRole($el, 'button'); 8365 $el.on('keydown', onEnterOrSpaceKey); 8366 } 8367 8368 addElLabel($el, message); 8369 addElControls($el, wrapperId); 8370 }; 8371 8372 const handleFocus = e => { 8373 const slideEl = e.target.closest(`.${swiper.params.slideClass}`); 8374 if (!slideEl || !swiper.slides.includes(slideEl)) return; 8375 const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex; 8376 const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl); 8377 if (isActive || isVisible) return; 8378 swiper.slideTo(swiper.slides.indexOf(slideEl), 0); 8379 }; 8380 8381 const initSlides = () => { 8382 const params = swiper.params.a11y; 8383 8384 if (params.itemRoleDescriptionMessage) { 8385 addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage); 8386 } 8387 8388 if (params.slideRole) { 8389 addElRole($(swiper.slides), params.slideRole); 8390 } 8391 8392 const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length; 8393 8394 if (params.slideLabelMessage) { 8395 swiper.slides.each((slideEl, index) => { 8396 const $slideEl = $(slideEl); 8397 const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index; 8398 const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength); 8399 addElLabel($slideEl, ariaLabelMessage); 8400 }); 8401 } 8402 }; 8403 8404 const init = () => { 8405 const params = swiper.params.a11y; 8406 swiper.$el.append(liveRegion); // Container 8407 8408 const $containerEl = swiper.$el; 8409 8410 if (params.containerRoleDescriptionMessage) { 8411 addElRoleDescription($containerEl, params.containerRoleDescriptionMessage); 8412 } 8413 8414 if (params.containerMessage) { 8415 addElLabel($containerEl, params.containerMessage); 8416 } // Wrapper 8417 8418 8419 const $wrapperEl = swiper.$wrapperEl; 8420 const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`; 8421 const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite'; 8422 addElId($wrapperEl, wrapperId); 8423 addElLive($wrapperEl, live); // Slide 8424 8425 initSlides(); // Navigation 8426 8427 let $nextEl; 8428 let $prevEl; 8429 8430 if (swiper.navigation && swiper.navigation.$nextEl) { 8431 $nextEl = swiper.navigation.$nextEl; 8432 } 8433 8434 if (swiper.navigation && swiper.navigation.$prevEl) { 8435 $prevEl = swiper.navigation.$prevEl; 8436 } 8437 8438 if ($nextEl && $nextEl.length) { 8439 initNavEl($nextEl, wrapperId, params.nextSlideMessage); 8440 } 8441 8442 if ($prevEl && $prevEl.length) { 8443 initNavEl($prevEl, wrapperId, params.prevSlideMessage); 8444 } // Pagination 8445 8446 8447 if (hasClickablePagination()) { 8448 swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey); 8449 } // Tab focus 8450 8451 8452 swiper.$el.on('focus', handleFocus, true); 8453 }; 8454 8455 function destroy() { 8456 if (liveRegion && liveRegion.length > 0) liveRegion.remove(); 8457 let $nextEl; 8458 let $prevEl; 8459 8460 if (swiper.navigation && swiper.navigation.$nextEl) { 8461 $nextEl = swiper.navigation.$nextEl; 8462 } 8463 8464 if (swiper.navigation && swiper.navigation.$prevEl) { 8465 $prevEl = swiper.navigation.$prevEl; 8466 } 8467 8468 if ($nextEl) { 8469 $nextEl.off('keydown', onEnterOrSpaceKey); 8470 } 8471 8472 if ($prevEl) { 8473 $prevEl.off('keydown', onEnterOrSpaceKey); 8474 } // Pagination 8475 8476 8477 if (hasClickablePagination()) { 8478 swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey); 8479 } // Tab focus 8480 8481 8482 swiper.$el.off('focus', handleFocus, true); 8483 } 8484 8485 on('beforeInit', () => { 8486 liveRegion = $(`<span class="${swiper.params.a11y.notificationClass}
vendor: 4,703 bytes, lines 8486-8673
8486" aria-live="assertive" aria-atomic="true"></span>`); 8487 }); 8488 on('afterInit', () => { 8489 if (!swiper.params.a11y.enabled) return; 8490 init(); 8491 }); 8492 on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => { 8493 if (!swiper.params.a11y.enabled) return; 8494 initSlides(); 8495 }); 8496 on('fromEdge toEdge afterInit lock unlock', () => { 8497 if (!swiper.params.a11y.enabled) return; 8498 updateNavigation(); 8499 }); 8500 on('paginationUpdate', () => { 8501 if (!swiper.params.a11y.enabled) return; 8502 updatePagination(); 8503 }); 8504 on('destroy', () => { 8505 if (!swiper.params.a11y.enabled) return; 8506 destroy(); 8507 }); 8508} 8509 8510function History(_ref) { 8511 let { 8512 swiper, 8513 extendParams, 8514 on 8515 } = _ref; 8516 extendParams({ 8517 history: { 8518 enabled: false, 8519 root: '', 8520 replaceState: false, 8521 key: 'slides', 8522 keepQuery: false 8523 } 8524 }); 8525 let initialized = false; 8526 let paths = {}; 8527 8528 const slugify = text => { 8529 return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, ''); 8530 }; 8531 8532 const getPathValues = urlOverride => { 8533 const window = getWindow(); 8534 let location; 8535 8536 if (urlOverride) { 8537 location = new URL(urlOverride); 8538 } else { 8539 location = window.location; 8540 } 8541 8542 const pathArray = location.pathname.slice(1).split('/').filter(part => part !== ''); 8543 const total = pathArray.length; 8544 const key = pathArray[total - 2]; 8545 const value = pathArray[total - 1]; 8546 return { 8547 key, 8548 value 8549 }; 8550 }; 8551 8552 const setHistory = (key, index) => { 8553 const window = getWindow(); 8554 if (!initialized || !swiper.params.history.enabled) return; 8555 let location; 8556 8557 if (swiper.params.url) { 8558 location = new URL(swiper.params.url); 8559 } else { 8560 location = window.location; 8561 } 8562 8563 const slide = swiper.slides.eq(index); 8564 let value = slugify(slide.attr('data-history')); 8565 8566 if (swiper.params.history.root.length > 0) { 8567 let root = swiper.params.history.root; 8568 if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1); 8569 value = `${root}/${key}/${value}`; 8570 } else if (!location.pathname.includes(key)) { 8571 value = `${key}/${value}`; 8572 } 8573 8574 if (swiper.params.history.keepQuery) { 8575 value += location.search; 8576 } 8577 8578 const currentState = window.history.state; 8579 8580 if (currentState && currentState.value === value) { 8581 return; 8582 } 8583 8584 if (swiper.params.history.replaceState) { 8585 window.history.replaceState({ 8586 value 8587 }, null, value); 8588 } else { 8589 window.history.pushState({ 8590 value 8591 }, null, value); 8592 } 8593 }; 8594 8595 const scrollToSlide = (speed, value, runCallbacks) => { 8596 if (value) { 8597 for (let i = 0, length = swiper.slides.length; i < length; i += 1) { 8598 const slide = swiper.slides.eq(i); 8599 const slideHistory = slugify(slide.attr('data-history')); 8600 8601 if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { 8602 const index = slide.index(); 8603 swiper.slideTo(index, speed, runCallbacks); 8604 } 8605 } 8606 } else { 8607 swiper.slideTo(0, speed, runCallbacks); 8608 } 8609 }; 8610 8611 const setHistoryPopState = () => { 8612 paths = getPathValues(swiper.params.url); 8613 scrollToSlide(swiper.params.speed, paths.value, false); 8614 }; 8615 8616 const init = () => { 8617 const window = getWindow(); 8618 if (!swiper.params.history) return; 8619 8620 if (!window.history || !window.history.pushState) { 8621 swiper.params.history.enabled = false; 8622 swiper.params.hashNavigation.enabled = true; 8623 return; 8624 } 8625 8626 initialized = true; 8627 paths = getPathValues(swiper.params.url); 8628 if (!paths.key && !paths.value) return; 8629 scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit); 8630 8631 if (!swiper.params.history.replaceState) { 8632 window.addEventListener('popstate', setHistoryPopState); 8633 } 8634 }; 8635 8636 const destroy = () => { 8637 const window = getWindow(); 8638 8639 if (!swiper.params.history.replaceState) { 8640 window.removeEventListener('popstate', setHistoryPopState); 8641 } 8642 }; 8643 8644 on('init', () => { 8645 if (swiper.params.history.enabled) { 8646 init(); 8647 } 8648 }); 8649 on('destroy', () => { 8650 if (swiper.params.history.enabled) { 8651 destroy(); 8652 } 8653 }); 8654 on('transitionEnd _freeModeNoMomentumRelease', () => { 8655 if (initialized) { 8656 setHistory(swiper.params.history.key, swiper.activeIndex); 8657 } 8658 }); 8659 on('slideChange', () => { 8660 if (initialized && swiper.params.cssMode) { 8661 setHistory(swiper.params.history.key, swiper.activeIndex); 8662 } 8663 }); 8664} 8665 8666function HashNavigation(_ref) { 8667 let { 8668 swiper, 8669 extendParams, 8670 emit, 8671 on 8672 } = _ref; 8673 let initialized = false;
8674 const document = getDocument(); 8675 const window = getWindow(); 8676 extendParams({ 8677 hashNavigation: { 8678 enabled: false, 8679 replaceState: false, 8680 watchState: false 8681 } 8682 }); 8683 8684 const onHashChange = () => { 8685 emit('hashChange'); 8686 const newHash = document.location.hash.replace('#', ''); 8687 const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); 8688 8689 if (newHash !== activeSlideHash) { 8690 const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index(); 8691 if (typeof newIndex === 'undefined') return; 8692 swiper.slideTo(newIndex); 8693 } 8694 }; 8695 8696 const setHash = () => { 8697 if (!initialized || !swiper.params.hashNavigation.enabled) return; 8698 8699 if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) { 8700 window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || ''); 8701 emit('hashSet'); 8702 } else { 8703 const slide = swiper.slides.eq(swiper.activeIndex); 8704 const hash = slide.attr('data-hash') || slide.attr('data-history'); 8705 document.location.hash = hash || ''; 8706 emit('hashSet'); 8707 } 8708 }; 8709 8710 const init = () => { 8711 if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return; 8712 initialized = true; 8713 const hash = document.location.hash.replace('#', ''); 8714 8715 if (hash) { 8716 const speed = 0; 8717 8718 for (let i = 0, length = swiper.slides.length; i < length; i += 1) { 8719 const slide = swiper.slides.eq(i); 8720 const slideHash = slide.attr('data-hash') || slide.attr('data-history'); 8721 8722 if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { 8723 const index = slide.index(); 8724 swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); 8725 } 8726 } 8727 } 8728 8729 if (swiper.params.hashNavigation.watchState) { 8730 $(window).on('hashchange', onHashChange); 8731 } 8732 }; 8733 8734 const destroy = () => { 8735 if (swiper.params.hashNavigation.watchState) { 8736 $(window).off('hashchange', onHashChange); 8737 } 8738 }; 8739 8740 on('init', () => { 8741 if (swiper.params.hashNavigation.enabled) { 8742 init(); 8743 } 8744 }); 8745 on('destroy', () => { 8746 if (swiper.params.hashNavigation.enabled) { 8747 destroy(); 8748 } 8749 }); 8750 on('transitionEnd _freeModeNoMomentumRelease', () => { 8751 if (initialized) { 8752 setHash(); 8753 } 8754 }); 8755 on('slideChange', () => { 8756 if (initialized && swiper.params.cssMode) { 8757 setHash(); 8758 } 8759 }); 8760} 8761 8762/* eslint no-underscore-dangle: "off" */ 8763function Autoplay(_ref) { 8764 let { 8765 swiper, 8766 extendParams, 8767 on, 8768 emit 8769 } = _ref; 8770 let timeout; 8771 swiper.autoplay = { 8772 running: false, 8773 paused: false 8774 }; 8775 extendParams({ 8776 autoplay: { 8777 enabled: false, 8778 delay: 3000, 8779 waitForTransition: true, 8780 disableOnInteraction: true, 8781 stopOnLastSlide: false, 8782 reverseDirection: false, 8783 pauseOnMouseEnter: false 8784 } 8785 }); 8786 8787 function run() { 8788 const $activeSlideEl = swiper.slides.eq(swiper.activeIndex); 8789 let delay = swiper.params.autoplay.delay; 8790 8791 if ($activeSlideEl.attr('data-swiper-autoplay')) { 8792 delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; 8793 } 8794 8795 clearTimeout(timeout); 8796 timeout = nextTick(() => { 8797 let autoplayResult; 8798 8799 if (swiper.params.autoplay.reverseDirection) { 8800 if (swiper.params.loop) { 8801 swiper.loopFix(); 8802 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); 8803 emit('autoplay'); 8804 } else if (!swiper.isBeginning) { 8805 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true); 8806 emit('autoplay'); 8807 } else if (!swiper.params.autoplay.stopOnLastSlide) { 8808 autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); 8809 emit('autoplay'); 8810 } else { 8811 stop(); 8812 } 8813 } else if (swiper.params.loop) { 8814 swiper.loopFix(); 8815 autoplayResult = swiper.slideNext(swiper.params.speed, true, true); 8816 emit('autoplay'); 8817 } else if (!swiper.isEnd) { 8818 autoplayResult = swiper.slideNext(swiper.params.speed, true, true); 8819 emit('autoplay'); 8820 } else if (!swiper.params.autoplay.stopOnLastSlide) { 8821 autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true); 8822 emit('autoplay'); 8823 } else { 8824 stop(); 8825 } 8826 8827 if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) { 8828 run(); 8829 } 8830 }, delay); 8831 } 8832 8833 function start() { 8834 if (typeof timeout !== 'undefined') return false;
vendor: 4,229 bytes, lines 8835-9009
8835 if (swiper.autoplay.running) return false; 8836 swiper.autoplay.running = true; 8837 emit('autoplayStart'); 8838 run(); 8839 return true; 8840 } 8841 8842 function stop() { 8843 if (!swiper.autoplay.running) return false; 8844 if (typeof timeout === 'undefined') return false; 8845 8846 if (timeout) { 8847 clearTimeout(timeout); 8848 timeout = undefined; 8849 } 8850 8851 swiper.autoplay.running = false; 8852 emit('autoplayStop'); 8853 return true; 8854 } 8855 8856 function pause(speed) { 8857 if (!swiper.autoplay.running) return; 8858 if (swiper.autoplay.paused) return; 8859 if (timeout) clearTimeout(timeout); 8860 swiper.autoplay.paused = true; 8861 8862 if (speed === 0 || !swiper.params.autoplay.waitForTransition) { 8863 swiper.autoplay.paused = false; 8864 run(); 8865 } else { 8866 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 8867 swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd); 8868 }); 8869 } 8870 } 8871 8872 function onVisibilityChange() { 8873 const document = getDocument(); 8874 8875 if (document.visibilityState === 'hidden' && swiper.autoplay.running) { 8876 pause(); 8877 } 8878 8879 if (document.visibilityState === 'visible' && swiper.autoplay.paused) { 8880 run(); 8881 swiper.autoplay.paused = false; 8882 } 8883 } 8884 8885 function onTransitionEnd(e) { 8886 if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return; 8887 if (e.target !== swiper.$wrapperEl[0]) return; 8888 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 8889 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd); 8890 }); 8891 swiper.autoplay.paused = false; 8892 8893 if (!swiper.autoplay.running) { 8894 stop(); 8895 } else { 8896 run(); 8897 } 8898 } 8899 8900 function onMouseEnter() { 8901 if (swiper.params.autoplay.disableOnInteraction) { 8902 stop(); 8903 } else { 8904 emit('autoplayPause'); 8905 pause(); 8906 } 8907 8908 ['transitionend', 'webkitTransitionEnd'].forEach(event => { 8909 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd); 8910 }); 8911 } 8912 8913 function onMouseLeave() { 8914 if (swiper.params.autoplay.disableOnInteraction) { 8915 return; 8916 } 8917 8918 swiper.autoplay.paused = false; 8919 emit('autoplayResume'); 8920 run(); 8921 } 8922 8923 function attachMouseEvents() { 8924 if (swiper.params.autoplay.pauseOnMouseEnter) { 8925 swiper.$el.on('mouseenter', onMouseEnter); 8926 swiper.$el.on('mouseleave', onMouseLeave); 8927 } 8928 } 8929 8930 function detachMouseEvents() { 8931 swiper.$el.off('mouseenter', onMouseEnter); 8932 swiper.$el.off('mouseleave', onMouseLeave); 8933 } 8934 8935 on('init', () => { 8936 if (swiper.params.autoplay.enabled) { 8937 start(); 8938 const document = getDocument(); 8939 document.addEventListener('visibilitychange', onVisibilityChange); 8940 attachMouseEvents(); 8941 } 8942 }); 8943 on('beforeTransitionStart', (_s, speed, internal) => { 8944 if (swiper.autoplay.running) { 8945 if (internal || !swiper.params.autoplay.disableOnInteraction) { 8946 swiper.autoplay.pause(speed); 8947 } else { 8948 stop(); 8949 } 8950 } 8951 }); 8952 on('sliderFirstMove', () => { 8953 if (swiper.autoplay.running) { 8954 if (swiper.params.autoplay.disableOnInteraction) { 8955 stop(); 8956 } else { 8957 pause(); 8958 } 8959 } 8960 }); 8961 on('touchEnd', () => { 8962 if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) { 8963 run(); 8964 } 8965 }); 8966 on('destroy', () => { 8967 detachMouseEvents(); 8968 8969 if (swiper.autoplay.running) { 8970 stop(); 8971 } 8972 8973 const document = getDocument(); 8974 document.removeEventListener('visibilitychange', onVisibilityChange); 8975 }); 8976 Object.assign(swiper.autoplay, { 8977 pause, 8978 run, 8979 start, 8980 stop 8981 }); 8982} 8983 8984function Thumb(_ref) { 8985 let { 8986 swiper, 8987 extendParams, 8988 on 8989 } = _ref; 8990 extendParams({ 8991 thumbs: { 8992 swiper: null, 8993 multipleActiveThumbs: true, 8994 autoScrollOffset: 0, 8995 slideThumbActiveClass: 'swiper-slide-thumb-active', 8996 thumbsContainerClass: 'swiper-thumbs' 8997 } 8998 }); 8999 let initialized = false; 9000 let swiperCreated = false; 9001 swiper.thumbs = { 9002 swiper: null 9003 }; 9004 9005 function onThumbClick() { 9006 const thumbsSwiper = swiper.thumbs.swiper; 9007 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 9008 const clickedIndex = thumbsSwiper.clickedIndex; 9009 const clickedSlide = thumbsSwiper.clickedSlide;
9010 if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return; 9011 if (typeof clickedIndex === 'undefined' || clickedIndex === null) return; 9012 let slideToIndex; 9013 9014 if (thumbsSwiper.params.loop) { 9015 slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); 9016 } else { 9017 slideToIndex = clickedIndex; 9018 } 9019 9020 if (swiper.params.loop) { 9021 let currentIndex = swiper.activeIndex; 9022 9023 if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { 9024 swiper.loopFix(); // eslint-disable-next-line 9025 9026 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; 9027 currentIndex = swiper.activeIndex; 9028 } 9029 9030 const prevIndex = swiper.slides.eq(currentIndex).prevAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index(); 9031 const nextIndex = swiper.slides.eq(currentIndex).nextAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index(); 9032 if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex; 9033 } 9034 9035 swiper.slideTo(slideToIndex); 9036 } 9037 9038 function init() { 9039 const { 9040 thumbs: thumbsParams 9041 } = swiper.params; 9042 if (initialized) return false; 9043 initialized = true; 9044 const SwiperClass = swiper.constructor; 9045 9046 if (thumbsParams.swiper instanceof SwiperClass) { 9047 swiper.thumbs.swiper = thumbsParams.swiper; 9048 Object.assign(swiper.thumbs.swiper.originalParams, { 9049 watchSlidesProgress: true, 9050 slideToClickedSlide: false 9051 }); 9052 Object.assign(swiper.thumbs.swiper.params, { 9053 watchSlidesProgress: true, 9054 slideToClickedSlide: false 9055 }); 9056 } else if (isObject(thumbsParams.swiper)) { 9057 const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper); 9058 Object.assign(thumbsSwiperParams, { 9059 watchSlidesProgress: true, 9060 slideToClickedSlide: false 9061 }); 9062 swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams); 9063 swiperCreated = true; 9064 } 9065 9066 swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); 9067 swiper.thumbs.swiper.on('tap', onThumbClick); 9068 return true; 9069 } 9070 9071 function update(initial) { 9072 const thumbsSwiper = swiper.thumbs.swiper; 9073 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 9074 const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; // Activate thumbs 9075 9076 let thumbsToActivate = 1; 9077 const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; 9078 9079 if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { 9080 thumbsToActivate = swiper.params.slidesPerView; 9081 } 9082 9083 if (!swiper.params.thumbs.multipleActiveThumbs) { 9084 thumbsToActivate = 1; 9085 } 9086 9087 thumbsToActivate = Math.floor(thumbsToActivate); 9088 thumbsSwiper.slides.removeClass(thumbActiveClass); 9089 9090 if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) { 9091 for (let i = 0; i < thumbsToActivate; i += 1) { 9092 thumbsSwiper.$wrapperEl.children(`[data-swiper-slide-index="${swiper.realIndex + i}"]`).addClass(thumbActiveClass); 9093 } 9094 } else { 9095 for (let i = 0; i < thumbsToActivate; i += 1) { 9096 thumbsSwiper.slides.eq(swiper.realIndex + i).addClass(thumbActiveClass); 9097 } 9098 } 9099 9100 const autoScrollOffset = swiper.params.thumbs.autoScrollOffset; 9101 const useOffset = autoScrollOffset && !thumbsSwiper.params.loop; 9102 9103 if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) { 9104 let currentThumbsIndex = thumbsSwiper.activeIndex; 9105 let newThumbsIndex; 9106 let direction; 9107 9108 if (thumbsSwiper.params.loop) { 9109 if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { 9110 thumbsSwiper.loopFix(); // eslint-disable-next-line 9111 9112 thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; 9113 currentThumbsIndex = thumbsSwiper.activeIndex; 9114 } // Find actual thumbs index to slide to 9115 9116 9117 const prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index(); 9118 const nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index(); 9119 9120 if (typeof prevThumbsIndex === 'undefined') { 9121 newThumbsIndex = nextThumbsIndex; 9122 } else if (typeof nextThumbsIndex === 'undefined') { 9123 newThumbsIndex = prevThumbsIndex; 9124 } else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) { 9125 newThumbsIndex = thumbsSwiper.params.slidesPerGroup > 1 ? nextThumbsIndex : currentThumbsIndex; 9126 } else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) { 9127 newThumbsIndex = nextThumbsIndex; 9128 } else { 9129 newThumbsIndex = prevThumbsIndex; 9130 } 9131 9132 direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev'; 9133 } else { 9134 newThumbsIndex = swiper.realIndex; 9135 direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev'; 9136 } 9137 9138 if (useOffset) { 9139 newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset; 9140 } 9141 9142 if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) { 9143 if (thumbsSwiper.params.centeredSlides) { 9144 if (newThumbsIndex > currentThumbsIndex) { 9145 newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; 9146 } else { 9147 newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; 9148 } 9149 } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ; 9150 9151 thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); 9152 } 9153 } 9154 } 9155 9156 on('beforeInit', () => { 9157 const { 9158 thumbs 9159 } = swiper.params; 9160 if (!thumbs || !thumbs.swiper) return; 9161 init(); 9162 update(true); 9163 }); 9164 on('slideChange update resize observerUpdate', () => { 9165 update(); 9166 }); 9167 on('setTransition', (_s, duration) => { 9168 const thumbsSwiper = swiper.thumbs.swiper; 9169 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 9170 thumbsSwiper.setTransition(duration); 9171 }); 9172 on('beforeDestroy', () => { 9173 const thumbsSwiper = swiper.thumbs.swiper; 9174 if (!thumbsSwiper || thumbsSwiper.destroyed) return; 9175 9176 if (swiperCreated) { 9177 thumbsSwiper.destroy(); 9178 } 9179 }); 9180 Object.assign(swiper.thumbs, { 9181 init, 9182 update 9183 }); 9184} 9185 9186function freeMode(_ref) { 9187 let { 9188 swiper, 9189 extendParams, 9190 emit, 9191 once 9192 } = _ref; 9193 extendParams({ 9194 freeMode: { 9195 enabled: false, 9196 momentum: true, 9197 momentumRatio: 1, 9198 momentumBounce: true, 9199 momentumBounceRatio: 1, 9200 momentumVelocityRatio: 1,
vendor: 7,985 bytes, lines 9201-9454
9201 sticky: false, 9202 minimumVelocity: 0.02 9203 } 9204 }); 9205 9206 function onTouchStart() { 9207 const translate = swiper.getTranslate(); 9208 swiper.setTranslate(translate); 9209 swiper.setTransition(0); 9210 swiper.touchEventsData.velocities.length = 0; 9211 swiper.freeMode.onTouchEnd({ 9212 currentPos: swiper.rtl ? swiper.translate : -swiper.translate 9213 }); 9214 } 9215 9216 function onTouchMove() { 9217 const { 9218 touchEventsData: data, 9219 touches 9220 } = swiper; // Velocity 9221 9222 if (data.velocities.length === 0) { 9223 data.velocities.push({ 9224 position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], 9225 time: data.touchStartTime 9226 }); 9227 } 9228 9229 data.velocities.push({ 9230 position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], 9231 time: now() 9232 }); 9233 } 9234 9235 function onTouchEnd(_ref2) { 9236 let { 9237 currentPos 9238 } = _ref2; 9239 const { 9240 params, 9241 $wrapperEl, 9242 rtlTranslate: rtl, 9243 snapGrid, 9244 touchEventsData: data 9245 } = swiper; // Time diff 9246 9247 const touchEndTime = now(); 9248 const timeDiff = touchEndTime - data.touchStartTime; 9249 9250 if (currentPos < -swiper.minTranslate()) { 9251 swiper.slideTo(swiper.activeIndex); 9252 return; 9253 } 9254 9255 if (currentPos > -swiper.maxTranslate()) { 9256 if (swiper.slides.length < snapGrid.length) { 9257 swiper.slideTo(snapGrid.length - 1); 9258 } else { 9259 swiper.slideTo(swiper.slides.length - 1); 9260 } 9261 9262 return; 9263 } 9264 9265 if (params.freeMode.momentum) { 9266 if (data.velocities.length > 1) { 9267 const lastMoveEvent = data.velocities.pop(); 9268 const velocityEvent = data.velocities.pop(); 9269 const distance = lastMoveEvent.position - velocityEvent.position; 9270 const time = lastMoveEvent.time - velocityEvent.time; 9271 swiper.velocity = distance / time; 9272 swiper.velocity /= 2; 9273 9274 if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) { 9275 swiper.velocity = 0; 9276 } // this implies that the user stopped moving a finger then released. 9277 // There would be no events with distance zero, so the last event is stale. 9278 9279 9280 if (time > 150 || now() - lastMoveEvent.time > 300) { 9281 swiper.velocity = 0; 9282 } 9283 } else { 9284 swiper.velocity = 0; 9285 } 9286 9287 swiper.velocity *= params.freeMode.momentumVelocityRatio; 9288 data.velocities.length = 0; 9289 let momentumDuration = 1000 * params.freeMode.momentumRatio; 9290 const momentumDistance = swiper.velocity * momentumDuration; 9291 let newPosition = swiper.translate + momentumDistance; 9292 if (rtl) newPosition = -newPosition; 9293 let doBounce = false; 9294 let afterBouncePosition; 9295 const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio; 9296 let needsLoopFix; 9297 9298 if (newPosition < swiper.maxTranslate()) { 9299 if (params.freeMode.momentumBounce) { 9300 if (newPosition + swiper.maxTranslate() < -bounceAmount) { 9301 newPosition = swiper.maxTranslate() - bounceAmount; 9302 } 9303 9304 afterBouncePosition = swiper.maxTranslate(); 9305 doBounce = true; 9306 data.allowMomentumBounce = true; 9307 } else { 9308 newPosition = swiper.maxTranslate(); 9309 } 9310 9311 if (params.loop && params.centeredSlides) needsLoopFix = true; 9312 } else if (newPosition > swiper.minTranslate()) { 9313 if (params.freeMode.momentumBounce) { 9314 if (newPosition - swiper.minTranslate() > bounceAmount) { 9315 newPosition = swiper.minTranslate() + bounceAmount; 9316 } 9317 9318 afterBouncePosition = swiper.minTranslate(); 9319 doBounce = true; 9320 data.allowMomentumBounce = true; 9321 } else { 9322 newPosition = swiper.minTranslate(); 9323 } 9324 9325 if (params.loop && params.centeredSlides) needsLoopFix = true; 9326 } else if (params.freeMode.sticky) { 9327 let nextSlide; 9328 9329 for (let j = 0; j < snapGrid.length; j += 1) { 9330 if (snapGrid[j] > -newPosition) { 9331 nextSlide = j; 9332 break; 9333 } 9334 } 9335 9336 if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { 9337 newPosition = snapGrid[nextSlide]; 9338 } else { 9339 newPosition = snapGrid[nextSlide - 1]; 9340 } 9341 9342 newPosition = -newPosition; 9343 } 9344 9345 if (needsLoopFix) { 9346 once('transitionEnd', () => { 9347 swiper.loopFix(); 9348 }); 9349 } // Fix duration 9350 9351 9352 if (swiper.velocity !== 0) { 9353 if (rtl) { 9354 momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); 9355 } else { 9356 momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); 9357 } 9358 9359 if (params.freeMode.sticky) { 9360 // If freeMode.sticky is active and the user ends a swipe with a slow-velocity 9361 // event, then durations can be 20+ seconds to slide one (or zero!) slides. 9362 // It's easy to see this when simulating touch with mouse events. To fix this, 9363 // limit single-slide swipes to the default slide duration. This also has the 9364 // nice side effect of matching slide speed if the user stopped moving before 9365 // lifting finger or mouse vs. moving slowly before lifting the finger/mouse. 9366 // For faster swipes, also apply limits (albeit higher ones). 9367 const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate); 9368 const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex]; 9369 9370 if (moveDistance < currentSlideSize) { 9371 momentumDuration = params.speed; 9372 } else if (moveDistance < 2 * currentSlideSize) { 9373 momentumDuration = params.speed * 1.5; 9374 } else { 9375 momentumDuration = params.speed * 2.5; 9376 } 9377 } 9378 } else if (params.freeMode.sticky) { 9379 swiper.slideToClosest(); 9380 return; 9381 } 9382 9383 if (params.freeMode.momentumBounce && doBounce) { 9384 swiper.updateProgress(afterBouncePosition); 9385 swiper.setTransition(momentumDuration); 9386 swiper.setTranslate(newPosition); 9387 swiper.transitionStart(true, swiper.swipeDirection); 9388 swiper.animating = true; 9389 $wrapperEl.transitionEnd(() => { 9390 if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return; 9391 emit('momentumBounce'); 9392 swiper.setTransition(params.speed); 9393 setTimeout(() => { 9394 swiper.setTranslate(afterBouncePosition); 9395 $wrapperEl.transitionEnd(() => { 9396 if (!swiper || swiper.destroyed) return; 9397 swiper.transitionEnd(); 9398 }); 9399 }, 0); 9400 }); 9401 } else if (swiper.velocity) { 9402 emit('_freeModeNoMomentumRelease'); 9403 swiper.updateProgress(newPosition); 9404 swiper.setTransition(momentumDuration); 9405 swiper.setTranslate(newPosition); 9406 swiper.transitionStart(true, swiper.swipeDirection); 9407 9408 if (!swiper.animating) { 9409 swiper.animating = true; 9410 $wrapperEl.transitionEnd(() => { 9411 if (!swiper || swiper.destroyed) return; 9412 swiper.transitionEnd(); 9413 }); 9414 } 9415 } else { 9416 swiper.updateProgress(newPosition); 9417 } 9418 9419 swiper.updateActiveIndex(); 9420 swiper.updateSlidesClasses(); 9421 } else if (params.freeMode.sticky) { 9422 swiper.slideToClosest(); 9423 return; 9424 } else if (params.freeMode) { 9425 emit('_freeModeNoMomentumRelease'); 9426 } 9427 9428 if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) { 9429 swiper.updateProgress(); 9430 swiper.updateActiveIndex(); 9431 swiper.updateSlidesClasses(); 9432 } 9433 } 9434 9435 Object.assign(swiper, { 9436 freeMode: { 9437 onTouchStart, 9438 onTouchMove, 9439 onTouchEnd 9440 } 9441 }); 9442} 9443 9444function Grid(_ref) { 9445 let { 9446 swiper, 9447 extendParams 9448 } = _ref; 9449 extendParams({ 9450 grid: { 9451 rows: 1, 9452 fill: 'column' 9453 } 9454 });
9455 let slidesNumberEvenToRows; 9456 let slidesPerRow; 9457 let numFullColumns; 9458 9459 const initSlides = slidesLength => { 9460 const { 9461 slidesPerView 9462 } = swiper.params; 9463 const { 9464 rows, 9465 fill 9466 } = swiper.params.grid; 9467 slidesPerRow = slidesNumberEvenToRows / rows; 9468 numFullColumns = Math.floor(slidesLength / rows); 9469 9470 if (Math.floor(slidesLength / rows) === slidesLength / rows) { 9471 slidesNumberEvenToRows = slidesLength; 9472 } else { 9473 slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows; 9474 } 9475 9476 if (slidesPerView !== 'auto' && fill === 'row') { 9477 slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows); 9478 } 9479 }; 9480 9481 const updateSlide = (i, slide, slidesLength, getDirectionLabel) => { 9482 const { 9483 slidesPerGroup, 9484 spaceBetween 9485 } = swiper.params; 9486 const { 9487 rows, 9488 fill 9489 } = swiper.params.grid; // Set slides order 9490 9491 let newSlideOrderIndex; 9492 let column; 9493 let row; 9494 9495 if (fill === 'row' && slidesPerGroup > 1) { 9496 const groupIndex = Math.floor(i / (slidesPerGroup * rows)); 9497 const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex; 9498 const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup); 9499 row = Math.floor(slideIndexInGroup / columnsInGroup); 9500 column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup; 9501 newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows; 9502 slide.css({ 9503 '-webkit-order': newSlideOrderIndex, 9504 order: newSlideOrderIndex 9505 }); 9506 } else if (fill === 'column') { 9507 column = Math.floor(i / rows); 9508 row = i - column * rows; 9509 9510 if (column > numFullColumns || column === numFullColumns && row === rows - 1) { 9511 row += 1; 9512 9513 if (row >= rows) { 9514 row = 0; 9515 column += 1; 9516 } 9517 } 9518 } else { 9519 row = Math.floor(i / slidesPerRow); 9520 column = i - row * slidesPerRow; 9521 } 9522 9523 slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : ''); 9524 }; 9525 9526 const updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => { 9527 const { 9528 spaceBetween, 9529 centeredSlides, 9530 roundLengths 9531 } = swiper.params; 9532 const { 9533 rows 9534 } = swiper.params.grid; 9535 swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows; 9536 swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween; 9537 swiper.$wrapperEl.css({ 9538 [getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px` 9539 }); 9540 9541 if (centeredSlides) { 9542 snapGrid.splice(0, snapGrid.length); 9543 const newSlidesGrid = []; 9544 9545 for (let i = 0; i < snapGrid.length; i += 1) { 9546 let slidesGridItem = snapGrid[i]; 9547 if (roundLengths) slidesGridItem = Math.floor(slidesGridItem); 9548 if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem); 9549 } 9550 9551 snapGrid.push(...newSlidesGrid); 9552 } 9553 }; 9554 9555 swiper.grid = { 9556 initSlides, 9557 updateSlide, 9558 updateWrapperSize 9559 }; 9560} 9561 9562function appendSlide(slides) { 9563 const swiper = this; 9564 const { 9565 $wrapperEl, 9566 params 9567 } = swiper; 9568 9569 if (params.loop) { 9570 swiper.loopDestroy(); 9571 } 9572 9573 if (typeof slides === 'object' && 'length' in slides) { 9574 for (let i = 0; i < slides.length; i += 1) { 9575 if (slides[i]) $wrapperEl.append(slides[i]); 9576 } 9577 } else { 9578 $wrapperEl.append(slides); 9579 } 9580 9581 if (params.loop) { 9582 swiper.loopCreate(); 9583 } 9584 9585 if (!params.observer) { 9586 swiper.update(); 9587 } 9588} 9589 9590function prependSlide(slides) { 9591 const swiper = this; 9592 const { 9593 params, 9594 $wrapperEl, 9595 activeIndex 9596 } = swiper; 9597 9598 if (params.loop) { 9599 swiper.loopDestroy(); 9600 } 9601 9602 let newActiveIndex = activeIndex + 1; 9603 9604 if (typeof slides === 'object' && 'length' in slides) { 9605 for (let i = 0; i < slides.length; i += 1) { 9606 if (slides[i]) $wrapperEl.prepend(slides[i]); 9607 } 9608 9609 newActiveIndex = activeIndex + slides.length; 9610 } else {
vendor: 5,224 bytes, lines 9611-9819
9611 $wrapperEl.prepend(slides); 9612 } 9613 9614 if (params.loop) { 9615 swiper.loopCreate(); 9616 } 9617 9618 if (!params.observer) { 9619 swiper.update(); 9620 } 9621 9622 swiper.slideTo(newActiveIndex, 0, false); 9623} 9624 9625function addSlide(index, slides) { 9626 const swiper = this; 9627 const { 9628 $wrapperEl, 9629 params, 9630 activeIndex 9631 } = swiper; 9632 let activeIndexBuffer = activeIndex; 9633 9634 if (params.loop) { 9635 activeIndexBuffer -= swiper.loopedSlides; 9636 swiper.loopDestroy(); 9637 swiper.slides = $wrapperEl.children(`.${params.slideClass}`); 9638 } 9639 9640 const baseLength = swiper.slides.length; 9641 9642 if (index <= 0) { 9643 swiper.prependSlide(slides); 9644 return; 9645 } 9646 9647 if (index >= baseLength) { 9648 swiper.appendSlide(slides); 9649 return; 9650 } 9651 9652 let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; 9653 const slidesBuffer = []; 9654 9655 for (let i = baseLength - 1; i >= index; i -= 1) { 9656 const currentSlide = swiper.slides.eq(i); 9657 currentSlide.remove(); 9658 slidesBuffer.unshift(currentSlide); 9659 } 9660 9661 if (typeof slides === 'object' && 'length' in slides) { 9662 for (let i = 0; i < slides.length; i += 1) { 9663 if (slides[i]) $wrapperEl.append(slides[i]); 9664 } 9665 9666 newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; 9667 } else { 9668 $wrapperEl.append(slides); 9669 } 9670 9671 for (let i = 0; i < slidesBuffer.length; i += 1) { 9672 $wrapperEl.append(slidesBuffer[i]); 9673 } 9674 9675 if (params.loop) { 9676 swiper.loopCreate(); 9677 } 9678 9679 if (!params.observer) { 9680 swiper.update(); 9681 } 9682 9683 if (params.loop) { 9684 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 9685 } else { 9686 swiper.slideTo(newActiveIndex, 0, false); 9687 } 9688} 9689 9690function removeSlide(slidesIndexes) { 9691 const swiper = this; 9692 const { 9693 params, 9694 $wrapperEl, 9695 activeIndex 9696 } = swiper; 9697 let activeIndexBuffer = activeIndex; 9698 9699 if (params.loop) { 9700 activeIndexBuffer -= swiper.loopedSlides; 9701 swiper.loopDestroy(); 9702 swiper.slides = $wrapperEl.children(`.${params.slideClass}`); 9703 } 9704 9705 let newActiveIndex = activeIndexBuffer; 9706 let indexToRemove; 9707 9708 if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { 9709 for (let i = 0; i < slidesIndexes.length; i += 1) { 9710 indexToRemove = slidesIndexes[i]; 9711 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); 9712 if (indexToRemove < newActiveIndex) newActiveIndex -= 1; 9713 } 9714 9715 newActiveIndex = Math.max(newActiveIndex, 0); 9716 } else { 9717 indexToRemove = slidesIndexes; 9718 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove(); 9719 if (indexToRemove < newActiveIndex) newActiveIndex -= 1; 9720 newActiveIndex = Math.max(newActiveIndex, 0); 9721 } 9722 9723 if (params.loop) { 9724 swiper.loopCreate(); 9725 } 9726 9727 if (!params.observer) { 9728 swiper.update(); 9729 } 9730 9731 if (params.loop) { 9732 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); 9733 } else { 9734 swiper.slideTo(newActiveIndex, 0, false); 9735 } 9736} 9737 9738function removeAllSlides() { 9739 const swiper = this; 9740 const slidesIndexes = []; 9741 9742 for (let i = 0; i < swiper.slides.length; i += 1) { 9743 slidesIndexes.push(i); 9744 } 9745 9746 swiper.removeSlide(slidesIndexes); 9747} 9748 9749function Manipulation(_ref) { 9750 let { 9751 swiper 9752 } = _ref; 9753 Object.assign(swiper, { 9754 appendSlide: appendSlide.bind(swiper), 9755 prependSlide: prependSlide.bind(swiper), 9756 addSlide: addSlide.bind(swiper), 9757 removeSlide: removeSlide.bind(swiper), 9758 removeAllSlides: removeAllSlides.bind(swiper) 9759 }); 9760} 9761 9762function effectInit(params) { 9763 const { 9764 effect, 9765 swiper, 9766 on, 9767 setTranslate, 9768 setTransition, 9769 overwriteParams, 9770 perspective, 9771 recreateShadows, 9772 getEffectParams 9773 } = params; 9774 on('beforeInit', () => { 9775 if (swiper.params.effect !== effect) return; 9776 swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`); 9777 9778 if (perspective && perspective()) { 9779 swiper.classNames.push(`${swiper.params.containerModifierClass}3d`); 9780 } 9781 9782 const overwriteParamsResult = overwriteParams ? overwriteParams() : {}; 9783 Object.assign(swiper.params, overwriteParamsResult); 9784 Object.assign(swiper.originalParams, overwriteParamsResult); 9785 }); 9786 on('setTranslate', () => { 9787 if (swiper.params.effect !== effect) return; 9788 setTranslate(); 9789 }); 9790 on('setTransition', (_s, duration) => { 9791 if (swiper.params.effect !== effect) return; 9792 setTransition(duration); 9793 }); 9794 on('transitionEnd', () => { 9795 if (swiper.params.effect !== effect) return; 9796 9797 if (recreateShadows) { 9798 if (!getEffectParams || !getEffectParams().slideShadows) return; // remove shadows 9799 9800 swiper.slides.each(slideEl => { 9801 const $slideEl = swiper.$(slideEl); 9802 $slideEl.find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').remove(); 9803 }); // create new one 9804 9805 recreateShadows(); 9806 } 9807 }); 9808 let requireUpdateOnVirtual; 9809 on('virtualUpdate', () => { 9810 if (swiper.params.effect !== effect) return; 9811 9812 if (!swiper.slides.length) { 9813 requireUpdateOnVirtual = true; 9814 } 9815 9816 requestAnimationFrame(() => { 9817 if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) { 9818 setTranslate(); 9819 requireUpdateOnVirtual = false;
9820 } 9821 }); 9822 }); 9823} 9824 9825function effectTarget(effectParams, $slideEl) { 9826 if (effectParams.transformEl) { 9827 return $slideEl.find(effectParams.transformEl).css({ 9828 'backface-visibility': 'hidden', 9829 '-webkit-backface-visibility': 'hidden' 9830 }); 9831 } 9832 9833 return $slideEl; 9834} 9835 9836function effectVirtualTransitionEnd(_ref) { 9837 let { 9838 swiper, 9839 duration, 9840 transformEl, 9841 allSlides 9842 } = _ref; 9843 const { 9844 slides, 9845 activeIndex, 9846 $wrapperEl 9847 } = swiper; 9848 9849 if (swiper.params.virtualTranslate && duration !== 0) { 9850 let eventTriggered = false; 9851 let $transitionEndTarget; 9852 9853 if (allSlides) { 9854 $transitionEndTarget = transformEl ? slides.find(transformEl) : slides; 9855 } else { 9856 $transitionEndTarget = transformEl ? slides.eq(activeIndex).find(transformEl) : slides.eq(activeIndex); 9857 } 9858 9859 $transitionEndTarget.transitionEnd(() => { 9860 if (eventTriggered) return; 9861 if (!swiper || swiper.destroyed) return; 9862 eventTriggered = true; 9863 swiper.animating = false; 9864 const triggerEvents = ['webkitTransitionEnd', 'transitionend']; 9865 9866 for (let i = 0; i < triggerEvents.length; i += 1) { 9867 $wrapperEl.trigger(triggerEvents[i]); 9868 } 9869 }); 9870 } 9871} 9872 9873function EffectFade(_ref) { 9874 let { 9875 swiper, 9876 extendParams, 9877 on 9878 } = _ref; 9879 extendParams({ 9880 fadeEffect: { 9881 crossFade: false, 9882 transformEl: null 9883 } 9884 }); 9885 9886 const setTranslate = () => { 9887 const { 9888 slides 9889 } = swiper; 9890 const params = swiper.params.fadeEffect; 9891 9892 for (let i = 0; i < slides.length; i += 1) { 9893 const $slideEl = swiper.slides.eq(i); 9894 const offset = $slideEl[0].swiperSlideOffset; 9895 let tx = -offset; 9896 if (!swiper.params.virtualTranslate) tx -= swiper.translate; 9897 let ty = 0; 9898 9899 if (!swiper.isHorizontal()) { 9900 ty = tx; 9901 tx = 0; 9902 } 9903 9904 const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); 9905 const $targetEl = effectTarget(params, $slideEl); 9906 $targetEl.css({ 9907 opacity: slideOpacity 9908 }).transform(`translate3d(${tx}px, ${ty}px, 0px)`); 9909 } 9910 }; 9911 9912 const setTransition = duration => { 9913 const { 9914 transformEl 9915 } = swiper.params.fadeEffect; 9916 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 9917 $transitionElements.transition(duration); 9918 effectVirtualTransitionEnd({ 9919 swiper, 9920 duration, 9921 transformEl, 9922 allSlides: true 9923 }); 9924 }; 9925 9926 effectInit({ 9927 effect: 'fade', 9928 swiper, 9929 on, 9930 setTranslate, 9931 setTransition, 9932 overwriteParams: () => ({ 9933 slidesPerView: 1, 9934 slidesPerGroup: 1, 9935 watchSlidesProgress: true, 9936 spaceBetween: 0, 9937 virtualTranslate: !swiper.params.cssMode 9938 }) 9939 }); 9940} 9941 9942function EffectCube(_ref) { 9943 let { 9944 swiper, 9945 extendParams, 9946 on 9947 } = _ref; 9948 extendParams({ 9949 cubeEffect: { 9950 slideShadows: true, 9951 shadow: true, 9952 shadowOffset: 20, 9953 shadowScale: 0.94 9954 } 9955 }); 9956 9957 const createSlideShadows = ($slideEl, progress, isHorizontal) => { 9958 let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 9959 let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 9960 9961 if (shadowBefore.length === 0) { 9962 shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`); 9963 $slideEl.append(shadowBefore); 9964 } 9965 9966 if (shadowAfter.length === 0) { 9967 shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`); 9968 $slideEl.append(shadowAfter); 9969 } 9970 9971 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); 9972 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); 9973 }; 9974 9975 const recreateShadows = () => { 9976 // create new ones 9977 const isHorizontal = swiper.isHorizontal(); 9978 swiper.slides.each(slideEl => { 9979 const progress = Math.max(Math.min(slideEl.progress, 1), -1); 9980 createSlideShadows($(slideEl), progress, isHorizontal); 9981 }); 9982 }; 9983 9984 const setTranslate = () => { 9985 const { 9986 $el, 9987 $wrapperEl, 9988 slides, 9989 width: swiperWidth, 9990 height: swiperHeight, 9991 rtlTranslate: rtl, 9992 size: swiperSize, 9993 browser 9994 } = swiper; 9995 const params = swiper.params.cubeEffect; 9996 const isHorizontal = swiper.isHorizontal(); 9997 const isVirtual = swiper.virtual && swiper.params.virtual.enabled; 9998 let wrapperRotate = 0; 9999 let $cubeShadowEl; 10000 10001 if (params.shadow) { 10002 if (isHorizontal) { 10003 $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); 10004 10005 if ($cubeShadowEl.length === 0) {
vendor: 18,877 bytes, lines 10006-10585
10006 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 10007 $wrapperEl.append($cubeShadowEl); 10008 } 10009 10010 $cubeShadowEl.css({ 10011 height: `${swiperWidth}px` 10012 }); 10013 } else { 10014 $cubeShadowEl = $el.find('.swiper-cube-shadow'); 10015 10016 if ($cubeShadowEl.length === 0) { 10017 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); 10018 $el.append($cubeShadowEl); 10019 } 10020 } 10021 } 10022 10023 for (let i = 0; i < slides.length; i += 1) { 10024 const $slideEl = slides.eq(i); 10025 let slideIndex = i; 10026 10027 if (isVirtual) { 10028 slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); 10029 } 10030 10031 let slideAngle = slideIndex * 90; 10032 let round = Math.floor(slideAngle / 360); 10033 10034 if (rtl) { 10035 slideAngle = -slideAngle; 10036 round = Math.floor(-slideAngle / 360); 10037 } 10038 10039 const progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 10040 let tx = 0; 10041 let ty = 0; 10042 let tz = 0; 10043 10044 if (slideIndex % 4 === 0) { 10045 tx = -round * 4 * swiperSize; 10046 tz = 0; 10047 } else if ((slideIndex - 1) % 4 === 0) { 10048 tx = 0; 10049 tz = -round * 4 * swiperSize; 10050 } else if ((slideIndex - 2) % 4 === 0) { 10051 tx = swiperSize + round * 4 * swiperSize; 10052 tz = swiperSize; 10053 } else if ((slideIndex - 3) % 4 === 0) { 10054 tx = -swiperSize; 10055 tz = 3 * swiperSize + swiperSize * 4 * round; 10056 } 10057 10058 if (rtl) { 10059 tx = -tx; 10060 } 10061 10062 if (!isHorizontal) { 10063 ty = tx; 10064 tx = 0; 10065 } 10066 10067 const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`; 10068 10069 if (progress <= 1 && progress > -1) { 10070 wrapperRotate = slideIndex * 90 + progress * 90; 10071 if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90; 10072 } 10073 10074 $slideEl.transform(transform); 10075 10076 if (params.slideShadows) { 10077 createSlideShadows($slideEl, progress, isHorizontal); 10078 } 10079 } 10080 10081 $wrapperEl.css({ 10082 '-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`, 10083 'transform-origin': `50% 50% -${swiperSize / 2}px` 10084 }); 10085 10086 if (params.shadow) { 10087 if (isHorizontal) { 10088 $cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`); 10089 } else { 10090 const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90; 10091 const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2); 10092 const scale1 = params.shadowScale; 10093 const scale2 = params.shadowScale / multiplier; 10094 const offset = params.shadowOffset; 10095 $cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`); 10096 } 10097 } 10098 10099 const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0; 10100 $wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`); 10101 $wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`); 10102 }; 10103 10104 const setTransition = duration => { 10105 const { 10106 $el, 10107 slides 10108 } = swiper; 10109 slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 10110 10111 if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { 10112 $el.find('.swiper-cube-shadow').transition(duration); 10113 } 10114 }; 10115 10116 effectInit({ 10117 effect: 'cube', 10118 swiper, 10119 on, 10120 setTranslate, 10121 setTransition, 10122 recreateShadows, 10123 getEffectParams: () => swiper.params.cubeEffect, 10124 perspective: () => true, 10125 overwriteParams: () => ({ 10126 slidesPerView: 1, 10127 slidesPerGroup: 1, 10128 watchSlidesProgress: true, 10129 resistanceRatio: 0, 10130 spaceBetween: 0, 10131 centeredSlides: false, 10132 virtualTranslate: true 10133 }) 10134 }); 10135} 10136 10137function createShadow(params, $slideEl, side) { 10138 const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}`; 10139 const $shadowContainer = params.transformEl ? $slideEl.find(params.transformEl) : $slideEl; 10140 let $shadowEl = $shadowContainer.children(`.${shadowClass}`); 10141 10142 if (!$shadowEl.length) { 10143 $shadowEl = $(`<div class="swiper-slide-shadow${side ? `-${side}` : ''}"></div>`); 10144 $shadowContainer.append($shadowEl); 10145 } 10146 10147 return $shadowEl; 10148} 10149 10150function EffectFlip(_ref) { 10151 let { 10152 swiper, 10153 extendParams, 10154 on 10155 } = _ref; 10156 extendParams({ 10157 flipEffect: { 10158 slideShadows: true, 10159 limitRotation: true, 10160 transformEl: null 10161 } 10162 }); 10163 10164 const createSlideShadows = ($slideEl, progress, params) => { 10165 let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 10166 let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 10167 10168 if (shadowBefore.length === 0) { 10169 shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top'); 10170 } 10171 10172 if (shadowAfter.length === 0) { 10173 shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom'); 10174 } 10175 10176 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0); 10177 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0); 10178 }; 10179 10180 const recreateShadows = () => { 10181 // Set shadows 10182 const params = swiper.params.flipEffect; 10183 swiper.slides.each(slideEl => { 10184 const $slideEl = $(slideEl); 10185 let progress = $slideEl[0].progress; 10186 10187 if (swiper.params.flipEffect.limitRotation) { 10188 progress = Math.max(Math.min(slideEl.progress, 1), -1); 10189 } 10190 10191 createSlideShadows($slideEl, progress, params); 10192 }); 10193 }; 10194 10195 const setTranslate = () => { 10196 const { 10197 slides, 10198 rtlTranslate: rtl 10199 } = swiper; 10200 const params = swiper.params.flipEffect; 10201 10202 for (let i = 0; i < slides.length; i += 1) { 10203 const $slideEl = slides.eq(i); 10204 let progress = $slideEl[0].progress; 10205 10206 if (swiper.params.flipEffect.limitRotation) { 10207 progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 10208 } 10209 10210 const offset = $slideEl[0].swiperSlideOffset; 10211 const rotate = -180 * progress; 10212 let rotateY = rotate; 10213 let rotateX = 0; 10214 let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset; 10215 let ty = 0; 10216 10217 if (!swiper.isHorizontal()) { 10218 ty = tx; 10219 tx = 0; 10220 rotateX = -rotateY; 10221 rotateY = 0; 10222 } else if (rtl) { 10223 rotateY = -rotateY; 10224 } 10225 10226 $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; 10227 10228 if (params.slideShadows) { 10229 createSlideShadows($slideEl, progress, params); 10230 } 10231 10232 const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`; 10233 const $targetEl = effectTarget(params, $slideEl); 10234 $targetEl.transform(transform); 10235 } 10236 }; 10237 10238 const setTransition = duration => { 10239 const { 10240 transformEl 10241 } = swiper.params.flipEffect; 10242 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 10243 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 10244 effectVirtualTransitionEnd({ 10245 swiper, 10246 duration, 10247 transformEl 10248 }); 10249 }; 10250 10251 effectInit({ 10252 effect: 'flip', 10253 swiper, 10254 on, 10255 setTranslate, 10256 setTransition, 10257 recreateShadows, 10258 getEffectParams: () => swiper.params.flipEffect, 10259 perspective: () => true, 10260 overwriteParams: () => ({ 10261 slidesPerView: 1, 10262 slidesPerGroup: 1, 10263 watchSlidesProgress: true, 10264 spaceBetween: 0, 10265 virtualTranslate: !swiper.params.cssMode 10266 }) 10267 }); 10268} 10269 10270function EffectCoverflow(_ref) { 10271 let { 10272 swiper, 10273 extendParams, 10274 on 10275 } = _ref; 10276 extendParams({ 10277 coverflowEffect: { 10278 rotate: 50, 10279 stretch: 0, 10280 depth: 100, 10281 scale: 1, 10282 modifier: 1, 10283 slideShadows: true, 10284 transformEl: null 10285 } 10286 }); 10287 10288 const setTranslate = () => { 10289 const { 10290 width: swiperWidth, 10291 height: swiperHeight, 10292 slides, 10293 slidesSizesGrid 10294 } = swiper; 10295 const params = swiper.params.coverflowEffect; 10296 const isHorizontal = swiper.isHorizontal(); 10297 const transform = swiper.translate; 10298 const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2; 10299 const rotate = isHorizontal ? params.rotate : -params.rotate; 10300 const translate = params.depth; // Each slide offset from center 10301 10302 for (let i = 0, length = slides.length; i < length; i += 1) { 10303 const $slideEl = slides.eq(i); 10304 const slideSize = slidesSizesGrid[i]; 10305 const slideOffset = $slideEl[0].swiperSlideOffset; 10306 const centerOffset = (center - slideOffset - slideSize / 2) / slideSize; 10307 const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier; 10308 let rotateY = isHorizontal ? rotate * offsetMultiplier : 0; 10309 let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0 10310 10311 let translateZ = -translate * Math.abs(offsetMultiplier); 10312 let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders 10313 10314 if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) { 10315 stretch = parseFloat(params.stretch) / 100 * slideSize; 10316 } 10317 10318 let translateY = isHorizontal ? 0 : stretch * offsetMultiplier; 10319 let translateX = isHorizontal ? stretch * offsetMultiplier : 0; 10320 let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values 10321 10322 if (Math.abs(translateX) < 0.001) translateX = 0; 10323 if (Math.abs(translateY) < 0.001) translateY = 0; 10324 if (Math.abs(translateZ) < 0.001) translateZ = 0; 10325 if (Math.abs(rotateY) < 0.001) rotateY = 0; 10326 if (Math.abs(rotateX) < 0.001) rotateX = 0; 10327 if (Math.abs(scale) < 0.001) scale = 0; 10328 const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`; 10329 const $targetEl = effectTarget(params, $slideEl); 10330 $targetEl.transform(slideTransform); 10331 $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; 10332 10333 if (params.slideShadows) { 10334 // Set shadows 10335 let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 10336 let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 10337 10338 if ($shadowBeforeEl.length === 0) { 10339 $shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top'); 10340 } 10341 10342 if ($shadowAfterEl.length === 0) { 10343 $shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom'); 10344 } 10345 10346 if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; 10347 if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0; 10348 } 10349 } 10350 }; 10351 10352 const setTransition = duration => { 10353 const { 10354 transformEl 10355 } = swiper.params.coverflowEffect; 10356 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 10357 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration); 10358 }; 10359 10360 effectInit({ 10361 effect: 'coverflow', 10362 swiper, 10363 on, 10364 setTranslate, 10365 setTransition, 10366 perspective: () => true, 10367 overwriteParams: () => ({ 10368 watchSlidesProgress: true 10369 }) 10370 }); 10371} 10372 10373function EffectCreative(_ref) { 10374 let { 10375 swiper, 10376 extendParams, 10377 on 10378 } = _ref; 10379 extendParams({ 10380 creativeEffect: { 10381 transformEl: null, 10382 limitProgress: 1, 10383 shadowPerProgress: false, 10384 progressMultiplier: 1, 10385 perspective: true, 10386 prev: { 10387 translate: [0, 0, 0], 10388 rotate: [0, 0, 0], 10389 opacity: 1, 10390 scale: 1 10391 }, 10392 next: { 10393 translate: [0, 0, 0], 10394 rotate: [0, 0, 0], 10395 opacity: 1, 10396 scale: 1 10397 } 10398 } 10399 }); 10400 10401 const getTranslateValue = value => { 10402 if (typeof value === 'string') return value; 10403 return `${value}px`; 10404 }; 10405 10406 const setTranslate = () => { 10407 const { 10408 slides, 10409 $wrapperEl, 10410 slidesSizesGrid 10411 } = swiper; 10412 const params = swiper.params.creativeEffect; 10413 const { 10414 progressMultiplier: multiplier 10415 } = params; 10416 const isCenteredSlides = swiper.params.centeredSlides; 10417 10418 if (isCenteredSlides) { 10419 const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0; 10420 $wrapperEl.transform(`translateX(calc(50% - ${margin}px))`); 10421 } 10422 10423 for (let i = 0; i < slides.length; i += 1) { 10424 const $slideEl = slides.eq(i); 10425 const slideProgress = $slideEl[0].progress; 10426 const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress); 10427 let originalProgress = progress; 10428 10429 if (!isCenteredSlides) { 10430 originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress); 10431 } 10432 10433 const offset = $slideEl[0].swiperSlideOffset; 10434 const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0]; 10435 const r = [0, 0, 0]; 10436 let custom = false; 10437 10438 if (!swiper.isHorizontal()) { 10439 t[1] = t[0]; 10440 t[0] = 0; 10441 } 10442 10443 let data = { 10444 translate: [0, 0, 0], 10445 rotate: [0, 0, 0], 10446 scale: 1, 10447 opacity: 1 10448 }; 10449 10450 if (progress < 0) { 10451 data = params.next; 10452 custom = true; 10453 } else if (progress > 0) { 10454 data = params.prev; 10455 custom = true; 10456 } // set translate 10457 10458 10459 t.forEach((value, index) => { 10460 t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`; 10461 }); // set rotates 10462 10463 r.forEach((value, index) => { 10464 r[index] = data.rotate[index] * Math.abs(progress * multiplier); 10465 }); 10466 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length; 10467 const translateString = t.join(', '); 10468 const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`; 10469 const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`; 10470 const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier; 10471 const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows 10472 10473 if (custom && data.shadow || !custom) { 10474 let $shadowEl = $slideEl.children('.swiper-slide-shadow'); 10475 10476 if ($shadowEl.length === 0 && data.shadow) { 10477 $shadowEl = createShadow(params, $slideEl); 10478 } 10479 10480 if ($shadowEl.length) { 10481 const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress; 10482 $shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1); 10483 } 10484 } 10485 10486 const $targetEl = effectTarget(params, $slideEl); 10487 $targetEl.transform(transform).css({ 10488 opacity: opacityString 10489 }); 10490 10491 if (data.origin) { 10492 $targetEl.css('transform-origin', data.origin); 10493 } 10494 } 10495 }; 10496 10497 const setTransition = duration => { 10498 const { 10499 transformEl 10500 } = swiper.params.creativeEffect; 10501 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 10502 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration); 10503 effectVirtualTransitionEnd({ 10504 swiper, 10505 duration, 10506 transformEl, 10507 allSlides: true 10508 }); 10509 }; 10510 10511 effectInit({ 10512 effect: 'creative', 10513 swiper, 10514 on, 10515 setTranslate, 10516 setTransition, 10517 perspective: () => swiper.params.creativeEffect.perspective, 10518 overwriteParams: () => ({ 10519 watchSlidesProgress: true, 10520 virtualTranslate: !swiper.params.cssMode 10521 }) 10522 }); 10523} 10524 10525function EffectCards(_ref) { 10526 let { 10527 swiper, 10528 extendParams, 10529 on 10530 } = _ref; 10531 extendParams({ 10532 cardsEffect: { 10533 slideShadows: true, 10534 transformEl: null, 10535 rotate: true 10536 } 10537 }); 10538 10539 const setTranslate = () => { 10540 const { 10541 slides, 10542 activeIndex 10543 } = swiper; 10544 const params = swiper.params.cardsEffect; 10545 const { 10546 startTranslate, 10547 isTouched 10548 } = swiper.touchEventsData; 10549 const currentTranslate = swiper.translate; 10550 10551 for (let i = 0; i < slides.length; i += 1) { 10552 const $slideEl = slides.eq(i); 10553 const slideProgress = $slideEl[0].progress; 10554 const progress = Math.min(Math.max(slideProgress, -4), 4); 10555 let offset = $slideEl[0].swiperSlideOffset; 10556 10557 if (swiper.params.centeredSlides && !swiper.params.cssMode) { 10558 swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`); 10559 } 10560 10561 if (swiper.params.centeredSlides && swiper.params.cssMode) { 10562 offset -= slides[0].swiperSlideOffset; 10563 } 10564 10565 let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset; 10566 let tY = 0; 10567 const tZ = -100 * Math.abs(progress); 10568 let scale = 1; 10569 let rotate = -2 * progress; 10570 let tXAdd = 8 - Math.abs(progress) * 0.75; 10571 const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i; 10572 const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate; 10573 const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate; 10574 10575 if (isSwipeToNext || isSwipeToPrev) { 10576 const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5; 10577 rotate += -28 * progress * subProgress; 10578 scale += -0.5 * subProgress; 10579 tXAdd += 96 * subProgress; 10580 tY = `${-25 * subProgress * Math.abs(progress)}%`; 10581 } 10582 10583 if (progress < 0) { 10584 // next 10585 tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
10586 } else if (progress > 0) { 10587 // prev 10588 tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`; 10589 } else { 10590 tX = `${tX}px`; 10591 } 10592 10593 if (!swiper.isHorizontal()) { 10594 const prevY = tY; 10595 tY = tX; 10596 tX = prevY; 10597 } 10598 10599 const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`; 10600 const transform = ` 10601 translate3d(${tX}, ${tY}, ${tZ}px) 10602 rotateZ(${params.rotate ? rotate : 0}deg) 10603 scale(${scaleString}) 10604 `; 10605 10606 if (params.slideShadows) { 10607 // Set shadows 10608 let $shadowEl = $slideEl.find('.swiper-slide-shadow'); 10609 10610 if ($shadowEl.length === 0) { 10611 $shadowEl = createShadow(params, $slideEl); 10612 } 10613 10614 if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1); 10615 } 10616 10617 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length; 10618 const $targetEl = effectTarget(params, $slideEl); 10619 $targetEl.transform(transform); 10620 } 10621 }; 10622 10623 const setTransition = duration => { 10624 const { 10625 transformEl 10626 } = swiper.params.cardsEffect; 10627 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides; 10628 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration); 10629 effectVirtualTransitionEnd({ 10630 swiper, 10631 duration, 10632 transformEl 10633 }); 10634 }; 10635 10636 effectInit({ 10637 effect: 'cards', 10638 swiper, 10639 on, 10640 setTranslate, 10641 setTransition, 10642 perspective: () => true, 10643 overwriteParams: () => ({ 10644 watchSlidesProgress: true, 10645 virtualTranslate: !swiper.params.cssMode 10646 }) 10647 }); 10648} 10649 10650// Swiper Class 10651const modules = [Virtual, Keyboard, Mousewheel, Navigation, Pagination, Scrollbar, Parallax, Zoom, Lazy, Controller, A11y, History, HashNavigation, Autoplay, Thumb, freeMode, Grid, Manipulation, EffectFade, EffectCube, EffectFlip, EffectCoverflow, EffectCreative, EffectCards]; 10652Swiper.use(modules); 10653 10654export { Swiper, Swiper as default }; 10655//# sourceMappingURL=swiper-bundle.esm.browser.js.map
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.