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