1/** 2 * Swiper 4.0.6 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 13, 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) * slidesNumber
1385EvenToRows; 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) {
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 (touches.currentY < touches.startY && swiper.translate <= swiper.maxTranslate()) || 2470 (touches.currentY > touches.startY && swiper.translate >= swiper.minTranslate()) 2471 ) { 2472 return; 2473 } 2474 } else if ( 2475 (touches.currentX < touches.startX && swiper.translate <= swiper.maxTranslate()) || 2476 (touches.currentX > touches.startX && swiper.translate >= swiper.minTranslate()) 2477 ) { 2478 return; 2479 } 2480 } 2481 if (data.isTouchEvent && doc.activeElement) { 2482 if (e.target === doc.activeElement && $$1(e.target).is(data.formElements)) { 2483 data.isMoved = true; 2484 swiper.allowClick = false; 2485 return; 2486 } 2487 } 2488 if (data.allowTouchCallbacks) { 2489 swiper.emit('touchMove', e); 2490 } 2491 if (e.targetTouches && e.targetTouches.length > 1) { return; } 2492 2493 touches.currentX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 2494 touches.currentY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 2495 2496 var diffX = touches.currentX - touches.startX; 2497 var diffY = touches.currentY - touches.startY; 2498 2499 if (typeof data.isScrolling === 'undefined') { 2500 var touchAngle; 2501 if ((swiper.isHorizontal() && touches.currentY === touches.startY) || (swiper.isVertical() && touches.currentX === touches.startX)) { 2502 data.isScrolling = false; 2503 } else { 2504 // eslint-disable-next-line 2505 if ((diffX * diffX) + (diffY * diffY) >= 25) { 2506 touchAngle = (Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180) / Math.PI; 2507 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : (90 - touchAngle > params.touchAngle); 2508 } 2509 } 2510 } 2511 if (data.isScrolling) { 2512 swiper.emit('touchMoveOpposite', e); 2513 } 2514 if (typeof startMoving === 'undefined') { 2515 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { 2516 data.startMoving = true; 2517 } 2518 } 2519 if (!data.isTouched) { return; } 2520 if (data.isScrolling) { 2521 data.isTouched = false; 2522 return; 2523 } 2524 if (!data.startMoving) { 2525 return; 2526 } 2527 swiper.allowClick = false; 2528 e.preventDefault(); 2529 if (params.touchMoveStopPropagation && !params.nested) { 2530 e.stopPropagation(); 2531 } 2532 2533 if (!data.isMoved) { 2534 if (params.loop) { 2535 swiper.loopFix(); 2536 } 2537 data.startTranslate = swiper.getTranslate(); 2538 swiper.setTransition(0); 2539 if (swiper.animating) { 2540 swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); 2541 } 2542 data.allowMomentumBounce = false; 2543 // Grab Cursor 2544 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 2545 swiper.setGrabCursor(true); 2546 } 2547 swiper.emit('sliderFirstMove', e); 2548 } 2549 swiper.emit('sliderMove', e); 2550 data.isMoved = true; 2551 2552 var diff = swiper.isHorizontal() ? diffX : diffY; 2553 touches.diff = diff; 2554 2555 diff *= params.touchRatio; 2556 if (rtl) { diff = -diff; } 2557 2558 swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; 2559 data.currentTranslate = diff + data.startTranslate; 2560 2561 var disableParentSwiper = true; 2562 var resistanceRatio = params.resistanceRatio; 2563 if (params.touchReleaseOnEdges) { 2564 resistanceRatio = 0; 2565 } 2566 if ((diff > 0 && data.currentTranslate > swiper.minTranslate())) { 2567 disableParentSwiper = false;
2568 if (params.resistance) { data.currentTranslate = (swiper.minTranslate() - 1) + (Math.pow( (-swiper.minTranslate() + data.startTranslate + diff), resistanceRatio )); } 2569 } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { 2570 disableParentSwiper = false; 2571 if (params.resistance) { data.currentTranslate = (swiper.maxTranslate() + 1) - (Math.pow( (swiper.maxTranslate() - data.startTranslate - diff), resistanceRatio )); } 2572 } 2573 2574 if (disableParentSwiper) { 2575 e.preventedByNestedSwiper = true; 2576 } 2577 2578 // Directions locks 2579 if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { 2580 data.currentTranslate = data.startTranslate; 2581 } 2582 if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { 2583 data.currentTranslate = data.startTranslate; 2584 } 2585 2586 2587 // Threshold 2588 if (params.threshold > 0) { 2589 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { 2590 if (!data.allowThresholdMove) { 2591 data.allowThresholdMove = true; 2592 touches.startX = touches.currentX; 2593 touches.startY = touches.currentY; 2594 data.currentTranslate = data.startTranslate; 2595 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; 2596 return; 2597 } 2598 } else { 2599 data.currentTranslate = data.startTranslate; 2600 return; 2601 } 2602 } 2603 2604 if (!params.followFinger) { return; } 2605 2606 // Update active index in free mode 2607 if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) { 2608 swiper.updateActiveIndex(); 2609 swiper.updateSlidesClasses(); 2610 } 2611 if (params.freeMode) { 2612 // Velocity 2613 if (data.velocities.length === 0) { 2614 data.velocities.push({ 2615 position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], 2616 time: data.touchStartTime, 2617 }); 2618 } 2619 data.velocities.push({ 2620 position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], 2621 time: Utils.now(), 2622 }); 2623 } 2624 // Update progress 2625 swiper.updateProgress(data.currentTranslate); 2626 // Update translate 2627 swiper.setTranslate(data.currentTranslate); 2628}; 2629 2630var onTouchEnd = function (event) { 2631 var swiper = this; 2632 var data = swiper.touchEventsData; 2633 2634 var params = swiper.params; 2635 var touches = swiper.touches; 2636 var rtl = swiper.rtl; 2637 var $wrapperEl = swiper.$wrapperEl; 2638 var slidesGrid = swiper.slidesGrid; 2639 var snapGrid = swiper.snapGrid; 2640 var e = event; 2641 if (e.originalEvent) { e = e.originalEvent; } 2642 if (data.allowTouchCallbacks) { 2643 swiper.emit('touchEnd', e); 2644 } 2645 data.allowTouchCallbacks = false; 2646 if (!data.isTouched) { return; } 2647 // Return Grab Cursor 2648 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { 2649 swiper.setGrabCursor(false); 2650 } 2651 2652 // Time diff 2653 var touchEndTime = Utils.now(); 2654 var timeDiff = touchEndTime - data.touchStartTime; 2655 2656 // Tap, doubleTap, Click 2657 if (swiper.allowClick) { 2658 swiper.updateClickedSlide(e); 2659 swiper.emit('tap', e); 2660 if (timeDiff < 300 && (touchEndTime - data.lastClickTime) > 300) { 2661 if (data.clickTimeout) { clearTimeout(data.clickTimeout); } 2662 data.clickTimeout = Utils.nextTick(function () { 2663 if (!swiper || swiper.destroyed) { return; } 2664 swiper.emit('click', e); 2665 }, 300); 2666 } 2667 if (timeDiff < 300 && (touchEndTime - data.lastClickTime) < 300) { 2668 if (data.clickTimeout) { clearTimeout(data.clickTimeout); } 2669 swiper.emit('doubleTap', e); 2670 } 2671 } 2672 2673 data.lastClickTime = Utils.now(); 2674 Utils.nextTick(function () { 2675 if (!swiper.destroyed) { swiper.allowClick = true; } 2676 }); 2677 2678 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { 2679 data.isTouched = false; 2680 data.isMoved = false; 2681 return; 2682 } 2683 data.isTouched = false; 2684 data.isMoved = false; 2685 2686 var currentPos; 2687 if (params.followFinger) { 2688 currentPos = rtl ? swiper.translate : -swiper.translate; 2689 } else { 2690 currentPos = -data.currentTranslate; 2691 } 2692 if (params.freeMode) {
2693 if (currentPos < -swiper.minTranslate()) { 2694 swiper.slideTo(swiper.activeIndex); 2695 return; 2696 } else if (currentPos > -swiper.maxTranslate()) { 2697 if (swiper.slides.length < snapGrid.length) { 2698 swiper.slideTo(snapGrid.length - 1); 2699 } else { 2700 swiper.slideTo(swiper.slides.length - 1); 2701 } 2702 return; 2703 } 2704 2705 if (params.freeModeMomentum) { 2706 if (data.velocities.length > 1) { 2707 var lastMoveEvent = data.velocities.pop(); 2708 var velocityEvent = data.velocities.pop(); 2709 2710 var distance = lastMoveEvent.position - velocityEvent.position; 2711 var time = lastMoveEvent.time - velocityEvent.time; 2712 swiper.velocity = distance / time; 2713 swiper.velocity /= 2; 2714 if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) { 2715 swiper.velocity = 0; 2716 } 2717 // this implies that the user stopped moving a finger then released. 2718 // There would be no events with distance zero, so the last event is stale. 2719 if (time > 150 || (Utils.now() - lastMoveEvent.time) > 300) { 2720 swiper.velocity = 0; 2721 } 2722 } else { 2723 swiper.velocity = 0; 2724 } 2725 swiper.velocity *= params.freeModeMomentumVelocityRatio; 2726 2727 data.velocities.length = 0; 2728 var momentumDuration = 1000 * params.freeModeMomentumRatio; 2729 var momentumDistance = swiper.velocity * momentumDuration; 2730 2731 var newPosition = swiper.translate + momentumDistance; 2732 if (rtl) { newPosition = -newPosition; } 2733 var doBounce = false; 2734 var afterBouncePosition; 2735 var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio; 2736 if (newPosition < swiper.maxTranslate()) { 2737 if (params.freeModeMomentumBounce) { 2738 if (newPosition + swiper.maxTranslate() < -bounceAmount) { 2739 newPosition = swiper.maxTranslate() - bounceAmount; 2740 } 2741 afterBouncePosition = swiper.maxTranslate(); 2742 doBounce = true; 2743 data.allowMomentumBounce = true; 2744 } else { 2745 newPosition = swiper.maxTranslate(); 2746 } 2747 } else if (newPosition > swiper.minTranslate()) { 2748 if (params.freeModeMomentumBounce) { 2749 if (newPosition - swiper.minTranslate() > bounceAmount) { 2750 newPosition = swiper.minTranslate() + bounceAmount; 2751 } 2752 afterBouncePosition = swiper.minTranslate(); 2753 doBounce = true; 2754 data.allowMomentumBounce = true; 2755 } else { 2756 newPosition = swiper.minTranslate(); 2757 } 2758 } else if (params.freeModeSticky) { 2759 var nextSlide; 2760 for (var j = 0; j < snapGrid.length; j += 1) { 2761 if (snapGrid[j] > -newPosition) { 2762 nextSlide = j; 2763 break; 2764 } 2765 } 2766 if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { 2767 newPosition = snapGrid[nextSlide]; 2768 } else { 2769 newPosition = snapGrid[nextSlide - 1]; 2770 } 2771 newPosition = -newPosition; 2772 } 2773 // Fix duration 2774 if (swiper.velocity !== 0) { 2775 if (rtl) { 2776 momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); 2777 } else { 2778 momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); 2779 } 2780 } else if (params.freeModeSticky) { 2781 swiper.slideReset(); 2782 return; 2783 } 2784 2785 if (params.freeModeMomentumBounce && doBounce) { 2786 swiper.updateProgress(afterBouncePosition); 2787 swiper.setTransition(momentumDuration); 2788 swiper.setTranslate(newPosition); 2789 swiper.transitionStart(); 2790 swiper.animating = true; 2791 $wrapperEl.transitionEnd(function () { 2792 if (!swiper || swiper.destroyed || !data.allowMomentumBounce) { return; } 2793 swiper.emit('momentumBounce'); 2794 2795 swiper.setTransition(params.speed); 2796 swiper.setTranslate(afterBouncePosition); 2797 $wrapperEl.transitionEnd(function () { 2798 if (!swiper || swiper.destroyed) { return; } 2799 swiper.transitionEnd(); 2800 }); 2801 }); 2802 } else if (swiper.velocity) { 2803 swiper.updateProgress(newPosition); 2804 swiper.setTransition(momentumDuration); 2805 swiper.setTranslate(newPosition); 2806 swiper.transitionStart(); 2807 if (!swiper.animating) { 2808 swiper.animating = true; 2809 $wrapperEl.transitionEnd(function () { 2810 if (!swiper || swiper.destroyed) { return; } 2811 swiper.transitionEnd(); 2812 }); 2813 } 2814 } else { 2815 swiper.updateProgress(newPosition); 2816 } 2817 2818 swiper.updateActiveIndex(); 2819 swiper.updateSlidesClasses(); 2820 } 2821 if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) { 2822 swiper.updateProgress(); 2823 swiper.updateActiveIndex(); 2824 swiper.updateSlidesClasses(); 2825 } 2826 return; 2827 } 2828 2829 // Find current slide 2830 var stopIndex = 0; 2831 var groupSize = swiper.slidesSizesGrid[0]; 2832 for (var i = 0; i < slidesGrid.length; i += params.slidesPerGroup) { 2833 if (typeof slidesGrid[i + params.slidesPerGroup] !== 'undefined') { 2834 if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + params.slidesPerGroup]) { 2835 stopIndex = i; 2836 groupSize = slidesGrid[i + params.slidesPerGroup] - slidesGrid[i]; 2837 } 2838 } else if (currentPos >= slidesGrid[i]) { 2839 stopIndex = i; 2840 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; 2841 } 2842 } 2843 2844 // Find current slide size 2845 var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; 2846 2847 if (timeDiff > params.longSwipesMs) { 2848 // Long touches 2849 if (!params.longSwipes) { 2850 swiper.slideTo(swiper.activeIndex); 2851 return; 2852 } 2853 if (swiper.swipeDirection === 'next') { 2854 if (ratio >= params.longSwipesRatio) { swiper.slideTo(stopIndex + params.slidesPerGroup); } 2855 else { swiper.slideTo(stopIndex); } 2856 } 2857 if (swiper.swipeDirection === 'prev') { 2858 if (ratio > (1 - params.longSwipesRatio)) { swiper.slideTo(stopIndex + params.slidesPerGroup); } 2859 else { swiper.slideTo(stopIndex); } 2860 } 2861 } else { 2862 // Short swipes 2863 if (!params.shortSwipes) { 2864 swiper.slideTo(swiper.activeIndex); 2865 return; 2866 } 2867 if (swiper.swipeDirection === 'next') { 2868 swiper.slideTo(stopIndex + params.slidesPerGroup); 2869 } 2870 if (swiper.swipeDirection === 'prev') { 2871 swiper.slideTo(stopIndex); 2872 } 2873 } 2874}; 2875 2876var onResize = function () { 2877 var swiper = this; 2878 2879 var params = swiper.params; 2880 var el = swiper.el; 2881 var allowSlideNext = swiper.allowSlideNext; 2882 var allowSlidePrev = swiper.allowSlidePrev; 2883 2884 if (el && el.offsetWidth === 0) { return; } 2885
2886 // Breakpoints 2887 if (params.breakpoints) { 2888 swiper.setBreakpoint(); 2889 } 2890 2891 // Disable locks on resize 2892 swiper.allowSlideNext = true; 2893 swiper.allowSlidePrev = true; 2894 2895 swiper.updateSize(); 2896 swiper.updateSlides(); 2897 2898 if (params.freeMode) { 2899 var newTranslate = Math.min(Math.max(swiper.translate, swiper.maxTranslate()), swiper.minTranslate()); 2900 swiper.setTranslate(newTranslate); 2901 swiper.updateActiveIndex(); 2902 swiper.updateSlidesClasses(); 2903 2904 if (params.autoHeight) { 2905 swiper.updateAutoHeight(); 2906 } 2907 } else { 2908 swiper.updateSlidesClasses(); 2909 if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 2910 swiper.slideTo(swiper.slides.length - 1, 0, false, true); 2911 } else { 2912 swiper.slideTo(swiper.activeIndex, 0, false, true); 2913 } 2914 } 2915 // Return locks after resize 2916 swiper.allowSlidePrev = allowSlidePrev; 2917 swiper.allowSlideNext = allowSlideNext; 2918}; 2919 2920var onClick = function (e) { 2921 var swiper = this; 2922 if (!swiper.allowClick) { 2923 if (swiper.params.preventClicks) { e.preventDefault(); } 2924 if (swiper.params.preventClicksPropagation && swiper.animating) { 2925 e.stopPropagation(); 2926 e.stopImmediatePropagation(); 2927 } 2928 } 2929}; 2930 2931function attachEvents() { 2932 var swiper = this; 2933 2934 var params = swiper.params; 2935 var touchEvents = swiper.touchEvents; 2936 var el = swiper.el; 2937 var wrapperEl = swiper.wrapperEl; 2938 2939 { 2940 swiper.onTouchStart = onTouchStart.bind(swiper); 2941 swiper.onTouchMove = onTouchMove.bind(swiper); 2942 swiper.onTouchEnd = onTouchEnd.bind(swiper); 2943 } 2944 2945 swiper.onClick = onClick.bind(swiper); 2946 2947 var target = params.touchEventsTarget === 'container' ? el : wrapperEl; 2948 var capture = !!params.nested; 2949 2950 // Touch Events 2951 { 2952 if (Browser.ie) { 2953 target.addEventListener(touchEvents.start, swiper.onTouchStart, false); 2954 (Support.touch ? target : doc).addEventListener(touchEvents.move, swiper.onTouchMove, capture); 2955 (Support.touch ? target : doc).addEventListener(touchEvents.end, swiper.onTouchEnd, false); 2956 } else { 2957 if (Support.touch) { 2958 var passiveListener = touchEvents.start === 'touchstart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 2959 target.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); 2960 target.addEventListener(touchEvents.move, swiper.onTouchMove, Support.passiveListener ? { passive: false, capture: capture } : capture); 2961 target.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); 2962 } 2963 if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { 2964 target.addEventListener('mousedown', swiper.onTouchStart, false); 2965 doc.addEventListener('mousemove', swiper.onTouchMove, capture); 2966 doc.addEventListener('mouseup', swiper.onTouchEnd, false); 2967 } 2968 } 2969 // Prevent Links Clicks 2970 if (params.preventClicks || params.preventClicksPropagation) { 2971 target.addEventListener('click', swiper.onClick, true); 2972 } 2973 } 2974 2975 // Resize handler 2976 swiper.on('resize observerUpdate', onResize); 2977} 2978 2979function detachEvents() { 2980 var swiper = this; 2981 2982 var params = swiper.params; 2983 var touchEvents = swiper.touchEvents; 2984 var el = swiper.el; 2985 var wrapperEl = swiper.wrapperEl; 2986 2987 var target = params.touchEventsTarget === 'container' ? el : wrapperEl; 2988 var capture = !!params.nested; 2989 2990 // Touch Events 2991 { 2992 if (Browser.ie) { 2993 target.removeEventListener(touchEvents.start, swiper.onTouchStart, false); 2994 (Support.touch ? target : doc).removeEventListener(touchEvents.move, swiper.onTouchMove, capture); 2995 (Support.touch ? target : doc).removeEventListener(touchEvents.end, swiper.onTouchEnd, false); 2996 } else { 2997 if (Support.touch) { 2998 var passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; 2999 target.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); 3000 target.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); 3001 target.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); 3002 } 3003 if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { 3004 target.removeEventListener('mousedown', swiper.onTouchStart, false); 3005 doc.removeEventListener('mousemove', swiper.onTouchMove, capture); 3006 doc.removeEventListener('mouseup', swiper.onTouchEnd, false); 3007 } 3008 } 3009 // Prevent Links Clicks 3010 if (params.preventClicks || params.preventClicksPropagation) { 3011 target.removeEventListener('click', swiper.onClick, true); 3012 } 3013 } 3014 3015 // Resize handler 3016 swiper.off('resize observerUpdate', onResize); 3017} 3018 3019var events = { 3020 attachEvents: attachEvents, 3021 detachEvents: detachEvents, 3022}; 3023 3024var setBreakpoint = function () { 3025 var swiper = this; 3026 var activeIndex = swiper.activeIndex; 3027 var loopedSlides = swiper.loopedSlides; if ( loopedSlides === void 0 ) loopedSlides = 0; 3028 var params = swiper.params; 3029 var breakpoints = params.breakpoints; 3030 if (!breakpoints || (breakpoints && Object.keys(breakpoints).length === 0)) { return; } 3031 // Set breakpoint for window width and update parameters
3032 var breakpoint = swiper.getBreakpoint(breakpoints); 3033 if (breakpoint && swiper.currentBreakpoint !== breakpoint) { 3034 var breakPointsParams = breakpoint in breakpoints ? breakpoints[breakpoint] : swiper.originalParams; 3035 var needsReLoop = params.loop && (breakPointsParams.slidesPerView !== params.slidesPerView); 3036 3037 Utils.extend(swiper.params, breakPointsParams); 3038 3039 Utils.extend(swiper, { 3040 allowTouchMove: swiper.params.allowTouchMove, 3041 allowSlideNext: swiper.params.allowSlideNext, 3042 allowSlidePrev: swiper.params.allowSlidePrev, 3043 }); 3044 3045 swiper.currentBreakpoint = breakpoint; 3046 3047 if (needsReLoop) { 3048 var oldIndex = activeIndex - loopedSlides; 3049 swiper.loopDestroy(); 3050 swiper.loopCreate(); 3051 swiper.updateSlides(); 3052 swiper.slideTo(oldIndex + loopedSlides, 0, false); 3053 } 3054 swiper.emit('breakpoint', breakPointsParams); 3055 } 3056}; 3057 3058var getBreakpoint = function (breakpoints) { 3059 // Get breakpoint for window width 3060 if (!breakpoints) { return undefined; } 3061 var breakpoint = false; 3062 var points = []; 3063 Object.keys(breakpoints).forEach(function (point) { 3064 points.push(point); 3065 }); 3066 points.sort(function (a, b) { return parseInt(a, 10) > parseInt(b, 10); }); 3067 for (var i = 0; i < points.length; i += 1) { 3068 var point = points[i]; 3069 if (point >= win.innerWidth && !breakpoint) { 3070 breakpoint = point; 3071 } 3072 } 3073 return breakpoint || 'max'; 3074}; 3075 3076var breakpoints = { setBreakpoint: setBreakpoint, getBreakpoint: getBreakpoint }; 3077 3078var addClasses = function () { 3079 var swiper = this; 3080 var classNames = swiper.classNames; 3081 var params = swiper.params; 3082 var rtl = swiper.rtl; 3083 var $el = swiper.$el; 3084 var suffixes = []; 3085 3086 suffixes.push(params.direction); 3087 3088 if (params.freeMode) { 3089 suffixes.push('free-mode'); 3090 } 3091 if (!Support.flexbox) { 3092 suffixes.push('no-flexbox'); 3093 } 3094 if (params.autoHeight) { 3095 suffixes.push('autoheight'); 3096 } 3097 if (rtl) { 3098 suffixes.push('rtl'); 3099 } 3100 if (params.slidesPerColumn > 1) { 3101 suffixes.push('multirow'); 3102 } 3103 if (Device.android) { 3104 suffixes.push('android'); 3105 } 3106 if (Device.ios) { 3107 suffixes.push('ios'); 3108 } 3109 // WP8 Touch Events Fix 3110 if (win.navigator.pointerEnabled || win.navigator.msPointerEnabled) { 3111 suffixes.push(("wp8-" + (params.direction))); 3112 } 3113 3114 suffixes.forEach(function (suffix) { 3115 classNames.push(params.containerModifierClass + suffix); 3116 }); 3117 3118 $el.addClass(classNames.join(' ')); 3119}; 3120 3121var removeClasses = function () { 3122 var swiper = this; 3123 var $el = swiper.$el; 3124 var classNames = swiper.classNames; 3125 3126 $el.removeClass(classNames.join(' ')); 3127}; 3128 3129var classes = { addClasses: addClasses, removeClasses: removeClasses }; 3130 3131var loadImage = function (imageEl, src, srcset, sizes, checkForComplete, callback) { 3132 var image; 3133 function onReady() { 3134 if (callback) { callback(); } 3135 } 3136 if (!imageEl.complete || !checkForComplete) { 3137 if (src) { 3138 image = new win.Image(); 3139 image.onload = onReady; 3140 image.onerror = onReady; 3141 if (sizes) { 3142 image.sizes = sizes; 3143 } 3144 if (srcset) { 3145 image.srcset = srcset; 3146 } 3147 if (src) { 3148 image.src = src; 3149 } 3150 } else { 3151 onReady(); 3152 } 3153 } else { 3154 // image already loaded... 3155 onReady(); 3156 } 3157}; 3158 3159var preloadImages = function () { 3160 var swiper = this; 3161 swiper.imagesToLoad = swiper.$el.find('img'); 3162 function onReady() { 3163 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) { return; } 3164 if (swiper.imagesLoaded !== undefined) { swiper.imagesLoaded += 1; } 3165 if (swiper.imagesLoaded === swiper.imagesToLoad.length) { 3166 if (swiper.params.updateOnImagesReady) { swiper.update(); } 3167 swiper.emit('imagesReady'); 3168 } 3169 } 3170 for (var i = 0; i < swiper.imagesToLoad.length; i += 1) { 3171 var imageEl = swiper.imagesToLoad[i]; 3172 swiper.loadImage( 3173 imageEl, 3174 imageEl.currentSrc || imageEl.getAttribute('src'), 3175 imageEl.srcset || imageEl.getAttribute('srcset'), 3176 imageEl.sizes || imageEl.getAttribute('sizes'), 3177 true, 3178 onReady 3179 ); 3180 } 3181}; 3182 3183var images = { 3184 loadImage: loadImage, 3185 preloadImages: preloadImages, 3186}; 3187 3188var defaults = { 3189 init: true, 3190 direction: 'horizontal', 3191 touchEventsTarget: 'container', 3192 initialSlide: 0, 3193 speed: 300, 3194 3195 // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView). 3196 iOSEdgeSwipeDetection: false, 3197 iOSEdgeSwipeThreshold: 20, 3198 3199 // Free mode 3200 freeMode: false, 3201 freeModeMomentum: true, 3202 freeModeMomentumRatio: 1, 3203 freeModeMomentumBounce: true, 3204 freeModeMomentumBounceRatio: 1, 3205 freeModeMomentumVelocityRatio: 1,
3206 freeModeSticky: false, 3207 freeModeMinimumVelocity: 0.02, 3208 3209 // Autoheight 3210 autoHeight: false, 3211 3212 // Set wrapper width 3213 setWrapperSize: false, 3214 3215 // Virtual Translate 3216 virtualTranslate: false, 3217 3218 // Effects 3219 effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' 3220 3221 // Breakpoints 3222 breakpoints: undefined, 3223 3224 // Slides grid 3225 spaceBetween: 0, 3226 slidesPerView: 1, 3227 slidesPerColumn: 1, 3228 slidesPerColumnFill: 'column', 3229 slidesPerGroup: 1, 3230 centeredSlides: false, 3231 slidesOffsetBefore: 0, // in px 3232 slidesOffsetAfter: 0, // in px 3233 normalizeSlideIndex: true, 3234 3235 // Round length 3236 roundLengths: false, 3237 3238 // Touches 3239 touchRatio: 1, 3240 touchAngle: 45, 3241 simulateTouch: true, 3242 shortSwipes: true, 3243 longSwipes: true, 3244 longSwipesRatio: 0.5, 3245 longSwipesMs: 300, 3246 followFinger: true, 3247 allowTouchMove: true, 3248 threshold: 0, 3249 touchMoveStopPropagation: true, 3250 touchReleaseOnEdges: false, 3251 3252 // Unique Navigation Elements 3253 uniqueNavElements: true, 3254 3255 // Resistance 3256 resistance: true, 3257 resistanceRatio: 0.85, 3258 3259 // Progress 3260 watchSlidesProgress: false, 3261 watchSlidesVisibility: false, 3262 3263 // Cursor 3264 grabCursor: false, 3265 3266 // Clicks 3267 preventClicks: true, 3268 preventClicksPropagation: true, 3269 slideToClickedSlide: false, 3270 3271 // Images 3272 preloadImages: true, 3273 updateOnImagesReady: true, 3274 3275 // loop 3276 loop: false, 3277 loopAdditionalSlides: 0, 3278 loopedSlides: null, 3279 loopFillGroupWithBlank: false, 3280 3281 // Swiping/no swiping 3282 allowSlidePrev: true, 3283 allowSlideNext: true, 3284 swipeHandler: null, // '.swipe-handler', 3285 noSwiping: true, 3286 noSwipingClass: 'swiper-no-swiping', 3287 3288 // Passive Listeners 3289 passiveListeners: true, 3290 3291 // NS 3292 containerModifierClass: 'swiper-container-', // NEW 3293 slideClass: 'swiper-slide', 3294 slideBlankClass: 'swiper-slide-invisible-blank', 3295 slideActiveClass: 'swiper-slide-active', 3296 slideDuplicateActiveClass: 'swiper-slide-duplicate-active', 3297 slideVisibleClass: 'swiper-slide-visible', 3298 slideDuplicateClass: 'swiper-slide-duplicate', 3299 slideNextClass: 'swiper-slide-next', 3300 slideDuplicateNextClass: 'swiper-slide-duplicate-next', 3301 slidePrevClass: 'swiper-slide-prev', 3302 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', 3303 wrapperClass: 'swiper-wrapper', 3304 3305 // Callbacks 3306 runCallbacksOnInit: true, 3307}; 3308 3309var prototypes = { 3310 update: update, 3311 translate: translate, 3312 transition: transition$1, 3313 slide: slide, 3314 loop: loop, 3315 grabCursor: grabCursor, 3316 manipulation: manipulation, 3317 events: events, 3318 breakpoints: breakpoints, 3319 classes: classes, 3320 images: images, 3321}; 3322 3323var extendedDefaults = {}; 3324 3325var Swiper$1 = (function (SwiperClass$$1) { 3326 function Swiper() { 3327 var args = [], len = arguments.length; 3328 while ( len-- ) args[ len ] = arguments[ len ]; 3329 3330 var el; 3331 var params; 3332 if (args.length === 1 && args[0].constructor && args[0].constructor === Object) { 3333 params = args[0]; 3334 } else { 3335 var assign; 3336 (assign = args, el = assign[0], params = assign[1]); 3337 } 3338 if (!params) { params = {}; } 3339 3340 params = Utils.extend({}, params); 3341 if (el && !params.el) { params.el = el; } 3342 3343 SwiperClass$$1.call(this, params); 3344 3345 Object.keys(prototypes).forEach(function (prototypeGroup) { 3346 Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) { 3347 if (!Swiper.prototype[protoMethod]) { 3348 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; 3349 } 3350 }); 3351 }); 3352 3353 // Swiper Instance 3354 var swiper = this; 3355 3356 Object.keys(swiper.modules).forEach(function (moduleName) { 3357 var module = swiper.modules[moduleName]; 3358 if (module.params) { 3359 var moduleParamName = Object.keys(module.params)[0]; 3360 var moduleParams = module.params[moduleParamName]; 3361 if (typeof moduleParams !== 'object') { return; } 3362 if (!(moduleParamName in params && 'enabled' in moduleParams)) { return; } 3363 if (params[moduleParamName] === true) { 3364 params[moduleParamName] = { enabled: true }; 3365 } 3366 if ( 3367 typeof params[moduleParamName] === 'object' && 3368 !('enabled' in params[moduleParamName]) 3369 ) { 3370 params[moduleParamName].enabled = true; 3371 } 3372 if (!params[moduleParamName]) { params[moduleParamName] = { enabled: false }; } 3373 } 3374 }); 3375 3376 // Extend defaults with modules params 3377 var swiperParams = Utils.extend({}, defaults); 3378 swiper.useModulesParams(swiperParams); 3379 3380 // Extend defaults with passed params 3381 swiper.params = Utils.extend({}, swiperParams, extendedDefaults, params); 3382 swiper.originalParams = Utils.extend({}, swiper.params); 3383 swiper.passedParams = Utils.extend({}, params); 3384 3385 // Find el 3386 var $el = $$1(swiper.params.el); 3387 el = $el[0]; 3388 3389 if (!el) { 3390 return undefined; 3391 } 3392 3393 if ($el.length > 1) { 3394 var swipers = []; 3395 $el.each(function (index, containerEl) { 3396 var newParams = Utils.extend({}, params, { el: containerEl }); 3397 swipers.push(new Swiper(newParams)); 3398 }); 3399 return swipers; 3400 } 3401 3402 el.swiper = swiper; 3403 $el.data('swiper', swiper); 3404 3405 // Find Wrapper 3406 var $wrapperEl = $el.children(("." + (swiper.params.wrapperClass))); 3407 3408 // Extend Swiper 3409 Utils.extend(swiper, { 3410 $el: $el, 3411 el: el, 3412 $wrapperEl: $wrapperEl, 3413 wrapperEl: $wrapperEl[0], 3414 3415 // Classes 3416 classNames: [], 3417 3418 // Slides 3419 slides: $$1(), 3420 slidesGrid: [], 3421 snapGrid: [], 3422 slidesSizesGrid: [], 3423 3424 // isDirection 3425 isHorizontal: function isHorizontal() { 3426 return swiper.params.direction === 'horizontal'; 3427 }, 3428 isVertical: function isVertical() { 3429 return swiper.params.direction === 'vertical'; 3430 }, 3431 // RTL 3432 rtl: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), 3433 wrongRTL: $wrapperEl.css('display') === '-webkit-box', 3434 3435 // Indexes 3436 activeIndex: 0, 3437 realIndex: 0, 3438 3439 // 3440 isBeginning: true, 3441 isEnd: false, 3442 3443 // Props 3444 translate: 0, 3445 progress: 0, 3446 velocity: 0, 3447 animating: false, 3448 3449 // Locks 3450 allowSlideNext: swiper.params.allowSlideNext, 3451 allowSlidePrev: swiper.params.allowSlidePrev, 3452 3453 // Touch Events 3454 touchEvents: (function touchEvents() { 3455 var touch = ['touchstart', 'touchmove', 'touchend']; 3456 var desktop = ['mousedown', 'mousemove', 'mouseup']; 3457 if (win.navigator.pointerEnabled) { 3458 desktop = ['pointerdown', 'pointermove', 'pointerup']; 3459 } else if (win.navigator.msPointerEnabled) { 3460 desktop = ['MSPointerDown', 'MsPointerMove', 'MsPointerUp']; 3461 } 3462 3463 return { 3464 start: Support.touch || !swiper.params.simulateTouch ? touch[0] : desktop[0],
3465 move: Support.touch || !swiper.params.simulateTouch ? touch[1] : desktop[1], 3466 end: Support.touch || !swiper.params.simulateTouch ? touch[2] : desktop[2], 3467 }; 3468 }()), 3469 touchEventsData: { 3470 isTouched: undefined, 3471 isMoved: undefined, 3472 allowTouchCallbacks: undefined, 3473 touchStartTime: undefined, 3474 isScrolling: undefined, 3475 currentTranslate: undefined, 3476 startTranslate: undefined, 3477 allowThresholdMove: undefined, 3478 // Form elements to match 3479 formElements: 'input, select, option, textarea, button, video', 3480 // Last click time 3481 lastClickTime: Utils.now(), 3482 clickTimeout: undefined, 3483 // Velocities 3484 velocities: [], 3485 allowMomentumBounce: undefined, 3486 isTouchEvent: undefined, 3487 startMoving: undefined, 3488 }, 3489 3490 // Clicks 3491 allowClick: true, 3492 3493 // Touches 3494 allowTouchMove: swiper.params.allowTouchMove, 3495 3496 touches: { 3497 startX: 0, 3498 startY: 0, 3499 currentX: 0, 3500 currentY: 0, 3501 diff: 0, 3502 }, 3503 3504 // Images 3505 imagesToLoad: [], 3506 imagesLoaded: 0, 3507 3508 }); 3509 3510 // Install Modules 3511 swiper.useModules(); 3512 3513 // Init 3514 if (swiper.params.init) { 3515 swiper.init(); 3516 } 3517 3518 // Return app instance 3519 return swiper; 3520 } 3521 3522 if ( SwiperClass$$1 ) Swiper.__proto__ = SwiperClass$$1; 3523 Swiper.prototype = Object.create( SwiperClass$$1 && SwiperClass$$1.prototype ); 3524 Swiper.prototype.constructor = Swiper; 3525 3526 var staticAccessors = { extendedDefaults: {},defaults: {},Class: {},$: {} }; 3527 Swiper.prototype.slidesPerViewDynamic = function slidesPerViewDynamic () { 3528 var swiper = this; 3529 var params = swiper.params; 3530 var slides = swiper.slides; 3531 var slidesGrid = swiper.slidesGrid; 3532 var swiperSize = swiper.size; 3533 var activeIndex = swiper.activeIndex; 3534 var spv = 1; 3535 if (params.centeredSlides) { 3536 var slideSize = slides[activeIndex].swiperSlideSize; 3537 var breakLoop; 3538 for (var i = activeIndex + 1; i < slides.length; i += 1) { 3539 if (slides[i] && !breakLoop) { 3540 slideSize += slides[i].swiperSlideSize; 3541 spv += 1; 3542 if (slideSize > swiperSize) { breakLoop = true; } 3543 } 3544 } 3545 for (var i$1 = activeIndex - 1; i$1 >= 0; i$1 -= 1) { 3546 if (slides[i$1] && !breakLoop) { 3547 slideSize += slides[i$1].swiperSlideSize; 3548 spv += 1; 3549 if (slideSize > swiperSize) { breakLoop = true; } 3550 } 3551 } 3552 } else { 3553 for (var i$2 = activeIndex + 1; i$2 < slides.length; i$2 += 1) { 3554 if (slidesGrid[i$2] - slidesGrid[activeIndex] < swiperSize) { 3555 spv += 1; 3556 } 3557 } 3558 } 3559 return spv; 3560 }; 3561 Swiper.prototype.update = function update$$1 () { 3562 var swiper = this; 3563 if (!swiper || swiper.destroyed) { return; } 3564 swiper.updateSize(); 3565 swiper.updateSlides(); 3566 swiper.updateProgress(); 3567 swiper.updateSlidesClasses(); 3568 3569 var newTranslate; 3570 function setTranslate() { 3571 newTranslate = Math.min(Math.max(swiper.translate, swiper.maxTranslate()), swiper.minTranslate()); 3572 swiper.setTranslate(newTranslate); 3573 swiper.updateActiveIndex(); 3574 swiper.updateSlidesClasses(); 3575 } 3576 var translated; 3577 if (swiper.params.freeMode) { 3578 setTranslate(); 3579 if (swiper.params.autoHeight) { 3580 swiper.updateAutoHeight(); 3581 } 3582 } else { 3583 if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { 3584 translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); 3585 } else { 3586 translated = swiper.slideTo(swiper.activeIndex, 0, false, true); 3587 } 3588 if (!translated) { 3589 setTranslate(); 3590 } 3591 } 3592 swiper.emit('update'); 3593 }; 3594 Swiper.prototype.init = function init () { 3595 var swiper = this; 3596 if (swiper.initialized) { return; } 3597 3598 swiper.emit('beforeInit'); 3599 3600 // Set breakpoint 3601 if (swiper.params.breakpoints) { 3602 swiper.setBreakpoint(); 3603 } 3604 3605 // Add Classes 3606 swiper.addClasses(); 3607 3608 // Create loop 3609 if (swiper.params.loop) { 3610 swiper.loopCreate(); 3611 } 3612 3613 // Update size 3614 swiper.updateSize(); 3615 3616 // Update slides 3617 swiper.updateSlides(); 3618 3619 // Set Grab Cursor 3620 if (swiper.params.grabCursor) {
3621 swiper.setGrabCursor(); 3622 } 3623 3624 if (swiper.params.preloadImages) { 3625 swiper.preloadImages(); 3626 } 3627 3628 // Slide To Initial Slide 3629 if (swiper.params.loop) { 3630 swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit); 3631 } else { 3632 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit); 3633 } 3634 3635 // Attach events 3636 swiper.attachEvents(); 3637 3638 // Init Flag 3639 swiper.initialized = true; 3640 3641 // Emit 3642 swiper.emit('init'); 3643 }; 3644 Swiper.prototype.destroy = function destroy (deleteInstance, cleanStyles) { 3645 if ( deleteInstance === void 0 ) deleteInstance = true; 3646 if ( cleanStyles === void 0 ) cleanStyles = true; 3647 3648 var swiper = this; 3649 var params = swiper.params; 3650 var $el = swiper.$el; 3651 var $wrapperEl = swiper.$wrapperEl; 3652 var slides = swiper.slides; 3653 swiper.emit('beforeDestroy'); 3654 3655 // Init Flag 3656 swiper.initialized = false; 3657 3658 // Detach events 3659 swiper.detachEvents(); 3660 3661 // Destroy loop 3662 if (params.loop) { 3663 swiper.loopDestroy(); 3664 } 3665 3666 // Cleanup styles 3667 if (cleanStyles) { 3668 swiper.removeClasses(); 3669 $el.removeAttr('style'); 3670 $wrapperEl.removeAttr('style'); 3671 if (slides && slides.length) { 3672 slides 3673 .removeClass([ 3674 params.slideVisibleClass, 3675 params.slideActiveClass, 3676 params.slideNextClass, 3677 params.slidePrevClass ].join(' ')) 3678 .removeAttr('style') 3679 .removeAttr('data-swiper-slide-index') 3680 .removeAttr('data-swiper-column') 3681 .removeAttr('data-swiper-row'); 3682 } 3683 } 3684 3685 swiper.emit('destroy'); 3686 3687 // Detach emitter events 3688 Object.keys(swiper.eventsListeners).forEach(function (eventName) { 3689 swiper.off(eventName); 3690 }); 3691 3692 if (deleteInstance !== false) { 3693 swiper.$el[0].swiper = null; 3694 swiper.$el.data('swiper', null); 3695 Utils.deleteProps(swiper); 3696 } 3697 swiper.destroyed = true; 3698 }; 3699 Swiper.extendDefaults = function extendDefaults (newDefaults) { 3700 Utils.extend(extendedDefaults, newDefaults); 3701 }; 3702 staticAccessors.extendedDefaults.get = function () { 3703 return extendedDefaults; 3704 }; 3705 staticAccessors.defaults.get = function () { 3706 return defaults; 3707 }; 3708 staticAccessors.Class.get = function () { 3709 return SwiperClass$$1; 3710 }; 3711 staticAccessors.$.get = function () { 3712 return $$1; 3713 }; 3714 3715 Object.defineProperties( Swiper, staticAccessors ); 3716 3717 return Swiper; 3718}(SwiperClass)); 3719 3720var Device$2 = { 3721 name: 'device', 3722 proto: { 3723 device: Device, 3724 }, 3725 static: { 3726 device: Device, 3727 }, 3728}; 3729 3730var Support$2 = { 3731 name: 'support', 3732 proto: { 3733 support: Support, 3734 }, 3735 static: { 3736 support: Support, 3737 }, 3738}; 3739 3740var Browser$2 = { 3741 name: 'browser', 3742 proto: { 3743 browser: Browser, 3744 }, 3745 static: { 3746 browser: Browser, 3747 }, 3748}; 3749 3750var Resize = { 3751 name: 'resize', 3752 create: function create() { 3753 var swiper = this; 3754 Utils.extend(swiper, { 3755 resize: { 3756 resizeHandler: function resizeHandler() { 3757 if (!swiper || swiper.destroyed || !swiper.initialized) { return; } 3758 swiper.emit('beforeResize'); 3759 swiper.emit('resize'); 3760 }, 3761 orientationChangeHandler: function orientationChangeHandler() { 3762 if (!swiper || swiper.destroyed || !swiper.initialized) { return; } 3763 swiper.emit('orientationchange'); 3764 }, 3765 }, 3766 }); 3767 }, 3768 on: { 3769 init: function init() { 3770 var swiper = this; 3771 // Emit resize 3772 win.addEventListener('resize', swiper.resize.resizeHandler); 3773 3774 // Emit orientationchange 3775 win.addEventListener('orientationchange', swiper.resize.orientationChangeHandler); 3776 }, 3777 destroy: function destroy() { 3778 var swiper = this; 3779 win.removeEventListener('resize', swiper.resize.resizeHandler); 3780 win.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler); 3781 }, 3782 }, 3783}; 3784 3785var Observer = { 3786 func: win.MutationObserver || win.WebkitMutationObserver, 3787 attach: function attach(target, options) { 3788 if ( options === void 0 ) options = {}; 3789 3790 var swiper = this; 3791 3792 var ObserverFunc = Observer.func; 3793 var observer = new ObserverFunc(function (mutations) { 3794 mutations.forEach(function (mutation) { 3795 swiper.emit('observerUpdate', mutation); 3796 }); 3797 }); 3798 3799 observer.observe(target, { 3800 attributes: typeof options.attributes === 'undefined' ? true : options.attributes, 3801 childList: typeof options.childList === 'undefined' ? true : options.childList, 3802 characterData: typeof options.characterData === 'undefined' ? true : options.characterData, 3803 }); 3804 3805 swiper.observer.observers.push(observer); 3806 },
3807 init: function init() { 3808 var swiper = this; 3809 if (!Support.observer || !swiper.params.observer) { return; } 3810 if (swiper.params.observeParents) { 3811 var containerParents = swiper.$el.parents(); 3812 for (var i = 0; i < containerParents.length; i += 1) { 3813 swiper.observer.attach(containerParents[i]); 3814 } 3815 } 3816 // Observe container 3817 swiper.observer.attach(swiper.$el[0], { childList: false }); 3818 3819 // Observe wrapper 3820 swiper.observer.attach(swiper.$wrapperEl[0], { attributes: false }); 3821 }, 3822 destroy: function destroy() { 3823 var swiper = this; 3824 swiper.observer.observers.forEach(function (observer) { 3825 observer.disconnect(); 3826 }); 3827 swiper.observer.observers = []; 3828 }, 3829}; 3830 3831var Observer$1 = { 3832 name: 'observer', 3833 params: { 3834 observer: false, 3835 observeParents: false, 3836 }, 3837 create: function create() { 3838 var swiper = this; 3839 Utils.extend(swiper, { 3840 observer: { 3841 init: Observer.init.bind(swiper), 3842 attach: Observer.attach.bind(swiper), 3843 destroy: Observer.destroy.bind(swiper), 3844 observers: [], 3845 }, 3846 }); 3847 }, 3848 on: { 3849 init: function init() { 3850 var swiper = this; 3851 swiper.observer.init(); 3852 }, 3853 destroy: function destroy() { 3854 var swiper = this; 3855 swiper.observer.destroy(); 3856 }, 3857 }, 3858}; 3859 3860var Virtual = { 3861 update: function update(force) { 3862 var swiper = this; 3863 var ref = swiper.params; 3864 var slidesPerView = ref.slidesPerView; 3865 var slidesPerGroup = ref.slidesPerGroup; 3866 var centeredSlides = ref.centeredSlides; 3867 var ref$1 = swiper.virtual; 3868 var previousFrom = ref$1.from; 3869 var previousTo = ref$1.to; 3870 var slides = ref$1.slides; 3871 var previousSlidesGrid = ref$1.slidesGrid; 3872 var renderSlide = ref$1.renderSlide; 3873 var previousOffset = ref$1.offset; 3874 swiper.updateActiveIndex(); 3875 var activeIndex = swiper.activeIndex || 0; 3876 3877 var offsetProp; 3878 if (swiper.rtl && swiper.isHorizontal()) { offsetProp = 'right'; } 3879 else { offsetProp = swiper.isHorizontal() ? 'left' : 'top'; } 3880 3881 var slidesAfter; 3882 var slidesBefore; 3883 if (centeredSlides) { 3884 slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup; 3885 slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup; 3886 } else { 3887 slidesAfter = slidesPerView + (slidesPerGroup - 1); 3888 slidesBefore = slidesPerGroup; 3889 } 3890 var from = Math.max((activeIndex || 0) - slidesBefore, 0); 3891 var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); 3892 var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); 3893 3894 Utils.extend(swiper.virtual, { 3895 from: from, 3896 to: to, 3897 offset: offset, 3898 slidesGrid: swiper.slidesGrid, 3899 }); 3900 3901 function onRendered() { 3902 swiper.updateSlides(); 3903 swiper.updateProgress(); 3904 swiper.updateSlidesClasses(); 3905 if (swiper.lazy && swiper.params.lazy.enabled) { 3906 swiper.lazy.load(); 3907 } 3908 } 3909 3910 if (previousFrom === from && previousTo === to && !force) { 3911 if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { 3912 swiper.slides.css(offsetProp, (offset + "px")); 3913 } 3914 swiper.updateProgress(); 3915 return; 3916 } 3917 if (swiper.params.virtual.renderExternal) { 3918 swiper.params.virtual.renderExternal.call(swiper, { 3919 offset: offset, 3920 from: from, 3921 to: to, 3922 slides: (function getSlides() { 3923 var slidesToRender = []; 3924 for (var i = from; i <= to; i += 1) { 3925 slidesToRender.push(slides[i]); 3926 } 3927 return slidesToRender; 3928 }()), 3929 }); 3930 onRendered(); 3931 return; 3932 } 3933 var prependIndexes = []; 3934 var appendIndexes = []; 3935 if (force) { 3936 swiper.$wrapperEl.find(("." + (swiper.params.slideClass))).remove(); 3937 } else { 3938 for (var i = previousFrom; i <= previousTo; i += 1) { 3939 if (i < from || i > to) { 3940 swiper.$wrapperEl.find(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + i + "\"]")).remove(); 3941 } 3942 } 3943 } 3944 for (var i$1 = 0; i$1 < slides.length; i$1 += 1) { 3945 if (i$1 >= from && i$1 <= to) { 3946 if (typeof previousTo === 'undefined' || force) { 3947 appendIndexes.push(i$1); 3948 } else { 3949 if (i$1 > previousTo) { appendIndexes.push(i$1); } 3950 if (i$1 < previousFrom) { prependIndexes.push(i$1); } 3951 } 3952 } 3953 }
3954 appendIndexes.forEach(function (index) { 3955 swiper.$wrapperEl.append(renderSlide(slides[index], index)); 3956 }); 3957 prependIndexes.sort(function (a, b) { return a < b; }).forEach(function (index) { 3958 swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); 3959 }); 3960 swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, (offset + "px")); 3961 onRendered(); 3962 }, 3963 renderSlide: function renderSlide(slide, index) { 3964 var swiper = this; 3965 var params = swiper.params.virtual; 3966 if (params.cache && swiper.virtual.cache[index]) { 3967 return swiper.virtual.cache[index]; 3968 } 3969 var $slideEl = params.renderSlide 3970 ? $$1(params.renderSlide.call(swiper, slide, index)) 3971 : $$1(("<div class=\"" + (swiper.params.slideClass) + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>")); 3972 if (!$slideEl.attr('data-swiper-slide-index')) { $slideEl.attr('data-swiper-slide-index', index); } 3973 if (params.cache) { swiper.virtual.cache[index] = $slideEl; } 3974 return $slideEl; 3975 }, 3976 appendSlide: function appendSlide(slide) { 3977 var swiper = this; 3978 swiper.virtual.slides.push(slide); 3979 swiper.virtual.update(true); 3980 }, 3981 prependSlide: function prependSlide(slide) { 3982 var swiper = this; 3983 swiper.virtual.slides.unshift(slide); 3984 if (swiper.params.virtual.cache) { 3985 var cache = swiper.virtual.cache; 3986 var newCache = {}; 3987 Object.keys(cache).forEach(function (cachedIndex) { 3988 newCache[cachedIndex + 1] = cache[cachedIndex]; 3989 }); 3990 swiper.virtual.cache = newCache; 3991 } 3992 swiper.virtual.update(true); 3993 swiper.slideNext(0); 3994 }, 3995}; 3996 3997var Virtual$1 = { 3998 name: 'virtual', 3999 params: { 4000 virtual: { 4001 enabled: false, 4002 slides: [], 4003 cache: true, 4004 renderSlide: null, 4005 renderExternal: null, 4006 }, 4007 }, 4008 create: function create() { 4009 var swiper = this; 4010 Utils.extend(swiper, { 4011 virtual: { 4012 update: Virtual.update.bind(swiper), 4013 appendSlide: Virtual.appendSlide.bind(swiper), 4014 prependSlide: Virtual.prependSlide.bind(swiper), 4015 renderSlide: Virtual.renderSlide.bind(swiper), 4016 slides: swiper.params.virtual.slides, 4017 cache: {}, 4018 }, 4019 }); 4020 }, 4021 on: { 4022 beforeInit: function beforeInit() { 4023 var swiper = this; 4024 if (!swiper.params.virtual.enabled) { return; } 4025 swiper.classNames.push(((swiper.params.containerModifierClass) + "virtual")); 4026 var overwriteParams = { 4027 watchSlidesProgress: true, 4028 }; 4029 Utils.extend(swiper.params, overwriteParams); 4030 Utils.extend(swiper.originalParams, overwriteParams); 4031
4032 swiper.virtual.update(); 4033 }, 4034 setTranslate: function setTranslate() { 4035 var swiper = this; 4036 if (!swiper.params.virtual.enabled) { return; } 4037 swiper.virtual.update(); 4038 }, 4039 }, 4040}; 4041 4042var Keyboard = { 4043 handle: function handle(event) { 4044 var swiper = this; 4045 var e = event; 4046 if (e.originalEvent) { e = e.originalEvent; } // jquery fix 4047 var kc = e.keyCode || e.charCode; 4048 // Directions locks 4049 if (!swiper.allowSlideNext && ((swiper.isHorizontal() && kc === 39) || (swiper.isVertical() && kc === 40))) { 4050 return false; 4051 } 4052 if (!swiper.allowSlidePrev && ((swiper.isHorizontal() && kc === 37) || (swiper.isVertical() && kc === 38))) { 4053 return false; 4054 } 4055 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { 4056 return undefined; 4057 } 4058 if (doc.activeElement && doc.activeElement.nodeName && (doc.activeElement.nodeName.toLowerCase() === 'input' || doc.activeElement.nodeName.toLowerCase() === 'textarea')) { 4059 return undefined; 4060 } 4061 if (kc === 37 || kc === 39 || kc === 38 || kc === 40) { 4062 var inView = false; 4063 // Check that swiper should be inside of visible area of window 4064 if (swiper.$el.parents(("." + (swiper.params.slideClass))).length > 0 && swiper.$el.parents(("." + (swiper.params.slideActiveClass))).length === 0) { 4065 return undefined; 4066 } 4067 var windowScroll = { 4068 left: win.pageXOffset, 4069 top: win.pageYOffset, 4070 }; 4071 var windowWidth = win.innerWidth; 4072 var windowHeight = win.innerHeight; 4073 var swiperOffset = swiper.$el.offset(); 4074 if (swiper.rtl) { swiperOffset.left -= swiper.$el[0].scrollLeft; } 4075 var swiperCoord = [ 4076 [swiperOffset.left, swiperOffset.top], 4077 [swiperOffset.left + swiper.width, swiperOffset.top], 4078 [swiperOffset.left, swiperOffset.top + swiper.height], 4079 [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height] ]; 4080 for (var i = 0; i < swiperCoord.length; i += 1) { 4081 var point = swiperCoord[i]; 4082 if ( 4083 point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth && 4084 point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight 4085 ) { 4086 inView = true; 4087 } 4088 } 4089 if (!inView) { return undefined; } 4090 } 4091 if (swiper.isHorizontal()) { 4092 if (kc === 37 || kc === 39) { 4093 if (e.preventDefault) { e.preventDefault(); } 4094 else { e.returnValue = false; } 4095 } 4096 if ((kc === 39 && !swiper.rtl) || (kc === 37 && swiper.rtl)) { swiper.slideNext(); } 4097 if ((kc === 37 && !swiper.rtl) || (kc === 39 && swiper.rtl)) { swiper.slidePrev(); } 4098 } else { 4099 if (kc === 38 || kc === 40) { 4100 if (e.preventDefault) { e.preventDefault(); } 4101 else { e.returnValue = false; } 4102 } 4103 if (kc === 40) { swiper.slideNext(); } 4104 if (kc === 38) { swiper.slidePrev(); } 4105 } 4106 swiper.emit('keyPress', kc); 4107 return undefined; 4108 }, 4109 enable: function enable() { 4110 var swiper = this; 4111 if (swiper.keyboard.enabled) { return; } 4112 $$1(doc).on('keydown', swiper.keyboard.handle); 4113 swiper.keyboard.enabled = true; 4114 }, 4115 disable: function disable() { 4116 var swiper = this; 4117 if (!swiper.keyboard.enabled) { return; } 4118 $$1(doc).off('keydown', swiper.keyboard.handle); 4119 swiper.keyboard.enabled = false; 4120 }, 4121}; 4122 4123var Keyboard$1 = { 4124 name: 'keyboard', 4125 params: { 4126 keyboard: { 4127 enabled: false, 4128 }, 4129 }, 4130 create: function create() { 4131 var swiper = this; 4132 Utils.extend(swiper, { 4133 keyboard: { 4134 enabled: false, 4135 enable: Keyboard.enable.bind(swiper), 4136 disable: Keyboard.disable.bind(swiper), 4137 handle: Keyboard.handle.bind(swiper), 4138 }, 4139 }); 4140 }, 4141 on: { 4142 init: function init() { 4143 var swiper = this; 4144 if (swiper.params.keyboard.enabled) { 4145 swiper.keyboard.enable(); 4146 } 4147 }, 4148 destroy: function destroy() { 4149 var swiper = this; 4150 if (swiper.keyboard.enabled) { 4151 swiper.keyboard.disable(); 4152 } 4153 }, 4154 }, 4155}; 4156 4157function isEventSupported() { 4158 var eventName = 'onwheel'; 4159 var isSupported = eventName in doc; 4160 4161 if (!isSupported) { 4162 var element = doc.createElement('div'); 4163 element.setAttribute(eventName, 'return;'); 4164 isSupported = typeof element[eventName] === 'function'; 4165 } 4166 4167 if (!isSupported && 4168 doc.implementation && 4169 doc.implementation.hasFeature && 4170 // always returns true in newer browsers as per the standard. 4171 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature 4172 doc.implementation.hasFeature('', '') !== true 4173 ) { 4174 // This is the only way to test support for the `wheel` event in IE9+. 4175 isSupported = doc.implementation.hasFeature('Events.wheel', '3.0'); 4176 } 4177 4178 return isSupported; 4179} 4180var Mousewheel = { 4181 lastScrollTime: Utils.now(), 4182 event: (function getEvent() { 4183 if (win.navigator.userAgent.indexOf('firefox') > -1) { return 'DOMMouseScroll'; } 4184 return isEventSupported() ? 'wheel' : 'mousewheel'; 4185 }()), 4186 normalize: function normalize(e) { 4187 // Reasonable defaults 4188 var PIXEL_STEP = 10; 4189 var LINE_HEIGHT = 40; 4190 var PAGE_HEIGHT = 800; 4191 4192 var sX = 0; 4193 var sY = 0; // spinX, spinY 4194 var pX = 0; 4195 var pY = 0; // pixelX, pixelY 4196 4197 // Legacy 4198 if ('detail' in e) { 4199 sY = e.detail; 4200 } 4201 if ('wheelDelta' in e) { 4202 sY = -e.wheelDelta / 120; 4203 } 4204 if ('wheelDeltaY' in e) { 4205 sY = -e.wheelDeltaY / 120; 4206 } 4207 if ('wheelDeltaX' in e) { 4208 sX = -e.wheelDeltaX / 120; 4209 } 4210 4211 // side scrolling on FF with DOMMouseScroll 4212 if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { 4213 sX = sY; 4214 sY = 0; 4215 } 4216 4217 pX = sX * PIXEL_STEP; 4218 pY = sY * PIXEL_STEP; 4219 4220 if ('deltaY' in e) { 4221 pY = e.deltaY; 4222 } 4223 if ('deltaX' in e) { 4224 pX = e.deltaX; 4225 } 4226 4227 if ((pX || pY) && e.deltaMode) { 4228 if (e.deltaMode === 1) { // delta in LINE units 4229 pX *= LINE_HEIGHT; 4230 pY *= LINE_HEIGHT; 4231 } else { // delta in PAGE units 4232 pX *= PAGE_HEIGHT; 4233 pY *= PAGE_HEIGHT; 4234 } 4235 } 4236 4237 // Fall-back if spin cannot be determined 4238 if (pX && !sX) { 4239 sX = (pX < 1) ? -1 : 1; 4240 } 4241 if (pY && !sY) { 4242 sY = (pY < 1) ? -1 : 1; 4243 } 4244 4245 return { 4246 spinX: sX, 4247 spinY: sY, 4248 pixelX: pX, 4249 pixelY: pY, 4250 }; 4251 }, 4252 handle: function handle(event) { 4253 var e = event; 4254 var swiper = this; 4255 var params = swiper.params.mousewheel; 4256 if (e.originalEvent) { e = e.originalEvent; } // jquery fix 4257 var delta = 0; 4258 var rtlFactor = swiper.rtl ? -1 : 1; 4259 4260 var data = Mousewheel.normalize(e); 4261 4262 if (params.forceToAxis) { 4263 if (swiper.isHorizontal()) { 4264 if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) { delta = data.pixelX * rtlFactor; } 4265 else { return true; } 4266 } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) { delta = data.pixelY; } 4267 else { return true; } 4268 } else { 4269 delta = Math.abs(data.pixelX) >
4269 Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; 4270 } 4271 4272 if (delta === 0) { return true; } 4273 4274 if (params.invert) { delta = -delta; } 4275 4276 if (!swiper.params.freeMode) { 4277 if (Utils.now() - swiper.mousewheel.lastScrollTime > 60) { 4278 if (delta < 0) { 4279 if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { 4280 swiper.slideNext(); 4281 swiper.emit('scroll', e); 4282 } else if (params.releaseOnEdges) { return true; } 4283 } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { 4284 swiper.slidePrev(); 4285 swiper.emit('scroll', e); 4286 } else if (params.releaseOnEdges) { return true; } 4287 } 4288 swiper.mousewheel.lastScrollTime = (new win.Date()).getTime(); 4289 } else { 4290 // Freemode or scrollContainer: 4291 var position = swiper.getTranslate() + (delta * params.sensitivity); 4292 var wasBeginning = swiper.isBeginning; 4293 var wasEnd = swiper.isEnd; 4294 4295 if (position >= swiper.minTranslate()) { position = swiper.minTranslate(); } 4296 if (position <= swiper.maxTranslate()) { position = swiper.maxTranslate(); } 4297 4298 swiper.setTransition(0); 4299 swiper.setTranslate(position); 4300 swiper.updateProgress(); 4301 swiper.updateActiveIndex(); 4302 swiper.updateSlidesClasses(); 4303 4304 if ((!wasBeginning && swiper.isBeginning) || (!wasEnd && swiper.isEnd)) { 4305 swiper.updateSlidesClasses(); 4306 } 4307 4308 if (swiper.params.freeModeSticky) { 4309 clearTimeout(swiper.mousewheel.timeout); 4310 swiper.mousewheel.timeout = Utils.nextTick(function () { 4311 swiper.slideReset(); 4312 }, 300); 4313 } 4314 // Emit event 4315 swiper.emit('scroll', e); 4316 4317 // Stop autoplay 4318 if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) { swiper.stopAutoplay(); } 4319 4320 // Return page scroll on edge positions 4321 if (position === 0 || position === swiper.maxTranslate()) { return true; } 4322 } 4323 4324 if (e.preventDefault) { e.preventDefault(); } 4325 else { e.returnValue = false; } 4326 return false; 4327 }, 4328 enable: function enable() { 4329 var swiper = this; 4330 if (!Mousewheel.event) { return false; } 4331 if (swiper.mousewheel.enabled) { return false; } 4332 var target = swiper.$el; 4333 if (swiper.params.mousewheel.eventsTarged !== 'container') { 4334 target = $$1(swiper.params.mousewheel.eventsTarged); 4335 } 4336 target.on(Mousewheel.event, swiper.mousewheel.handle); 4337 swiper.mousewheel.enabled = true; 4338 return true; 4339 }, 4340 disable: function disable() { 4341 var swiper = this; 4342 if (!Mousewheel.event) { return false; } 4343 if (!swiper.mousewheel.enabled) { return false; } 4344 var target = swiper.$el; 4345 if (swiper.params.mousewheel.eventsTarged !== 'container') { 4346 target = $$1(swiper.params.mousewheel.eventsTarged); 4347 } 4348 target.off(Mousewheel.event, swiper.mousewheel.handle); 4349 swiper.mousewheel.enabled = false; 4350 return true; 4351 }, 4352}; 4353 4354var Mousewheel$1 = { 4355 name: 'mousewheel', 4356 params: { 4357 mousewheel: { 4358 enabled: false, 4359 releaseOnEdges: false, 4360 invert: false,
4361 forceToAxis: false, 4362 sensitivity: 1, 4363 eventsTarged: 'container', 4364 }, 4365 }, 4366 create: function create() { 4367 var swiper = this; 4368 Utils.extend(swiper, { 4369 mousewheel: { 4370 enabled: false, 4371 enable: Mousewheel.enable.bind(swiper), 4372 disable: Mousewheel.disable.bind(swiper), 4373 handle: Mousewheel.handle.bind(swiper), 4374 lastScrollTime: Utils.now(), 4375 }, 4376 }); 4377 }, 4378 on: { 4379 init: function init() { 4380 var swiper = this; 4381 if (swiper.params.mousewheel.enabled) { swiper.mousewheel.enable(); } 4382 }, 4383 destroy: function destroy() { 4384 var swiper = this; 4385 if (swiper.mousewheel.enabled) { swiper.mousewheel.disable(); } 4386 }, 4387 }, 4388}; 4389 4390var Navigation = { 4391 update: function update() { 4392 // Update Navigation Buttons 4393 var swiper = this; 4394 var params = swiper.params.navigation; 4395 4396 if (swiper.params.loop) { return; } 4397 var ref = swiper.navigation; 4398 var $nextEl = ref.$nextEl; 4399 var $prevEl = ref.$prevEl; 4400 4401 if ($prevEl && $prevEl.length > 0) { 4402 if (swiper.isBeginning) { 4403 $prevEl.addClass(params.disabledClass); 4404 } else { 4405 $prevEl.removeClass(params.disabledClass); 4406 } 4407 } 4408 if ($nextEl && $nextEl.length > 0) { 4409 if (swiper.isEnd) { 4410 $nextEl.addClass(params.disabledClass); 4411 } else { 4412 $nextEl.removeClass(params.disabledClass); 4413 } 4414 } 4415 }, 4416 init: function init() { 4417 var swiper = this; 4418 var params = swiper.params.navigation; 4419 if (!(params.nextEl || params.prevEl)) { return; } 4420 4421 var $nextEl; 4422 var $prevEl; 4423 if (params.nextEl) { 4424 $nextEl = $$1(params.nextEl); 4425 if ( 4426 swiper.params.uniqueNavElements && 4427 typeof params.nextEl === 'string' && 4428 $nextEl.length > 1 && 4429 swiper.$el.find(params.nextEl).length === 1 4430 ) { 4431 $nextEl = swiper.$el.find(params.nextEl); 4432 } 4433 } 4434 if (params.prevEl) { 4435 $prevEl = $$1(params.prevEl); 4436 if ( 4437 swiper.params.uniqueNavElements && 4438 typeof params.prevEl === 'string' && 4439 $prevEl.length > 1 && 4440 swiper.$el.find(params.prevEl).length === 1 4441 ) { 4442 $prevEl = swiper.$el.find(params.prevEl); 4443 } 4444 } 4445 4446 if ($nextEl && $nextEl.length > 0) { 4447 $nextEl.on('click', function (e) { 4448 e.preventDefault(); 4449 if (swiper.isEnd && !swiper.params.loop) { return; } 4450 swiper.slideNext(); 4451 }); 4452 } 4453 if ($prevEl && $prevEl.length > 0) { 4454 $prevEl.on('click', function (e) { 4455 e.preventDefault(); 4456 if (swiper.isBeginning && !swiper.params.loop) { return; } 4457 swiper.slidePrev(); 4458 }); 4459 } 4460 4461 Utils.extend(swiper.navigation, { 4462 $nextEl: $nextEl, 4463 nextEl: $nextEl && $nextEl[0], 4464 $prevEl: $prevEl, 4465 prevEl: $prevEl && $prevEl[0], 4466 }); 4467 }, 4468 destroy: function destroy() { 4469 var swiper = this; 4470 var ref = swiper.navigation; 4471 var $nextEl = ref.$nextEl; 4472 var $prevEl = ref.$prevEl; 4473 if ($nextEl && $nextEl.length) { 4474 $nextEl.off('click'); 4475 $nextEl.removeClass(swiper.params.navigation.disabledClass); 4476 } 4477 if ($prevEl && $prevEl.length) { 4478 $prevEl.off('click'); 4479 $prevEl.removeClass(swiper.params.navigation.disabledClass); 4480 } 4481 }, 4482}; 4483 4484var Navigation$1 = { 4485 name: 'navigation', 4486 params: { 4487 navigation: { 4488 nextEl: null, 4489 prevEl: null, 4490 4491 hideOnClick: false, 4492 disabledClass: 'swiper-button-disabled', 4493 hiddenClass: 'swiper-button-hidden', 4494 }, 4495 }, 4496 create: function create() { 4497 var swiper = this; 4498 Utils.extend(swiper, { 4499 navigation: { 4500 init: Navigation.init.bind(swiper), 4501 update: Navigation.update.bind(swiper), 4502 destroy: Navigation.destroy.bind(swiper), 4503 }, 4504 }); 4505 }, 4506 on: { 4507 init: function init() { 4508 var swiper = this; 4509 swiper.navigation.init(); 4510 swiper.navigation.update(); 4511 }, 4512 toEdge: function toEdge() { 4513 var swiper = this; 4514 swiper.navigation.update(); 4515 }, 4516 fromEdge: function fromEdge() { 4517 var swiper = this; 4518 swiper.navigation.update(); 4519 }, 4520 destroy: function destroy() { 4521 var swiper = this; 4522 swiper.navigation.destroy(); 4523 }, 4524 click: function click(e) { 4525 var swiper = this; 4526 var ref = swiper.navigation; 4527 var $nextEl = ref.$nextEl; 4528 var $prevEl = ref.$prevEl; 4529 if ( 4530 swiper.params.navigation.hideOnClick && 4531 !$$1(e.target).is($prevEl) && 4532 !$$1(e.target).is($nextEl) 4533 ) { 4534 if ($nextEl) { $nextEl.toggleClass(swiper.params.navigation.hiddenClass); } 4535 if ($prevEl) { $prevEl.toggleClass(swiper.params.navigation.hiddenClass); } 4536 } 4537 }, 4538 }, 4539}; 4540 4541var Pagination = {
4542 update: function update() { 4543 // Render || Update Pagination bullets/items 4544 var swiper = this; 4545 var rtl = swiper.rtl; 4546 var params = swiper.params.pagination; 4547 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 4548 var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 4549 var $el = swiper.pagination.$el; 4550 // Current/Total 4551 var current; 4552 var total = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 4553 if (swiper.params.loop) { 4554 current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); 4555 if (current > slidesLength - 1 - (swiper.loopedSlides * 2)) { 4556 current -= (slidesLength - (swiper.loopedSlides * 2)); 4557 } 4558 if (current > total - 1) { current -= total; } 4559 if (current < 0 && swiper.params.paginationType !== 'bullets') { current = total + current; } 4560 } else if (typeof swiper.snapIndex !== 'undefined') { 4561 current = swiper.snapIndex; 4562 } else { 4563 current = swiper.activeIndex || 0; 4564 } 4565 // Types 4566 if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { 4567 var bullets = swiper.pagination.bullets; 4568 if (params.dynamicBullets) { 4569 swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); 4570 $el.css(swiper.isHorizontal() ? 'width' : 'height', ((swiper.pagination.bulletSize * 5) + "px")); 4571 } 4572 bullets.removeClass(((params.bulletActiveClass) + " " + (params.bulletActiveClass) + "-next " + (params.bulletActiveClass) + "-next-next " + (params.bulletActiveClass) + "-prev " + (params.bulletActiveClass) + "-prev-prev")); 4573 if ($el.length > 1) { 4574 bullets.each(function (index, bullet) { 4575 var $bullet = $$1(bullet); 4576 if ($bullet.index() === current) { 4577 $bullet.addClass(params.bulletActiveClass); 4578 if (params.dynamicBullets) { 4579 $bullet 4580 .prev() 4581 .addClass(((params.bulletActiveClass) + "-prev")) 4582 .prev() 4583 .addClass(((params.bulletActiveClass) + "-prev-prev")); 4584 $bullet 4585 .next() 4586 .addClass(((params.bulletActiveClass) + "-next")) 4587 .next() 4588 .addClass(((params.bulletActiveClass) + "-next-next")); 4589 } 4590 } 4591 }); 4592 } else { 4593 var $bullet = bullets.eq(current); 4594 $bullet.addClass(params.bulletActiveClass); 4595 if (params.dynamicBullets) { 4596 $bullet 4597 .prev() 4598 .addClass(((params.bulletActiveClass) + "-prev")) 4599 .prev() 4600 .addClass(((params.bulletActiveClass) + "-prev-prev")); 4601 $bullet 4602 .next() 4603 .addClass(((params.bulletActiveClass) + "-next")) 4604 .next() 4605 .addClass(((params.bulletActiveClass) + "-next-next")); 4606 } 4607 } 4608 if (params.dynamicBullets) { 4609 var dynamicBulletsLength = Math.min(bullets.length, 5); 4610 var bulletsOffset = (((swiper.pagination.bulletSize * dynamicBulletsLength) - (swiper.pagination.bulletSize)) / 2) - (current * swiper.pagination.bulletSize); 4611 var offsetProp = rtl ? 'right' : 'left'; 4612 bullets.css(swiper.isHorizontal() ? offsetProp : 'top', (bulletsOffset + "px")); 4613 } 4614 } 4615 if (params.type === 'fraction') { 4616 $el.find(("." + (params.currentClass))).text(current + 1); 4617 $el.find(("." + (params.totalClass))).text(total); 4618 } 4619 if (params.type === 'progressbar') { 4620 var scale = (current + 1) / total; 4621 var scaleX = scale; 4622 var scaleY = 1; 4623 if (!swiper.isHorizontal()) { 4624 scaleY = scale; 4625 scaleX = 1; 4626 } 4627 $el.find(("." + (params.progressbarFillClass))).transform(("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")")).transition(swiper.params.speed); 4628 } 4629 if (params.type === 'custom' && params.renderCustom) { 4630 $el.html(params.renderCustom(swiper, current + 1, total)); 4631 swiper.emit('paginationRender', swiper, $el[0]); 4632 } else { 4633 swiper.emit('paginationUpdate', swiper, $el[0]); 4634 } 4635 }, 4636 render: function render() { 4637 // Render Container 4638 var swiper = this; 4639 var params = swiper.params.pagination; 4640 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 4641 var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; 4642 4643 var $el = swiper.pagination.$el; 4644 var paginationHTML = ''; 4645 if (params.type === 'bullets') { 4646 var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; 4647 for (var i = 0; i < numberOfBullets; i += 1) { 4648 if (params.renderBullet) {
4649 paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); 4650 } else { 4651 paginationHTML += "<" + (params.bulletElement) + " class=\"" + (params.bulletClass) + "\"></" + (params.bulletElement) + ">"; 4652 } 4653 } 4654 $el.html(paginationHTML); 4655 swiper.pagination.bullets = $el.find(("." + (params.bulletClass))); 4656 } 4657 if (params.type === 'fraction') { 4658 if (params.renderFraction) { 4659 paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); 4660 } else { 4661 paginationHTML = 4662 "<span class=\"" + (params.currentClass) + "\"></span>" + 4663 ' / ' + 4664 "<span class=\"" + (params.totalClass) + "\"></span>"; 4665 } 4666 $el.html(paginationHTML); 4667 } 4668 if (params.type === 'progressbar') { 4669 if (params.renderProgressbar) { 4670 paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); 4671 } else { 4672 paginationHTML = "<span class=\"" + (params.progressbarFillClass) + "\"></span>"; 4673 } 4674 $el.html(paginationHTML); 4675 } 4676 if (params.type !== 'custom') { 4677 swiper.emit('paginationRender', swiper.pagination.$el[0]); 4678 } 4679 }, 4680 init: function init() { 4681 var swiper = this; 4682 var params = swiper.params.pagination; 4683 if (!params.el) { return; } 4684 4685 var $el = $$1(params.el); 4686 if ($el.length === 0) { return; } 4687 4688 if ( 4689 swiper.params.uniqueNavElements && 4690 typeof params.el === 'string' && 4691 $el.length > 1 && 4692 swiper.$el.find(params.el).length === 1 4693 ) { 4694 $el = swiper.$el.find(params.el); 4695 } 4696 4697 if (params.type === 'bullets' && params.clickable) { 4698 $el.addClass(params.clickableClass); 4699 } 4700 4701 $el.addClass(params.modifierClass + params.type); 4702 4703 if (params.type === 'bullets' && params.dynamicBullets) { 4704 $el.addClass(("" + (params.modifierClass) + (params.type) + "-dynamic")); 4705 } 4706 4707 if (params.clickable) { 4708 $el.on('click', ("." + (params.bulletClass)), function onClick(e) { 4709 e.preventDefault(); 4710 var index = $$1(this).index() * swiper.params.slidesPerGroup; 4711 if (swiper.params.loop) { index += swiper.loopedSlides; } 4712 swiper.slideTo(index); 4713 }); 4714 } 4715 4716 Utils.extend(swiper.pagination, { 4717 $el: $el, 4718 el: $el[0], 4719 }); 4720 }, 4721 destroy: function destroy() { 4722 var swiper = this; 4723 var params = swiper.params.pagination; 4724 if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } 4725 var $el = swiper.pagination.$el; 4726 4727 $el.removeClass(params.hiddenClass); 4728 $el.removeClass(params.modifierClass + params.type); 4729 if (swiper.pagination.bullets) { swiper.pagination.bullets.removeClass(params.bulletActiveClass); } 4730 if (params.clickable) { 4731 $el.off('click', ("." + (params.bulletClass))); 4732 } 4733 }, 4734}; 4735 4736var Pagination$1 = { 4737 name: 'pagination', 4738 params: { 4739 pagination: { 4740 el: null, 4741 bulletElement: 'span', 4742 clickable: false, 4743 hideOnClick: false, 4744 renderBullet: null, 4745 renderProgressbar: null, 4746 renderFraction: null, 4747 renderCustom: null, 4748 type: 'bullets', // 'bullets' or 'progressbar' or 'fraction' or 'custom' 4749 dynamicBullets: false, 4750 4751 bulletClass: 'swiper-pagination-bullet', 4752 bulletActiveClass: 'swiper-pagination-bullet-active', 4753 modifierClass: 'swiper-pagination-', // NEW 4754 currentClass: 'swiper-pagination-current', 4755 totalClass: 'swiper-pagination-total', 4756 hiddenClass: 'swiper-pagination-hidden', 4757 progressbarFillClass: 'swiper-pagination-progressbar-fill', 4758 clickableClass: 'swiper-pagination-clickable', // NEW 4759 }, 4760 }, 4761 create: function create() { 4762 var swiper = this; 4763 Utils.extend(swiper, { 4764 pagination: { 4765 init: Pagination.init.bind(swiper), 4766 render: Pagination.render.bind(swiper), 4767 update: Pagination.update.bind(swiper), 4768 destroy: Pagination.destroy.bind(swiper), 4769 }, 4770 }); 4771 }, 4772 on: { 4773 init: function init() { 4774 var swiper = this; 4775 swiper.pagination.init(); 4776 swiper.pagination.render(); 4777 swiper.pagination.update(); 4778 }, 4779 activeIndexChange: function activeIndexChange() { 4780 var swiper = this; 4781 if (swiper.params.loop) { 4782 swiper.pagination.update(); 4783 } else if (typeof swiper.snapIndex === 'undefined') { 4784 swiper.pagination.update(); 4785 } 4786 }, 4787 snapIndexChange: function snapIndexChange() { 4788 var swiper = this; 4789 if (!swiper.params.loop) { 4790 swiper.pagination.update(); 4791 } 4792 }, 4793 slidesLengthChange: function slidesLengthChange() { 4794 var swiper = this; 4795 if (swiper.params.loop) { 4796 swiper.pagination.render(); 4797 swiper.pagination.update(); 4798 } 4799 }, 4800 snapGridLengthChange: function snapGridLengthChange() { 4801 var swiper = this; 4802 if (!swiper.params.loop) { 4803 swiper.pagination.render(); 4804 swiper.pagination.update(); 4805 } 4806 }, 4807 destroy: function destroy() { 4808 var swiper = this; 4809 swiper.pagination.destroy(); 4810 }, 4811 click: function click(e) { 4812 var swiper = this; 4813 if ( 4814 swiper.params.pagination.el && 4815 swiper.params.pagination.hideOnClick && 4816 swiper.pagination.$el.length > 0 && 4817 !$$1(e.target).hasClass(swiper.params.pagination.bulletClass) 4818 ) { 4819 swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass); 4820 } 4821 }, 4822 }, 4823}; 4824 4825var Scrollbar = { 4826 setTranslate: function setTranslate() { 4827 var swiper = this; 4828 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 4829 var scrollbar = swiper.scrollbar; 4830 var rtl = swiper.rtl; 4831 var progress = swiper.progress; 4832 var dragSize = scrollbar.dragSize; 4833 var trackSize = scrollbar.trackSize; 4834 var $dragEl = scrollbar.$dragEl; 4835 var $el = scrollbar.$el; 4836 var params = swiper.params.scrollbar; 4837 4838 var newSize = dragSize; 4839 var newPos = (trackSize - dragSize) * progress; 4840 if (rtl && swiper.isHorizontal()) { 4841 newPos = -newPos; 4842 if (newPos > 0) { 4843 newSize = dragSize - newPos; 4844 newPos = 0; 4845 } else if (-newPos + dragSize > trackSize) { 4846 newSize = trackSize + newPos; 4847 } 4848 } else if (newPos < 0) { 4849 newSize = dragSize + newPos; 4850 newPos = 0; 4851 } else if (newPos + dragSize > trackSize) { 4852 newSize = trackSize - newPos; 4853 } 4854 if (swiper.isHorizontal()) { 4855 if (Support.transforms3d) { 4856 $dragEl.transform(("translate3d(" + newPos + "px, 0, 0)")); 4857 } else {
4858 $dragEl.transform(("translateX(" + newPos + "px)")); 4859 } 4860 $dragEl[0].style.width = newSize + "px"; 4861 } else { 4862 if (Support.transforms3d) { 4863 $dragEl.transform(("translate3d(0px, " + newPos + "px, 0)")); 4864 } else { 4865 $dragEl.transform(("translateY(" + newPos + "px)")); 4866 } 4867 $dragEl[0].style.height = newSize + "px"; 4868 } 4869 if (params.hide) { 4870 clearTimeout(swiper.scrollbar.timeout); 4871 $el[0].style.opacity = 1; 4872 swiper.scrollbar.timeout = setTimeout(function () { 4873 $el[0].style.opacity = 0; 4874 $el.transition(400); 4875 }, 1000); 4876 } 4877 }, 4878 setTransition: function setTransition(duration) { 4879 var swiper = this; 4880 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 4881 swiper.scrollbar.$dragEl.transition(duration); 4882 }, 4883 updateSize: function updateSize() { 4884 var swiper = this; 4885 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } 4886 4887 var scrollbar = swiper.scrollbar; 4888 var $dragEl = scrollbar.$dragEl; 4889 var $el = scrollbar.$el; 4890 4891 $dragEl[0].style.width = ''; 4892 $dragEl[0].style.height = ''; 4893 var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; 4894 4895 var divider = swiper.size / swiper.virtualSize; 4896 var moveDivider = divider * (trackSize / swiper.size); 4897 var dragSize; 4898 if (swiper.params.scrollbar.dragSize === 'auto') { 4899 dragSize = trackSize * divider; 4900 } else { 4901 dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); 4902 } 4903 4904 if (swiper.isHorizontal()) { 4905 $dragEl[0].style.width = dragSize + "px"; 4906 } else { 4907 $dragEl[0].style.height = dragSize + "px"; 4908 } 4909 4910 if (divider >= 1) { 4911 $el[0].style.display = 'none'; 4912 } else { 4913 $el[0].style.display = ''; 4914 } 4915 if (swiper.params.scrollbarHide) { 4916 $el[0].style.opacity = 0; 4917 } 4918 Utils.extend(scrollbar, { 4919 trackSize: trackSize, 4920 divider: divider, 4921 moveDivider: moveDivider, 4922 dragSize: dragSize, 4923 }); 4924 }, 4925 setDragPosition: function setDragPosition(e) { 4926 var swiper = this; 4927 var scrollbar = swiper.scrollbar; 4928 var $el = scrollbar.$el; 4929 var dragSize = scrollbar.dragSize; 4930 var moveDivider = scrollbar.moveDivider; 4931 4932 var pointerPosition; 4933 if (swiper.isHorizontal()) { 4934 pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX); 4935 } else { 4936 pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY); 4937 } 4938 var position = (pointerPosition) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragSize / 2); 4939 var positionMin = -swiper.minTranslate() * moveDivider; 4940 var positionMax = -swiper.maxTranslate() * moveDivider; 4941 if (position < positionMin) { 4942 position = positionMin; 4943 } else if (position > positionMax) { 4944 position = positionMax; 4945 } 4946 if (swiper.rtl) { 4947 position = positionMax - position; 4948 } 4949 position = -position / moveDivider; 4950 swiper.updateProgress(position); 4951 swiper.setTranslate(position); 4952 swiper.updateActiveIndex(); 4953 swiper.updateSlidesClasses(); 4954 }, 4955 onDragStart: function onDragStart(e) { 4956 var swiper = this; 4957 var params = swiper.params.scrollbar; 4958 var scrollbar = swiper.scrollbar; 4959 var $wrapperEl = swiper.$wrapperEl; 4960 var $el = scrollbar.$el; 4961 var $dragEl = scrollbar.$dragEl; 4962 swiper.scrollbar.isTouched = true; 4963 e.preventDefault(); 4964 e.stopPropagation(); 4965 4966 $wrapperEl.transition(100); 4967 $dragEl.transition(100); 4968 scrollbar.setDragPosition(e); 4969 4970 clearTimeout(swiper.scrollbar.dragTimeout); 4971 4972 $el.transition(0); 4973 if (params.hide) { 4974 $el.css('opacity', 1); 4975 } 4976 swiper.emit('scrollbarDragStart', e); 4977 }, 4978 onDragMove: function onDragMove(e) { 4979 var swiper = this; 4980 var scrollbar = swiper.scrollbar; 4981 var $wrapperEl = swiper.$wrapperEl; 4982 var $el = scrollbar.$el; 4983 var $dragEl = scrollbar.$dragEl; 4984 4985 if (!swiper.scrollbar.isTouched) { return; } 4986 if (e.preventDefault) { e.preventDefault(); } 4987 else { e.returnValue = false; } 4988 scrollbar.setDragPosition(e); 4989 $wrapperEl.transition(0); 4990 $el.transition(0); 4991 $dragEl.transition(0); 4992 swiper.emit('scrollbarDragMove', e); 4993 }, 4994 onDragEnd: function onDragEnd(e) { 4995 var swiper = this; 4996 4997 var params = swiper.params.scrollbar; 4998 var scrollbar = swiper.scrollbar; 4999 var $el = scrollbar.$el; 5000 5001 if (!swiper.scrollbar.isTouched) { return; } 5002 swiper.scrollbar.isTouched = false;
5003 if (params.hide) { 5004 clearTimeout(swiper.scrollbar.dragTimeout); 5005 swiper.scrollbar.dragTimeout = Utils.nextTick(function () { 5006 $el.css('opacity', 0); 5007 $el.transition(400); 5008 }, 1000); 5009 } 5010 swiper.emit('scrollbarDragEnd', e); 5011 if (params.snapOnRelease) { 5012 swiper.slideReset(); 5013 } 5014 }, 5015 enableDraggable: function enableDraggable() { 5016 var swiper = this; 5017 if (!swiper.params.scrollbar.el) { return; } 5018 var scrollbar = swiper.scrollbar; 5019 var $el = scrollbar.$el; 5020 var target = Support.touch ? $el[0] : document; 5021 $el.on(swiper.scrollbar.dragEvents.start, swiper.scrollbar.onDragStart); 5022 $$1(target).on(swiper.scrollbar.dragEvents.move, swiper.scrollbar.onDragMove); 5023 $$1(target).on(swiper.scrollbar.dragEvents.end, swiper.scrollbar.onDragEnd); 5024 }, 5025 disableDraggable: function disableDraggable() { 5026 var swiper = this; 5027 if (!swiper.params.scrollbar.el) { return; } 5028 var scrollbar = swiper.scrollbar; 5029 var $el = scrollbar.$el; 5030 var target = Support.touch ? $el[0] : document; 5031 $el.off(swiper.scrollbar.dragEvents.start); 5032 $$1(target).off(swiper.scrollbar.dragEvents.move); 5033 $$1(target).off(swiper.scrollbar.dragEvents.end); 5034 }, 5035 init: function init() { 5036 var swiper = this; 5037 if (!swiper.params.scrollbar.el) { return; } 5038 var scrollbar = swiper.scrollbar; 5039 var $swiperEl = swiper.$el; 5040 var touchEvents = swiper.touchEvents; 5041 var params = swiper.params.scrollbar; 5042 5043 var $el = $$1(params.el); 5044 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { 5045 $el = $swiperEl.find(params.el); 5046 } 5047 5048 var $dragEl = $el.find('.swiper-scrollbar-drag'); 5049 if ($dragEl.length === 0) { 5050 $dragEl = $$1('<div class="swiper-scrollbar-drag"></div>'); 5051 $el.append($dragEl); 5052 } 5053 5054 swiper.scrollbar.dragEvents = (function dragEvents() { 5055 if ((swiper.params.simulateTouch === false && !Support.touch)) { 5056 return { 5057 start: 'mousedown', 5058 move: 'mousemove', 5059 end: 'mouseup', 5060 }; 5061 } 5062 return touchEvents; 5063 }()); 5064 5065 Utils.extend(scrollbar, { 5066 $el: $el, 5067 el: $el[0], 5068 $dragEl: $dragEl, 5069 dragEl: $dragEl[0], 5070 }); 5071 5072 if (params.draggable) { 5073 scrollbar.enableDraggable(); 5074 } 5075 }, 5076 destroy: function destroy() { 5077 var swiper = this; 5078 swiper.scrollbar.disableDraggable(); 5079 }, 5080}; 5081 5082var Scrollbar$1 = { 5083 name: 'scrollbar', 5084 params: { 5085 scrollbar: { 5086 el: null, 5087 dragSize: 'auto', 5088 hide: false, 5089 draggable: false, 5090 snapOnRelease: true, 5091 }, 5092 }, 5093 create: function create() { 5094 var swiper = this; 5095 Utils.extend(swiper, { 5096 scrollbar: { 5097 init: Scrollbar.init.bind(swiper), 5098 destroy: Scrollbar.destroy.bind(swiper), 5099 updateSize: Scrollbar.updateSize.bind(swiper), 5100 setTranslate: Scrollbar.setTranslate.bind(swiper), 5101 setTransition: Scrollbar.setTransition.bind(swiper), 5102 enableDraggable: Scrollbar.enableDraggable.bind(swiper), 5103 disableDraggable: Scrollbar.disableDraggable.bind(swiper), 5104 setDragPosition: Scrollbar.setDragPosition.bind(swiper), 5105 onDragStart: Scrollbar.onDragStart.bind(swiper), 5106 onDragMove: Scrollbar.onDragMove.bind(swiper), 5107 onDragEnd: Scrollbar.onDragEnd.bind(swiper), 5108 isTouched: false, 5109 timeout: null, 5110 dragTimeout: null, 5111 }, 5112 }); 5113 }, 5114 on: { 5115 init: function init() { 5116 var swiper = this; 5117 swiper.scrollbar.init(); 5118 swiper.scrollbar.updateSize(); 5119 swiper.scrollbar.setTranslate(); 5120 }, 5121 update: function update() { 5122 var swiper = this; 5123 swiper.scrollbar.updateSize(); 5124 }, 5125 resize: function resize() { 5126 var swiper = this; 5127 swiper.scrollbar.updateSize(); 5128 }, 5129 observerUpdate: function observerUpdate() { 5130 var swiper = this; 5131 swiper.scrollbar.updateSize(); 5132 }, 5133 setTranslate: function setTranslate() { 5134 var swiper = this; 5135 swiper.scrollbar.setTranslate(); 5136 }, 5137 setTransition: function setTransition(duration) { 5138 var swiper = this; 5139 swiper.scrollbar.setTransition(duration); 5140 }, 5141 destroy: function destroy() { 5142 var swiper = this; 5143 swiper.scrollbar.destroy(); 5144 }, 5145 }, 5146}; 5147 5148var Parallax = { 5149 setTransform: function setTransform(el, progress) { 5150 var swiper = this; 5151 var rtl = swiper.rtl; 5152 5153 var $el = $$1(el); 5154 var rtlFactor = rtl ? -1 : 1; 5155 5156 var p = $el.attr('data-swiper-parallax') || '0'; 5157 var x = $el.attr('data-swiper-parallax-x'); 5158 var y = $el.attr('data-swiper-parallax-y'); 5159 var scale = $el.attr('data-swiper-parallax-scale'); 5160 var opacity = $el.attr('data-swiper-parallax-opacity'); 5161 5162 if (x || y) { 5163 x = x || '0'; 5164 y = y || '0'; 5165 } else if (swiper.isHorizontal()) { 5166 x = p; 5167 y = '0'; 5168 } else { 5169 y = p; 5170 x = '0'; 5171 } 5172 5173 if ((x).indexOf('%') >= 0) { 5174 x = (parseInt(x, 10) * progress * rtlFactor) + "%"; 5175 } else { 5176 x = (x * progress * rtlFactor) + "px"; 5177 } 5178 if ((y).indexOf('%') >= 0) { 5179 y = (parseInt(y, 10) * progress) + "%"; 5180 } else { 5181 y = (y * progress) + "px"; 5182 } 5183 5184 if (typeof opacity !== 'undefined' && opacity !== null) { 5185 var currentOpacity = opacity - ((opacity - 1) * (1 - Math.abs(progress))); 5186 $el[0].style.opacity = currentOpacity; 5187 } 5188 if (typeof scale === 'undefined' || scale === null) { 5189 $el.transform(("translate3d(" + x + ", " + y + ", 0px)")); 5190 } else { 5191 var currentScale = scale - ((scale - 1) * (1 - Math.abs(progress))); 5192 $el.transform(("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")")); 5193 } 5194 }, 5195 setTranslate: function setTranslate() { 5196 var swiper = this; 5197 var $el = swiper.$el; 5198 var slides = swiper.slides; 5199 var progress = swiper.progress; 5200 var snapGrid = swiper.snapGrid; 5201 $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 5202 .each(function (index, el) { 5203 swiper.parallax.setTransform(el, progress); 5204 }); 5205 slides.each(function (slideIndex, slideEl) { 5206 var slideProgress = slideEl.progress; 5207 if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { 5208 slideProgress += Math.ceil(slideIndex / 2) - (progress * (snapGrid.length - 1)); 5209 } 5210 slideProgress = Math.min(Math.max(slideProgress, -1), 1); 5211 $$1(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 5212 .each(function (index, el) { 5213 swiper.parallax.setTransform(el, slideProgress); 5214 }); 5215 }); 5216 }, 5217 setTransition: function setTransition(duration) { 5218 if ( duration === void 0 ) duration = this.params.speed; 5219 5220 var swiper = this; 5221 var $el = swiper.$el; 5222 $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') 5223 .each(function (index, parallaxEl) { 5224 var $parallaxEl = $$1(parallaxEl); 5225 var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; 5226 if (duration === 0) { parallaxDuration = 0; } 5227 $parallaxEl.transition(parallaxDuration); 5228 }); 5229 }, 5230}; 5231 5232var Parallax$1 = { 5233 name: 'parallax', 5234 params: { 5235 parallax: { 5236 enabled: false, 5237 }, 5238 }, 5239 create: function create() { 5240 var swiper = this; 5241 Utils.extend(swiper, { 5242 parallax: { 5243 setTransform: Parallax.setTransform.bind(swiper), 5244 setTranslate: Parallax.setTranslate.bind(swiper), 5245 setTransition: Parallax.setTransition.bind(swiper), 5246 }, 5247 }); 5248 }, 5249 on: { 5250 beforeInit: function beforeInit() { 5251 var swiper = this; 5252 swiper.params.watchSlidesProgress = true; 5253 },
5254 init: function init() { 5255 var swiper = this; 5256 if (!swiper.params.parallax) { return; } 5257 swiper.parallax.setTranslate(); 5258 }, 5259 setTranslate: function setTranslate() { 5260 var swiper = this; 5261 if (!swiper.params.parallax) { return; } 5262 swiper.parallax.setTranslate(); 5263 }, 5264 setTransition: function setTransition(duration) { 5265 var swiper = this; 5266 if (!swiper.params.parallax) { return; } 5267 swiper.parallax.setTransition(duration); 5268 }, 5269 }, 5270}; 5271 5272var Zoom = { 5273 // Calc Scale From Multi-touches 5274 getDistanceBetweenTouches: function getDistanceBetweenTouches(e) { 5275 if (e.targetTouches.length < 2) { return 1; } 5276 var x1 = e.targetTouches[0].pageX; 5277 var y1 = e.targetTouches[0].pageY; 5278 var x2 = e.targetTouches[1].pageX; 5279 var y2 = e.targetTouches[1].pageY; 5280 var distance = Math.sqrt((Math.pow( (x2 - x1), 2 )) + (Math.pow( (y2 - y1), 2 ))); 5281 return distance; 5282 }, 5283 // Events 5284 onGestureStart: function onGestureStart(e) { 5285 var swiper = this; 5286 var params = swiper.params.zoom; 5287 var zoom = swiper.zoom; 5288 var gesture = zoom.gesture; 5289 zoom.fakeGestureTouched = false; 5290 zoom.fakeGestureMoved = false; 5291 if (!Support.gestures) { 5292 if (e.type !== 'touchstart' || (e.type === 'touchstart' && e.targetTouches.length < 2)) { 5293 return; 5294 } 5295 zoom.fakeGestureTouched = true; 5296 gesture.scaleStart = Zoom.getDistanceBetweenTouches(e); 5297 } 5298 if (!gesture.$slideEl || !gesture.$slideEl.length) { 5299 gesture.$slideEl = $$1(this); 5300 if (gesture.$slideEl.length === 0) { gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); } 5301 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 5302 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 5303 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 5304 if (gesture.$imageWrapEl.length === 0) { 5305 gesture.$imageEl = undefined; 5306 return; 5307 } 5308 } 5309 gesture.$imageEl.transition(0); 5310 swiper.zoom.isScaling = true; 5311 }, 5312 onGestureChange: function onGestureChange(e) { 5313 var swiper = this; 5314 var params = swiper.params.zoom; 5315 var zoom = swiper.zoom; 5316 var gesture = zoom.gesture; 5317 if (!Support.gestures) { 5318 if (e.type !== 'touchmove' || (e.type === 'touchmove' && e.targetTouches.length < 2)) { 5319 return; 5320 } 5321 zoom.fakeGestureMoved = true; 5322 gesture.scaleMove = Zoom.getDistanceBetweenTouches(e); 5323 } 5324 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5325 if (Support.gestures) { 5326 swiper.zoom.scale = e.scale * zoom.currentScale; 5327 } else { 5328 zoom.scale = (gesture.scaleMove / gesture.scaleStart) * zoom.currentScale; 5329 } 5330 if (zoom.scale > gesture.maxRatio) { 5331 zoom.scale = (gesture.maxRatio - 1) + (Math.pow( ((zoom.scale - gesture.maxRatio) + 1), 0.5 )); 5332 } 5333 if (zoom.scale < params.minRatio) { 5334 zoom.scale = (params.minRatio + 1) - (Math.pow( ((params.minRatio - zoom.scale) + 1), 0.5 )); 5335 } 5336 gesture.$imageEl.transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 5337 }, 5338 onGestureEnd: function onGestureEnd(e) { 5339 var swiper = this; 5340 var params = swiper.params.zoom; 5341 var zoom = swiper.zoom; 5342 var gesture = zoom.gesture; 5343 if (!Support.gestures) { 5344 if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) { 5345 return; 5346 } 5347 if (e.type !== 'touchend' || (e.type === 'touchend' && e.changedTouches.length < 2 && !Device.android)) { 5348 return; 5349 } 5350 zoom.fakeGestureTouched = false; 5351 zoom.fakeGestureMoved = false; 5352 } 5353 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5354 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); 5355 gesture.$imageEl.transition(swiper.params.speed).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 5356 zoom.currentScale = zoom.scale; 5357 zoom.isScaling = false; 5358 if (zoom.scale === 1) { gesture.$slideEl = undefined; } 5359 }, 5360 onTouchStart: function onTouchStart(e) { 5361 var swiper = this; 5362 var zoom = swiper.zoom; 5363 var gesture = zoom.gesture; 5364 var image = zoom.image; 5365 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5366 if (image.isTouched) { return; } 5367 if (Device.android) { e.preventDefault(); } 5368 image.isTouched = true; 5369 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; 5370 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; 5371 }, 5372 onTouchMove: function onTouchMove(e) { 5373 var swiper = this; 5374 var zoom = swiper.zoom; 5375 var gesture = zoom.gesture; 5376 var image = zoom.image; 5377 var velocity = zoom.velocity; 5378 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5379 swiper.allowClick = false;
5380 if (!image.isTouched || !gesture.$slideEl) { return; } 5381 5382 if (!image.isMoved) { 5383 image.width = gesture.$imageEl[0].offsetWidth; 5384 image.height = gesture.$imageEl[0].offsetHeight; 5385 image.startX = Utils.getTranslate(gesture.$imageWrapEl[0], 'x') || 0; 5386 image.startY = Utils.getTranslate(gesture.$imageWrapEl[0], 'y') || 0; 5387 gesture.slideWidth = gesture.$slideEl[0].offsetWidth; 5388 gesture.slideHeight = gesture.$slideEl[0].offsetHeight; 5389 gesture.$imageWrapEl.transition(0); 5390 if (swiper.rtl) { image.startX = -image.startX; } 5391 if (swiper.rtl) { image.startY = -image.startY; } 5392 } 5393 // Define if we need image drag 5394 var scaledWidth = image.width * zoom.scale; 5395 var scaledHeight = image.height * zoom.scale; 5396 5397 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) { return; } 5398 5399 image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); 5400 image.maxX = -image.minX; 5401 image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); 5402 image.maxY = -image.minY; 5403 5404 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; 5405 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; 5406 5407 if (!image.isMoved && !zoom.isScaling) { 5408 if ( 5409 swiper.isHorizontal() && 5410 ( 5411 (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x) || 5412 (Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x) 5413 ) 5414 ) { 5415 image.isTouched = false; 5416 return; 5417 } else if ( 5418 !swiper.isHorizontal() && 5419 ( 5420 (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y) || 5421 (Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y) 5422 ) 5423 ) { 5424 image.isTouched = false; 5425 return; 5426 } 5427 } 5428 e.preventDefault(); 5429 e.stopPropagation(); 5430 5431 image.isMoved = true; 5432 image.currentX = (image.touchesCurrent.x - image.touchesStart.x) + image.startX; 5433 image.currentY = (image.touchesCurrent.y - image.touchesStart.y) + image.startY; 5434 5435 if (image.currentX < image.minX) { 5436 image.currentX = (image.minX + 1) - (Math.pow( ((image.minX - image.currentX) + 1), 0.8 )); 5437 } 5438 if (image.currentX > image.maxX) { 5439 image.currentX = (image.maxX - 1) + (Math.pow( ((image.currentX - image.maxX) + 1), 0.8 )); 5440 } 5441 5442 if (image.currentY < image.minY) { 5443 image.currentY = (image.minY + 1) - (Math.pow( ((image.minY - image.currentY) + 1), 0.8 )); 5444 } 5445 if (image.currentY > image.maxY) { 5446 image.currentY = (image.maxY - 1) + (Math.pow( ((image.currentY - image.maxY) + 1), 0.8 )); 5447 } 5448 5449 // Velocity 5450 if (!velocity.prevPositionX) { velocity.prevPositionX = image.touchesCurrent.x; } 5451 if (!velocity.prevPositionY) { velocity.prevPositionY = image.touchesCurrent.y; } 5452 if (!velocity.prevTime) { velocity.prevTime = Date.now(); } 5453 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; 5454 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; 5455 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) { velocity.x = 0; } 5456 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) { velocity.y = 0; } 5457 velocity.prevPositionX = image.touchesCurrent.x; 5458 velocity.prevPositionY = image.touchesCurrent.y; 5459 velocity.prevTime = Date.now(); 5460 5461 gesture.$imageWrapEl.transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); 5462 }, 5463 onTouchEnd: function onTouchEnd() { 5464 var swiper = this; 5465 var zoom = swiper.zoom; 5466 var gesture = zoom.gesture; 5467 var image = zoom.image; 5468 var velocity = zoom.velocity; 5469 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5470 if (!image.isTouched || !image.isMoved) { 5471 image.isTouched = false; 5472 image.isMoved = false;
5473 return; 5474 } 5475 image.isTouched = false; 5476 image.isMoved = false; 5477 var momentumDurationX = 300; 5478 var momentumDurationY = 300; 5479 var momentumDistanceX = velocity.x * momentumDurationX; 5480 var newPositionX = image.currentX + momentumDistanceX; 5481 var momentumDistanceY = velocity.y * momentumDurationY; 5482 var newPositionY = image.currentY + momentumDistanceY; 5483 5484 // Fix duration 5485 if (velocity.x !== 0) { momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); } 5486 if (velocity.y !== 0) { momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); } 5487 var momentumDuration = Math.max(momentumDurationX, momentumDurationY); 5488 5489 image.currentX = newPositionX; 5490 image.currentY = newPositionY; 5491 5492 // Define if we need image drag 5493 var scaledWidth = image.width * zoom.scale; 5494 var scaledHeight = image.height * zoom.scale; 5495 image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); 5496 image.maxX = -image.minX; 5497 image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); 5498 image.maxY = -image.minY; 5499 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); 5500 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); 5501 5502 gesture.$imageWrapEl.transition(momentumDuration).transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); 5503 }, 5504 onTransitionEnd: function onTransitionEnd() { 5505 var swiper = this; 5506 var zoom = swiper.zoom; 5507 var gesture = zoom.gesture; 5508 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { 5509 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); 5510 gesture.$imageWrapEl.transform('translate3d(0,0,0)'); 5511 gesture.$slideEl = undefined; 5512 gesture.$imageEl = undefined; 5513 gesture.$imageWrapEl = undefined; 5514 5515 zoom.scale = 1; 5516 zoom.currentScale = 1; 5517 } 5518 }, 5519 // Toggle Zoom 5520 toggle: function toggle(e) { 5521 var swiper = this; 5522 var zoom = swiper.zoom; 5523 5524 if (zoom.scale && zoom.scale !== 1) { 5525 // Zoom Out 5526 zoom.out(); 5527 } else { 5528 // Zoom In 5529 zoom.in(e); 5530 } 5531 }, 5532 in: function in$1(e) { 5533 var swiper = this; 5534 5535 var zoom = swiper.zoom; 5536 var params = swiper.params.zoom; 5537 var gesture = zoom.gesture; 5538 var image = zoom.image; 5539 5540 if (!gesture.$slideEl) { 5541 gesture.$slideEl = swiper.clickedSlide ? $$1(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); 5542 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 5543 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 5544 } 5545 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5546 5547 gesture.$slideEl.addClass(("" + (params.zoomedSlideClass))); 5548 5549 var touchX; 5550 var touchY; 5551 var offsetX; 5552 var offsetY; 5553 var diffX; 5554 var diffY; 5555 var translateX; 5556 var translateY; 5557 var imageWidth; 5558 var imageHeight; 5559 var scaledWidth; 5560 var scaledHeight; 5561 var translateMinX; 5562 var translateMinY; 5563 var translateMaxX; 5564 var translateMaxY; 5565 var slideWidth; 5566 var slideHeight; 5567 5568 if (typeof image.touchesStart.x === 'undefined' && e) { 5569 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; 5570 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; 5571 } else { 5572 touchX = image.touchesStart.x; 5573 touchY = image.touchesStart.y; 5574 } 5575 5576 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 5577 zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; 5578 if (e) { 5579 slideWidth = gesture.$slideEl[0].offsetWidth; 5580 slideHeight = gesture.$slideEl[0].offsetHeight; 5581 offsetX = gesture.$slideEl.offset().left; 5582 offsetY = gesture.$slideEl.offset().top; 5583 diffX = (offsetX + (slideWidth / 2)) - touchX; 5584 diffY = (offsetY + (slideHeight / 2)) - touchY; 5585 5586 imageWidth = gesture.$imageEl[0].offsetWidth; 5587 imageHeight = gesture.$imageEl[0].offsetHeight; 5588 scaledWidth = imageWidth * zoom.scale; 5589 scaledHeight = imageHeight * zoom.scale; 5590 5591 translateMinX = Math.min(((slideWidth / 2) - (scaledWidth / 2)), 0); 5592 translateMinY = Math.min(((slideHeight / 2) - (scaledHeight / 2)), 0); 5593 translateMaxX = -translateMinX; 5594 translateMaxY = -translateMinY; 5595 5596 translateX = diffX * zoom.scale; 5597 translateY = diffY * zoom.scale; 5598 5599 if (translateX < translateMinX) { 5600 translateX = translateMinX; 5601 } 5602 if (translateX > translateMaxX) { 5603 translateX = translateMaxX; 5604 } 5605 5606 if (translateY < translateMinY) { 5607 translateY = translateMinY; 5608 } 5609 if (translateY > translateMaxY) { 5610 translateY = translateMaxY; 5611 } 5612 } else { 5613 translateX = 0; 5614 translateY = 0; 5615 } 5616 gesture.$imageWrapEl.transition(300).transform(("translate3d(" + translateX + "px, " + translateY + "px,0
5616)")); 5617 gesture.$imageEl.transition(300).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); 5618 }, 5619 out: function out() { 5620 var swiper = this; 5621 5622 var zoom = swiper.zoom; 5623 var params = swiper.params.zoom; 5624 var gesture = zoom.gesture; 5625 5626 if (!gesture.$slideEl) { 5627 gesture.$slideEl = swiper.clickedSlide ? $$1(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); 5628 gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); 5629 gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); 5630 } 5631 if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } 5632 5633 zoom.scale = 1; 5634 zoom.currentScale = 1; 5635 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); 5636 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); 5637 gesture.$slideEl.removeClass(("" + (params.zoomedSlideClass))); 5638 gesture.$slideEl = undefined; 5639 }, 5640 // Attach/Detach Events 5641 enable: function enable() { 5642 var swiper = this; 5643 var zoom = swiper.zoom; 5644 if (zoom.enabled) { return; } 5645 zoom.enabled = true; 5646 5647 var slides = swiper.slides; 5648 5649 var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; 5650 5651 // Scale image 5652 if (Support.gestures) { 5653 slides.on('gesturestart', zoom.onGestureStart, passiveListener); 5654 slides.on('gesturechange', zoom.onGestureChange, passiveListener); 5655 slides.on('gestureend', zoom.onGestureEnd, passiveListener); 5656 } else if (swiper.touchEvents.start === 'touchstart') { 5657 slides.on(swiper.touchEvents.start, zoom.onGestureStart, passiveListener); 5658 slides.on(swiper.touchEvents.move, zoom.onGestureChange, passiveListener); 5659 slides.on(swiper.touchEvents.end, zoom.onGestureEnd, passiveListener); 5660 } 5661 5662 // Move image 5663 swiper.slides.each(function (index, slideEl) { 5664 var $slideEl = $$1(slideEl); 5665 if ($slideEl.find(("." + (swiper.params.zoom.containerClass))).length > 0) { 5666 $slideEl.on(swiper.touchEvents.move, zoom.onTouchMove); 5667 } 5668 }); 5669 }, 5670 disable: function disable() { 5671 var swiper = this; 5672 var zoom = swiper.zoom; 5673 if (!zoom.enabled) { return; } 5674 5675 swiper.zoom.enabled = false; 5676 5677 var slides = swiper.slides; 5678 5679 var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; 5680 5681 // Scale image 5682 if (Support.gestures) { 5683 slides.off('gesturestart', zoom.onGestureStart, passiveListener); 5684 slides.off('gesturechange', zoom.onGestureChange, passiveListener); 5685 slides.off('gestureend', zoom.onGestureEnd, passiveListener); 5686 } else if (swiper.touchEvents.start === 'touchstart') { 5687 slides.off(swiper.touchEvents.start, zoom.onGestureStart, passiveListener); 5688 slides.off(swiper.touchEvents.move, zoom.onGestureChange, passiveListener); 5689 slides.off(swiper.touchEvents.end, zoom.onGestureEnd, passiveListener); 5690 } 5691 5692 // Move image 5693 swiper.slides.each(function (index, slideEl) { 5694 var $slideEl = $$1(slideEl); 5695 if ($slideEl.find(("." + (swiper.params.zoom.containerClass))).length > 0) { 5696 $slideEl.off(swiper.touchEvents.move, zoom.onTouchMove); 5697 } 5698 }); 5699 }, 5700}; 5701 5702var Zoom$1 = { 5703 name: 'zoom', 5704 params: { 5705 zoom: { 5706 enabled: false, 5707 maxRatio: 3, 5708 minRatio: 1, 5709 toggle: true, 5710 containerClass: 'swiper-zoom-container', 5711 zoomedSlideClass: 'swiper-slide-zoomed', 5712 }, 5713 }, 5714 create: function create() { 5715 var swiper = this; 5716 var zoom = { 5717 enabled: false, 5718 scale: 1, 5719 currentScale: 1, 5720 isScaling: false, 5721 gesture: { 5722 $slideEl: undefined, 5723 slideWidth: undefined, 5724 slideHeight: undefined, 5725 $imageEl: undefined, 5726 $imageWrapEl: undefined, 5727 maxRatio: 3, 5728 }, 5729 image: { 5730 isTouched: undefined, 5731 isMoved: undefined, 5732 currentX: undefined, 5733 currentY: undefined, 5734 minX: undefined, 5735 minY: undefined, 5736 maxX: undefined, 5737 maxY: undefined, 5738 width: undefined, 5739 height: undefined, 5740 startX: undefined, 5741 startY: undefined, 5742 touchesStart: {}, 5743 touchesCurrent: {}, 5744 }, 5745 velocity: { 5746 x: undefined, 5747 y: undefined, 5748 prevPositionX: undefined, 5749 prevPositionY: undefined, 5750 prevTime: undefined, 5751 }, 5752 }; 5753 ('onGestureStart onGestureChange onGestureEnd onTouchStart onTouchMove onTouchEnd onTransitionEnd toggle enable disable in out').split(' ').forEach(function (methodName) { 5754 zoom[methodName] = Zoom[methodName].bind(swiper); 5755 }); 5756 Utils.extend(swiper, { 5757 zoom: zoom, 5758 }); 5759 }, 5760 on: {
5761 init: function init() { 5762 var swiper = this; 5763 if (swiper.params.zoom.enabled) { 5764 swiper.zoom.enable(); 5765 } 5766 }, 5767 destroy: function destroy() { 5768 var swiper = this; 5769 swiper.zoom.disable(); 5770 }, 5771 touchStart: function touchStart(e) { 5772 var swiper = this; 5773 if (!swiper.zoom.enabled) { return; } 5774 swiper.zoom.onTouchStart(e); 5775 }, 5776 touchEnd: function touchEnd(e) { 5777 var swiper = this; 5778 if (!swiper.zoom.enabled) { return; } 5779 swiper.zoom.onTouchEnd(e); 5780 }, 5781 doubleTap: function doubleTap(e) { 5782 var swiper = this; 5783 if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { 5784 swiper.zoom.toggle(e); 5785 } 5786 }, 5787 transitionEnd: function transitionEnd() { 5788 var swiper = this; 5789 if (swiper.zoom.enabled && swiper.params.zoom.enabled) { 5790 swiper.zoom.onTransitionEnd(); 5791 } 5792 }, 5793 }, 5794}; 5795 5796var Lazy = { 5797 loadInSlide: function loadInSlide(index, loadInDuplicate) { 5798 if ( loadInDuplicate === void 0 ) loadInDuplicate = true; 5799 5800 var swiper = this; 5801 var params = swiper.params.lazy; 5802 if (typeof index === 'undefined') { return; } 5803 if (swiper.slides.length === 0) { return; } 5804 var isVirtual = swiper.virtual && swiper.params.virtual.enabled; 5805 5806 var $slideEl = isVirtual 5807 ? swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")) 5808 : swiper.slides.eq(index); 5809 5810 var $images = $slideEl.find(("." + (params.elementClass) + ":not(." + (params.loadedClass) + "):not(." + (params.loadingClass) + ")")); 5811 if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { 5812 $images = $images.add($slideEl[0]); 5813 } 5814 if ($images.length === 0) { return; } 5815 5816 $images.each(function (imageIndex, imageEl) { 5817 var $imageEl = $$1(imageEl); 5818 $imageEl.addClass(params.loadingClass); 5819 5820 var background = $imageEl.attr('data-background'); 5821 var src = $imageEl.attr('data-src'); 5822 var srcset = $imageEl.attr('data-srcset'); 5823 var sizes = $imageEl.attr('data-sizes'); 5824 5825 swiper.loadImage($imageEl[0], (src || background), srcset, sizes, false, function () { 5826 if (typeof swiper === 'undefined' || swiper === null || !swiper || (swiper && !swiper.params) || swiper.destroyed) { return; } 5827 if (background) { 5828 $imageEl.css('background-image', ("url(\"" + background + "\")")); 5829 $imageEl.removeAttr('data-background'); 5830 } else { 5831 if (srcset) { 5832 $imageEl.attr('srcset', srcset); 5833 $imageEl.removeAttr('data-srcset'); 5834 } 5835 if (sizes) { 5836 $imageEl.attr('sizes', sizes); 5837 $imageEl.removeAttr('data-sizes'); 5838 } 5839 if (src) { 5840 $imageEl.attr('src', src); 5841 $imageEl.removeAttr('data-src'); 5842 } 5843 } 5844 5845 $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); 5846 $slideEl.find(("." + (params.preloaderClass))).remove(); 5847 if (swiper.params.loop && loadInDuplicate) { 5848 var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); 5849 if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { 5850 var originalSlide = swiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + (swiper.params.slideDuplicateClass) + ")")); 5851 swiper.lazy.loadInSlide(originalSlide.index(), false); 5852 } else { 5853 var duplicatedSlide = swiper.$wrapperEl.children(("." + (swiper.params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]")); 5854 swiper.lazy.loadInSlide(duplicatedSlide.index(), false); 5855 } 5856 } 5857 swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]); 5858 }); 5859 5860 swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]); 5861 }); 5862 }, 5863 load: function load() { 5864 var swiper = this; 5865 var $wrapperEl = swiper.$wrapperEl; 5866 var swiperParams = swiper.params; 5867 var slides = swiper.slides; 5868 var activeIndex = swiper.activeIndex; 5869 var isVirtual = swiper.virtual && swiperParams.virtual.enabled; 5870 var params = swiperParams.lazy; 5871 5872 var slidesPerView = swiperParams.slidesPerView; 5873 if (slidesPerView === 'auto') { 5874 slidesPerView = 0; 5875 } 5876 5877 function slideExist(index) { 5878 if (isVirtual) { 5879 if ($wrapperEl.children(("." + (swiperParams.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")).length) { 5880 return true; 5881 } 5882 } else if (slides[index]) { return true; } 5883 return false;
5884 } 5885 function slideIndex(slideEl) { 5886 if (isVirtual) { 5887 return $$1(slideEl).attr('data-swiper-slide-index'); 5888 } 5889 return $$1(slideEl).index(); 5890 } 5891 5892 if (!swiper.lazy.initialImageLoaded) { swiper.lazy.initialImageLoaded = true; } 5893 if (swiper.params.watchSlidesVisibility) { 5894 $wrapperEl.children(("." + (swiperParams.slideVisibleClass))).each(function (elIndex, slideEl) { 5895 var index = isVirtual ? $$1(slideEl).attr('data-swiper-slide-index') : $$1(slideEl).index(); 5896 swiper.lazy.loadInSlide(index); 5897 }); 5898 } else if (slidesPerView > 1) { 5899 for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) { 5900 if (slideExist(i)) { swiper.lazy.loadInSlide(i); } 5901 } 5902 } else { 5903 swiper.lazy.loadInSlide(activeIndex); 5904 } 5905 if (params.loadPrevNext) { 5906 if (slidesPerView > 1 || (params.loadPrevNextAmount && params.loadPrevNextAmount > 1)) { 5907 var amount = params.loadPrevNextAmount; 5908 var spv = slidesPerView; 5909 var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); 5910 var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); 5911 // Next Slides 5912 for (var i$1 = activeIndex + slidesPerView; i$1 < maxIndex; i$1 += 1) { 5913 if (slideExist(i$1)) { swiper.lazy.loadInSlide(i$1); } 5914 } 5915 // Prev Slides 5916 for (var i$2 = minIndex; i$2 < activeIndex; i$2 += 1) { 5917 if (slideExist(i$2)) { swiper.lazy.loadInSlide(i$2); } 5918 } 5919 } else { 5920 var nextSlide = $wrapperEl.children(("." + (swiperParams.slideNextClass))); 5921 if (nextSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(nextSlide)); } 5922 5923 var prevSlide = $wrapperEl.children(("." + (swiperParams.slidePrevClass))); 5924 if (prevSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(prevSlide)); } 5925 } 5926 } 5927 }, 5928}; 5929 5930var Lazy$1 = { 5931 name: 'lazy', 5932 params: { 5933 lazy: { 5934 enabled: false, 5935 loadPrevNext: false, 5936 loadPrevNextAmount: 1, 5937 loadOnTransitionStart: false, 5938 5939 elementClass: 'swiper-lazy', 5940 loadingClass: 'swiper-lazy-loading', 5941 loadedClass: 'swiper-lazy-loaded', 5942 preloaderClass: 'swiper-lazy-preloader', 5943 }, 5944 }, 5945 create: function create() { 5946 var swiper = this; 5947 Utils.extend(swiper, { 5948 lazy: { 5949 initialImageLoaded: false, 5950 load: Lazy.load.bind(swiper), 5951 loadInSlide: Lazy.loadInSlide.bind(swiper), 5952 }, 5953 }); 5954 }, 5955 on: { 5956 beforeInit: function beforeInit() { 5957 var swiper = this; 5958 if (swiper.params.preloadImages) { swiper.params.preloadImages = false; } 5959 }, 5960 init: function init() { 5961 var swiper = this; 5962 if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) { 5963 swiper.lazy.load(); 5964 } 5965 }, 5966 scroll: function scroll() { 5967 var swiper = this; 5968 if (swiper.params.freeMode && !swiper.params.freeModeSticky) { 5969 swiper.lazy.load(); 5970 } 5971 }, 5972 resize: function resize() { 5973 var swiper = this; 5974 if (swiper.params.lazy.enabled) { 5975 swiper.lazy.load(); 5976 } 5977 }, 5978 scrollbarDragMove: function scrollbarDragMove() { 5979 var swiper = this; 5980 if (swiper.params.lazy.enabled) { 5981 swiper.lazy.load(); 5982 } 5983 }, 5984 transitionStart: function transitionStart() { 5985 var swiper = this; 5986 if (swiper.params.lazy.enabled) { 5987 if (swiper.params.lazy.loadOnTransitionStart || (!swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded)) { 5988 swiper.lazy.load(); 5989 } 5990 } 5991 }, 5992 transitionEnd: function transitionEnd() { 5993 var swiper = this; 5994 if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { 5995 swiper.lazy.load(); 5996 } 5997 }, 5998 }, 5999}; 6000 6001/* eslint no-bitwise: ["error", { "allow": [">>"] }] */ 6002var Controller = { 6003 LinearSpline: function LinearSpline(x, y) { 6004 var binarySearch = (function search() { 6005 var maxIndex; 6006 var minIndex; 6007 var guess; 6008 return function (array, val) { 6009 minIndex = -1; 6010 maxIndex = array.length; 6011 while (maxIndex - minIndex > 1) {
6012 guess = maxIndex + minIndex >> 1; 6013 if (array[guess] <= val) { 6014 minIndex = guess; 6015 } else { 6016 maxIndex = guess; 6017 } 6018 } 6019 return maxIndex; 6020 }; 6021 }()); 6022 this.x = x; 6023 this.y = y; 6024 this.lastIndex = x.length - 1; 6025 // Given an x value (x2), return the expected y2 value: 6026 // (x1,y1) is the known point before given value, 6027 // (x3,y3) is the known point after given value. 6028 var i1; 6029 var i3; 6030 6031 this.interpolate = function interpolate(x2) { 6032 if (!x2) { return 0; } 6033 6034 // Get the indexes of x1 and x3 (the array indexes before and after given x2): 6035 i3 = binarySearch(this.x, x2); 6036 i1 = i3 - 1; 6037 6038 // We have our indexes i1 & i3, so we can calculate already: 6039 // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 6040 return (((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1])) + this.y[i1]; 6041 }; 6042 return this; 6043 }, 6044 // xxx: for now i will just save one spline function to to 6045 getInterpolateFunction: function getInterpolateFunction(c) { 6046 var swiper = this; 6047 if (!swiper.controller.spline) { 6048 swiper.controller.spline = swiper.params.loop ? 6049 new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) : 6050 new Controller.LinearSpline(swiper.snapGrid, c.snapGrid); 6051 } 6052 }, 6053 setTranslate: function setTranslate(setTranslate$1, byController) { 6054 var swiper = this; 6055 var controlled = swiper.controller.control; 6056 var multiplier; 6057 var controlledTranslate; 6058 function setControlledTranslate(c) { 6059 // this will create an Interpolate function based on the snapGrids 6060 // x is the Grid of the scrolled scroller and y will be the controlled scroller 6061 // it makes sense to create this only once and recall it for the interpolation 6062 // the function does a lot of value caching for performance 6063 var translate = c.rtl && c.params.direction === 'horizontal' ? -swiper.translate : swiper.translate; 6064 if (swiper.params.controller.by === 'slide') { 6065 swiper.controller.getInterpolateFunction(c); 6066 // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid 6067 // but it did not work out 6068 controlledTranslate = -swiper.controller.spline.interpolate(-translate); 6069 } 6070 6071 if (!controlledTranslate || swiper.params.controller.by === 'container') { 6072 multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); 6073 controlledTranslate = ((translate - swiper.minTranslate()) * multiplier) + c.minTranslate(); 6074 } 6075 6076 if (swiper.params.controller.inverse) { 6077 controlledTranslate = c.maxTranslate() - controlledTranslate; 6078 } 6079 c.updateProgress(controlledTranslate); 6080 c.setTranslate(controlledTranslate, swiper); 6081 c.updateActiveIndex(); 6082 c.updateSlidesClasses(); 6083 } 6084 if (Array.isArray(controlled)) { 6085 for (var i = 0; i < controlled.length; i += 1) { 6086 if (controlled[i] !== byController && controlled[i] instanceof Swiper$1) { 6087 setControlledTranslate(controlled[i]); 6088 } 6089 } 6090 } else if (controlled instanceof Swiper$1 && byController !== controlled) { 6091 setControlledTranslate(controlled); 6092 } 6093 }, 6094 setTransition: function setTransition(duration, byController) { 6095 var swiper = this; 6096 var controlled = swiper.controller.control; 6097 var i; 6098 function setControlledTransition(c) { 6099 c.setTransition(duration, swiper); 6100 if (duration !== 0) { 6101 c.transitionStart(); 6102 c.$wrapperEl.transitionEnd(function () { 6103 if (!controlled) { return; } 6104 if (c.params.loop && swiper.params.controller.by === 'slide') { 6105 c.loopFix(); 6106 } 6107 c.transitionEnd(); 6108 }); 6109 } 6110 } 6111 if (Array.isArray(controlled)) { 6112 for (i = 0; i < controlled.length; i += 1) { 6113 if (controlled[i] !== byController && controlled[i] instanceof Swiper$1) { 6114 setControlledTransition(controlled[i]); 6115 } 6116 } 6117 } else if (controlled instanceof Swiper$1 && byController !== controlled) { 6118 setControlledTransition(controlled); 6119 } 6120 }, 6121}; 6122var Controller$1 = { 6123 name: 'controller', 6124 params: { 6125 controller: { 6126 control: undefined, 6127 inverse: false, 6128 by: 'slide', // or 'container' 6129 }, 6130 }, 6131 create: function create() { 6132 var swiper = this; 6133 Utils.extend(swiper, { 6134 controller: { 6135 control: swiper.params.controller.control, 6136 getInterpolateFunction: Controller.getInterpolateFunction.bind(swiper), 6137 setTranslate: Controller.setTranslate.bind(swiper), 6138 setTransition: Controller.setTransition.bind(swiper), 6139 }, 6140 }); 6141 }, 6142 on: {
6143 update: function update() { 6144 var swiper = this; 6145 if (!swiper.controller.control) { return; } 6146 if (swiper.controller.spline) { 6147 swiper.controller.spline = undefined; 6148 delete swiper.controller.spline; 6149 } 6150 }, 6151 resize: function resize() { 6152 var swiper = this; 6153 if (!swiper.controller.control) { return; } 6154 if (swiper.controller.spline) { 6155 swiper.controller.spline = undefined; 6156 delete swiper.controller.spline; 6157 } 6158 }, 6159 observerUpdate: function observerUpdate() { 6160 var swiper = this; 6161 if (!swiper.controller.control) { return; } 6162 if (swiper.controller.spline) { 6163 swiper.controller.spline = undefined; 6164 delete swiper.controller.spline; 6165 } 6166 }, 6167 setTranslate: function setTranslate(translate, byController) { 6168 var swiper = this; 6169 if (!swiper.controller.control) { return; } 6170 swiper.controller.setTranslate(translate, byController); 6171 }, 6172 setTransition: function setTransition(duration, byController) { 6173 var swiper = this; 6174 if (!swiper.controller.control) { return; } 6175 swiper.controller.setTransition(duration, byController); 6176 }, 6177 }, 6178}; 6179 6180var a11y = { 6181 makeElFocusable: function makeElFocusable($el) { 6182 $el.attr('tabIndex', '0'); 6183 return $el; 6184 }, 6185 addElRole: function addElRole($el, role) { 6186 $el.attr('role', role); 6187 return $el; 6188 }, 6189 addElLabel: function addElLabel($el, label) { 6190 $el.attr('aria-label', label); 6191 return $el; 6192 }, 6193 disableEl: function disableEl($el) { 6194 $el.attr('aria-disabled', true); 6195 return $el; 6196 }, 6197 enableEl: function enableEl($el) { 6198 $el.attr('aria-disabled', false); 6199 return $el; 6200 }, 6201 onEnterKey: function onEnterKey(e) { 6202 var swiper = this; 6203 var params = swiper.params.a11y; 6204 if (e.keyCode !== 13) { return; } 6205 var $targetEl = $$1(e.target); 6206 if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { 6207 if (!(swiper.isEnd && !swiper.params.loop)) { 6208 swiper.slideNext(); 6209 } 6210 if (swiper.isEnd) { 6211 swiper.a11y.notify(params.lastSlideMessage); 6212 } else { 6213 swiper.a11y.notify(params.nextSlideMessage); 6214 } 6215 } 6216 if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { 6217 if (!(swiper.isBeginning && !swiper.params.loop)) { 6218 swiper.slidePrev(); 6219 } 6220 if (swiper.isBeginning) { 6221 swiper.a11y.notify(params.firstSlideMessage); 6222 } else { 6223 swiper.a11y.notify(params.prevSlideMessage); 6224 } 6225 } 6226 if (swiper.pagination && $targetEl.is(("." + (swiper.params.pagination.bulletClass)))) { 6227 $targetEl[0].click(); 6228 } 6229 }, 6230 notify: function notify(message) { 6231 var swiper = this; 6232 var notification = swiper.a11y.liveRegion; 6233 if (notification.length === 0) { return; } 6234 notification.html(''); 6235 notification.html(message); 6236 }, 6237 updateNavigation: function updateNavigation() { 6238 var swiper = this; 6239 6240 if (swiper.params.loop) { return; } 6241 var ref = swiper.navigation; 6242 var $nextEl = ref.$nextEl; 6243 var $prevEl = ref.$prevEl; 6244 6245 if ($prevEl && $prevEl.length > 0) { 6246 if (swiper.isBeginning) { 6247 swiper.a11y.disableEl($prevEl); 6248 } else { 6249 swiper.a11y.enableEl($prevEl); 6250 } 6251 } 6252 if ($nextEl && $nextEl.length > 0) { 6253 if (swiper.isEnd) { 6254 swiper.a11y.disableEl($nextEl); 6255 } else { 6256 swiper.a11y.enableEl($nextEl); 6257 } 6258 } 6259 }, 6260 updatePagination: function updatePagination() { 6261 var swiper = this; 6262 var params = swiper.params.a11y; 6263 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 6264 swiper.pagination.bullets.each(function (bulletIndex, bulletEl) { 6265 var $bulletEl = $$1(bulletEl); 6266 swiper.a11y.makeElFocusable($bulletEl); 6267 swiper.a11y.addElRole($bulletEl, 'button'); 6268 swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/{{index}}/, $bulletEl.index() + 1)); 6269 }); 6270 } 6271 },
6272 init: function init() { 6273 var swiper = this; 6274 6275 swiper.$el.append(swiper.a11y.liveRegion); 6276 6277 // Navigation 6278 var params = swiper.params.a11y; 6279 var $nextEl; 6280 var $prevEl; 6281 if (swiper.navigation && swiper.navigation.$nextEl) { 6282 $nextEl = swiper.navigation.$nextEl; 6283 } 6284 if (swiper.navigation && swiper.navigation.$prevEl) { 6285 $prevEl = swiper.navigation.$prevEl; 6286 } 6287 if ($nextEl) { 6288 swiper.a11y.makeElFocusable($nextEl); 6289 swiper.a11y.addElRole($nextEl, 'button'); 6290 swiper.a11y.addElLabel($nextEl, params.nextSlideMessage); 6291 $nextEl.on('keydown', swiper.a11y.onEnterKey); 6292 } 6293 if ($prevEl) { 6294 swiper.a11y.makeElFocusable($prevEl); 6295 swiper.a11y.addElRole($prevEl, 'button'); 6296 swiper.a11y.addElLabel($prevEl, params.prevSlideMessage); 6297 $prevEl.on('keydown', swiper.a11y.onEnterKey); 6298 } 6299 6300 // Pagination 6301 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 6302 swiper.pagination.$el.on('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); 6303 } 6304 }, 6305 destroy: function destroy() { 6306 var swiper = this; 6307 if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) { swiper.a11y.liveRegion.remove(); } 6308 6309 var $nextEl; 6310 var $prevEl; 6311 if (swiper.navigation && swiper.navigation.$nextEl) { 6312 $nextEl = swiper.navigation.$nextEl; 6313 } 6314 if (swiper.navigation && swiper.navigation.$prevEl) { 6315 $prevEl = swiper.navigation.$prevEl; 6316 } 6317 if ($nextEl) { 6318 $nextEl.off('keydown', swiper.a11y.onEnterKey); 6319 } 6320 if ($prevEl) { 6321 $prevEl.off('keydown', swiper.a11y.onEnterKey); 6322 } 6323 6324 // Pagination 6325 if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { 6326 swiper.pagination.$el.off('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); 6327 } 6328 }, 6329}; 6330var A11y = { 6331 name: 'a11y', 6332 params: { 6333 a11y: { 6334 enabled: false, 6335 notificationClass: 'swiper-notification', 6336 prevSlideMessage: 'Previous slide', 6337 nextSlideMessage: 'Next slide', 6338 firstSlideMessage: 'This is the first slide', 6339 lastSlideMessage: 'This is the last slide', 6340 paginationBulletMessage: 'Go to slide {{index}}', 6341 }, 6342 }, 6343 create: function create() { 6344 var swiper = this; 6345 Utils.extend(swiper, { 6346 a11y: { 6347 liveRegion: $$1(("<span class=\"" + (swiper.params.a11y.notificationClass) + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>")), 6348 }, 6349 }); 6350 Object.keys(a11y).forEach(function (methodName) { 6351 swiper.a11y[methodName] = a11y[methodName].bind(swiper); 6352 }); 6353 }, 6354 on: { 6355 init: function init() { 6356 var swiper = this; 6357 if (!swiper.params.a11y.enabled) { return; } 6358 swiper.a11y.init(); 6359 swiper.a11y.updateNavigation(); 6360 }, 6361 toEdge: function toEdge() { 6362 var swiper = this; 6363 if (!swiper.params.a11y.enabled) { return; } 6364 swiper.a11y.updateNavigation(); 6365 }, 6366 fromEdge: function fromEdge() { 6367 var swiper = this; 6368 if (!swiper.params.a11y.enabled) { return; } 6369 swiper.a11y.updateNavigation(); 6370 }, 6371 paginationUpdate: function paginationUpdate() { 6372 var swiper = this; 6373 if (!swiper.params.a11y.enabled) { return; } 6374 swiper.a11y.updatePagination(); 6375 }, 6376 destroy: function destroy() { 6377 var swiper = this; 6378 if (!swiper.params.a11y.enabled) { return; } 6379 swiper.a11y.destroy(); 6380 }, 6381 }, 6382}; 6383 6384var History = { 6385 init: function init() { 6386 var swiper = this; 6387 if (!swiper.params.history) { return; } 6388 if (!win.history || !win.history.pushState) { 6389 swiper.params.history.enabled = false; 6390 swiper.params.hashNavigation.enabled = true; 6391 return; 6392 } 6393 var history = swiper.history; 6394 history.initialized = true; 6395 history.paths = History.getPathValues(); 6396 if (!history.paths.key && !history.paths.value) { return; } 6397 history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit); 6398 if (!swiper.params.history.replaceState) { 6399 win.addEventListener('popstate', swiper.history.setHistoryPopState); 6400 } 6401 }, 6402 destroy: function destroy() { 6403 var swiper = this; 6404 if (!swiper.params.history.replaceState) { 6405 win.removeEventListener('popstate', swiper.history.setHistoryPopState); 6406 } 6407 }, 6408 setHistoryPopState: function setHistoryPopState() { 6409 var swiper = this; 6410 swiper.history.paths = History.getPathValues(); 6411 swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false); 6412 }, 6413 getPathValues: function getPathValues() { 6414 var pathArray = win.location.pathname.slice(1).split('/').filter(function (part) { return part !== ''; }); 6415 var total = pathArray.length; 6416 var key = pathArray[total - 2]; 6417 var value = pathArray[total - 1]; 6418 return { key: key, value: value }; 6419 }, 6420 setHistory: function setHistory(key, index) { 6421 var swiper = this; 6422 if (!swiper.history.initialized || !swiper.params.history.enabled) { return; } 6423 var slide = swiper.slides.eq(index); 6424 var value = History.slugify(slide.attr('data-history')); 6425 if (!win.location.pathname.includes(key)) { 6426 value = key + "/" + value; 6427 } 6428 var currentState = win.history.state; 6429 if (currentState && currentState.value === value) { 6430 return; 6431 } 6432 if (swiper.params.history.replaceState) { 6433 win.history.replaceState({ value: value }, null, value); 6434 } else { 6435 win.history.pushState({ value: value }, null, value); 6436 } 6437 }, 6438 slugify: function slugify(text) { 6439 return text.toString().toLowerCase() 6440 .replace(/\s+/g, '-') 6441 .replace(/[^\w-]+/g, '') 6442 .replace(/--+/g, '-') 6443 .replace(/^-+/, '') 6444 .replace(/-+$/, ''); 6445 }, 6446 scrollToSlide: function scrollToSlide(speed, value, runCallbacks) { 6447 var swiper = this; 6448 if (value) { 6449 for (var i = 0, length = swiper.slides.length; i < length; i += 1) { 6450 var slide = swiper.slides.eq(i); 6451 var slideHistory = History.slugify(slide.attr('data-history')); 6452 if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { 6453 var index = slide.index(); 6454 swiper.slideTo(index, speed, runCallbacks); 6455 } 6456 } 6457 } else { 6458 swiper.slideTo(0, speed, runCallbacks); 6459 } 6460 }, 6461}; 6462 6463var History$1 = { 6464 name: 'history', 6465 params: { 6466 history: { 6467 enabled: false, 6468 replaceState: false, 6469 key: 'slides', 6470 }, 6471 }, 6472 create: function create() { 6473 var swiper = this; 6474 Utils.extend(swiper, { 6475 history: { 6476 init: History.init.bind(swiper), 6477 setHistory: History.setHistory.bind(swiper), 6478 setHistoryPopState: History.setHistoryPopState.bind(swiper), 6479 scrollToSlide: History.scrollToSlide.bind(swiper), 6480 }, 6481 }); 6482 }, 6483 on: {
6484 init: function init() { 6485 var swiper = this; 6486 if (swiper.params.history.enabled) { 6487 swiper.history.init(); 6488 } 6489 }, 6490 destroy: function destroy() { 6491 var swiper = this; 6492 if (swiper.params.history.enabled) { 6493 swiper.history.destroy(); 6494 } 6495 }, 6496 transitionEnd: function transitionEnd() { 6497 var swiper = this; 6498 if (swiper.history.initialized) { 6499 swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); 6500 } 6501 }, 6502 }, 6503}; 6504 6505var HashNavigation = { 6506 onHashCange: function onHashCange() { 6507 var swiper = this; 6508 var newHash = doc.location.hash.replace('#', ''); 6509 var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); 6510 if (newHash !== activeSlideHash) { 6511 swiper.slideTo(swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-hash=\"" + newHash + "\"]")).index()); 6512 } 6513 }, 6514 setHash: function setHash() { 6515 var swiper = this; 6516 if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) { return; } 6517 if (swiper.params.hashNavigation.replaceState && win.history && win.history.replaceState) { 6518 win.history.replaceState(null, null, (("#" + (swiper.slides.eq(swiper.activeIndex).attr('data-hash'))) || '')); 6519 } else { 6520 var slide = swiper.slides.eq(swiper.activeIndex); 6521 var hash = slide.attr('data-hash') || slide.attr('data-history'); 6522 doc.location.hash = hash || ''; 6523 } 6524 }, 6525 init: function init() { 6526 var swiper = this; 6527 if (!swiper.params.hashNavigation.enabled || (swiper.params.history && swiper.params.history.enabled)) { return; } 6528 swiper.hashNavigation.initialized = true; 6529 var hash = doc.location.hash.replace('#', ''); 6530 if (hash) { 6531 var speed = 0; 6532 for (var i = 0, length = swiper.slides.length; i < length; i += 1) { 6533 var slide = swiper.slides.eq(i); 6534 var slideHash = slide.attr('data-hash') || slide.attr('data-history'); 6535 if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { 6536 var index = slide.index(); 6537 swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); 6538 } 6539 } 6540 } 6541 if (swiper.params.hashNavigation.watchState) { 6542 $$1(win).on('hashchange', swiper.hashNavigation.onHashCange); 6543 } 6544 }, 6545 destroy: function destroy() { 6546 var swiper = this; 6547 if (swiper.params.hashNavigation.watchState) { 6548 $$1(win).off('hashchange', swiper.hashNavigation.onHashCange); 6549 } 6550 }, 6551}; 6552var HashNavigation$1 = { 6553 name: 'hash-navigation', 6554 params: { 6555 hashNavigation: { 6556 enabled: false, 6557 replaceState: false, 6558 watchState: false, 6559 }, 6560 }, 6561 create: function create() { 6562 var swiper = this; 6563 Utils.extend(swiper, { 6564 hashNavigation: { 6565 initialized: false, 6566 init: HashNavigation.init.bind(swiper), 6567 destroy: HashNavigation.destroy.bind(swiper), 6568 setHash: HashNavigation.setHash.bind(swiper), 6569 onHashCange: HashNavigation.onHashCange.bind(swiper), 6570 }, 6571 }); 6572 }, 6573 on: { 6574 init: function init() { 6575 var swiper = this; 6576 if (swiper.params.hashNavigation.enabled) { 6577 swiper.hashNavigation.init(); 6578 } 6579 }, 6580 destroy: function destroy() { 6581 var swiper = this; 6582 if (swiper.params.hashNavigation.enabled) { 6583 swiper.hashNavigation.destroy(); 6584 } 6585 }, 6586 transitionEnd: function transitionEnd() { 6587 var swiper = this; 6588 if (swiper.hashNavigation.initialized) { 6589 swiper.hashNavigation.setHash(); 6590 } 6591 }, 6592 }, 6593}; 6594 6595var Autoplay = { 6596 run: function run() { 6597 var swiper = this; 6598 var $activeSlideEl = swiper.slides.eq(swiper.activeIndex); 6599 var delay = swiper.params.autoplay.delay; 6600 if ($activeSlideEl.attr('data-swiper-autoplay')) { 6601 delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; 6602 } 6603 swiper.autoplay.timeout = Utils.nextTick(function () { 6604 if (swiper.params.loop) { 6605 swiper.loopFix(); 6606 swiper.slideNext(swiper.params.speed, true, true); 6607 swiper.emit('autoplay'); 6608 } else if (!swiper.isEnd) { 6609 swiper.slideNext(swiper.params.speed, true, true); 6610 swiper.emit('autoplay'); 6611 } else if (!swiper.params.autoplay.stopOnLastSlide) { 6612 swiper.slideTo(0, swiper.params.speed, true, true); 6613 swiper.emit('autoplay'); 6614 } else { 6615 swiper.autoplay.stop(); 6616 } 6617 }, delay); 6618 }, 6619 start: function start() { 6620 var swiper = this; 6621 if (typeof swiper.autoplay.timeout !== 'undefined') { return false; } 6622 if (swiper.autoplay.running) { return false; } 6623 swiper.autoplay.running = true; 6624 swiper.emit('autoplayStart'); 6625 swiper.autoplay.run(); 6626 return true; 6627 }, 6628 stop: function stop() { 6629 var swiper = this; 6630 if (!swiper.autoplay.running) { return false; } 6631 if (typeof swiper.autoplay.timeout === 'undefined') { return false; } 6632 6633 if (swiper.autoplay.timeout) { 6634 clearTimeout(swiper.autoplay.timeout); 6635 swiper.autoplay.timeout = undefined; 6636 } 6637 swiper.autoplay.running = false;
6638 swiper.emit('autoplayStop'); 6639 return true; 6640 }, 6641 pause: function pause(speed) { 6642 var swiper = this; 6643 if (!swiper.autoplay.running) { return; } 6644 if (swiper.autoplay.paused) { return; } 6645 if (swiper.autoplay.timeout) { clearTimeout(swiper.autoplay.timeout); } 6646 swiper.autoplay.paused = true; 6647 if (speed === 0) { 6648 swiper.autoplay.paused = false; 6649 swiper.autoplay.run(); 6650 } else { 6651 swiper.$wrapperEl.transitionEnd(function () { 6652 if (!swiper || swiper.destroyed) { return; } 6653 swiper.autoplay.paused = false; 6654 if (!swiper.autoplay.running) { 6655 swiper.autoplay.stop(); 6656 } else { 6657 swiper.autoplay.run(); 6658 } 6659 }); 6660 } 6661 }, 6662}; 6663 6664var Autoplay$1 = { 6665 name: 'autoplay', 6666 params: { 6667 autoplay: { 6668 enabled: false, 6669 delay: 3000, 6670 disableOnInteraction: true, 6671 stopOnLastSlide: false, 6672 }, 6673 }, 6674 create: function create() { 6675 var swiper = this; 6676 Utils.extend(swiper, { 6677 autoplay: { 6678 running: false, 6679 paused: false, 6680 run: Autoplay.run.bind(swiper), 6681 start: Autoplay.start.bind(swiper), 6682 stop: Autoplay.stop.bind(swiper), 6683 pause: Autoplay.pause.bind(swiper), 6684 }, 6685 }); 6686 }, 6687 on: { 6688 init: function init() { 6689 var swiper = this; 6690 if (swiper.params.autoplay.enabled) { 6691 swiper.autoplay.start(); 6692 } 6693 }, 6694 beforeTransitionStart: function beforeTransitionStart(speed, internal) { 6695 var swiper = this; 6696 if (swiper.autoplay.running) { 6697 if (internal || !swiper.params.autoplay.disableOnInteraction) { 6698 swiper.autoplay.pause(speed); 6699 } else { 6700 swiper.autoplay.stop(); 6701 } 6702 } 6703 }, 6704 sliderFirstMove: function sliderFirstMove() { 6705 var swiper = this; 6706 if (swiper.autoplay.running) { 6707 if (swiper.params.autoplay.disableOnInteraction) { 6708 swiper.autoplay.stop(); 6709 } else { 6710 swiper.autoplay.pause(); 6711 } 6712 } 6713 }, 6714 destroy: function destroy() { 6715 var swiper = this; 6716 if (swiper.autoplay.running) { 6717 swiper.autoplay.stop(); 6718 } 6719 }, 6720 }, 6721}; 6722 6723var Fade = { 6724 setTranslate: function setTranslate() { 6725 var swiper = this; 6726 var slides = swiper.slides; 6727 for (var i = 0; i < slides.length; i += 1) { 6728 var $slideEl = swiper.slides.eq(i); 6729 var offset = $slideEl[0].swiperSlideOffset; 6730 var tx = -offset; 6731 if (!swiper.params.virtualTranslate) { tx -= swiper.translate; } 6732 var ty = 0; 6733 if (!swiper.isHorizontal()) { 6734 ty = tx; 6735 tx = 0; 6736 } 6737 var slideOpacity = swiper.params.fadeEffect.crossFade ? 6738 Math.max(1 - Math.abs($slideEl[0].progress), 0) : 6739 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); 6740 $slideEl 6741 .css({ 6742 opacity: slideOpacity, 6743 }) 6744 .transform(("translate3d(" + tx + "px, " + ty + "px, 0px)")); 6745 } 6746 }, 6747 setTransition: function setTransition(duration) { 6748 var swiper = this; 6749 var slides = swiper.slides; 6750 var $wrapperEl = swiper.$wrapperEl; 6751 slides.transition(duration); 6752 if (swiper.params.virtualTranslate && duration !== 0) { 6753 var eventTriggered = false; 6754 slides.transitionEnd(function () { 6755 if (eventTriggered) { return; } 6756 if (!swiper || swiper.destroyed) { return; } 6757 eventTriggered = true; 6758 swiper.animating = false; 6759 var triggerEvents = ['webkitTransitionEnd', 'transitionend']; 6760 for (var i = 0; i < triggerEvents.length; i += 1) { 6761 $wrapperEl.trigger(triggerEvents[i]); 6762 } 6763 }); 6764 } 6765 }, 6766}; 6767 6768var EffectFade = { 6769 name: 'effect-fade', 6770 params: { 6771 fadeEffect: { 6772 crossFade: false, 6773 }, 6774 }, 6775 create: function create() { 6776 var swiper = this; 6777 Utils.extend(swiper, { 6778 fadeEffect: { 6779 setTranslate: Fade.setTranslate.bind(swiper), 6780 setTransition: Fade.setTransition.bind(swiper), 6781 }, 6782 }); 6783 }, 6784 on: { 6785 beforeInit: function beforeInit() { 6786 var swiper = this; 6787 if (swiper.params.effect !== 'fade') { return; } 6788 swiper.classNames.push(((swiper.params.containerModifierClass) + "fade")); 6789 var overwriteParams = { 6790 slidesPerView: 1, 6791 slidesPerColumn: 1, 6792 slidesPerGroup: 1, 6793 watchSlidesProgress: true, 6794 spaceBetween: 0, 6795 virtualTranslate: true, 6796 }; 6797 Utils.extend(swiper.params, overwriteParams); 6798 Utils.extend(swiper.originalParams, overwriteParams); 6799 }, 6800 setTranslate: function setTranslate() { 6801 var swiper = this; 6802 if (swiper.params.effect !== 'fade') { return; } 6803 swiper.fadeEffect.setTranslate(); 6804 }, 6805 setTransition: function setTransition(duration) { 6806 var swiper = this; 6807 if (swiper.params.effect !== 'fade') { return; } 6808 swiper.fadeEffect.setTransition(duration); 6809 }, 6810 }, 6811}; 6812 6813var Cube = { 6814 setTranslate: function setTranslate() { 6815 var swiper = this; 6816 var $el = swiper.$el; 6817 var $wrapperEl = swiper.$wrapperEl; 6818 var slides = swiper.slides; 6819 var swiperWidth = swiper.width; 6820 var swiperHeight = swiper.height; 6821 var rtl = swiper.rtl; 6822 var swiperSize = swiper.size; 6823 var params = swiper.params.cubeEffect; 6824 var isHorizontal = swiper.isHorizontal(); 6825 var isVirtual = swiper.virtual && swiper.params.virtual.enabled; 6826 var wrapperRotate = 0; 6827 var $cubeShadowEl; 6828 if (params.shadow) { 6829 if (isHorizontal) { 6830 $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); 6831 if ($cubeShadowEl.length === 0) { 6832 $cubeShadowEl = $$1('<div class="swiper-cube-shadow"></div>'); 6833 $wrapperEl.append($cubeShadowEl); 6834 } 6835 $cubeShadowEl.css({ height: (swiperWidth + "px") }); 6836 } else { 6837 $cubeShadowEl = $el.find('.swiper-cube-shadow'); 6838 if ($cubeShadowEl.length === 0) { 6839 $cubeShadowEl = $$1('<div class="swiper-cube-shadow"></div>'); 6840 $el.append($cubeShadowEl); 6841 } 6842 } 6843 } 6844 for (var i = 0; i < slides.length; i += 1) { 6845 var $slideEl = slides.eq(i); 6846 var slideIndex = i; 6847 if (isVirtual) { 6848 slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); 6849 } 6850 var slideAngle = slideIndex * 90; 6851 var round = Math.floor(slideAngle / 360); 6852 if (rtl) { 6853 slideAngle = -slideAngle; 6854 round = Math.floor(-slideAngle / 360); 6855 } 6856 var progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 6857 var tx = 0; 6858 var ty = 0; 6859 var tz = 0; 6860 if (slideIndex % 4 === 0) { 6861 tx = -round * 4 * swiperSize; 6862 tz = 0; 6863 } else if ((slideIndex - 1) % 4 === 0) { 6864 tx = 0; 6865 tz = -round * 4 * swiperSize; 6866 } else if ((slideIndex - 2) % 4 === 0) { 6867 tx = swiperSize + (round * 4 * swiperSize); 6868 tz = swiperSize; 6869 } else if ((slideIndex - 3) % 4 === 0) { 6870 tx = -swiperSize; 6871 tz = (3 * swiperSize) + (swiperSize * 4 * round); 6872 } 6873 if (rtl) { 6874 tx = -tx; 6875 } 6876 6877 if (!isHorizontal) { 6878 ty = tx; 6879 tx = 0; 6880 } 6881 6882 var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)"; 6883 if (progress <= 1 && progress > -1) { 6884 wrapperRotate = (slideIndex * 90) + (progress * 90); 6885 if (rtl) { wrapperRotate = (-slideIndex * 90) - (progress * 90); } 6886 } 6887 $slideEl.transform(transform); 6888 if (params.slideShadows) { 6889 // Set shadows 6890 var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 6891 var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 6892 if (shadowBefore.length === 0) { 6893 shadowBefore = $$1(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); 6894 $slideEl.append(shadowBefore); 6895 } 6896 if (shadowAfter.length === 0) { 6897 shadowAfter = $$1(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); 6898 $slideEl.append(shadowAfter); 6899 } 6900 if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } 6901 if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } 6902 } 6903 } 6904 $wrapperEl.css({ 6905 '-webkit-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 6906 '-moz-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 6907 '-ms-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 6908 'transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), 6909 }); 6910 6911 if (params.shadow) { 6912 if (isHorizontal) { 6913 $cubeShadowEl.transform(("translate3d(0px, " + ((swiperWidth / 2) + params.shadowOffset) + "px, " + (-swiperWidth / 2) + "px) rotateX(90deg) rotateZ(0deg) scale(" + (params.shadowScale) + ")")); 6914 } else { 6915 var shadowAngle = Math.abs(wrapperRotate) - (Math.floor(Math.abs(wrapperRotate) / 90) * 90); 6916 var multiplier = 1.5 - (
6917 (Math.sin((shadowAngle * 2 * Math.PI) / 360) / 2) + 6918 (Math.cos((shadowAngle * 2 * Math.PI) / 360) / 2) 6919 ); 6920 var scale1 = params.shadowScale; 6921 var scale2 = params.shadowScale / multiplier; 6922 var offset = params.shadowOffset; 6923 $cubeShadowEl.transform(("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + ((swiperHeight / 2) + offset) + "px, " + (-swiperHeight / 2 / scale2) + "px) rotateX(-90deg)")); 6924 } 6925 } 6926 var zFactor = (Browser.isSafari || Browser.isUiWebView) ? (-swiperSize / 2) : 0; 6927 $wrapperEl 6928 .transform(("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)")); 6929 }, 6930 setTransition: function setTransition(duration) { 6931 var swiper = this; 6932 var $el = swiper.$el; 6933 var slides = swiper.slides; 6934 slides 6935 .transition(duration) 6936 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 6937 .transition(duration); 6938 if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { 6939 $el.find('.swiper-cube-shadow').transition(duration); 6940 } 6941 }, 6942}; 6943 6944var EffectCube = { 6945 name: 'effect-cube', 6946 params: { 6947 cubeEffect: { 6948 slideShadows: true, 6949 shadow: true, 6950 shadowOffset: 20, 6951 shadowScale: 0.94, 6952 }, 6953 }, 6954 create: function create() { 6955 var swiper = this; 6956 Utils.extend(swiper, { 6957 cubeEffect: { 6958 setTranslate: Cube.setTranslate.bind(swiper), 6959 setTransition: Cube.setTransition.bind(swiper), 6960 }, 6961 }); 6962 }, 6963 on: { 6964 beforeInit: function beforeInit() { 6965 var swiper = this; 6966 if (swiper.params.effect !== 'cube') { return; } 6967 swiper.classNames.push(((swiper.params.containerModifierClass) + "cube")); 6968 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 6969 var overwriteParams = { 6970 slidesPerView: 1, 6971 slidesPerColumn: 1, 6972 slidesPerGroup: 1, 6973 watchSlidesProgress: true, 6974 resistanceRatio: 0, 6975 spaceBetween: 0, 6976 centeredSlides: false, 6977 virtualTranslate: true, 6978 }; 6979 Utils.extend(swiper.params, overwriteParams); 6980 Utils.extend(swiper.originalParams, overwriteParams); 6981 }, 6982 setTranslate: function setTranslate() { 6983 var swiper = this; 6984 if (swiper.params.effect !== 'cube') { return; } 6985 swiper.cubeEffect.setTranslate(); 6986 }, 6987 setTransition: function setTransition(duration) { 6988 var swiper = this; 6989 if (swiper.params.effect !== 'cube') { return; } 6990 swiper.cubeEffect.setTransition(duration); 6991 }, 6992 }, 6993}; 6994 6995var Flip = { 6996 setTranslate: function setTranslate() { 6997 var swiper = this; 6998 var slides = swiper.slides; 6999 for (var i = 0; i < slides.length; i += 1) { 7000 var $slideEl = slides.eq(i); 7001 var progress = $slideEl[0].progress; 7002 if (swiper.params.flipEffect.limitRotation) { 7003 progress = Math.max(Math.min($slideEl[0].progress, 1), -1); 7004 } 7005 var offset = $slideEl[0].swiperSlideOffset; 7006 var rotate = -180 * progress; 7007 var rotateY = rotate; 7008 var rotateX = 0; 7009 var tx = -offset; 7010 var ty = 0; 7011 if (!swiper.isHorizontal()) { 7012 ty = tx; 7013 tx = 0; 7014 rotateX = -rotateY; 7015 rotateY = 0; 7016 } else if (swiper.rtl) { 7017 rotateY = -rotateY; 7018 } 7019 7020 $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; 7021 7022 if (swiper.params.flipEffect.slideShadows) { 7023 // Set shadows 7024 var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 7025 var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 7026 if (shadowBefore.length === 0) { 7027 shadowBefore = $$1(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>")); 7028 $slideEl.append(shadowBefore); 7029 } 7030 if (shadowAfter.length === 0) { 7031 shadowAfter = $$1(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>")); 7032 $slideEl.append(shadowAfter); 7033 } 7034 if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } 7035 if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } 7036 } 7037 $slideEl 7038 .transform(("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)")); 7039 } 7040 }, 7041 setTransition: function setTransition(duration) { 7042 var swiper = this; 7043 var slides = swiper.slides; 7044 var activeIndex = swiper.activeIndex; 7045 var $wrapperEl = swiper.$wrapperEl; 7046 slides 7047 .transition(duration) 7048 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 7049 .transition(duration); 7050 if (swiper.params.virtualTranslate && duration !== 0) { 7051 var eventTriggered = false;
7052 // eslint-disable-next-line 7053 slides.eq(activeIndex).transitionEnd(function onTransitionEnd() { 7054 if (eventTriggered) { return; } 7055 if (!swiper || swiper.destroyed) { return; } 7056 // if (!$(this).hasClass(swiper.params.slideActiveClass)) return; 7057 eventTriggered = true; 7058 swiper.animating = false; 7059 var triggerEvents = ['webkitTransitionEnd', 'transitionend']; 7060 for (var i = 0; i < triggerEvents.length; i += 1) { 7061 $wrapperEl.trigger(triggerEvents[i]); 7062 } 7063 }); 7064 } 7065 }, 7066}; 7067 7068var EffectFlip = { 7069 name: 'effect-flip', 7070 params: { 7071 flipEffect: { 7072 slideShadows: true, 7073 limitRotation: true, 7074 }, 7075 }, 7076 create: function create() { 7077 var swiper = this; 7078 Utils.extend(swiper, { 7079 flipEffect: { 7080 setTranslate: Flip.setTranslate.bind(swiper), 7081 setTransition: Flip.setTransition.bind(swiper), 7082 }, 7083 }); 7084 }, 7085 on: { 7086 beforeInit: function beforeInit() { 7087 var swiper = this; 7088 if (swiper.params.effect !== 'flip') { return; } 7089 swiper.classNames.push(((swiper.params.containerModifierClass) + "flip")); 7090 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 7091 var overwriteParams = { 7092 slidesPerView: 1, 7093 slidesPerColumn: 1, 7094 slidesPerGroup: 1, 7095 watchSlidesProgress: true, 7096 spaceBetween: 0, 7097 virtualTranslate: true, 7098 }; 7099 Utils.extend(swiper.params, overwriteParams); 7100 Utils.extend(swiper.originalParams, overwriteParams); 7101 }, 7102 setTranslate: function setTranslate() { 7103 var swiper = this; 7104 if (swiper.params.effect !== 'flip') { return; } 7105 swiper.flipEffect.setTranslate(); 7106 }, 7107 setTransition: function setTransition(duration) { 7108 var swiper = this; 7109 if (swiper.params.effect !== 'flip') { return; } 7110 swiper.flipEffect.setTransition(duration); 7111 }, 7112 }, 7113}; 7114 7115var Coverflow = { 7116 setTranslate: function setTranslate() { 7117 var swiper = this; 7118 var swiperWidth = swiper.width; 7119 var swiperHeight = swiper.height; 7120 var slides = swiper.slides; 7121 var $wrapperEl = swiper.$wrapperEl; 7122 var slidesSizesGrid = swiper.slidesSizesGrid; 7123 var params = swiper.params.coverflowEffect; 7124 var isHorizontal = swiper.isHorizontal(); 7125 var transform = swiper.translate; 7126 var center = isHorizontal ? -transform + (swiperWidth / 2) : -transform + (swiperHeight / 2); 7127 var rotate = isHorizontal ? params.rotate : -params.rotate; 7128 var translate = params.depth; 7129 // Each slide offset from center 7130 for (var i = 0, length = slides.length; i < length; i += 1) { 7131 var $slideEl = slides.eq(i); 7132 var slideSize = slidesSizesGrid[i]; 7133 var slideOffset = $slideEl[0].swiperSlideOffset; 7134 var offsetMultiplier = ((center - slideOffset - (slideSize / 2)) / slideSize) * params.modifier; 7135 7136 var rotateY = isHorizontal ? rotate * offsetMultiplier : 0; 7137 var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; 7138 // var rotateZ = 0 7139 var translateZ = -translate * Math.abs(offsetMultiplier); 7140 7141 var translateY = isHorizontal ? 0 : params.stretch * (offsetMultiplier); 7142 var translateX = isHorizontal ? params.stretch * (offsetMultiplier) : 0; 7143 7144 // Fix for ultra small values 7145 if (Math.abs(translateX) < 0.001) { translateX = 0; } 7146 if (Math.abs(translateY) < 0.001) { translateY = 0; } 7147 if (Math.abs(translateZ) < 0.001) { translateZ = 0; } 7148 if (Math.abs(rotateY) < 0.001) { rotateY = 0; } 7149 if (Math.abs(rotateX) < 0.001) { rotateX = 0; } 7150 7151 var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"; 7152 7153 $slideEl.transform(slideTransform); 7154 $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; 7155 if (params.slideShadows) { 7156 // Set shadows 7157 var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); 7158 var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); 7159 if ($shadowBeforeEl.length === 0) { 7160 $shadowBeforeEl = $$1(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); 7161 $slideEl.append($shadowBeforeEl); 7162 } 7163 if ($shadowAfterEl.length === 0) { 7164 $shadowAfterEl = $$1(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); 7165 $slideEl.append($shadowAfterEl); 7166 } 7167 if ($shadowBeforeEl.length) { $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; } 7168 if ($shadowAfterEl.length) { $shadowAfterEl[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0; } 7169 } 7170 } 7171 7172 // Set correct perspective for IE10 7173 if (Browser.ie) { 7174 var ws = $wrapperEl[0].style; 7175 ws.perspectiveOrigin = center + "px 50%"; 7176 } 7177 }, 7178 setTransition: function setTransition(duration) { 7179 var swiper = this; 7180 swiper.slides 7181 .transition(duration) 7182 .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') 7183 .transition(duration); 7184 }, 7185}; 7186 7187var EffectCoverflow = { 7188 name: 'effect-coverflow', 7189 params: { 7190 coverflowEffect: { 7191 rotate: 50, 7192 stretch: 0, 7193 depth: 100, 7194 modifier: 1, 7195 slideShadows: true, 7196 }, 7197 }, 7198 create: function create() { 7199 var swiper = this; 7200 Utils.extend(swiper, { 7201 coverflowEffect: { 7202 setTranslate: Coverflow.setTranslate.bind(swiper), 7203 setTransition: Coverflow.setTransition.bind(swiper), 7204 }, 7205 }); 7206 }, 7207 on: { 7208 beforeInit: function beforeInit() { 7209 var swiper = this; 7210 if (swiper.params.effect !== 'coverflow') { return; } 7211 7212 swiper.classNames.push(((swiper.params.containerModifierClass) + "coverflow")); 7213 swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); 7214 7215 swiper.params.watchSlidesProgress = true; 7216 swiper.originalParams.watchSlidesProgress = true; 7217 }, 7218 setTranslate: function setTranslate() { 7219 var swiper = this; 7220 if (swiper.params.effect !== 'coverflow') { return; } 7221 swiper.coverflowEffect.setTranslate(); 7222 }, 7223 setTransition: function setTransition(duration) { 7224 var swiper = this; 7225 if (swiper.params.effect !== 'coverflow') { return; } 7226 swiper.coverflowEffect.setTransition(duration); 7227 }, 7228 }, 7229}; 7230 7231// Swiper Class 7232// Core Modules 7233Swiper$1.components = [ 7234 Device$2, 7235 Support$2, 7236 Browser$2, 7237 Resize, 7238 Observer$1, 7239 Virtual$1, 7240 Keyboard$1, 7241 Mousewheel$1, 7242 Navigation$1, 7243 Pagination$1, 7244 Scrollbar$1, 7245 Parallax$1, 7246 Zoom$1, 7247 Lazy$1, 7248 Controller$1, 7249 A11y, 7250 History$1, 7251 HashNavigation$1, 7252 Autoplay$1, 7253 EffectFade, 7254 EffectCube, 7255 EffectFlip, 7256 EffectCoverflow 7257]; 7258 7259return Swiper$1; 7260 7261})));
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.