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