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