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