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