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