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