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