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