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