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