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