PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev2
Elementor Website Builder – more than just a page builder v3.23.0-dev2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / assets / lib / swiper / swiper.js

swiper.js in Elementor Website Builder – more than just a page builder 3.23.0-dev2, at assets/lib/swiper/swiper.js

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