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