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