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