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