UNPKG

303 kBJavaScriptView Raw
1/**
2 * Swiper 8.4.7
3 * Most modern mobile touch slider and framework with hardware accelerated transitions
4 * https://swiperjs.com
5 *
6 * Copyright 2014-2023 Vladimir Kharlampidi
7 *
8 * Released under the MIT License
9 *
10 * Released on: January 30, 2023
11 */
12
13/**
14 * SSR Window 4.0.2
15 * Better handling for window object in SSR environment
16 * https://github.com/nolimits4web/ssr-window
17 *
18 * Copyright 2021, Vladimir Kharlampidi
19 *
20 * Licensed under MIT
21 *
22 * Released on: December 13, 2021
23 */
24
25/* eslint-disable no-param-reassign */
26function isObject$1(obj) {
27 return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
28}
29
30function extend$1(target, src) {
31 if (target === void 0) {
32 target = {};
33 }
34
35 if (src === void 0) {
36 src = {};
37 }
38
39 Object.keys(src).forEach(key => {
40 if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) {
41 extend$1(target[key], src[key]);
42 }
43 });
44}
45
46const ssrDocument = {
47 body: {},
48
49 addEventListener() {},
50
51 removeEventListener() {},
52
53 activeElement: {
54 blur() {},
55
56 nodeName: ''
57 },
58
59 querySelector() {
60 return null;
61 },
62
63 querySelectorAll() {
64 return [];
65 },
66
67 getElementById() {
68 return null;
69 },
70
71 createEvent() {
72 return {
73 initEvent() {}
74
75 };
76 },
77
78 createElement() {
79 return {
80 children: [],
81 childNodes: [],
82 style: {},
83
84 setAttribute() {},
85
86 getElementsByTagName() {
87 return [];
88 }
89
90 };
91 },
92
93 createElementNS() {
94 return {};
95 },
96
97 importNode() {
98 return null;
99 },
100
101 location: {
102 hash: '',
103 host: '',
104 hostname: '',
105 href: '',
106 origin: '',
107 pathname: '',
108 protocol: '',
109 search: ''
110 }
111};
112
113function getDocument() {
114 const doc = typeof document !== 'undefined' ? document : {};
115 extend$1(doc, ssrDocument);
116 return doc;
117}
118
119const ssrWindow = {
120 document: ssrDocument,
121 navigator: {
122 userAgent: ''
123 },
124 location: {
125 hash: '',
126 host: '',
127 hostname: '',
128 href: '',
129 origin: '',
130 pathname: '',
131 protocol: '',
132 search: ''
133 },
134 history: {
135 replaceState() {},
136
137 pushState() {},
138
139 go() {},
140
141 back() {}
142
143 },
144 CustomEvent: function CustomEvent() {
145 return this;
146 },
147
148 addEventListener() {},
149
150 removeEventListener() {},
151
152 getComputedStyle() {
153 return {
154 getPropertyValue() {
155 return '';
156 }
157
158 };
159 },
160
161 Image() {},
162
163 Date() {},
164
165 screen: {},
166
167 setTimeout() {},
168
169 clearTimeout() {},
170
171 matchMedia() {
172 return {};
173 },
174
175 requestAnimationFrame(callback) {
176 if (typeof setTimeout === 'undefined') {
177 callback();
178 return null;
179 }
180
181 return setTimeout(callback, 0);
182 },
183
184 cancelAnimationFrame(id) {
185 if (typeof setTimeout === 'undefined') {
186 return;
187 }
188
189 clearTimeout(id);
190 }
191
192};
193
194function getWindow() {
195 const win = typeof window !== 'undefined' ? window : {};
196 extend$1(win, ssrWindow);
197 return win;
198}
199
200/**
201 * Dom7 4.0.4
202 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
203 * https://framework7.io/docs/dom7.html
204 *
205 * Copyright 2022, Vladimir Kharlampidi
206 *
207 * Licensed under MIT
208 *
209 * Released on: January 11, 2022
210 */
211/* eslint-disable no-proto */
212
213function makeReactive(obj) {
214 const proto = obj.__proto__;
215 Object.defineProperty(obj, '__proto__', {
216 get() {
217 return proto;
218 },
219
220 set(value) {
221 proto.__proto__ = value;
222 }
223
224 });
225}
226
227class Dom7 extends Array {
228 constructor(items) {
229 if (typeof items === 'number') {
230 super(items);
231 } else {
232 super(...(items || []));
233 makeReactive(this);
234 }
235 }
236
237}
238
239function arrayFlat(arr) {
240 if (arr === void 0) {
241 arr = [];
242 }
243
244 const res = [];
245 arr.forEach(el => {
246 if (Array.isArray(el)) {
247 res.push(...arrayFlat(el));
248 } else {
249 res.push(el);
250 }
251 });
252 return res;
253}
254
255function arrayFilter(arr, callback) {
256 return Array.prototype.filter.call(arr, callback);
257}
258
259function arrayUnique(arr) {
260 const uniqueArray = [];
261
262 for (let i = 0; i < arr.length; i += 1) {
263 if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
264 }
265
266 return uniqueArray;
267}
268
269
270function qsa(selector, context) {
271 if (typeof selector !== 'string') {
272 return [selector];
273 }
274
275 const a = [];
276 const res = context.querySelectorAll(selector);
277
278 for (let i = 0; i < res.length; i += 1) {
279 a.push(res[i]);
280 }
281
282 return a;
283}
284
285function $(selector, context) {
286 const window = getWindow();
287 const document = getDocument();
288 let arr = [];
289
290 if (!context && selector instanceof Dom7) {
291 return selector;
292 }
293
294 if (!selector) {
295 return new Dom7(arr);
296 }
297
298 if (typeof selector === 'string') {
299 const html = selector.trim();
300
301 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
302 let toCreate = 'div';
303 if (html.indexOf('<li') === 0) toCreate = 'ul';
304 if (html.indexOf('<tr') === 0) toCreate = 'tbody';
305 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
306 if (html.indexOf('<tbody') === 0) toCreate = 'table';
307 if (html.indexOf('<option') === 0) toCreate = 'select';
308 const tempParent = document.createElement(toCreate);
309 tempParent.innerHTML = html;
310
311 for (let i = 0; i < tempParent.childNodes.length; i += 1) {
312 arr.push(tempParent.childNodes[i]);
313 }
314 } else {
315 arr = qsa(selector.trim(), context || document);
316 } // arr = qsa(selector, document);
317
318 } else if (selector.nodeType || selector === window || selector === document) {
319 arr.push(selector);
320 } else if (Array.isArray(selector)) {
321 if (selector instanceof Dom7) return selector;
322 arr = selector;
323 }
324
325 return new Dom7(arrayUnique(arr));
326}
327
328$.fn = Dom7.prototype; // eslint-disable-next-line
329
330function addClass() {
331 for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
332 classes[_key] = arguments[_key];
333 }
334
335 const classNames = arrayFlat(classes.map(c => c.split(' ')));
336 this.forEach(el => {
337 el.classList.add(...classNames);
338 });
339 return this;
340}
341
342function removeClass() {
343 for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
344 classes[_key2] = arguments[_key2];
345 }
346
347 const classNames = arrayFlat(classes.map(c => c.split(' ')));
348 this.forEach(el => {
349 el.classList.remove(...classNames);
350 });
351 return this;
352}
353
354function toggleClass() {
355 for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
356 classes[_key3] = arguments[_key3];
357 }
358
359 const classNames = arrayFlat(classes.map(c => c.split(' ')));
360 this.forEach(el => {
361 classNames.forEach(className => {
362 el.classList.toggle(className);
363 });
364 });
365}
366
367function hasClass() {
368 for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
369 classes[_key4] = arguments[_key4];
370 }
371
372 const classNames = arrayFlat(classes.map(c => c.split(' ')));
373 return arrayFilter(this, el => {
374 return classNames.filter(className => el.classList.contains(className)).length > 0;
375 }).length > 0;
376}
377
378function attr(attrs, value) {
379 if (arguments.length === 1 && typeof attrs === 'string') {
380 // Get attr
381 if (this[0]) return this[0].getAttribute(attrs);
382 return undefined;
383 } // Set attrs
384
385
386 for (let i = 0; i < this.length; i += 1) {
387 if (arguments.length === 2) {
388 // String
389 this[i].setAttribute(attrs, value);
390 } else {
391 // Object
392 for (const attrName in attrs) {
393 this[i][attrName] = attrs[attrName];
394 this[i].setAttribute(attrName, attrs[attrName]);
395 }
396 }
397 }
398
399 return this;
400}
401
402function removeAttr(attr) {
403 for (let i = 0; i < this.length; i += 1) {
404 this[i].removeAttribute(attr);
405 }
406
407 return this;
408}
409
410function transform(transform) {
411 for (let i = 0; i < this.length; i += 1) {
412 this[i].style.transform = transform;
413 }
414
415 return this;
416}
417
418function transition$1(duration) {
419 for (let i = 0; i < this.length; i += 1) {
420 this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;
421 }
422
423 return this;
424}
425
426function on() {
427 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
428 args[_key5] = arguments[_key5];
429 }
430
431 let [eventType, targetSelector, listener, capture] = args;
432
433 if (typeof args[1] === 'function') {
434 [eventType, listener, capture] = args;
435 targetSelector = undefined;
436 }
437
438 if (!capture) capture = false;
439
440 function handleLiveEvent(e) {
441 const target = e.target;
442 if (!target) return;
443 const eventData = e.target.dom7EventData || [];
444
445 if (eventData.indexOf(e) < 0) {
446 eventData.unshift(e);
447 }
448
449 if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
450 const parents = $(target).parents(); // eslint-disable-line
451
452 for (let k = 0; k < parents.length; k += 1) {
453 if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);
454 }
455 }
456 }
457
458 function handleEvent(e) {
459 const eventData = e && e.target ? e.target.dom7EventData || [] : [];
460
461 if (eventData.indexOf(e) < 0) {
462 eventData.unshift(e);
463 }
464
465 listener.apply(this, eventData);
466 }
467
468 const events = eventType.split(' ');
469 let j;
470
471 for (let i = 0; i < this.length; i += 1) {
472 const el = this[i];
473
474 if (!targetSelector) {
475 for (j = 0; j < events.length; j += 1) {
476 const event = events[j];
477 if (!el.dom7Listeners) el.dom7Listeners = {};
478 if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
479 el.dom7Listeners[event].push({
480 listener,
481 proxyListener: handleEvent
482 });
483 el.addEventListener(event, handleEvent, capture);
484 }
485 } else {
486 // Live events
487 for (j = 0; j < events.length; j += 1) {
488 const event = events[j];
489 if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
490 if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];
491 el.dom7LiveListeners[event].push({
492 listener,
493 proxyListener: handleLiveEvent
494 });
495 el.addEventListener(event, handleLiveEvent, capture);
496 }
497 }
498 }
499
500 return this;
501}
502
503function off() {
504 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
505 args[_key6] = arguments[_key6];
506 }
507
508 let [eventType, targetSelector, listener, capture] = args;
509
510 if (typeof args[1] === 'function') {
511 [eventType, listener, capture] = args;
512 targetSelector = undefined;
513 }
514
515 if (!capture) capture = false;
516 const events = eventType.split(' ');
517
518 for (let i = 0; i < events.length; i += 1) {
519 const event = events[i];
520
521 for (let j = 0; j < this.length; j += 1) {
522 const el = this[j];
523 let handlers;
524
525 if (!targetSelector && el.dom7Listeners) {
526 handlers = el.dom7Listeners[event];
527 } else if (targetSelector && el.dom7LiveListeners) {
528 handlers = el.dom7LiveListeners[event];
529 }
530
531 if (handlers && handlers.length) {
532 for (let k = handlers.length - 1; k >= 0; k -= 1) {
533 const handler = handlers[k];
534
535 if (listener && handler.listener === listener) {
536 el.removeEventListener(event, handler.proxyListener, capture);
537 handlers.splice(k, 1);
538 } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
539 el.removeEventListener(event, handler.proxyListener, capture);
540 handlers.splice(k, 1);
541 } else if (!listener) {
542 el.removeEventListener(event, handler.proxyListener, capture);
543 handlers.splice(k, 1);
544 }
545 }
546 }
547 }
548 }
549
550 return this;
551}
552
553function trigger() {
554 const window = getWindow();
555
556 for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
557 args[_key9] = arguments[_key9];
558 }
559
560 const events = args[0].split(' ');
561 const eventData = args[1];
562
563 for (let i = 0; i < events.length; i += 1) {
564 const event = events[i];
565
566 for (let j = 0; j < this.length; j += 1) {
567 const el = this[j];
568
569 if (window.CustomEvent) {
570 const evt = new window.CustomEvent(event, {
571 detail: eventData,
572 bubbles: true,
573 cancelable: true
574 });
575 el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);
576 el.dispatchEvent(evt);
577 el.dom7EventData = [];
578 delete el.dom7EventData;
579 }
580 }
581 }
582
583 return this;
584}
585
586function transitionEnd$1(callback) {
587 const dom = this;
588
589 function fireCallBack(e) {
590 if (e.target !== this) return;
591 callback.call(this, e);
592 dom.off('transitionend', fireCallBack);
593 }
594
595 if (callback) {
596 dom.on('transitionend', fireCallBack);
597 }
598
599 return this;
600}
601
602function outerWidth(includeMargins) {
603 if (this.length > 0) {
604 if (includeMargins) {
605 const styles = this.styles();
606 return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));
607 }
608
609 return this[0].offsetWidth;
610 }
611
612 return null;
613}
614
615function outerHeight(includeMargins) {
616 if (this.length > 0) {
617 if (includeMargins) {
618 const styles = this.styles();
619 return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));
620 }
621
622 return this[0].offsetHeight;
623 }
624
625 return null;
626}
627
628function offset() {
629 if (this.length > 0) {
630 const window = getWindow();
631 const document = getDocument();
632 const el = this[0];
633 const box = el.getBoundingClientRect();
634 const body = document.body;
635 const clientTop = el.clientTop || body.clientTop || 0;
636 const clientLeft = el.clientLeft || body.clientLeft || 0;
637 const scrollTop = el === window ? window.scrollY : el.scrollTop;
638 const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
639 return {
640 top: box.top + scrollTop - clientTop,
641 left: box.left + scrollLeft - clientLeft
642 };
643 }
644
645 return null;
646}
647
648function styles() {
649 const window = getWindow();
650 if (this[0]) return window.getComputedStyle(this[0], null);
651 return {};
652}
653
654function css(props, value) {
655 const window = getWindow();
656 let i;
657
658 if (arguments.length === 1) {
659 if (typeof props === 'string') {
660 // .css('width')
661 if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
662 } else {
663 // .css({ width: '100px' })
664 for (i = 0; i < this.length; i += 1) {
665 for (const prop in props) {
666 this[i].style[prop] = props[prop];
667 }
668 }
669
670 return this;
671 }
672 }
673
674 if (arguments.length === 2 && typeof props === 'string') {
675 // .css('width', '100px')
676 for (i = 0; i < this.length; i += 1) {
677 this[i].style[props] = value;
678 }
679
680 return this;
681 }
682
683 return this;
684}
685
686function each(callback) {
687 if (!callback) return this;
688 this.forEach((el, index) => {
689 callback.apply(el, [el, index]);
690 });
691 return this;
692}
693
694function filter(callback) {
695 const result = arrayFilter(this, callback);
696 return $(result);
697}
698
699function html(html) {
700 if (typeof html === 'undefined') {
701 return this[0] ? this[0].innerHTML : null;
702 }
703
704 for (let i = 0; i < this.length; i += 1) {
705 this[i].innerHTML = html;
706 }
707
708 return this;
709}
710
711function text(text) {
712 if (typeof text === 'undefined') {
713 return this[0] ? this[0].textContent.trim() : null;
714 }
715
716 for (let i = 0; i < this.length; i += 1) {
717 this[i].textContent = text;
718 }
719
720 return this;
721}
722
723function is(selector) {
724 const window = getWindow();
725 const document = getDocument();
726 const el = this[0];
727 let compareWith;
728 let i;
729 if (!el || typeof selector === 'undefined') return false;
730
731 if (typeof selector === 'string') {
732 if (el.matches) return el.matches(selector);
733 if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
734 if (el.msMatchesSelector) return el.msMatchesSelector(selector);
735 compareWith = $(selector);
736
737 for (i = 0; i < compareWith.length; i += 1) {
738 if (compareWith[i] === el) return true;
739 }
740
741 return false;
742 }
743
744 if (selector === document) {
745 return el === document;
746 }
747
748 if (selector === window) {
749 return el === window;
750 }
751
752 if (selector.nodeType || selector instanceof Dom7) {
753 compareWith = selector.nodeType ? [selector] : selector;
754
755 for (i = 0; i < compareWith.length; i += 1) {
756 if (compareWith[i] === el) return true;
757 }
758
759 return false;
760 }
761
762 return false;
763}
764
765function index() {
766 let child = this[0];
767 let i;
768
769 if (child) {
770 i = 0; // eslint-disable-next-line
771
772 while ((child = child.previousSibling) !== null) {
773 if (child.nodeType === 1) i += 1;
774 }
775
776 return i;
777 }
778
779 return undefined;
780}
781
782function eq(index) {
783 if (typeof index === 'undefined') return this;
784 const length = this.length;
785
786 if (index > length - 1) {
787 return $([]);
788 }
789
790 if (index < 0) {
791 const returnIndex = length + index;
792 if (returnIndex < 0) return $([]);
793 return $([this[returnIndex]]);
794 }
795
796 return $([this[index]]);
797}
798
799function append() {
800 let newChild;
801 const document = getDocument();
802
803 for (let k = 0; k < arguments.length; k += 1) {
804 newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
805
806 for (let i = 0; i < this.length; i += 1) {
807 if (typeof newChild === 'string') {
808 const tempDiv = document.createElement('div');
809 tempDiv.innerHTML = newChild;
810
811 while (tempDiv.firstChild) {
812 this[i].appendChild(tempDiv.firstChild);
813 }
814 } else if (newChild instanceof Dom7) {
815 for (let j = 0; j < newChild.length; j += 1) {
816 this[i].appendChild(newChild[j]);
817 }
818 } else {
819 this[i].appendChild(newChild);
820 }
821 }
822 }
823
824 return this;
825}
826
827function prepend(newChild) {
828 const document = getDocument();
829 let i;
830 let j;
831
832 for (i = 0; i < this.length; i += 1) {
833 if (typeof newChild === 'string') {
834 const tempDiv = document.createElement('div');
835 tempDiv.innerHTML = newChild;
836
837 for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
838 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
839 }
840 } else if (newChild instanceof Dom7) {
841 for (j = 0; j < newChild.length; j += 1) {
842 this[i].insertBefore(newChild[j], this[i].childNodes[0]);
843 }
844 } else {
845 this[i].insertBefore(newChild, this[i].childNodes[0]);
846 }
847 }
848
849 return this;
850}
851
852function next(selector) {
853 if (this.length > 0) {
854 if (selector) {
855 if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
856 return $([this[0].nextElementSibling]);
857 }
858
859 return $([]);
860 }
861
862 if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);
863 return $([]);
864 }
865
866 return $([]);
867}
868
869function nextAll(selector) {
870 const nextEls = [];
871 let el = this[0];
872 if (!el) return $([]);
873
874 while (el.nextElementSibling) {
875 const next = el.nextElementSibling; // eslint-disable-line
876
877 if (selector) {
878 if ($(next).is(selector)) nextEls.push(next);
879 } else nextEls.push(next);
880
881 el = next;
882 }
883
884 return $(nextEls);
885}
886
887function prev(selector) {
888 if (this.length > 0) {
889 const el = this[0];
890
891 if (selector) {
892 if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
893 return $([el.previousElementSibling]);
894 }
895
896 return $([]);
897 }
898
899 if (el.previousElementSibling) return $([el.previousElementSibling]);
900 return $([]);
901 }
902
903 return $([]);
904}
905
906function prevAll(selector) {
907 const prevEls = [];
908 let el = this[0];
909 if (!el) return $([]);
910
911 while (el.previousElementSibling) {
912 const prev = el.previousElementSibling; // eslint-disable-line
913
914 if (selector) {
915 if ($(prev).is(selector)) prevEls.push(prev);
916 } else prevEls.push(prev);
917
918 el = prev;
919 }
920
921 return $(prevEls);
922}
923
924function parent(selector) {
925 const parents = []; // eslint-disable-line
926
927 for (let i = 0; i < this.length; i += 1) {
928 if (this[i].parentNode !== null) {
929 if (selector) {
930 if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
931 } else {
932 parents.push(this[i].parentNode);
933 }
934 }
935 }
936
937 return $(parents);
938}
939
940function parents(selector) {
941 const parents = []; // eslint-disable-line
942
943 for (let i = 0; i < this.length; i += 1) {
944 let parent = this[i].parentNode; // eslint-disable-line
945
946 while (parent) {
947 if (selector) {
948 if ($(parent).is(selector)) parents.push(parent);
949 } else {
950 parents.push(parent);
951 }
952
953 parent = parent.parentNode;
954 }
955 }
956
957 return $(parents);
958}
959
960function closest(selector) {
961 let closest = this; // eslint-disable-line
962
963 if (typeof selector === 'undefined') {
964 return $([]);
965 }
966
967 if (!closest.is(selector)) {
968 closest = closest.parents(selector).eq(0);
969 }
970
971 return closest;
972}
973
974function find(selector) {
975 const foundElements = [];
976
977 for (let i = 0; i < this.length; i += 1) {
978 const found = this[i].querySelectorAll(selector);
979
980 for (let j = 0; j < found.length; j += 1) {
981 foundElements.push(found[j]);
982 }
983 }
984
985 return $(foundElements);
986}
987
988function children(selector) {
989 const children = []; // eslint-disable-line
990
991 for (let i = 0; i < this.length; i += 1) {
992 const childNodes = this[i].children;
993
994 for (let j = 0; j < childNodes.length; j += 1) {
995 if (!selector || $(childNodes[j]).is(selector)) {
996 children.push(childNodes[j]);
997 }
998 }
999 }
1000
1001 return $(children);
1002}
1003
1004function remove() {
1005 for (let i = 0; i < this.length; i += 1) {
1006 if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
1007 }
1008
1009 return this;
1010}
1011
1012const Methods = {
1013 addClass,
1014 removeClass,
1015 hasClass,
1016 toggleClass,
1017 attr,
1018 removeAttr,
1019 transform,
1020 transition: transition$1,
1021 on,
1022 off,
1023 trigger,
1024 transitionEnd: transitionEnd$1,
1025 outerWidth,
1026 outerHeight,
1027 styles,
1028 offset,
1029 css,
1030 each,
1031 html,
1032 text,
1033 is,
1034 index,
1035 eq,
1036 append,
1037 prepend,
1038 next,
1039 nextAll,
1040 prev,
1041 prevAll,
1042 parent,
1043 parents,
1044 closest,
1045 find,
1046 children,
1047 filter,
1048 remove
1049};
1050Object.keys(Methods).forEach(methodName => {
1051 Object.defineProperty($.fn, methodName, {
1052 value: Methods[methodName],
1053 writable: true
1054 });
1055});
1056
1057function deleteProps(obj) {
1058 const object = obj;
1059 Object.keys(object).forEach(key => {
1060 try {
1061 object[key] = null;
1062 } catch (e) {// no getter for object
1063 }
1064
1065 try {
1066 delete object[key];
1067 } catch (e) {// something got wrong
1068 }
1069 });
1070}
1071
1072function nextTick(callback, delay) {
1073 if (delay === void 0) {
1074 delay = 0;
1075 }
1076
1077 return setTimeout(callback, delay);
1078}
1079
1080function now() {
1081 return Date.now();
1082}
1083
1084function getComputedStyle$1(el) {
1085 const window = getWindow();
1086 let style;
1087
1088 if (window.getComputedStyle) {
1089 style = window.getComputedStyle(el, null);
1090 }
1091
1092 if (!style && el.currentStyle) {
1093 style = el.currentStyle;
1094 }
1095
1096 if (!style) {
1097 style = el.style;
1098 }
1099
1100 return style;
1101}
1102
1103function getTranslate(el, axis) {
1104 if (axis === void 0) {
1105 axis = 'x';
1106 }
1107
1108 const window = getWindow();
1109 let matrix;
1110 let curTransform;
1111 let transformMatrix;
1112 const curStyle = getComputedStyle$1(el);
1113
1114 if (window.WebKitCSSMatrix) {
1115 curTransform = curStyle.transform || curStyle.webkitTransform;
1116
1117 if (curTransform.split(',').length > 6) {
1118 curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
1119 } // Some old versions of Webkit choke when 'none' is passed; pass
1120 // empty string instead in this case
1121
1122
1123 transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
1124 } else {
1125 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
1126 matrix = transformMatrix.toString().split(',');
1127 }
1128
1129 if (axis === 'x') {
1130 // Latest Chrome and webkits Fix
1131 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix
1132 else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers
1133 else curTransform = parseFloat(matrix[4]);
1134 }
1135
1136 if (axis === 'y') {
1137 // Latest Chrome and webkits Fix
1138 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix
1139 else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers
1140 else curTransform = parseFloat(matrix[5]);
1141 }
1142
1143 return curTransform || 0;
1144}
1145
1146function isObject(o) {
1147 return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
1148}
1149
1150function isNode(node) {
1151 // eslint-disable-next-line
1152 if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
1153 return node instanceof HTMLElement;
1154 }
1155
1156 return node && (node.nodeType === 1 || node.nodeType === 11);
1157}
1158
1159function extend() {
1160 const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
1161 const noExtend = ['__proto__', 'constructor', 'prototype'];
1162
1163 for (let i = 1; i < arguments.length; i += 1) {
1164 const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
1165
1166 if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
1167 const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
1168
1169 for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
1170 const nextKey = keysArray[nextIndex];
1171 const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
1172
1173 if (desc !== undefined && desc.enumerable) {
1174 if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
1175 if (nextSource[nextKey].__swiper__) {
1176 to[nextKey] = nextSource[nextKey];
1177 } else {
1178 extend(to[nextKey], nextSource[nextKey]);
1179 }
1180 } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
1181 to[nextKey] = {};
1182
1183 if (nextSource[nextKey].__swiper__) {
1184 to[nextKey] = nextSource[nextKey];
1185 } else {
1186 extend(to[nextKey], nextSource[nextKey]);
1187 }
1188 } else {
1189 to[nextKey] = nextSource[nextKey];
1190 }
1191 }
1192 }
1193 }
1194 }
1195
1196 return to;
1197}
1198
1199function setCSSProperty(el, varName, varValue) {
1200 el.style.setProperty(varName, varValue);
1201}
1202
1203function animateCSSModeScroll(_ref) {
1204 let {
1205 swiper,
1206 targetPosition,
1207 side
1208 } = _ref;
1209 const window = getWindow();
1210 const startPosition = -swiper.translate;
1211 let startTime = null;
1212 let time;
1213 const duration = swiper.params.speed;
1214 swiper.wrapperEl.style.scrollSnapType = 'none';
1215 window.cancelAnimationFrame(swiper.cssModeFrameID);
1216 const dir = targetPosition > startPosition ? 'next' : 'prev';
1217
1218 const isOutOfBound = (current, target) => {
1219 return dir === 'next' && current >= target || dir === 'prev' && current <= target;
1220 };
1221
1222 const animate = () => {
1223 time = new Date().getTime();
1224
1225 if (startTime === null) {
1226 startTime = time;
1227 }
1228
1229 const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
1230 const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
1231 let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
1232
1233 if (isOutOfBound(currentPosition, targetPosition)) {
1234 currentPosition = targetPosition;
1235 }
1236
1237 swiper.wrapperEl.scrollTo({
1238 [side]: currentPosition
1239 });
1240
1241 if (isOutOfBound(currentPosition, targetPosition)) {
1242 swiper.wrapperEl.style.overflow = 'hidden';
1243 swiper.wrapperEl.style.scrollSnapType = '';
1244 setTimeout(() => {
1245 swiper.wrapperEl.style.overflow = '';
1246 swiper.wrapperEl.scrollTo({
1247 [side]: currentPosition
1248 });
1249 });
1250 window.cancelAnimationFrame(swiper.cssModeFrameID);
1251 return;
1252 }
1253
1254 swiper.cssModeFrameID = window.requestAnimationFrame(animate);
1255 };
1256
1257 animate();
1258}
1259
1260let support;
1261
1262function calcSupport() {
1263 const window = getWindow();
1264 const document = getDocument();
1265 return {
1266 smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
1267 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
1268 passiveListener: function checkPassiveListener() {
1269 let supportsPassive = false;
1270
1271 try {
1272 const opts = Object.defineProperty({}, 'passive', {
1273 // eslint-disable-next-line
1274 get() {
1275 supportsPassive = true;
1276 }
1277
1278 });
1279 window.addEventListener('testPassiveListener', null, opts);
1280 } catch (e) {// No support
1281 }
1282
1283 return supportsPassive;
1284 }(),
1285 gestures: function checkGestures() {
1286 return 'ongesturestart' in window;
1287 }()
1288 };
1289}
1290
1291function getSupport() {
1292 if (!support) {
1293 support = calcSupport();
1294 }
1295
1296 return support;
1297}
1298
1299let deviceCached;
1300
1301function calcDevice(_temp) {
1302 let {
1303 userAgent
1304 } = _temp === void 0 ? {} : _temp;
1305 const support = getSupport();
1306 const window = getWindow();
1307 const platform = window.navigator.platform;
1308 const ua = userAgent || window.navigator.userAgent;
1309 const device = {
1310 ios: false,
1311 android: false
1312 };
1313 const screenWidth = window.screen.width;
1314 const screenHeight = window.screen.height;
1315 const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
1316
1317 let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
1318 const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
1319 const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
1320 const windows = platform === 'Win32';
1321 let macos = platform === 'MacIntel'; // iPadOs 13 fix
1322
1323 const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
1324
1325 if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
1326 ipad = ua.match(/(Version)\/([\d.]+)/);
1327 if (!ipad) ipad = [0, 1, '13_0_0'];
1328 macos = false;
1329 } // Android
1330
1331
1332 if (android && !windows) {
1333 device.os = 'android';
1334 device.android = true;
1335 }
1336
1337 if (ipad || iphone || ipod) {
1338 device.os = 'ios';
1339 device.ios = true;
1340 } // Export object
1341
1342
1343 return device;
1344}
1345
1346function getDevice(overrides) {
1347 if (overrides === void 0) {
1348 overrides = {};
1349 }
1350
1351 if (!deviceCached) {
1352 deviceCached = calcDevice(overrides);
1353 }
1354
1355 return deviceCached;
1356}
1357
1358let browser;
1359
1360function calcBrowser() {
1361 const window = getWindow();
1362
1363 function isSafari() {
1364 const ua = window.navigator.userAgent.toLowerCase();
1365 return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
1366 }
1367
1368 return {
1369 isSafari: isSafari(),
1370 isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
1371 };
1372}
1373
1374function getBrowser() {
1375 if (!browser) {
1376 browser = calcBrowser();
1377 }
1378
1379 return browser;
1380}
1381
1382function Resize(_ref) {
1383 let {
1384 swiper,
1385 on,
1386 emit
1387 } = _ref;
1388 const window = getWindow();
1389 let observer = null;
1390 let animationFrame = null;
1391
1392 const resizeHandler = () => {
1393 if (!swiper || swiper.destroyed || !swiper.initialized) return;
1394 emit('beforeResize');
1395 emit('resize');
1396 };
1397
1398 const createObserver = () => {
1399 if (!swiper || swiper.destroyed || !swiper.initialized) return;
1400 observer = new ResizeObserver(entries => {
1401 animationFrame = window.requestAnimationFrame(() => {
1402 const {
1403 width,
1404 height
1405 } = swiper;
1406 let newWidth = width;
1407 let newHeight = height;
1408 entries.forEach(_ref2 => {
1409 let {
1410 contentBoxSize,
1411 contentRect,
1412 target
1413 } = _ref2;
1414 if (target && target !== swiper.el) return;
1415 newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
1416 newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
1417 });
1418
1419 if (newWidth !== width || newHeight !== height) {
1420 resizeHandler();
1421 }
1422 });
1423 });
1424 observer.observe(swiper.el);
1425 };
1426
1427 const removeObserver = () => {
1428 if (animationFrame) {
1429 window.cancelAnimationFrame(animationFrame);
1430 }
1431
1432 if (observer && observer.unobserve && swiper.el) {
1433 observer.unobserve(swiper.el);
1434 observer = null;
1435 }
1436 };
1437
1438 const orientationChangeHandler = () => {
1439 if (!swiper || swiper.destroyed || !swiper.initialized) return;
1440 emit('orientationchange');
1441 };
1442
1443 on('init', () => {
1444 if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
1445 createObserver();
1446 return;
1447 }
1448
1449 window.addEventListener('resize', resizeHandler);
1450 window.addEventListener('orientationchange', orientationChangeHandler);
1451 });
1452 on('destroy', () => {
1453 removeObserver();
1454 window.removeEventListener('resize', resizeHandler);
1455 window.removeEventListener('orientationchange', orientationChangeHandler);
1456 });
1457}
1458
1459function Observer(_ref) {
1460 let {
1461 swiper,
1462 extendParams,
1463 on,
1464 emit
1465 } = _ref;
1466 const observers = [];
1467 const window = getWindow();
1468
1469 const attach = function (target, options) {
1470 if (options === void 0) {
1471 options = {};
1472 }
1473
1474 const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
1475 const observer = new ObserverFunc(mutations => {
1476 // The observerUpdate event should only be triggered
1477 // once despite the number of mutations. Additional
1478 // triggers are redundant and are very costly
1479 if (mutations.length === 1) {
1480 emit('observerUpdate', mutations[0]);
1481 return;
1482 }
1483
1484 const observerUpdate = function observerUpdate() {
1485 emit('observerUpdate', mutations[0]);
1486 };
1487
1488 if (window.requestAnimationFrame) {
1489 window.requestAnimationFrame(observerUpdate);
1490 } else {
1491 window.setTimeout(observerUpdate, 0);
1492 }
1493 });
1494 observer.observe(target, {
1495 attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
1496 childList: typeof options.childList === 'undefined' ? true : options.childList,
1497 characterData: typeof options.characterData === 'undefined' ? true : options.characterData
1498 });
1499 observers.push(observer);
1500 };
1501
1502 const init = () => {
1503 if (!swiper.params.observer) return;
1504
1505 if (swiper.params.observeParents) {
1506 const containerParents = swiper.$el.parents();
1507
1508 for (let i = 0; i < containerParents.length; i += 1) {
1509 attach(containerParents[i]);
1510 }
1511 } // Observe container
1512
1513
1514 attach(swiper.$el[0], {
1515 childList: swiper.params.observeSlideChildren
1516 }); // Observe wrapper
1517
1518 attach(swiper.$wrapperEl[0], {
1519 attributes: false
1520 });
1521 };
1522
1523 const destroy = () => {
1524 observers.forEach(observer => {
1525 observer.disconnect();
1526 });
1527 observers.splice(0, observers.length);
1528 };
1529
1530 extendParams({
1531 observer: false,
1532 observeParents: false,
1533 observeSlideChildren: false
1534 });
1535 on('init', init);
1536 on('destroy', destroy);
1537}
1538
1539/* eslint-disable no-underscore-dangle */
1540var eventsEmitter = {
1541 on(events, handler, priority) {
1542 const self = this;
1543 if (!self.eventsListeners || self.destroyed) return self;
1544 if (typeof handler !== 'function') return self;
1545 const method = priority ? 'unshift' : 'push';
1546 events.split(' ').forEach(event => {
1547 if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
1548 self.eventsListeners[event][method](handler);
1549 });
1550 return self;
1551 },
1552
1553 once(events, handler, priority) {
1554 const self = this;
1555 if (!self.eventsListeners || self.destroyed) return self;
1556 if (typeof handler !== 'function') return self;
1557
1558 function onceHandler() {
1559 self.off(events, onceHandler);
1560
1561 if (onceHandler.__emitterProxy) {
1562 delete onceHandler.__emitterProxy;
1563 }
1564
1565 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1566 args[_key] = arguments[_key];
1567 }
1568
1569 handler.apply(self, args);
1570 }
1571
1572 onceHandler.__emitterProxy = handler;
1573 return self.on(events, onceHandler, priority);
1574 },
1575
1576 onAny(handler, priority) {
1577 const self = this;
1578 if (!self.eventsListeners || self.destroyed) return self;
1579 if (typeof handler !== 'function') return self;
1580 const method = priority ? 'unshift' : 'push';
1581
1582 if (self.eventsAnyListeners.indexOf(handler) < 0) {
1583 self.eventsAnyListeners[method](handler);
1584 }
1585
1586 return self;
1587 },
1588
1589 offAny(handler) {
1590 const self = this;
1591 if (!self.eventsListeners || self.destroyed) return self;
1592 if (!self.eventsAnyListeners) return self;
1593 const index = self.eventsAnyListeners.indexOf(handler);
1594
1595 if (index >= 0) {
1596 self.eventsAnyListeners.splice(index, 1);
1597 }
1598
1599 return self;
1600 },
1601
1602 off(events, handler) {
1603 const self = this;
1604 if (!self.eventsListeners || self.destroyed) return self;
1605 if (!self.eventsListeners) return self;
1606 events.split(' ').forEach(event => {
1607 if (typeof handler === 'undefined') {
1608 self.eventsListeners[event] = [];
1609 } else if (self.eventsListeners[event]) {
1610 self.eventsListeners[event].forEach((eventHandler, index) => {
1611 if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
1612 self.eventsListeners[event].splice(index, 1);
1613 }
1614 });
1615 }
1616 });
1617 return self;
1618 },
1619
1620 emit() {
1621 const self = this;
1622 if (!self.eventsListeners || self.destroyed) return self;
1623 if (!self.eventsListeners) return self;
1624 let events;
1625 let data;
1626 let context;
1627
1628 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1629 args[_key2] = arguments[_key2];
1630 }
1631
1632 if (typeof args[0] === 'string' || Array.isArray(args[0])) {
1633 events = args[0];
1634 data = args.slice(1, args.length);
1635 context = self;
1636 } else {
1637 events = args[0].events;
1638 data = args[0].data;
1639 context = args[0].context || self;
1640 }
1641
1642 data.unshift(context);
1643 const eventsArray = Array.isArray(events) ? events : events.split(' ');
1644 eventsArray.forEach(event => {
1645 if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
1646 self.eventsAnyListeners.forEach(eventHandler => {
1647 eventHandler.apply(context, [event, ...data]);
1648 });
1649 }
1650
1651 if (self.eventsListeners && self.eventsListeners[event]) {
1652 self.eventsListeners[event].forEach(eventHandler => {
1653 eventHandler.apply(context, data);
1654 });
1655 }
1656 });
1657 return self;
1658 }
1659
1660};
1661
1662function updateSize() {
1663 const swiper = this;
1664 let width;
1665 let height;
1666 const $el = swiper.$el;
1667
1668 if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
1669 width = swiper.params.width;
1670 } else {
1671 width = $el[0].clientWidth;
1672 }
1673
1674 if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
1675 height = swiper.params.height;
1676 } else {
1677 height = $el[0].clientHeight;
1678 }
1679
1680 if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
1681 return;
1682 } // Subtract paddings
1683
1684
1685 width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10);
1686 height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10);
1687 if (Number.isNaN(width)) width = 0;
1688 if (Number.isNaN(height)) height = 0;
1689 Object.assign(swiper, {
1690 width,
1691 height,
1692 size: swiper.isHorizontal() ? width : height
1693 });
1694}
1695
1696function updateSlides() {
1697 const swiper = this;
1698
1699 function getDirectionLabel(property) {
1700 if (swiper.isHorizontal()) {
1701 return property;
1702 } // prettier-ignore
1703
1704
1705 return {
1706 'width': 'height',
1707 'margin-top': 'margin-left',
1708 'margin-bottom ': 'margin-right',
1709 'margin-left': 'margin-top',
1710 'margin-right': 'margin-bottom',
1711 'padding-left': 'padding-top',
1712 'padding-right': 'padding-bottom',
1713 'marginRight': 'marginBottom'
1714 }[property];
1715 }
1716
1717 function getDirectionPropertyValue(node, label) {
1718 return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
1719 }
1720
1721 const params = swiper.params;
1722 const {
1723 $wrapperEl,
1724 size: swiperSize,
1725 rtlTranslate: rtl,
1726 wrongRTL
1727 } = swiper;
1728 const isVirtual = swiper.virtual && params.virtual.enabled;
1729 const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
1730 const slides = $wrapperEl.children(`.${swiper.params.slideClass}`);
1731 const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
1732 let snapGrid = [];
1733 const slidesGrid = [];
1734 const slidesSizesGrid = [];
1735 let offsetBefore = params.slidesOffsetBefore;
1736
1737 if (typeof offsetBefore === 'function') {
1738 offsetBefore = params.slidesOffsetBefore.call(swiper);
1739 }
1740
1741 let offsetAfter = params.slidesOffsetAfter;
1742
1743 if (typeof offsetAfter === 'function') {
1744 offsetAfter = params.slidesOffsetAfter.call(swiper);
1745 }
1746
1747 const previousSnapGridLength = swiper.snapGrid.length;
1748 const previousSlidesGridLength = swiper.slidesGrid.length;
1749 let spaceBetween = params.spaceBetween;
1750 let slidePosition = -offsetBefore;
1751 let prevSlideSize = 0;
1752 let index = 0;
1753
1754 if (typeof swiperSize === 'undefined') {
1755 return;
1756 }
1757
1758 if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
1759 spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
1760 }
1761
1762 swiper.virtualSize = -spaceBetween; // reset margins
1763
1764 if (rtl) slides.css({
1765 marginLeft: '',
1766 marginBottom: '',
1767 marginTop: ''
1768 });else slides.css({
1769 marginRight: '',
1770 marginBottom: '',
1771 marginTop: ''
1772 }); // reset cssMode offsets
1773
1774 if (params.centeredSlides && params.cssMode) {
1775 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', '');
1776 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', '');
1777 }
1778
1779 const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
1780
1781 if (gridEnabled) {
1782 swiper.grid.initSlides(slidesLength);
1783 } // Calc slides
1784
1785
1786 let slideSize;
1787 const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
1788 return typeof params.breakpoints[key].slidesPerView !== 'undefined';
1789 }).length > 0;
1790
1791 for (let i = 0; i < slidesLength; i += 1) {
1792 slideSize = 0;
1793 const slide = slides.eq(i);
1794
1795 if (gridEnabled) {
1796 swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
1797 }
1798
1799 if (slide.css('display') === 'none') continue; // eslint-disable-line
1800
1801 if (params.slidesPerView === 'auto') {
1802 if (shouldResetSlideSize) {
1803 slides[i].style[getDirectionLabel('width')] = ``;
1804 }
1805
1806 const slideStyles = getComputedStyle(slide[0]);
1807 const currentTransform = slide[0].style.transform;
1808 const currentWebKitTransform = slide[0].style.webkitTransform;
1809
1810 if (currentTransform) {
1811 slide[0].style.transform = 'none';
1812 }
1813
1814 if (currentWebKitTransform) {
1815 slide[0].style.webkitTransform = 'none';
1816 }
1817
1818 if (params.roundLengths) {
1819 slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
1820 } else {
1821 // eslint-disable-next-line
1822 const width = getDirectionPropertyValue(slideStyles, 'width');
1823 const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
1824 const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
1825 const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
1826 const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
1827 const boxSizing = slideStyles.getPropertyValue('box-sizing');
1828
1829 if (boxSizing && boxSizing === 'border-box') {
1830 slideSize = width + marginLeft + marginRight;
1831 } else {
1832 const {
1833 clientWidth,
1834 offsetWidth
1835 } = slide[0];
1836 slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
1837 }
1838 }
1839
1840 if (currentTransform) {
1841 slide[0].style.transform = currentTransform;
1842 }
1843
1844 if (currentWebKitTransform) {
1845 slide[0].style.webkitTransform = currentWebKitTransform;
1846 }
1847
1848 if (params.roundLengths) slideSize = Math.floor(slideSize);
1849 } else {
1850 slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
1851 if (params.roundLengths) slideSize = Math.floor(slideSize);
1852
1853 if (slides[i]) {
1854 slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
1855 }
1856 }
1857
1858 if (slides[i]) {
1859 slides[i].swiperSlideSize = slideSize;
1860 }
1861
1862 slidesSizesGrid.push(slideSize);
1863
1864 if (params.centeredSlides) {
1865 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
1866 if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
1867 if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
1868 if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
1869 if (params.roundLengths) slidePosition = Math.floor(slidePosition);
1870 if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
1871 slidesGrid.push(slidePosition);
1872 } else {
1873 if (params.roundLengths) slidePosition = Math.floor(slidePosition);
1874 if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
1875 slidesGrid.push(slidePosition);
1876 slidePosition = slidePosition + slideSize + spaceBetween;
1877 }
1878
1879 swiper.virtualSize += slideSize + spaceBetween;
1880 prevSlideSize = slideSize;
1881 index += 1;
1882 }
1883
1884 swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
1885
1886 if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
1887 $wrapperEl.css({
1888 width: `${swiper.virtualSize + params.spaceBetween}px`
1889 });
1890 }
1891
1892 if (params.setWrapperSize) {
1893 $wrapperEl.css({
1894 [getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px`
1895 });
1896 }
1897
1898 if (gridEnabled) {
1899 swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
1900 } // Remove last grid elements depending on width
1901
1902
1903 if (!params.centeredSlides) {
1904 const newSlidesGrid = [];
1905
1906 for (let i = 0; i < snapGrid.length; i += 1) {
1907 let slidesGridItem = snapGrid[i];
1908 if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
1909
1910 if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
1911 newSlidesGrid.push(slidesGridItem);
1912 }
1913 }
1914
1915 snapGrid = newSlidesGrid;
1916
1917 if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
1918 snapGrid.push(swiper.virtualSize - swiperSize);
1919 }
1920 }
1921
1922 if (snapGrid.length === 0) snapGrid = [0];
1923
1924 if (params.spaceBetween !== 0) {
1925 const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
1926 slides.filter((_, slideIndex) => {
1927 if (!params.cssMode) return true;
1928
1929 if (slideIndex === slides.length - 1) {
1930 return false;
1931 }
1932
1933 return true;
1934 }).css({
1935 [key]: `${spaceBetween}px`
1936 });
1937 }
1938
1939 if (params.centeredSlides && params.centeredSlidesBounds) {
1940 let allSlidesSize = 0;
1941 slidesSizesGrid.forEach(slideSizeValue => {
1942 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
1943 });
1944 allSlidesSize -= params.spaceBetween;
1945 const maxSnap = allSlidesSize - swiperSize;
1946 snapGrid = snapGrid.map(snap => {
1947 if (snap < 0) return -offsetBefore;
1948 if (snap > maxSnap) return maxSnap + offsetAfter;
1949 return snap;
1950 });
1951 }
1952
1953 if (params.centerInsufficientSlides) {
1954 let allSlidesSize = 0;
1955 slidesSizesGrid.forEach(slideSizeValue => {
1956 allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
1957 });
1958 allSlidesSize -= params.spaceBetween;
1959
1960 if (allSlidesSize < swiperSize) {
1961 const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
1962 snapGrid.forEach((snap, snapIndex) => {
1963 snapGrid[snapIndex] = snap - allSlidesOffset;
1964 });
1965 slidesGrid.forEach((snap, snapIndex) => {
1966 slidesGrid[snapIndex] = snap + allSlidesOffset;
1967 });
1968 }
1969 }
1970
1971 Object.assign(swiper, {
1972 slides,
1973 snapGrid,
1974 slidesGrid,
1975 slidesSizesGrid
1976 });
1977
1978 if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
1979 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
1980 setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
1981 const addToSnapGrid = -swiper.snapGrid[0];
1982 const addToSlidesGrid = -swiper.slidesGrid[0];
1983 swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
1984 swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
1985 }
1986
1987 if (slidesLength !== previousSlidesLength) {
1988 swiper.emit('slidesLengthChange');
1989 }
1990
1991 if (snapGrid.length !== previousSnapGridLength) {
1992 if (swiper.params.watchOverflow) swiper.checkOverflow();
1993 swiper.emit('snapGridLengthChange');
1994 }
1995
1996 if (slidesGrid.length !== previousSlidesGridLength) {
1997 swiper.emit('slidesGridLengthChange');
1998 }
1999
2000 if (params.watchSlidesProgress) {
2001 swiper.updateSlidesOffset();
2002 }
2003
2004 if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
2005 const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
2006 const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass);
2007
2008 if (slidesLength <= params.maxBackfaceHiddenSlides) {
2009 if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass);
2010 } else if (hasClassBackfaceClassAdded) {
2011 swiper.$el.removeClass(backFaceHiddenClass);
2012 }
2013 }
2014}
2015
2016function updateAutoHeight(speed) {
2017 const swiper = this;
2018 const activeSlides = [];
2019 const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2020 let newHeight = 0;
2021 let i;
2022
2023 if (typeof speed === 'number') {
2024 swiper.setTransition(speed);
2025 } else if (speed === true) {
2026 swiper.setTransition(swiper.params.speed);
2027 }
2028
2029 const getSlideByIndex = index => {
2030 if (isVirtual) {
2031 return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) === index)[0];
2032 }
2033
2034 return swiper.slides.eq(index)[0];
2035 }; // Find slides currently in view
2036
2037
2038 if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
2039 if (swiper.params.centeredSlides) {
2040 (swiper.visibleSlides || $([])).each(slide => {
2041 activeSlides.push(slide);
2042 });
2043 } else {
2044 for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
2045 const index = swiper.activeIndex + i;
2046 if (index > swiper.slides.length && !isVirtual) break;
2047 activeSlides.push(getSlideByIndex(index));
2048 }
2049 }
2050 } else {
2051 activeSlides.push(getSlideByIndex(swiper.activeIndex));
2052 } // Find new height from highest slide in view
2053
2054
2055 for (i = 0; i < activeSlides.length; i += 1) {
2056 if (typeof activeSlides[i] !== 'undefined') {
2057 const height = activeSlides[i].offsetHeight;
2058 newHeight = height > newHeight ? height : newHeight;
2059 }
2060 } // Update Height
2061
2062
2063 if (newHeight || newHeight === 0) swiper.$wrapperEl.css('height', `${newHeight}px`);
2064}
2065
2066function updateSlidesOffset() {
2067 const swiper = this;
2068 const slides = swiper.slides;
2069
2070 for (let i = 0; i < slides.length; i += 1) {
2071 slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop;
2072 }
2073}
2074
2075function updateSlidesProgress(translate) {
2076 if (translate === void 0) {
2077 translate = this && this.translate || 0;
2078 }
2079
2080 const swiper = this;
2081 const params = swiper.params;
2082 const {
2083 slides,
2084 rtlTranslate: rtl,
2085 snapGrid
2086 } = swiper;
2087 if (slides.length === 0) return;
2088 if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
2089 let offsetCenter = -translate;
2090 if (rtl) offsetCenter = translate; // Visible Slides
2091
2092 slides.removeClass(params.slideVisibleClass);
2093 swiper.visibleSlidesIndexes = [];
2094 swiper.visibleSlides = [];
2095
2096 for (let i = 0; i < slides.length; i += 1) {
2097 const slide = slides[i];
2098 let slideOffset = slide.swiperSlideOffset;
2099
2100 if (params.cssMode && params.centeredSlides) {
2101 slideOffset -= slides[0].swiperSlideOffset;
2102 }
2103
2104 const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
2105 const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
2106 const slideBefore = -(offsetCenter - slideOffset);
2107 const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
2108 const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
2109
2110 if (isVisible) {
2111 swiper.visibleSlides.push(slide);
2112 swiper.visibleSlidesIndexes.push(i);
2113 slides.eq(i).addClass(params.slideVisibleClass);
2114 }
2115
2116 slide.progress = rtl ? -slideProgress : slideProgress;
2117 slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
2118 }
2119
2120 swiper.visibleSlides = $(swiper.visibleSlides);
2121}
2122
2123function updateProgress(translate) {
2124 const swiper = this;
2125
2126 if (typeof translate === 'undefined') {
2127 const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line
2128
2129 translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
2130 }
2131
2132 const params = swiper.params;
2133 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2134 let {
2135 progress,
2136 isBeginning,
2137 isEnd
2138 } = swiper;
2139 const wasBeginning = isBeginning;
2140 const wasEnd = isEnd;
2141
2142 if (translatesDiff === 0) {
2143 progress = 0;
2144 isBeginning = true;
2145 isEnd = true;
2146 } else {
2147 progress = (translate - swiper.minTranslate()) / translatesDiff;
2148 isBeginning = progress <= 0;
2149 isEnd = progress >= 1;
2150 }
2151
2152 Object.assign(swiper, {
2153 progress,
2154 isBeginning,
2155 isEnd
2156 });
2157 if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
2158
2159 if (isBeginning && !wasBeginning) {
2160 swiper.emit('reachBeginning toEdge');
2161 }
2162
2163 if (isEnd && !wasEnd) {
2164 swiper.emit('reachEnd toEdge');
2165 }
2166
2167 if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
2168 swiper.emit('fromEdge');
2169 }
2170
2171 swiper.emit('progress', progress);
2172}
2173
2174function updateSlidesClasses() {
2175 const swiper = this;
2176 const {
2177 slides,
2178 params,
2179 $wrapperEl,
2180 activeIndex,
2181 realIndex
2182 } = swiper;
2183 const isVirtual = swiper.virtual && params.virtual.enabled;
2184 slides.removeClass(`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`);
2185 let activeSlide;
2186
2187 if (isVirtual) {
2188 activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`);
2189 } else {
2190 activeSlide = slides.eq(activeIndex);
2191 } // Active classes
2192
2193
2194 activeSlide.addClass(params.slideActiveClass);
2195
2196 if (params.loop) {
2197 // Duplicate to all looped slides
2198 if (activeSlide.hasClass(params.slideDuplicateClass)) {
2199 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
2200 } else {
2201 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
2202 }
2203 } // Next Slide
2204
2205
2206 let nextSlide = activeSlide.nextAll(`.${params.slideClass}`).eq(0).addClass(params.slideNextClass);
2207
2208 if (params.loop && nextSlide.length === 0) {
2209 nextSlide = slides.eq(0);
2210 nextSlide.addClass(params.slideNextClass);
2211 } // Prev Slide
2212
2213
2214 let prevSlide = activeSlide.prevAll(`.${params.slideClass}`).eq(0).addClass(params.slidePrevClass);
2215
2216 if (params.loop && prevSlide.length === 0) {
2217 prevSlide = slides.eq(-1);
2218 prevSlide.addClass(params.slidePrevClass);
2219 }
2220
2221 if (params.loop) {
2222 // Duplicate to all looped slides
2223 if (nextSlide.hasClass(params.slideDuplicateClass)) {
2224 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
2225 } else {
2226 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
2227 }
2228
2229 if (prevSlide.hasClass(params.slideDuplicateClass)) {
2230 $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
2231 } else {
2232 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
2233 }
2234 }
2235
2236 swiper.emitSlidesClasses();
2237}
2238
2239function updateActiveIndex(newActiveIndex) {
2240 const swiper = this;
2241 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
2242 const {
2243 slidesGrid,
2244 snapGrid,
2245 params,
2246 activeIndex: previousIndex,
2247 realIndex: previousRealIndex,
2248 snapIndex: previousSnapIndex
2249 } = swiper;
2250 let activeIndex = newActiveIndex;
2251 let snapIndex;
2252
2253 if (typeof activeIndex === 'undefined') {
2254 for (let i = 0; i < slidesGrid.length; i += 1) {
2255 if (typeof slidesGrid[i + 1] !== 'undefined') {
2256 if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
2257 activeIndex = i;
2258 } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
2259 activeIndex = i + 1;
2260 }
2261 } else if (translate >= slidesGrid[i]) {
2262 activeIndex = i;
2263 }
2264 } // Normalize slideIndex
2265
2266
2267 if (params.normalizeSlideIndex) {
2268 if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
2269 }
2270 }
2271
2272 if (snapGrid.indexOf(translate) >= 0) {
2273 snapIndex = snapGrid.indexOf(translate);
2274 } else {
2275 const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
2276 snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
2277 }
2278
2279 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
2280
2281 if (activeIndex === previousIndex) {
2282 if (snapIndex !== previousSnapIndex) {
2283 swiper.snapIndex = snapIndex;
2284 swiper.emit('snapIndexChange');
2285 }
2286
2287 return;
2288 } // Get real index
2289
2290
2291 const realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10);
2292 Object.assign(swiper, {
2293 snapIndex,
2294 realIndex,
2295 previousIndex,
2296 activeIndex
2297 });
2298 swiper.emit('activeIndexChange');
2299 swiper.emit('snapIndexChange');
2300
2301 if (previousRealIndex !== realIndex) {
2302 swiper.emit('realIndexChange');
2303 }
2304
2305 if (swiper.initialized || swiper.params.runCallbacksOnInit) {
2306 swiper.emit('slideChange');
2307 }
2308}
2309
2310function updateClickedSlide(e) {
2311 const swiper = this;
2312 const params = swiper.params;
2313 const slide = $(e).closest(`.${params.slideClass}`)[0];
2314 let slideFound = false;
2315 let slideIndex;
2316
2317 if (slide) {
2318 for (let i = 0; i < swiper.slides.length; i += 1) {
2319 if (swiper.slides[i] === slide) {
2320 slideFound = true;
2321 slideIndex = i;
2322 break;
2323 }
2324 }
2325 }
2326
2327 if (slide && slideFound) {
2328 swiper.clickedSlide = slide;
2329
2330 if (swiper.virtual && swiper.params.virtual.enabled) {
2331 swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
2332 } else {
2333 swiper.clickedIndex = slideIndex;
2334 }
2335 } else {
2336 swiper.clickedSlide = undefined;
2337 swiper.clickedIndex = undefined;
2338 return;
2339 }
2340
2341 if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
2342 swiper.slideToClickedSlide();
2343 }
2344}
2345
2346var update = {
2347 updateSize,
2348 updateSlides,
2349 updateAutoHeight,
2350 updateSlidesOffset,
2351 updateSlidesProgress,
2352 updateProgress,
2353 updateSlidesClasses,
2354 updateActiveIndex,
2355 updateClickedSlide
2356};
2357
2358function getSwiperTranslate(axis) {
2359 if (axis === void 0) {
2360 axis = this.isHorizontal() ? 'x' : 'y';
2361 }
2362
2363 const swiper = this;
2364 const {
2365 params,
2366 rtlTranslate: rtl,
2367 translate,
2368 $wrapperEl
2369 } = swiper;
2370
2371 if (params.virtualTranslate) {
2372 return rtl ? -translate : translate;
2373 }
2374
2375 if (params.cssMode) {
2376 return translate;
2377 }
2378
2379 let currentTranslate = getTranslate($wrapperEl[0], axis);
2380 if (rtl) currentTranslate = -currentTranslate;
2381 return currentTranslate || 0;
2382}
2383
2384function setTranslate(translate, byController) {
2385 const swiper = this;
2386 const {
2387 rtlTranslate: rtl,
2388 params,
2389 $wrapperEl,
2390 wrapperEl,
2391 progress
2392 } = swiper;
2393 let x = 0;
2394 let y = 0;
2395 const z = 0;
2396
2397 if (swiper.isHorizontal()) {
2398 x = rtl ? -translate : translate;
2399 } else {
2400 y = translate;
2401 }
2402
2403 if (params.roundLengths) {
2404 x = Math.floor(x);
2405 y = Math.floor(y);
2406 }
2407
2408 if (params.cssMode) {
2409 wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
2410 } else if (!params.virtualTranslate) {
2411 $wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
2412 }
2413
2414 swiper.previousTranslate = swiper.translate;
2415 swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
2416
2417 let newProgress;
2418 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2419
2420 if (translatesDiff === 0) {
2421 newProgress = 0;
2422 } else {
2423 newProgress = (translate - swiper.minTranslate()) / translatesDiff;
2424 }
2425
2426 if (newProgress !== progress) {
2427 swiper.updateProgress(translate);
2428 }
2429
2430 swiper.emit('setTranslate', swiper.translate, byController);
2431}
2432
2433function minTranslate() {
2434 return -this.snapGrid[0];
2435}
2436
2437function maxTranslate() {
2438 return -this.snapGrid[this.snapGrid.length - 1];
2439}
2440
2441function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
2442 if (translate === void 0) {
2443 translate = 0;
2444 }
2445
2446 if (speed === void 0) {
2447 speed = this.params.speed;
2448 }
2449
2450 if (runCallbacks === void 0) {
2451 runCallbacks = true;
2452 }
2453
2454 if (translateBounds === void 0) {
2455 translateBounds = true;
2456 }
2457
2458 const swiper = this;
2459 const {
2460 params,
2461 wrapperEl
2462 } = swiper;
2463
2464 if (swiper.animating && params.preventInteractionOnTransition) {
2465 return false;
2466 }
2467
2468 const minTranslate = swiper.minTranslate();
2469 const maxTranslate = swiper.maxTranslate();
2470 let newTranslate;
2471 if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress
2472
2473 swiper.updateProgress(newTranslate);
2474
2475 if (params.cssMode) {
2476 const isH = swiper.isHorizontal();
2477
2478 if (speed === 0) {
2479 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
2480 } else {
2481 if (!swiper.support.smoothScroll) {
2482 animateCSSModeScroll({
2483 swiper,
2484 targetPosition: -newTranslate,
2485 side: isH ? 'left' : 'top'
2486 });
2487 return true;
2488 }
2489
2490 wrapperEl.scrollTo({
2491 [isH ? 'left' : 'top']: -newTranslate,
2492 behavior: 'smooth'
2493 });
2494 }
2495
2496 return true;
2497 }
2498
2499 if (speed === 0) {
2500 swiper.setTransition(0);
2501 swiper.setTranslate(newTranslate);
2502
2503 if (runCallbacks) {
2504 swiper.emit('beforeTransitionStart', speed, internal);
2505 swiper.emit('transitionEnd');
2506 }
2507 } else {
2508 swiper.setTransition(speed);
2509 swiper.setTranslate(newTranslate);
2510
2511 if (runCallbacks) {
2512 swiper.emit('beforeTransitionStart', speed, internal);
2513 swiper.emit('transitionStart');
2514 }
2515
2516 if (!swiper.animating) {
2517 swiper.animating = true;
2518
2519 if (!swiper.onTranslateToWrapperTransitionEnd) {
2520 swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
2521 if (!swiper || swiper.destroyed) return;
2522 if (e.target !== this) return;
2523 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
2524 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
2525 swiper.onTranslateToWrapperTransitionEnd = null;
2526 delete swiper.onTranslateToWrapperTransitionEnd;
2527
2528 if (runCallbacks) {
2529 swiper.emit('transitionEnd');
2530 }
2531 };
2532 }
2533
2534 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
2535 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
2536 }
2537 }
2538
2539 return true;
2540}
2541
2542var translate = {
2543 getTranslate: getSwiperTranslate,
2544 setTranslate,
2545 minTranslate,
2546 maxTranslate,
2547 translateTo
2548};
2549
2550function setTransition(duration, byController) {
2551 const swiper = this;
2552
2553 if (!swiper.params.cssMode) {
2554 swiper.$wrapperEl.transition(duration);
2555 }
2556
2557 swiper.emit('setTransition', duration, byController);
2558}
2559
2560function transitionEmit(_ref) {
2561 let {
2562 swiper,
2563 runCallbacks,
2564 direction,
2565 step
2566 } = _ref;
2567 const {
2568 activeIndex,
2569 previousIndex
2570 } = swiper;
2571 let dir = direction;
2572
2573 if (!dir) {
2574 if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
2575 }
2576
2577 swiper.emit(`transition${step}`);
2578
2579 if (runCallbacks && activeIndex !== previousIndex) {
2580 if (dir === 'reset') {
2581 swiper.emit(`slideResetTransition${step}`);
2582 return;
2583 }
2584
2585 swiper.emit(`slideChangeTransition${step}`);
2586
2587 if (dir === 'next') {
2588 swiper.emit(`slideNextTransition${step}`);
2589 } else {
2590 swiper.emit(`slidePrevTransition${step}`);
2591 }
2592 }
2593}
2594
2595function transitionStart(runCallbacks, direction) {
2596 if (runCallbacks === void 0) {
2597 runCallbacks = true;
2598 }
2599
2600 const swiper = this;
2601 const {
2602 params
2603 } = swiper;
2604 if (params.cssMode) return;
2605
2606 if (params.autoHeight) {
2607 swiper.updateAutoHeight();
2608 }
2609
2610 transitionEmit({
2611 swiper,
2612 runCallbacks,
2613 direction,
2614 step: 'Start'
2615 });
2616}
2617
2618function transitionEnd(runCallbacks, direction) {
2619 if (runCallbacks === void 0) {
2620 runCallbacks = true;
2621 }
2622
2623 const swiper = this;
2624 const {
2625 params
2626 } = swiper;
2627 swiper.animating = false;
2628 if (params.cssMode) return;
2629 swiper.setTransition(0);
2630 transitionEmit({
2631 swiper,
2632 runCallbacks,
2633 direction,
2634 step: 'End'
2635 });
2636}
2637
2638var transition = {
2639 setTransition,
2640 transitionStart,
2641 transitionEnd
2642};
2643
2644function slideTo(index, speed, runCallbacks, internal, initial) {
2645 if (index === void 0) {
2646 index = 0;
2647 }
2648
2649 if (speed === void 0) {
2650 speed = this.params.speed;
2651 }
2652
2653 if (runCallbacks === void 0) {
2654 runCallbacks = true;
2655 }
2656
2657 if (typeof index !== 'number' && typeof index !== 'string') {
2658 throw new Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
2659 }
2660
2661 if (typeof index === 'string') {
2662 /**
2663 * The `index` argument converted from `string` to `number`.
2664 * @type {number}
2665 */
2666 const indexAsNumber = parseInt(index, 10);
2667 /**
2668 * Determines whether the `index` argument is a valid `number`
2669 * after being converted from the `string` type.
2670 * @type {boolean}
2671 */
2672
2673 const isValidNumber = isFinite(indexAsNumber);
2674
2675 if (!isValidNumber) {
2676 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
2677 } // Knowing that the converted `index` is a valid number,
2678 // we can update the original argument's value.
2679
2680
2681 index = indexAsNumber;
2682 }
2683
2684 const swiper = this;
2685 let slideIndex = index;
2686 if (slideIndex < 0) slideIndex = 0;
2687 const {
2688 params,
2689 snapGrid,
2690 slidesGrid,
2691 previousIndex,
2692 activeIndex,
2693 rtlTranslate: rtl,
2694 wrapperEl,
2695 enabled
2696 } = swiper;
2697
2698 if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
2699 return false;
2700 }
2701
2702 const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
2703 let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
2704 if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
2705 const translate = -snapGrid[snapIndex]; // Normalize slideIndex
2706
2707 if (params.normalizeSlideIndex) {
2708 for (let i = 0; i < slidesGrid.length; i += 1) {
2709 const normalizedTranslate = -Math.floor(translate * 100);
2710 const normalizedGrid = Math.floor(slidesGrid[i] * 100);
2711 const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
2712
2713 if (typeof slidesGrid[i + 1] !== 'undefined') {
2714 if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
2715 slideIndex = i;
2716 } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
2717 slideIndex = i + 1;
2718 }
2719 } else if (normalizedTranslate >= normalizedGrid) {
2720 slideIndex = i;
2721 }
2722 }
2723 } // Directions locks
2724
2725
2726 if (swiper.initialized && slideIndex !== activeIndex) {
2727 if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
2728 return false;
2729 }
2730
2731 if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
2732 if ((activeIndex || 0) !== slideIndex) return false;
2733 }
2734 }
2735
2736 if (slideIndex !== (previousIndex || 0) && runCallbacks) {
2737 swiper.emit('beforeSlideChangeStart');
2738 } // Update progress
2739
2740
2741 swiper.updateProgress(translate);
2742 let direction;
2743 if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index
2744
2745 if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
2746 swiper.updateActiveIndex(slideIndex); // Update Height
2747
2748 if (params.autoHeight) {
2749 swiper.updateAutoHeight();
2750 }
2751
2752 swiper.updateSlidesClasses();
2753
2754 if (params.effect !== 'slide') {
2755 swiper.setTranslate(translate);
2756 }
2757
2758 if (direction !== 'reset') {
2759 swiper.transitionStart(runCallbacks, direction);
2760 swiper.transitionEnd(runCallbacks, direction);
2761 }
2762
2763 return false;
2764 }
2765
2766 if (params.cssMode) {
2767 const isH = swiper.isHorizontal();
2768 const t = rtl ? translate : -translate;
2769
2770 if (speed === 0) {
2771 const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2772
2773 if (isVirtual) {
2774 swiper.wrapperEl.style.scrollSnapType = 'none';
2775 swiper._immediateVirtual = true;
2776 }
2777
2778 wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
2779
2780 if (isVirtual) {
2781 requestAnimationFrame(() => {
2782 swiper.wrapperEl.style.scrollSnapType = '';
2783 swiper._swiperImmediateVirtual = false;
2784 });
2785 }
2786 } else {
2787 if (!swiper.support.smoothScroll) {
2788 animateCSSModeScroll({
2789 swiper,
2790 targetPosition: t,
2791 side: isH ? 'left' : 'top'
2792 });
2793 return true;
2794 }
2795
2796 wrapperEl.scrollTo({
2797 [isH ? 'left' : 'top']: t,
2798 behavior: 'smooth'
2799 });
2800 }
2801
2802 return true;
2803 }
2804
2805 swiper.setTransition(speed);
2806 swiper.setTranslate(translate);
2807 swiper.updateActiveIndex(slideIndex);
2808 swiper.updateSlidesClasses();
2809 swiper.emit('beforeTransitionStart', speed, internal);
2810 swiper.transitionStart(runCallbacks, direction);
2811
2812 if (speed === 0) {
2813 swiper.transitionEnd(runCallbacks, direction);
2814 } else if (!swiper.animating) {
2815 swiper.animating = true;
2816
2817 if (!swiper.onSlideToWrapperTransitionEnd) {
2818 swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
2819 if (!swiper || swiper.destroyed) return;
2820 if (e.target !== this) return;
2821 swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
2822 swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
2823 swiper.onSlideToWrapperTransitionEnd = null;
2824 delete swiper.onSlideToWrapperTransitionEnd;
2825 swiper.transitionEnd(runCallbacks, direction);
2826 };
2827 }
2828
2829 swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
2830 swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
2831 }
2832
2833 return true;
2834}
2835
2836function slideToLoop(index, speed, runCallbacks, internal) {
2837 if (index === void 0) {
2838 index = 0;
2839 }
2840
2841 if (speed === void 0) {
2842 speed = this.params.speed;
2843 }
2844
2845 if (runCallbacks === void 0) {
2846 runCallbacks = true;
2847 }
2848
2849 if (typeof index === 'string') {
2850 /**
2851 * The `index` argument converted from `string` to `number`.
2852 * @type {number}
2853 */
2854 const indexAsNumber = parseInt(index, 10);
2855 /**
2856 * Determines whether the `index` argument is a valid `number`
2857 * after being converted from the `string` type.
2858 * @type {boolean}
2859 */
2860
2861 const isValidNumber = isFinite(indexAsNumber);
2862
2863 if (!isValidNumber) {
2864 throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
2865 } // Knowing that the converted `index` is a valid number,
2866 // we can update the original argument's value.
2867
2868
2869 index = indexAsNumber;
2870 }
2871
2872 const swiper = this;
2873 let newIndex = index;
2874
2875 if (swiper.params.loop) {
2876 newIndex += swiper.loopedSlides;
2877 }
2878
2879 return swiper.slideTo(newIndex, speed, runCallbacks, internal);
2880}
2881
2882/* eslint no-unused-vars: "off" */
2883function slideNext(speed, runCallbacks, internal) {
2884 if (speed === void 0) {
2885 speed = this.params.speed;
2886 }
2887
2888 if (runCallbacks === void 0) {
2889 runCallbacks = true;
2890 }
2891
2892 const swiper = this;
2893 const {
2894 animating,
2895 enabled,
2896 params
2897 } = swiper;
2898 if (!enabled) return swiper;
2899 let perGroup = params.slidesPerGroup;
2900
2901 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
2902 perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
2903 }
2904
2905 const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
2906
2907 if (params.loop) {
2908 if (animating && params.loopPreventsSlide) return false;
2909 swiper.loopFix(); // eslint-disable-next-line
2910
2911 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
2912 }
2913
2914 if (params.rewind && swiper.isEnd) {
2915 return swiper.slideTo(0, speed, runCallbacks, internal);
2916 }
2917
2918 return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
2919}
2920
2921/* eslint no-unused-vars: "off" */
2922function slidePrev(speed, runCallbacks, internal) {
2923 if (speed === void 0) {
2924 speed = this.params.speed;
2925 }
2926
2927 if (runCallbacks === void 0) {
2928 runCallbacks = true;
2929 }
2930
2931 const swiper = this;
2932 const {
2933 params,
2934 animating,
2935 snapGrid,
2936 slidesGrid,
2937 rtlTranslate,
2938 enabled
2939 } = swiper;
2940 if (!enabled) return swiper;
2941
2942 if (params.loop) {
2943 if (animating && params.loopPreventsSlide) return false;
2944 swiper.loopFix(); // eslint-disable-next-line
2945
2946 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
2947 }
2948
2949 const translate = rtlTranslate ? swiper.translate : -swiper.translate;
2950
2951 function normalize(val) {
2952 if (val < 0) return -Math.floor(Math.abs(val));
2953 return Math.floor(val);
2954 }
2955
2956 const normalizedTranslate = normalize(translate);
2957 const normalizedSnapGrid = snapGrid.map(val => normalize(val));
2958 let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
2959
2960 if (typeof prevSnap === 'undefined' && params.cssMode) {
2961 let prevSnapIndex;
2962 snapGrid.forEach((snap, snapIndex) => {
2963 if (normalizedTranslate >= snap) {
2964 // prevSnap = snap;
2965 prevSnapIndex = snapIndex;
2966 }
2967 });
2968
2969 if (typeof prevSnapIndex !== 'undefined') {
2970 prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
2971 }
2972 }
2973
2974 let prevIndex = 0;
2975
2976 if (typeof prevSnap !== 'undefined') {
2977 prevIndex = slidesGrid.indexOf(prevSnap);
2978 if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
2979
2980 if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
2981 prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
2982 prevIndex = Math.max(prevIndex, 0);
2983 }
2984 }
2985
2986 if (params.rewind && swiper.isBeginning) {
2987 const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
2988 return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
2989 }
2990
2991 return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
2992}
2993
2994/* eslint no-unused-vars: "off" */
2995function slideReset(speed, runCallbacks, internal) {
2996 if (speed === void 0) {
2997 speed = this.params.speed;
2998 }
2999
3000 if (runCallbacks === void 0) {
3001 runCallbacks = true;
3002 }
3003
3004 const swiper = this;
3005 return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
3006}
3007
3008/* eslint no-unused-vars: "off" */
3009function slideToClosest(speed, runCallbacks, internal, threshold) {
3010 if (speed === void 0) {
3011 speed = this.params.speed;
3012 }
3013
3014 if (runCallbacks === void 0) {
3015 runCallbacks = true;
3016 }
3017
3018 if (threshold === void 0) {
3019 threshold = 0.5;
3020 }
3021
3022 const swiper = this;
3023 let index = swiper.activeIndex;
3024 const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
3025 const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
3026 const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
3027
3028 if (translate >= swiper.snapGrid[snapIndex]) {
3029 // The current translate is on or after the current snap index, so the choice
3030 // is between the current index and the one after it.
3031 const currentSnap = swiper.snapGrid[snapIndex];
3032 const nextSnap = swiper.snapGrid[snapIndex + 1];
3033
3034 if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
3035 index += swiper.params.slidesPerGroup;
3036 }
3037 } else {
3038 // The current translate is before the current snap index, so the choice
3039 // is between the current index and the one before it.
3040 const prevSnap = swiper.snapGrid[snapIndex - 1];
3041 const currentSnap = swiper.snapGrid[snapIndex];
3042
3043 if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
3044 index -= swiper.params.slidesPerGroup;
3045 }
3046 }
3047
3048 index = Math.max(index, 0);
3049 index = Math.min(index, swiper.slidesGrid.length - 1);
3050 return swiper.slideTo(index, speed, runCallbacks, internal);
3051}
3052
3053function slideToClickedSlide() {
3054 const swiper = this;
3055 const {
3056 params,
3057 $wrapperEl
3058 } = swiper;
3059 const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
3060 let slideToIndex = swiper.clickedIndex;
3061 let realIndex;
3062
3063 if (params.loop) {
3064 if (swiper.animating) return;
3065 realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
3066
3067 if (params.centeredSlides) {
3068 if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
3069 swiper.loopFix();
3070 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
3071 nextTick(() => {
3072 swiper.slideTo(slideToIndex);
3073 });
3074 } else {
3075 swiper.slideTo(slideToIndex);
3076 }
3077 } else if (slideToIndex > swiper.slides.length - slidesPerView) {
3078 swiper.loopFix();
3079 slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
3080 nextTick(() => {
3081 swiper.slideTo(slideToIndex);
3082 });
3083 } else {
3084 swiper.slideTo(slideToIndex);
3085 }
3086 } else {
3087 swiper.slideTo(slideToIndex);
3088 }
3089}
3090
3091var slide = {
3092 slideTo,
3093 slideToLoop,
3094 slideNext,
3095 slidePrev,
3096 slideReset,
3097 slideToClosest,
3098 slideToClickedSlide
3099};
3100
3101function loopCreate() {
3102 const swiper = this;
3103 const document = getDocument();
3104 const {
3105 params,
3106 $wrapperEl
3107 } = swiper; // Remove duplicated slides
3108
3109 const $selector = $wrapperEl.children().length > 0 ? $($wrapperEl.children()[0].parentNode) : $wrapperEl;
3110 $selector.children(`.${params.slideClass}.${params.slideDuplicateClass}`).remove();
3111 let slides = $selector.children(`.${params.slideClass}`);
3112
3113 if (params.loopFillGroupWithBlank) {
3114 const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
3115
3116 if (blankSlidesNum !== params.slidesPerGroup) {
3117 for (let i = 0; i < blankSlidesNum; i += 1) {
3118 const blankNode = $(document.createElement('div')).addClass(`${params.slideClass} ${params.slideBlankClass}`);
3119 $selector.append(blankNode);
3120 }
3121
3122 slides = $selector.children(`.${params.slideClass}`);
3123 }
3124 }
3125
3126 if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
3127 swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
3128 swiper.loopedSlides += params.loopAdditionalSlides;
3129
3130 if (swiper.loopedSlides > slides.length && swiper.params.loopedSlidesLimit) {
3131 swiper.loopedSlides = slides.length;
3132 }
3133
3134 const prependSlides = [];
3135 const appendSlides = [];
3136 slides.each((el, index) => {
3137 const slide = $(el);
3138 slide.attr('data-swiper-slide-index', index);
3139 });
3140
3141 for (let i = 0; i < swiper.loopedSlides; i += 1) {
3142 const index = i - Math.floor(i / slides.length) * slides.length;
3143 appendSlides.push(slides.eq(index)[0]);
3144 prependSlides.unshift(slides.eq(slides.length - index - 1)[0]);
3145 }
3146
3147 for (let i = 0; i < appendSlides.length; i += 1) {
3148 $selector.append($(appendSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
3149 }
3150
3151 for (let i = prependSlides.length - 1; i >= 0; i -= 1) {
3152 $selector.prepend($(prependSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
3153 }
3154}
3155
3156function loopFix() {
3157 const swiper = this;
3158 swiper.emit('beforeLoopFix');
3159 const {
3160 activeIndex,
3161 slides,
3162 loopedSlides,
3163 allowSlidePrev,
3164 allowSlideNext,
3165 snapGrid,
3166 rtlTranslate: rtl
3167 } = swiper;
3168 let newIndex;
3169 swiper.allowSlidePrev = true;
3170 swiper.allowSlideNext = true;
3171 const snapTranslate = -snapGrid[activeIndex];
3172 const diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding
3173
3174 if (activeIndex < loopedSlides) {
3175 newIndex = slides.length - loopedSlides * 3 + activeIndex;
3176 newIndex += loopedSlides;
3177 const slideChanged = swiper.slideTo(newIndex, 0, false, true);
3178
3179 if (slideChanged && diff !== 0) {
3180 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
3181 }
3182 } else if (activeIndex >= slides.length - loopedSlides) {
3183 // Fix For Positive Oversliding
3184 newIndex = -slides.length + activeIndex + loopedSlides;
3185 newIndex += loopedSlides;
3186 const slideChanged = swiper.slideTo(newIndex, 0, false, true);
3187
3188 if (slideChanged && diff !== 0) {
3189 swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
3190 }
3191 }
3192
3193 swiper.allowSlidePrev = allowSlidePrev;
3194 swiper.allowSlideNext = allowSlideNext;
3195 swiper.emit('loopFix');
3196}
3197
3198function loopDestroy() {
3199 const swiper = this;
3200 const {
3201 $wrapperEl,
3202 params,
3203 slides
3204 } = swiper;
3205 $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass},.${params.slideClass}.${params.slideBlankClass}`).remove();
3206 slides.removeAttr('data-swiper-slide-index');
3207}
3208
3209var loop = {
3210 loopCreate,
3211 loopFix,
3212 loopDestroy
3213};
3214
3215function setGrabCursor(moving) {
3216 const swiper = this;
3217 if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
3218 const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
3219 el.style.cursor = 'move';
3220 el.style.cursor = moving ? 'grabbing' : 'grab';
3221}
3222
3223function unsetGrabCursor() {
3224 const swiper = this;
3225
3226 if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
3227 return;
3228 }
3229
3230 swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
3231}
3232
3233var grabCursor = {
3234 setGrabCursor,
3235 unsetGrabCursor
3236};
3237
3238function closestElement(selector, base) {
3239 if (base === void 0) {
3240 base = this;
3241 }
3242
3243 function __closestFrom(el) {
3244 if (!el || el === getDocument() || el === getWindow()) return null;
3245 if (el.assignedSlot) el = el.assignedSlot;
3246 const found = el.closest(selector);
3247
3248 if (!found && !el.getRootNode) {
3249 return null;
3250 }
3251
3252 return found || __closestFrom(el.getRootNode().host);
3253 }
3254
3255 return __closestFrom(base);
3256}
3257
3258function onTouchStart(event) {
3259 const swiper = this;
3260 const document = getDocument();
3261 const window = getWindow();
3262 const data = swiper.touchEventsData;
3263 const {
3264 params,
3265 touches,
3266 enabled
3267 } = swiper;
3268 if (!enabled) return;
3269
3270 if (swiper.animating && params.preventInteractionOnTransition) {
3271 return;
3272 }
3273
3274 if (!swiper.animating && params.cssMode && params.loop) {
3275 swiper.loopFix();
3276 }
3277
3278 let e = event;
3279 if (e.originalEvent) e = e.originalEvent;
3280 let $targetEl = $(e.target);
3281
3282 if (params.touchEventsTarget === 'wrapper') {
3283 if (!$targetEl.closest(swiper.wrapperEl).length) return;
3284 }
3285
3286 data.isTouchEvent = e.type === 'touchstart';
3287 if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
3288 if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
3289 if (data.isTouched && data.isMoved) return; // change target el for shadow root component
3290
3291 const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== ''; // eslint-disable-next-line
3292
3293 const eventPath = event.composedPath ? event.composedPath() : event.path;
3294
3295 if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
3296 $targetEl = $(eventPath[0]);
3297 }
3298
3299 const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
3300 const isTargetShadow = !!(e.target && e.target.shadowRoot); // use closestElement for shadow root element to get the actual closest for nested shadow root element
3301
3302 if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, $targetEl[0]) : $targetEl.closest(noSwipingSelector)[0])) {
3303 swiper.allowClick = true;
3304 return;
3305 }
3306
3307 if (params.swipeHandler) {
3308 if (!$targetEl.closest(params.swipeHandler)[0]) return;
3309 }
3310
3311 touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
3312 touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
3313 const startX = touches.currentX;
3314 const startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
3315
3316 const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
3317 const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
3318
3319 if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
3320 if (edgeSwipeDetection === 'prevent') {
3321 event.preventDefault();
3322 } else {
3323 return;
3324 }
3325 }
3326
3327 Object.assign(data, {
3328 isTouched: true,
3329 isMoved: false,
3330 allowTouchCallbacks: true,
3331 isScrolling: undefined,
3332 startMoving: undefined
3333 });
3334 touches.startX = startX;
3335 touches.startY = startY;
3336 data.touchStartTime = now();
3337 swiper.allowClick = true;
3338 swiper.updateSize();
3339 swiper.swipeDirection = undefined;
3340 if (params.threshold > 0) data.allowThresholdMove = false;
3341
3342 if (e.type !== 'touchstart') {
3343 let preventDefault = true;
3344
3345 if ($targetEl.is(data.focusableElements)) {
3346 preventDefault = false;
3347
3348 if ($targetEl[0].nodeName === 'SELECT') {
3349 data.isTouched = false;
3350 }
3351 }
3352
3353 if (document.activeElement && $(document.activeElement).is(data.focusableElements) && document.activeElement !== $targetEl[0]) {
3354 document.activeElement.blur();
3355 }
3356
3357 const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
3358
3359 if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
3360 e.preventDefault();
3361 }
3362 }
3363
3364 if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
3365 swiper.freeMode.onTouchStart();
3366 }
3367
3368 swiper.emit('touchStart', e);
3369}
3370
3371function onTouchMove(event) {
3372 const document = getDocument();
3373 const swiper = this;
3374 const data = swiper.touchEventsData;
3375 const {
3376 params,
3377 touches,
3378 rtlTranslate: rtl,
3379 enabled
3380 } = swiper;
3381 if (!enabled) return;
3382 let e = event;
3383 if (e.originalEvent) e = e.originalEvent;
3384
3385 if (!data.isTouched) {
3386 if (data.startMoving && data.isScrolling) {
3387 swiper.emit('touchMoveOpposite', e);
3388 }
3389
3390 return;
3391 }
3392
3393 if (data.isTouchEvent && e.type !== 'touchmove') return;
3394 const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
3395 const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
3396 const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
3397
3398 if (e.preventedByNestedSwiper) {
3399 touches.startX = pageX;
3400 touches.startY = pageY;
3401 return;
3402 }
3403
3404 if (!swiper.allowTouchMove) {
3405 if (!$(e.target).is(data.focusableElements)) {
3406 swiper.allowClick = false;
3407 }
3408
3409 if (data.isTouched) {
3410 Object.assign(touches, {
3411 startX: pageX,
3412 startY: pageY,
3413 currentX: pageX,
3414 currentY: pageY
3415 });
3416 data.touchStartTime = now();
3417 }
3418
3419 return;
3420 }
3421
3422 if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
3423 if (swiper.isVertical()) {
3424 // Vertical
3425 if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
3426 data.isTouched = false;
3427 data.isMoved = false;
3428 return;
3429 }
3430 } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
3431 return;
3432 }
3433 }
3434
3435 if (data.isTouchEvent && document.activeElement) {
3436 if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) {
3437 data.isMoved = true;
3438 swiper.allowClick = false;
3439 return;
3440 }
3441 }
3442
3443 if (data.allowTouchCallbacks) {
3444 swiper.emit('touchMove', e);
3445 }
3446
3447 if (e.targetTouches && e.targetTouches.length > 1) return;
3448 touches.currentX = pageX;
3449 touches.currentY = pageY;
3450 const diffX = touches.currentX - touches.startX;
3451 const diffY = touches.currentY - touches.startY;
3452 if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
3453
3454 if (typeof data.isScrolling === 'undefined') {
3455 let touchAngle;
3456
3457 if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
3458 data.isScrolling = false;
3459 } else {
3460 // eslint-disable-next-line
3461 if (diffX * diffX + diffY * diffY >= 25) {
3462 touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
3463 data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
3464 }
3465 }
3466 }
3467
3468 if (data.isScrolling) {
3469 swiper.emit('touchMoveOpposite', e);
3470 }
3471
3472 if (typeof data.startMoving === 'undefined') {
3473 if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
3474 data.startMoving = true;
3475 }
3476 }
3477
3478 if (data.isScrolling) {
3479 data.isTouched = false;
3480 return;
3481 }
3482
3483 if (!data.startMoving) {
3484 return;
3485 }
3486
3487 swiper.allowClick = false;
3488
3489 if (!params.cssMode && e.cancelable) {
3490 e.preventDefault();
3491 }
3492
3493 if (params.touchMoveStopPropagation && !params.nested) {
3494 e.stopPropagation();
3495 }
3496
3497 if (!data.isMoved) {
3498 if (params.loop && !params.cssMode) {
3499 swiper.loopFix();
3500 }
3501
3502 data.startTranslate = swiper.getTranslate();
3503 swiper.setTransition(0);
3504
3505 if (swiper.animating) {
3506 swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend');
3507 }
3508
3509 data.allowMomentumBounce = false; // Grab Cursor
3510
3511 if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
3512 swiper.setGrabCursor(true);
3513 }
3514
3515 swiper.emit('sliderFirstMove', e);
3516 }
3517
3518 swiper.emit('sliderMove', e);
3519 data.isMoved = true;
3520 let diff = swiper.isHorizontal() ? diffX : diffY;
3521 touches.diff = diff;
3522 diff *= params.touchRatio;
3523 if (rtl) diff = -diff;
3524 swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
3525 data.currentTranslate = diff + data.startTranslate;
3526 let disableParentSwiper = true;
3527 let resistanceRatio = params.resistanceRatio;
3528
3529 if (params.touchReleaseOnEdges) {
3530 resistanceRatio = 0;
3531 }
3532
3533 if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
3534 disableParentSwiper = false;
3535 if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
3536 } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
3537 disableParentSwiper = false;
3538 if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
3539 }
3540
3541 if (disableParentSwiper) {
3542 e.preventedByNestedSwiper = true;
3543 } // Directions locks
3544
3545
3546 if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
3547 data.currentTranslate = data.startTranslate;
3548 }
3549
3550 if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
3551 data.currentTranslate = data.startTranslate;
3552 }
3553
3554 if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
3555 data.currentTranslate = data.startTranslate;
3556 } // Threshold
3557
3558
3559 if (params.threshold > 0) {
3560 if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
3561 if (!data.allowThresholdMove) {
3562 data.allowThresholdMove = true;
3563 touches.startX = touches.currentX;
3564 touches.startY = touches.currentY;
3565 data.currentTranslate = data.startTranslate;
3566 touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
3567 return;
3568 }
3569 } else {
3570 data.currentTranslate = data.startTranslate;
3571 return;
3572 }
3573 }
3574
3575 if (!params.followFinger || params.cssMode) return; // Update active index in free mode
3576
3577 if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
3578 swiper.updateActiveIndex();
3579 swiper.updateSlidesClasses();
3580 }
3581
3582 if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
3583 swiper.freeMode.onTouchMove();
3584 } // Update progress
3585
3586
3587 swiper.updateProgress(data.currentTranslate); // Update translate
3588
3589 swiper.setTranslate(data.currentTranslate);
3590}
3591
3592function onTouchEnd(event) {
3593 const swiper = this;
3594 const data = swiper.touchEventsData;
3595 const {
3596 params,
3597 touches,
3598 rtlTranslate: rtl,
3599 slidesGrid,
3600 enabled
3601 } = swiper;
3602 if (!enabled) return;
3603 let e = event;
3604 if (e.originalEvent) e = e.originalEvent;
3605
3606 if (data.allowTouchCallbacks) {
3607 swiper.emit('touchEnd', e);
3608 }
3609
3610 data.allowTouchCallbacks = false;
3611
3612 if (!data.isTouched) {
3613 if (data.isMoved && params.grabCursor) {
3614 swiper.setGrabCursor(false);
3615 }
3616
3617 data.isMoved = false;
3618 data.startMoving = false;
3619 return;
3620 } // Return Grab Cursor
3621
3622
3623 if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
3624 swiper.setGrabCursor(false);
3625 } // Time diff
3626
3627
3628 const touchEndTime = now();
3629 const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
3630
3631 if (swiper.allowClick) {
3632 const pathTree = e.path || e.composedPath && e.composedPath();
3633 swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
3634 swiper.emit('tap click', e);
3635
3636 if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
3637 swiper.emit('doubleTap doubleClick', e);
3638 }
3639 }
3640
3641 data.lastClickTime = now();
3642 nextTick(() => {
3643 if (!swiper.destroyed) swiper.allowClick = true;
3644 });
3645
3646 if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
3647 data.isTouched = false;
3648 data.isMoved = false;
3649 data.startMoving = false;
3650 return;
3651 }
3652
3653 data.isTouched = false;
3654 data.isMoved = false;
3655 data.startMoving = false;
3656 let currentPos;
3657
3658 if (params.followFinger) {
3659 currentPos = rtl ? swiper.translate : -swiper.translate;
3660 } else {
3661 currentPos = -data.currentTranslate;
3662 }
3663
3664 if (params.cssMode) {
3665 return;
3666 }
3667
3668 if (swiper.params.freeMode && params.freeMode.enabled) {
3669 swiper.freeMode.onTouchEnd({
3670 currentPos
3671 });
3672 return;
3673 } // Find current slide
3674
3675
3676 let stopIndex = 0;
3677 let groupSize = swiper.slidesSizesGrid[0];
3678
3679 for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
3680 const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
3681
3682 if (typeof slidesGrid[i + increment] !== 'undefined') {
3683 if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
3684 stopIndex = i;
3685 groupSize = slidesGrid[i + increment] - slidesGrid[i];
3686 }
3687 } else if (currentPos >= slidesGrid[i]) {
3688 stopIndex = i;
3689 groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
3690 }
3691 }
3692
3693 let rewindFirstIndex = null;
3694 let rewindLastIndex = null;
3695
3696 if (params.rewind) {
3697 if (swiper.isBeginning) {
3698 rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
3699 } else if (swiper.isEnd) {
3700 rewindFirstIndex = 0;
3701 }
3702 } // Find current slide size
3703
3704
3705 const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
3706 const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
3707
3708 if (timeDiff > params.longSwipesMs) {
3709 // Long touches
3710 if (!params.longSwipes) {
3711 swiper.slideTo(swiper.activeIndex);
3712 return;
3713 }
3714
3715 if (swiper.swipeDirection === 'next') {
3716 if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
3717 }
3718
3719 if (swiper.swipeDirection === 'prev') {
3720 if (ratio > 1 - params.longSwipesRatio) {
3721 swiper.slideTo(stopIndex + increment);
3722 } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
3723 swiper.slideTo(rewindLastIndex);
3724 } else {
3725 swiper.slideTo(stopIndex);
3726 }
3727 }
3728 } else {
3729 // Short swipes
3730 if (!params.shortSwipes) {
3731 swiper.slideTo(swiper.activeIndex);
3732 return;
3733 }
3734
3735 const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
3736
3737 if (!isNavButtonTarget) {
3738 if (swiper.swipeDirection === 'next') {
3739 swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
3740 }
3741
3742 if (swiper.swipeDirection === 'prev') {
3743 swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
3744 }
3745 } else if (e.target === swiper.navigation.nextEl) {
3746 swiper.slideTo(stopIndex + increment);
3747 } else {
3748 swiper.slideTo(stopIndex);
3749 }
3750 }
3751}
3752
3753function onResize() {
3754 const swiper = this;
3755 const {
3756 params,
3757 el
3758 } = swiper;
3759 if (el && el.offsetWidth === 0) return; // Breakpoints
3760
3761 if (params.breakpoints) {
3762 swiper.setBreakpoint();
3763 } // Save locks
3764
3765
3766 const {
3767 allowSlideNext,
3768 allowSlidePrev,
3769 snapGrid
3770 } = swiper; // Disable locks on resize
3771
3772 swiper.allowSlideNext = true;
3773 swiper.allowSlidePrev = true;
3774 swiper.updateSize();
3775 swiper.updateSlides();
3776 swiper.updateSlidesClasses();
3777
3778 if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
3779 swiper.slideTo(swiper.slides.length - 1, 0, false, true);
3780 } else {
3781 swiper.slideTo(swiper.activeIndex, 0, false, true);
3782 }
3783
3784 if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
3785 swiper.autoplay.run();
3786 } // Return locks after resize
3787
3788
3789 swiper.allowSlidePrev = allowSlidePrev;
3790 swiper.allowSlideNext = allowSlideNext;
3791
3792 if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
3793 swiper.checkOverflow();
3794 }
3795}
3796
3797function onClick(e) {
3798 const swiper = this;
3799 if (!swiper.enabled) return;
3800
3801 if (!swiper.allowClick) {
3802 if (swiper.params.preventClicks) e.preventDefault();
3803
3804 if (swiper.params.preventClicksPropagation && swiper.animating) {
3805 e.stopPropagation();
3806 e.stopImmediatePropagation();
3807 }
3808 }
3809}
3810
3811function onScroll() {
3812 const swiper = this;
3813 const {
3814 wrapperEl,
3815 rtlTranslate,
3816 enabled
3817 } = swiper;
3818 if (!enabled) return;
3819 swiper.previousTranslate = swiper.translate;
3820
3821 if (swiper.isHorizontal()) {
3822 swiper.translate = -wrapperEl.scrollLeft;
3823 } else {
3824 swiper.translate = -wrapperEl.scrollTop;
3825 } // eslint-disable-next-line
3826
3827
3828 if (swiper.translate === 0) swiper.translate = 0;
3829 swiper.updateActiveIndex();
3830 swiper.updateSlidesClasses();
3831 let newProgress;
3832 const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
3833
3834 if (translatesDiff === 0) {
3835 newProgress = 0;
3836 } else {
3837 newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
3838 }
3839
3840 if (newProgress !== swiper.progress) {
3841 swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
3842 }
3843
3844 swiper.emit('setTranslate', swiper.translate, false);
3845}
3846
3847let dummyEventAttached = false;
3848
3849function dummyEventListener() {}
3850
3851const events = (swiper, method) => {
3852 const document = getDocument();
3853 const {
3854 params,
3855 touchEvents,
3856 el,
3857 wrapperEl,
3858 device,
3859 support
3860 } = swiper;
3861 const capture = !!params.nested;
3862 const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
3863 const swiperMethod = method; // Touch Events
3864
3865 if (!support.touch) {
3866 el[domMethod](touchEvents.start, swiper.onTouchStart, false);
3867 document[domMethod](touchEvents.move, swiper.onTouchMove, capture);
3868 document[domMethod](touchEvents.end, swiper.onTouchEnd, false);
3869 } else {
3870 const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? {
3871 passive: true,
3872 capture: false
3873 } : false;
3874 el[domMethod](touchEvents.start, swiper.onTouchStart, passiveListener);
3875 el[domMethod](touchEvents.move, swiper.onTouchMove, support.passiveListener ? {
3876 passive: false,
3877 capture
3878 } : capture);
3879 el[domMethod](touchEvents.end, swiper.onTouchEnd, passiveListener);
3880
3881 if (touchEvents.cancel) {
3882 el[domMethod](touchEvents.cancel, swiper.onTouchEnd, passiveListener);
3883 }
3884 } // Prevent Links Clicks
3885
3886
3887 if (params.preventClicks || params.preventClicksPropagation) {
3888 el[domMethod]('click', swiper.onClick, true);
3889 }
3890
3891 if (params.cssMode) {
3892 wrapperEl[domMethod]('scroll', swiper.onScroll);
3893 } // Resize handler
3894
3895
3896 if (params.updateOnWindowResize) {
3897 swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
3898 } else {
3899 swiper[swiperMethod]('observerUpdate', onResize, true);
3900 }
3901};
3902
3903function attachEvents() {
3904 const swiper = this;
3905 const document = getDocument();
3906 const {
3907 params,
3908 support
3909 } = swiper;
3910 swiper.onTouchStart = onTouchStart.bind(swiper);
3911 swiper.onTouchMove = onTouchMove.bind(swiper);
3912 swiper.onTouchEnd = onTouchEnd.bind(swiper);
3913
3914 if (params.cssMode) {
3915 swiper.onScroll = onScroll.bind(swiper);
3916 }
3917
3918 swiper.onClick = onClick.bind(swiper);
3919
3920 if (support.touch && !dummyEventAttached) {
3921 document.addEventListener('touchstart', dummyEventListener);
3922 dummyEventAttached = true;
3923 }
3924
3925 events(swiper, 'on');
3926}
3927
3928function detachEvents() {
3929 const swiper = this;
3930 events(swiper, 'off');
3931}
3932
3933var events$1 = {
3934 attachEvents,
3935 detachEvents
3936};
3937
3938const isGridEnabled = (swiper, params) => {
3939 return swiper.grid && params.grid && params.grid.rows > 1;
3940};
3941
3942function setBreakpoint() {
3943 const swiper = this;
3944 const {
3945 activeIndex,
3946 initialized,
3947 loopedSlides = 0,
3948 params,
3949 $el
3950 } = swiper;
3951 const breakpoints = params.breakpoints;
3952 if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters
3953
3954 const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
3955 if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
3956 const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
3957 const breakpointParams = breakpointOnlyParams || swiper.originalParams;
3958 const wasMultiRow = isGridEnabled(swiper, params);
3959 const isMultiRow = isGridEnabled(swiper, breakpointParams);
3960 const wasEnabled = params.enabled;
3961
3962 if (wasMultiRow && !isMultiRow) {
3963 $el.removeClass(`${params.containerModifierClass}grid ${params.containerModifierClass}grid-column`);
3964 swiper.emitContainerClasses();
3965 } else if (!wasMultiRow && isMultiRow) {
3966 $el.addClass(`${params.containerModifierClass}grid`);
3967
3968 if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
3969 $el.addClass(`${params.containerModifierClass}grid-column`);
3970 }
3971
3972 swiper.emitContainerClasses();
3973 } // Toggle navigation, pagination, scrollbar
3974
3975
3976 ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
3977 const wasModuleEnabled = params[prop] && params[prop].enabled;
3978 const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
3979
3980 if (wasModuleEnabled && !isModuleEnabled) {
3981 swiper[prop].disable();
3982 }
3983
3984 if (!wasModuleEnabled && isModuleEnabled) {
3985 swiper[prop].enable();
3986 }
3987 });
3988 const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
3989 const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
3990
3991 if (directionChanged && initialized) {
3992 swiper.changeDirection();
3993 }
3994
3995 extend(swiper.params, breakpointParams);
3996 const isEnabled = swiper.params.enabled;
3997 Object.assign(swiper, {
3998 allowTouchMove: swiper.params.allowTouchMove,
3999 allowSlideNext: swiper.params.allowSlideNext,
4000 allowSlidePrev: swiper.params.allowSlidePrev
4001 });
4002
4003 if (wasEnabled && !isEnabled) {
4004 swiper.disable();
4005 } else if (!wasEnabled && isEnabled) {
4006 swiper.enable();
4007 }
4008
4009 swiper.currentBreakpoint = breakpoint;
4010 swiper.emit('_beforeBreakpoint', breakpointParams);
4011
4012 if (needsReLoop && initialized) {
4013 swiper.loopDestroy();
4014 swiper.loopCreate();
4015 swiper.updateSlides();
4016 swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false);
4017 }
4018
4019 swiper.emit('breakpoint', breakpointParams);
4020}
4021
4022function getBreakpoint(breakpoints, base, containerEl) {
4023 if (base === void 0) {
4024 base = 'window';
4025 }
4026
4027 if (!breakpoints || base === 'container' && !containerEl) return undefined;
4028 let breakpoint = false;
4029 const window = getWindow();
4030 const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
4031 const points = Object.keys(breakpoints).map(point => {
4032 if (typeof point === 'string' && point.indexOf('@') === 0) {
4033 const minRatio = parseFloat(point.substr(1));
4034 const value = currentHeight * minRatio;
4035 return {
4036 value,
4037 point
4038 };
4039 }
4040
4041 return {
4042 value: point,
4043 point
4044 };
4045 });
4046 points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
4047
4048 for (let i = 0; i < points.length; i += 1) {
4049 const {
4050 point,
4051 value
4052 } = points[i];
4053
4054 if (base === 'window') {
4055 if (window.matchMedia(`(min-width: ${value}px)`).matches) {
4056 breakpoint = point;
4057 }
4058 } else if (value <= containerEl.clientWidth) {
4059 breakpoint = point;
4060 }
4061 }
4062
4063 return breakpoint || 'max';
4064}
4065
4066var breakpoints = {
4067 setBreakpoint,
4068 getBreakpoint
4069};
4070
4071function prepareClasses(entries, prefix) {
4072 const resultClasses = [];
4073 entries.forEach(item => {
4074 if (typeof item === 'object') {
4075 Object.keys(item).forEach(classNames => {
4076 if (item[classNames]) {
4077 resultClasses.push(prefix + classNames);
4078 }
4079 });
4080 } else if (typeof item === 'string') {
4081 resultClasses.push(prefix + item);
4082 }
4083 });
4084 return resultClasses;
4085}
4086
4087function addClasses() {
4088 const swiper = this;
4089 const {
4090 classNames,
4091 params,
4092 rtl,
4093 $el,
4094 device,
4095 support
4096 } = swiper; // prettier-ignore
4097
4098 const suffixes = prepareClasses(['initialized', params.direction, {
4099 'pointer-events': !support.touch
4100 }, {
4101 'free-mode': swiper.params.freeMode && params.freeMode.enabled
4102 }, {
4103 'autoheight': params.autoHeight
4104 }, {
4105 'rtl': rtl
4106 }, {
4107 'grid': params.grid && params.grid.rows > 1
4108 }, {
4109 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
4110 }, {
4111 'android': device.android
4112 }, {
4113 'ios': device.ios
4114 }, {
4115 'css-mode': params.cssMode
4116 }, {
4117 'centered': params.cssMode && params.centeredSlides
4118 }, {
4119 'watch-progress': params.watchSlidesProgress
4120 }], params.containerModifierClass);
4121 classNames.push(...suffixes);
4122 $el.addClass([...classNames].join(' '));
4123 swiper.emitContainerClasses();
4124}
4125
4126function removeClasses() {
4127 const swiper = this;
4128 const {
4129 $el,
4130 classNames
4131 } = swiper;
4132 $el.removeClass(classNames.join(' '));
4133 swiper.emitContainerClasses();
4134}
4135
4136var classes = {
4137 addClasses,
4138 removeClasses
4139};
4140
4141function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) {
4142 const window = getWindow();
4143 let image;
4144
4145 function onReady() {
4146 if (callback) callback();
4147 }
4148
4149 const isPicture = $(imageEl).parent('picture')[0];
4150
4151 if (!isPicture && (!imageEl.complete || !checkForComplete)) {
4152 if (src) {
4153 image = new window.Image();
4154 image.onload = onReady;
4155 image.onerror = onReady;
4156
4157 if (sizes) {
4158 image.sizes = sizes;
4159 }
4160
4161 if (srcset) {
4162 image.srcset = srcset;
4163 }
4164
4165 if (src) {
4166 image.src = src;
4167 }
4168 } else {
4169 onReady();
4170 }
4171 } else {
4172 // image already loaded...
4173 onReady();
4174 }
4175}
4176
4177function preloadImages() {
4178 const swiper = this;
4179 swiper.imagesToLoad = swiper.$el.find('img');
4180
4181 function onReady() {
4182 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return;
4183 if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1;
4184
4185 if (swiper.imagesLoaded === swiper.imagesToLoad.length) {
4186 if (swiper.params.updateOnImagesReady) swiper.update();
4187 swiper.emit('imagesReady');
4188 }
4189 }
4190
4191 for (let i = 0; i < swiper.imagesToLoad.length; i += 1) {
4192 const imageEl = swiper.imagesToLoad[i];
4193 swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady);
4194 }
4195}
4196
4197var images = {
4198 loadImage,
4199 preloadImages
4200};
4201
4202function checkOverflow() {
4203 const swiper = this;
4204 const {
4205 isLocked: wasLocked,
4206 params
4207 } = swiper;
4208 const {
4209 slidesOffsetBefore
4210 } = params;
4211
4212 if (slidesOffsetBefore) {
4213 const lastSlideIndex = swiper.slides.length - 1;
4214 const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
4215 swiper.isLocked = swiper.size > lastSlideRightEdge;
4216 } else {
4217 swiper.isLocked = swiper.snapGrid.length === 1;
4218 }
4219
4220 if (params.allowSlideNext === true) {
4221 swiper.allowSlideNext = !swiper.isLocked;
4222 }
4223
4224 if (params.allowSlidePrev === true) {
4225 swiper.allowSlidePrev = !swiper.isLocked;
4226 }
4227
4228 if (wasLocked && wasLocked !== swiper.isLocked) {
4229 swiper.isEnd = false;
4230 }
4231
4232 if (wasLocked !== swiper.isLocked) {
4233 swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
4234 }
4235}
4236
4237var checkOverflow$1 = {
4238 checkOverflow
4239};
4240
4241var defaults = {
4242 init: true,
4243 direction: 'horizontal',
4244 touchEventsTarget: 'wrapper',
4245 initialSlide: 0,
4246 speed: 300,
4247 cssMode: false,
4248 updateOnWindowResize: true,
4249 resizeObserver: true,
4250 nested: false,
4251 createElements: false,
4252 enabled: true,
4253 focusableElements: 'input, select, option, textarea, button, video, label',
4254 // Overrides
4255 width: null,
4256 height: null,
4257 //
4258 preventInteractionOnTransition: false,
4259 // ssr
4260 userAgent: null,
4261 url: null,
4262 // To support iOS's swipe-to-go-back gesture (when being used in-app).
4263 edgeSwipeDetection: false,
4264 edgeSwipeThreshold: 20,
4265 // Autoheight
4266 autoHeight: false,
4267 // Set wrapper width
4268 setWrapperSize: false,
4269 // Virtual Translate
4270 virtualTranslate: false,
4271 // Effects
4272 effect: 'slide',
4273 // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
4274 // Breakpoints
4275 breakpoints: undefined,
4276 breakpointsBase: 'window',
4277 // Slides grid
4278 spaceBetween: 0,
4279 slidesPerView: 1,
4280 slidesPerGroup: 1,
4281 slidesPerGroupSkip: 0,
4282 slidesPerGroupAuto: false,
4283 centeredSlides: false,
4284 centeredSlidesBounds: false,
4285 slidesOffsetBefore: 0,
4286 // in px
4287 slidesOffsetAfter: 0,
4288 // in px
4289 normalizeSlideIndex: true,
4290 centerInsufficientSlides: false,
4291 // Disable swiper and hide navigation when container not overflow
4292 watchOverflow: true,
4293 // Round length
4294 roundLengths: false,
4295 // Touches
4296 touchRatio: 1,
4297 touchAngle: 45,
4298 simulateTouch: true,
4299 shortSwipes: true,
4300 longSwipes: true,
4301 longSwipesRatio: 0.5,
4302 longSwipesMs: 300,
4303 followFinger: true,
4304 allowTouchMove: true,
4305 threshold: 0,
4306 touchMoveStopPropagation: false,
4307 touchStartPreventDefault: true,
4308 touchStartForcePreventDefault: false,
4309 touchReleaseOnEdges: false,
4310 // Unique Navigation Elements
4311 uniqueNavElements: true,
4312 // Resistance
4313 resistance: true,
4314 resistanceRatio: 0.85,
4315 // Progress
4316 watchSlidesProgress: false,
4317 // Cursor
4318 grabCursor: false,
4319 // Clicks
4320 preventClicks: true,
4321 preventClicksPropagation: true,
4322 slideToClickedSlide: false,
4323 // Images
4324 preloadImages: true,
4325 updateOnImagesReady: true,
4326 // loop
4327 loop: false,
4328 loopAdditionalSlides: 0,
4329 loopedSlides: null,
4330 loopedSlidesLimit: true,
4331 loopFillGroupWithBlank: false,
4332 loopPreventsSlide: true,
4333 // rewind
4334 rewind: false,
4335 // Swiping/no swiping
4336 allowSlidePrev: true,
4337 allowSlideNext: true,
4338 swipeHandler: null,
4339 // '.swipe-handler',
4340 noSwiping: true,
4341 noSwipingClass: 'swiper-no-swiping',
4342 noSwipingSelector: null,
4343 // Passive Listeners
4344 passiveListeners: true,
4345 maxBackfaceHiddenSlides: 10,
4346 // NS
4347 containerModifierClass: 'swiper-',
4348 // NEW
4349 slideClass: 'swiper-slide',
4350 slideBlankClass: 'swiper-slide-invisible-blank',
4351 slideActiveClass: 'swiper-slide-active',
4352 slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
4353 slideVisibleClass: 'swiper-slide-visible',
4354 slideDuplicateClass: 'swiper-slide-duplicate',
4355 slideNextClass: 'swiper-slide-next',
4356 slideDuplicateNextClass: 'swiper-slide-duplicate-next',
4357 slidePrevClass: 'swiper-slide-prev',
4358 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
4359 wrapperClass: 'swiper-wrapper',
4360 // Callbacks
4361 runCallbacksOnInit: true,
4362 // Internals
4363 _emitClasses: false
4364};
4365
4366function moduleExtendParams(params, allModulesParams) {
4367 return function extendParams(obj) {
4368 if (obj === void 0) {
4369 obj = {};
4370 }
4371
4372 const moduleParamName = Object.keys(obj)[0];
4373 const moduleParams = obj[moduleParamName];
4374
4375 if (typeof moduleParams !== 'object' || moduleParams === null) {
4376 extend(allModulesParams, obj);
4377 return;
4378 }
4379
4380 if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) {
4381 params[moduleParamName] = {
4382 auto: true
4383 };
4384 }
4385
4386 if (!(moduleParamName in params && 'enabled' in moduleParams)) {
4387 extend(allModulesParams, obj);
4388 return;
4389 }
4390
4391 if (params[moduleParamName] === true) {
4392 params[moduleParamName] = {
4393 enabled: true
4394 };
4395 }
4396
4397 if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
4398 params[moduleParamName].enabled = true;
4399 }
4400
4401 if (!params[moduleParamName]) params[moduleParamName] = {
4402 enabled: false
4403 };
4404 extend(allModulesParams, obj);
4405 };
4406}
4407
4408/* eslint no-param-reassign: "off" */
4409const prototypes = {
4410 eventsEmitter,
4411 update,
4412 translate,
4413 transition,
4414 slide,
4415 loop,
4416 grabCursor,
4417 events: events$1,
4418 breakpoints,
4419 checkOverflow: checkOverflow$1,
4420 classes,
4421 images
4422};
4423const extendedDefaults = {};
4424
4425class Swiper {
4426 constructor() {
4427 let el;
4428 let params;
4429
4430 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4431 args[_key] = arguments[_key];
4432 }
4433
4434 if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
4435 params = args[0];
4436 } else {
4437 [el, params] = args;
4438 }
4439
4440 if (!params) params = {};
4441 params = extend({}, params);
4442 if (el && !params.el) params.el = el;
4443
4444 if (params.el && $(params.el).length > 1) {
4445 const swipers = [];
4446 $(params.el).each(containerEl => {
4447 const newParams = extend({}, params, {
4448 el: containerEl
4449 });
4450 swipers.push(new Swiper(newParams));
4451 }); // eslint-disable-next-line no-constructor-return
4452
4453 return swipers;
4454 } // Swiper Instance
4455
4456
4457 const swiper = this;
4458 swiper.__swiper__ = true;
4459 swiper.support = getSupport();
4460 swiper.device = getDevice({
4461 userAgent: params.userAgent
4462 });
4463 swiper.browser = getBrowser();
4464 swiper.eventsListeners = {};
4465 swiper.eventsAnyListeners = [];
4466 swiper.modules = [...swiper.__modules__];
4467
4468 if (params.modules && Array.isArray(params.modules)) {
4469 swiper.modules.push(...params.modules);
4470 }
4471
4472 const allModulesParams = {};
4473 swiper.modules.forEach(mod => {
4474 mod({
4475 swiper,
4476 extendParams: moduleExtendParams(params, allModulesParams),
4477 on: swiper.on.bind(swiper),
4478 once: swiper.once.bind(swiper),
4479 off: swiper.off.bind(swiper),
4480 emit: swiper.emit.bind(swiper)
4481 });
4482 }); // Extend defaults with modules params
4483
4484 const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params
4485
4486 swiper.params = extend({}, swiperParams, extendedDefaults, params);
4487 swiper.originalParams = extend({}, swiper.params);
4488 swiper.passedParams = extend({}, params); // add event listeners
4489
4490 if (swiper.params && swiper.params.on) {
4491 Object.keys(swiper.params.on).forEach(eventName => {
4492 swiper.on(eventName, swiper.params.on[eventName]);
4493 });
4494 }
4495
4496 if (swiper.params && swiper.params.onAny) {
4497 swiper.onAny(swiper.params.onAny);
4498 } // Save Dom lib
4499
4500
4501 swiper.$ = $; // Extend Swiper
4502
4503 Object.assign(swiper, {
4504 enabled: swiper.params.enabled,
4505 el,
4506 // Classes
4507 classNames: [],
4508 // Slides
4509 slides: $(),
4510 slidesGrid: [],
4511 snapGrid: [],
4512 slidesSizesGrid: [],
4513
4514 // isDirection
4515 isHorizontal() {
4516 return swiper.params.direction === 'horizontal';
4517 },
4518
4519 isVertical() {
4520 return swiper.params.direction === 'vertical';
4521 },
4522
4523 // Indexes
4524 activeIndex: 0,
4525 realIndex: 0,
4526 //
4527 isBeginning: true,
4528 isEnd: false,
4529 // Props
4530 translate: 0,
4531 previousTranslate: 0,
4532 progress: 0,
4533 velocity: 0,
4534 animating: false,
4535 // Locks
4536 allowSlideNext: swiper.params.allowSlideNext,
4537 allowSlidePrev: swiper.params.allowSlidePrev,
4538 // Touch Events
4539 touchEvents: function touchEvents() {
4540 const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
4541 const desktop = ['pointerdown', 'pointermove', 'pointerup'];
4542 swiper.touchEventsTouch = {
4543 start: touch[0],
4544 move: touch[1],
4545 end: touch[2],
4546 cancel: touch[3]
4547 };
4548 swiper.touchEventsDesktop = {
4549 start: desktop[0],
4550 move: desktop[1],
4551 end: desktop[2]
4552 };
4553 return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop;
4554 }(),
4555 touchEventsData: {
4556 isTouched: undefined,
4557 isMoved: undefined,
4558 allowTouchCallbacks: undefined,
4559 touchStartTime: undefined,
4560 isScrolling: undefined,
4561 currentTranslate: undefined,
4562 startTranslate: undefined,
4563 allowThresholdMove: undefined,
4564 // Form elements to match
4565 focusableElements: swiper.params.focusableElements,
4566 // Last click time
4567 lastClickTime: now(),
4568 clickTimeout: undefined,
4569 // Velocities
4570 velocities: [],
4571 allowMomentumBounce: undefined,
4572 isTouchEvent: undefined,
4573 startMoving: undefined
4574 },
4575 // Clicks
4576 allowClick: true,
4577 // Touches
4578 allowTouchMove: swiper.params.allowTouchMove,
4579 touches: {
4580 startX: 0,
4581 startY: 0,
4582 currentX: 0,
4583 currentY: 0,
4584 diff: 0
4585 },
4586 // Images
4587 imagesToLoad: [],
4588 imagesLoaded: 0
4589 });
4590 swiper.emit('_swiper'); // Init
4591
4592 if (swiper.params.init) {
4593 swiper.init();
4594 } // Return app instance
4595 // eslint-disable-next-line no-constructor-return
4596
4597
4598 return swiper;
4599 }
4600
4601 enable() {
4602 const swiper = this;
4603 if (swiper.enabled) return;
4604 swiper.enabled = true;
4605
4606 if (swiper.params.grabCursor) {
4607 swiper.setGrabCursor();
4608 }
4609
4610 swiper.emit('enable');
4611 }
4612
4613 disable() {
4614 const swiper = this;
4615 if (!swiper.enabled) return;
4616 swiper.enabled = false;
4617
4618 if (swiper.params.grabCursor) {
4619 swiper.unsetGrabCursor();
4620 }
4621
4622 swiper.emit('disable');
4623 }
4624
4625 setProgress(progress, speed) {
4626 const swiper = this;
4627 progress = Math.min(Math.max(progress, 0), 1);
4628 const min = swiper.minTranslate();
4629 const max = swiper.maxTranslate();
4630 const current = (max - min) * progress + min;
4631 swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
4632 swiper.updateActiveIndex();
4633 swiper.updateSlidesClasses();
4634 }
4635
4636 emitContainerClasses() {
4637 const swiper = this;
4638 if (!swiper.params._emitClasses || !swiper.el) return;
4639 const cls = swiper.el.className.split(' ').filter(className => {
4640 return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
4641 });
4642 swiper.emit('_containerClasses', cls.join(' '));
4643 }
4644
4645 getSlideClasses(slideEl) {
4646 const swiper = this;
4647 if (swiper.destroyed) return '';
4648 return slideEl.className.split(' ').filter(className => {
4649 return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
4650 }).join(' ');
4651 }
4652
4653 emitSlidesClasses() {
4654 const swiper = this;
4655 if (!swiper.params._emitClasses || !swiper.el) return;
4656 const updates = [];
4657 swiper.slides.each(slideEl => {
4658 const classNames = swiper.getSlideClasses(slideEl);
4659 updates.push({
4660 slideEl,
4661 classNames
4662 });
4663 swiper.emit('_slideClass', slideEl, classNames);
4664 });
4665 swiper.emit('_slideClasses', updates);
4666 }
4667
4668 slidesPerViewDynamic(view, exact) {
4669 if (view === void 0) {
4670 view = 'current';
4671 }
4672
4673 if (exact === void 0) {
4674 exact = false;
4675 }
4676
4677 const swiper = this;
4678 const {
4679 params,
4680 slides,
4681 slidesGrid,
4682 slidesSizesGrid,
4683 size: swiperSize,
4684 activeIndex
4685 } = swiper;
4686 let spv = 1;
4687
4688 if (params.centeredSlides) {
4689 let slideSize = slides[activeIndex].swiperSlideSize;
4690 let breakLoop;
4691
4692 for (let i = activeIndex + 1; i < slides.length; i += 1) {
4693 if (slides[i] && !breakLoop) {
4694 slideSize += slides[i].swiperSlideSize;
4695 spv += 1;
4696 if (slideSize > swiperSize) breakLoop = true;
4697 }
4698 }
4699
4700 for (let i = activeIndex - 1; i >= 0; i -= 1) {
4701 if (slides[i] && !breakLoop) {
4702 slideSize += slides[i].swiperSlideSize;
4703 spv += 1;
4704 if (slideSize > swiperSize) breakLoop = true;
4705 }
4706 }
4707 } else {
4708 // eslint-disable-next-line
4709 if (view === 'current') {
4710 for (let i = activeIndex + 1; i < slides.length; i += 1) {
4711 const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
4712
4713 if (slideInView) {
4714 spv += 1;
4715 }
4716 }
4717 } else {
4718 // previous
4719 for (let i = activeIndex - 1; i >= 0; i -= 1) {
4720 const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
4721
4722 if (slideInView) {
4723 spv += 1;
4724 }
4725 }
4726 }
4727 }
4728
4729 return spv;
4730 }
4731
4732 update() {
4733 const swiper = this;
4734 if (!swiper || swiper.destroyed) return;
4735 const {
4736 snapGrid,
4737 params
4738 } = swiper; // Breakpoints
4739
4740 if (params.breakpoints) {
4741 swiper.setBreakpoint();
4742 }
4743
4744 swiper.updateSize();
4745 swiper.updateSlides();
4746 swiper.updateProgress();
4747 swiper.updateSlidesClasses();
4748
4749 function setTranslate() {
4750 const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
4751 const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
4752 swiper.setTranslate(newTranslate);
4753 swiper.updateActiveIndex();
4754 swiper.updateSlidesClasses();
4755 }
4756
4757 let translated;
4758
4759 if (swiper.params.freeMode && swiper.params.freeMode.enabled) {
4760 setTranslate();
4761
4762 if (swiper.params.autoHeight) {
4763 swiper.updateAutoHeight();
4764 }
4765 } else {
4766 if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
4767 translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
4768 } else {
4769 translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
4770 }
4771
4772 if (!translated) {
4773 setTranslate();
4774 }
4775 }
4776
4777 if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
4778 swiper.checkOverflow();
4779 }
4780
4781 swiper.emit('update');
4782 }
4783
4784 changeDirection(newDirection, needUpdate) {
4785 if (needUpdate === void 0) {
4786 needUpdate = true;
4787 }
4788
4789 const swiper = this;
4790 const currentDirection = swiper.params.direction;
4791
4792 if (!newDirection) {
4793 // eslint-disable-next-line
4794 newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
4795 }
4796
4797 if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
4798 return swiper;
4799 }
4800
4801 swiper.$el.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`).addClass(`${swiper.params.containerModifierClass}${newDirection}`);
4802 swiper.emitContainerClasses();
4803 swiper.params.direction = newDirection;
4804 swiper.slides.each(slideEl => {
4805 if (newDirection === 'vertical') {
4806 slideEl.style.width = '';
4807 } else {
4808 slideEl.style.height = '';
4809 }
4810 });
4811 swiper.emit('changeDirection');
4812 if (needUpdate) swiper.update();
4813 return swiper;
4814 }
4815
4816 changeLanguageDirection(direction) {
4817 const swiper = this;
4818 if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
4819 swiper.rtl = direction === 'rtl';
4820 swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
4821
4822 if (swiper.rtl) {
4823 swiper.$el.addClass(`${swiper.params.containerModifierClass}rtl`);
4824 swiper.el.dir = 'rtl';
4825 } else {
4826 swiper.$el.removeClass(`${swiper.params.containerModifierClass}rtl`);
4827 swiper.el.dir = 'ltr';
4828 }
4829
4830 swiper.update();
4831 }
4832
4833 mount(el) {
4834 const swiper = this;
4835 if (swiper.mounted) return true; // Find el
4836
4837 const $el = $(el || swiper.params.el);
4838 el = $el[0];
4839
4840 if (!el) {
4841 return false;
4842 }
4843
4844 el.swiper = swiper;
4845
4846 const getWrapperSelector = () => {
4847 return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
4848 };
4849
4850 const getWrapper = () => {
4851 if (el && el.shadowRoot && el.shadowRoot.querySelector) {
4852 const res = $(el.shadowRoot.querySelector(getWrapperSelector())); // Children needs to return slot items
4853
4854 res.children = options => $el.children(options);
4855
4856 return res;
4857 }
4858
4859 if (!$el.children) {
4860 return $($el).children(getWrapperSelector());
4861 }
4862
4863 return $el.children(getWrapperSelector());
4864 }; // Find Wrapper
4865
4866
4867 let $wrapperEl = getWrapper();
4868
4869 if ($wrapperEl.length === 0 && swiper.params.createElements) {
4870 const document = getDocument();
4871 const wrapper = document.createElement('div');
4872 $wrapperEl = $(wrapper);
4873 wrapper.className = swiper.params.wrapperClass;
4874 $el.append(wrapper);
4875 $el.children(`.${swiper.params.slideClass}`).each(slideEl => {
4876 $wrapperEl.append(slideEl);
4877 });
4878 }
4879
4880 Object.assign(swiper, {
4881 $el,
4882 el,
4883 $wrapperEl,
4884 wrapperEl: $wrapperEl[0],
4885 mounted: true,
4886 // RTL
4887 rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl',
4888 rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
4889 wrongRTL: $wrapperEl.css('display') === '-webkit-box'
4890 });
4891 return true;
4892 }
4893
4894 init(el) {
4895 const swiper = this;
4896 if (swiper.initialized) return swiper;
4897 const mounted = swiper.mount(el);
4898 if (mounted === false) return swiper;
4899 swiper.emit('beforeInit'); // Set breakpoint
4900
4901 if (swiper.params.breakpoints) {
4902 swiper.setBreakpoint();
4903 } // Add Classes
4904
4905
4906 swiper.addClasses(); // Create loop
4907
4908 if (swiper.params.loop) {
4909 swiper.loopCreate();
4910 } // Update size
4911
4912
4913 swiper.updateSize(); // Update slides
4914
4915 swiper.updateSlides();
4916
4917 if (swiper.params.watchOverflow) {
4918 swiper.checkOverflow();
4919 } // Set Grab Cursor
4920
4921
4922 if (swiper.params.grabCursor && swiper.enabled) {
4923 swiper.setGrabCursor();
4924 }
4925
4926 if (swiper.params.preloadImages) {
4927 swiper.preloadImages();
4928 } // Slide To Initial Slide
4929
4930
4931 if (swiper.params.loop) {
4932 swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit, false, true);
4933 } else {
4934 swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
4935 } // Attach events
4936
4937
4938 swiper.attachEvents(); // Init Flag
4939
4940 swiper.initialized = true; // Emit
4941
4942 swiper.emit('init');
4943 swiper.emit('afterInit');
4944 return swiper;
4945 }
4946
4947 destroy(deleteInstance, cleanStyles) {
4948 if (deleteInstance === void 0) {
4949 deleteInstance = true;
4950 }
4951
4952 if (cleanStyles === void 0) {
4953 cleanStyles = true;
4954 }
4955
4956 const swiper = this;
4957 const {
4958 params,
4959 $el,
4960 $wrapperEl,
4961 slides
4962 } = swiper;
4963
4964 if (typeof swiper.params === 'undefined' || swiper.destroyed) {
4965 return null;
4966 }
4967
4968 swiper.emit('beforeDestroy'); // Init Flag
4969
4970 swiper.initialized = false; // Detach events
4971
4972 swiper.detachEvents(); // Destroy loop
4973
4974 if (params.loop) {
4975 swiper.loopDestroy();
4976 } // Cleanup styles
4977
4978
4979 if (cleanStyles) {
4980 swiper.removeClasses();
4981 $el.removeAttr('style');
4982 $wrapperEl.removeAttr('style');
4983
4984 if (slides && slides.length) {
4985 slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index');
4986 }
4987 }
4988
4989 swiper.emit('destroy'); // Detach emitter events
4990
4991 Object.keys(swiper.eventsListeners).forEach(eventName => {
4992 swiper.off(eventName);
4993 });
4994
4995 if (deleteInstance !== false) {
4996 swiper.$el[0].swiper = null;
4997 deleteProps(swiper);
4998 }
4999
5000 swiper.destroyed = true;
5001 return null;
5002 }
5003
5004 static extendDefaults(newDefaults) {
5005 extend(extendedDefaults, newDefaults);
5006 }
5007
5008 static get extendedDefaults() {
5009 return extendedDefaults;
5010 }
5011
5012 static get defaults() {
5013 return defaults;
5014 }
5015
5016 static installModule(mod) {
5017 if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
5018 const modules = Swiper.prototype.__modules__;
5019
5020 if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
5021 modules.push(mod);
5022 }
5023 }
5024
5025 static use(module) {
5026 if (Array.isArray(module)) {
5027 module.forEach(m => Swiper.installModule(m));
5028 return Swiper;
5029 }
5030
5031 Swiper.installModule(module);
5032 return Swiper;
5033 }
5034
5035}
5036
5037Object.keys(prototypes).forEach(prototypeGroup => {
5038 Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
5039 Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
5040 });
5041});
5042Swiper.use([Resize, Observer]);
5043
5044function Virtual(_ref) {
5045 let {
5046 swiper,
5047 extendParams,
5048 on,
5049 emit
5050 } = _ref;
5051 extendParams({
5052 virtual: {
5053 enabled: false,
5054 slides: [],
5055 cache: true,
5056 renderSlide: null,
5057 renderExternal: null,
5058 renderExternalUpdate: true,
5059 addSlidesBefore: 0,
5060 addSlidesAfter: 0
5061 }
5062 });
5063 let cssModeTimeout;
5064 swiper.virtual = {
5065 cache: {},
5066 from: undefined,
5067 to: undefined,
5068 slides: [],
5069 offset: 0,
5070 slidesGrid: []
5071 };
5072
5073 function renderSlide(slide, index) {
5074 const params = swiper.params.virtual;
5075
5076 if (params.cache && swiper.virtual.cache[index]) {
5077 return swiper.virtual.cache[index];
5078 }
5079
5080 const $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $(`<div class="${swiper.params.slideClass}" data-swiper-slide-index="${index}">${slide}</div>`);
5081 if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index);
5082 if (params.cache) swiper.virtual.cache[index] = $slideEl;
5083 return $slideEl;
5084 }
5085
5086 function update(force) {
5087 const {
5088 slidesPerView,
5089 slidesPerGroup,
5090 centeredSlides
5091 } = swiper.params;
5092 const {
5093 addSlidesBefore,
5094 addSlidesAfter
5095 } = swiper.params.virtual;
5096 const {
5097 from: previousFrom,
5098 to: previousTo,
5099 slides,
5100 slidesGrid: previousSlidesGrid,
5101 offset: previousOffset
5102 } = swiper.virtual;
5103
5104 if (!swiper.params.cssMode) {
5105 swiper.updateActiveIndex();
5106 }
5107
5108 const activeIndex = swiper.activeIndex || 0;
5109 let offsetProp;
5110 if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top';
5111 let slidesAfter;
5112 let slidesBefore;
5113
5114 if (centeredSlides) {
5115 slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter;
5116 slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore;
5117 } else {
5118 slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter;
5119 slidesBefore = slidesPerGroup + addSlidesBefore;
5120 }
5121
5122 const from = Math.max((activeIndex || 0) - slidesBefore, 0);
5123 const to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1);
5124 const offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
5125 Object.assign(swiper.virtual, {
5126 from,
5127 to,
5128 offset,
5129 slidesGrid: swiper.slidesGrid
5130 });
5131
5132 function onRendered() {
5133 swiper.updateSlides();
5134 swiper.updateProgress();
5135 swiper.updateSlidesClasses();
5136
5137 if (swiper.lazy && swiper.params.lazy.enabled) {
5138 swiper.lazy.load();
5139 }
5140
5141 emit('virtualUpdate');
5142 }
5143
5144 if (previousFrom === from && previousTo === to && !force) {
5145 if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
5146 swiper.slides.css(offsetProp, `${offset}px`);
5147 }
5148
5149 swiper.updateProgress();
5150 emit('virtualUpdate');
5151 return;
5152 }
5153
5154 if (swiper.params.virtual.renderExternal) {
5155 swiper.params.virtual.renderExternal.call(swiper, {
5156 offset,
5157 from,
5158 to,
5159 slides: function getSlides() {
5160 const slidesToRender = [];
5161
5162 for (let i = from; i <= to; i += 1) {
5163 slidesToRender.push(slides[i]);
5164 }
5165
5166 return slidesToRender;
5167 }()
5168 });
5169
5170 if (swiper.params.virtual.renderExternalUpdate) {
5171 onRendered();
5172 } else {
5173 emit('virtualUpdate');
5174 }
5175
5176 return;
5177 }
5178
5179 const prependIndexes = [];
5180 const appendIndexes = [];
5181
5182 if (force) {
5183 swiper.$wrapperEl.find(`.${swiper.params.slideClass}`).remove();
5184 } else {
5185 for (let i = previousFrom; i <= previousTo; i += 1) {
5186 if (i < from || i > to) {
5187 swiper.$wrapperEl.find(`.${swiper.params.slideClass}[data-swiper-slide-index="${i}"]`).remove();
5188 }
5189 }
5190 }
5191
5192 for (let i = 0; i < slides.length; i += 1) {
5193 if (i >= from && i <= to) {
5194 if (typeof previousTo === 'undefined' || force) {
5195 appendIndexes.push(i);
5196 } else {
5197 if (i > previousTo) appendIndexes.push(i);
5198 if (i < previousFrom) prependIndexes.push(i);
5199 }
5200 }
5201 }
5202
5203 appendIndexes.forEach(index => {
5204 swiper.$wrapperEl.append(renderSlide(slides[index], index));
5205 });
5206 prependIndexes.sort((a, b) => b - a).forEach(index => {
5207 swiper.$wrapperEl.prepend(renderSlide(slides[index], index));
5208 });
5209 swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, `${offset}px`);
5210 onRendered();
5211 }
5212
5213 function appendSlide(slides) {
5214 if (typeof slides === 'object' && 'length' in slides) {
5215 for (let i = 0; i < slides.length; i += 1) {
5216 if (slides[i]) swiper.virtual.slides.push(slides[i]);
5217 }
5218 } else {
5219 swiper.virtual.slides.push(slides);
5220 }
5221
5222 update(true);
5223 }
5224
5225 function prependSlide(slides) {
5226 const activeIndex = swiper.activeIndex;
5227 let newActiveIndex = activeIndex + 1;
5228 let numberOfNewSlides = 1;
5229
5230 if (Array.isArray(slides)) {
5231 for (let i = 0; i < slides.length; i += 1) {
5232 if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
5233 }
5234
5235 newActiveIndex = activeIndex + slides.length;
5236 numberOfNewSlides = slides.length;
5237 } else {
5238 swiper.virtual.slides.unshift(slides);
5239 }
5240
5241 if (swiper.params.virtual.cache) {
5242 const cache = swiper.virtual.cache;
5243 const newCache = {};
5244 Object.keys(cache).forEach(cachedIndex => {
5245 const $cachedEl = cache[cachedIndex];
5246 const cachedElIndex = $cachedEl.attr('data-swiper-slide-index');
5247
5248 if (cachedElIndex) {
5249 $cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides);
5250 }
5251
5252 newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl;
5253 });
5254 swiper.virtual.cache = newCache;
5255 }
5256
5257 update(true);
5258 swiper.slideTo(newActiveIndex, 0);
5259 }
5260
5261 function removeSlide(slidesIndexes) {
5262 if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return;
5263 let activeIndex = swiper.activeIndex;
5264
5265 if (Array.isArray(slidesIndexes)) {
5266 for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) {
5267 swiper.virtual.slides.splice(slidesIndexes[i], 1);
5268
5269 if (swiper.params.virtual.cache) {
5270 delete swiper.virtual.cache[slidesIndexes[i]];
5271 }
5272
5273 if (slidesIndexes[i] < activeIndex) activeIndex -= 1;
5274 activeIndex = Math.max(activeIndex, 0);
5275 }
5276 } else {
5277 swiper.virtual.slides.splice(slidesIndexes, 1);
5278
5279 if (swiper.params.virtual.cache) {
5280 delete swiper.virtual.cache[slidesIndexes];
5281 }
5282
5283 if (slidesIndexes < activeIndex) activeIndex -= 1;
5284 activeIndex = Math.max(activeIndex, 0);
5285 }
5286
5287 update(true);
5288 swiper.slideTo(activeIndex, 0);
5289 }
5290
5291 function removeAllSlides() {
5292 swiper.virtual.slides = [];
5293
5294 if (swiper.params.virtual.cache) {
5295 swiper.virtual.cache = {};
5296 }
5297
5298 update(true);
5299 swiper.slideTo(0, 0);
5300 }
5301
5302 on('beforeInit', () => {
5303 if (!swiper.params.virtual.enabled) return;
5304 swiper.virtual.slides = swiper.params.virtual.slides;
5305 swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`);
5306 swiper.params.watchSlidesProgress = true;
5307 swiper.originalParams.watchSlidesProgress = true;
5308
5309 if (!swiper.params.initialSlide) {
5310 update();
5311 }
5312 });
5313 on('setTranslate', () => {
5314 if (!swiper.params.virtual.enabled) return;
5315
5316 if (swiper.params.cssMode && !swiper._immediateVirtual) {
5317 clearTimeout(cssModeTimeout);
5318 cssModeTimeout = setTimeout(() => {
5319 update();
5320 }, 100);
5321 } else {
5322 update();
5323 }
5324 });
5325 on('init update resize', () => {
5326 if (!swiper.params.virtual.enabled) return;
5327
5328 if (swiper.params.cssMode) {
5329 setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`);
5330 }
5331 });
5332 Object.assign(swiper.virtual, {
5333 appendSlide,
5334 prependSlide,
5335 removeSlide,
5336 removeAllSlides,
5337 update
5338 });
5339}
5340
5341/* eslint-disable consistent-return */
5342function Keyboard(_ref) {
5343 let {
5344 swiper,
5345 extendParams,
5346 on,
5347 emit
5348 } = _ref;
5349 const document = getDocument();
5350 const window = getWindow();
5351 swiper.keyboard = {
5352 enabled: false
5353 };
5354 extendParams({
5355 keyboard: {
5356 enabled: false,
5357 onlyInViewport: true,
5358 pageUpDown: true
5359 }
5360 });
5361
5362 function handle(event) {
5363 if (!swiper.enabled) return;
5364 const {
5365 rtlTranslate: rtl
5366 } = swiper;
5367 let e = event;
5368 if (e.originalEvent) e = e.originalEvent; // jquery fix
5369
5370 const kc = e.keyCode || e.charCode;
5371 const pageUpDown = swiper.params.keyboard.pageUpDown;
5372 const isPageUp = pageUpDown && kc === 33;
5373 const isPageDown = pageUpDown && kc === 34;
5374 const isArrowLeft = kc === 37;
5375 const isArrowRight = kc === 39;
5376 const isArrowUp = kc === 38;
5377 const isArrowDown = kc === 40; // Directions locks
5378
5379 if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) {
5380 return false;
5381 }
5382
5383 if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) {
5384 return false;
5385 }
5386
5387 if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
5388 return undefined;
5389 }
5390
5391 if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
5392 return undefined;
5393 }
5394
5395 if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) {
5396 let inView = false; // Check that swiper should be inside of visible area of window
5397
5398 if (swiper.$el.parents(`.${swiper.params.slideClass}`).length > 0 && swiper.$el.parents(`.${swiper.params.slideActiveClass}`).length === 0) {
5399 return undefined;
5400 }
5401
5402 const $el = swiper.$el;
5403 const swiperWidth = $el[0].clientWidth;
5404 const swiperHeight = $el[0].clientHeight;
5405 const windowWidth = window.innerWidth;
5406 const windowHeight = window.innerHeight;
5407 const swiperOffset = swiper.$el.offset();
5408 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
5409 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]];
5410
5411 for (let i = 0; i < swiperCoord.length; i += 1) {
5412 const point = swiperCoord[i];
5413
5414 if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) {
5415 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
5416
5417 inView = true;
5418 }
5419 }
5420
5421 if (!inView) return undefined;
5422 }
5423
5424 if (swiper.isHorizontal()) {
5425 if (isPageUp || isPageDown || isArrowLeft || isArrowRight) {
5426 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
5427 }
5428
5429 if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext();
5430 if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev();
5431 } else {
5432 if (isPageUp || isPageDown || isArrowUp || isArrowDown) {
5433 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
5434 }
5435
5436 if (isPageDown || isArrowDown) swiper.slideNext();
5437 if (isPageUp || isArrowUp) swiper.slidePrev();
5438 }
5439
5440 emit('keyPress', kc);
5441 return undefined;
5442 }
5443
5444 function enable() {
5445 if (swiper.keyboard.enabled) return;
5446 $(document).on('keydown', handle);
5447 swiper.keyboard.enabled = true;
5448 }
5449
5450 function disable() {
5451 if (!swiper.keyboard.enabled) return;
5452 $(document).off('keydown', handle);
5453 swiper.keyboard.enabled = false;
5454 }
5455
5456 on('init', () => {
5457 if (swiper.params.keyboard.enabled) {
5458 enable();
5459 }
5460 });
5461 on('destroy', () => {
5462 if (swiper.keyboard.enabled) {
5463 disable();
5464 }
5465 });
5466 Object.assign(swiper.keyboard, {
5467 enable,
5468 disable
5469 });
5470}
5471
5472/* eslint-disable consistent-return */
5473function Mousewheel(_ref) {
5474 let {
5475 swiper,
5476 extendParams,
5477 on,
5478 emit
5479 } = _ref;
5480 const window = getWindow();
5481 extendParams({
5482 mousewheel: {
5483 enabled: false,
5484 releaseOnEdges: false,
5485 invert: false,
5486 forceToAxis: false,
5487 sensitivity: 1,
5488 eventsTarget: 'container',
5489 thresholdDelta: null,
5490 thresholdTime: null
5491 }
5492 });
5493 swiper.mousewheel = {
5494 enabled: false
5495 };
5496 let timeout;
5497 let lastScrollTime = now();
5498 let lastEventBeforeSnap;
5499 const recentWheelEvents = [];
5500
5501 function normalize(e) {
5502 // Reasonable defaults
5503 const PIXEL_STEP = 10;
5504 const LINE_HEIGHT = 40;
5505 const PAGE_HEIGHT = 800;
5506 let sX = 0;
5507 let sY = 0; // spinX, spinY
5508
5509 let pX = 0;
5510 let pY = 0; // pixelX, pixelY
5511 // Legacy
5512
5513 if ('detail' in e) {
5514 sY = e.detail;
5515 }
5516
5517 if ('wheelDelta' in e) {
5518 sY = -e.wheelDelta / 120;
5519 }
5520
5521 if ('wheelDeltaY' in e) {
5522 sY = -e.wheelDeltaY / 120;
5523 }
5524
5525 if ('wheelDeltaX' in e) {
5526 sX = -e.wheelDeltaX / 120;
5527 } // side scrolling on FF with DOMMouseScroll
5528
5529
5530 if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
5531 sX = sY;
5532 sY = 0;
5533 }
5534
5535 pX = sX * PIXEL_STEP;
5536 pY = sY * PIXEL_STEP;
5537
5538 if ('deltaY' in e) {
5539 pY = e.deltaY;
5540 }
5541
5542 if ('deltaX' in e) {
5543 pX = e.deltaX;
5544 }
5545
5546 if (e.shiftKey && !pX) {
5547 // if user scrolls with shift he wants horizontal scroll
5548 pX = pY;
5549 pY = 0;
5550 }
5551
5552 if ((pX || pY) && e.deltaMode) {
5553 if (e.deltaMode === 1) {
5554 // delta in LINE units
5555 pX *= LINE_HEIGHT;
5556 pY *= LINE_HEIGHT;
5557 } else {
5558 // delta in PAGE units
5559 pX *= PAGE_HEIGHT;
5560 pY *= PAGE_HEIGHT;
5561 }
5562 } // Fall-back if spin cannot be determined
5563
5564
5565 if (pX && !sX) {
5566 sX = pX < 1 ? -1 : 1;
5567 }
5568
5569 if (pY && !sY) {
5570 sY = pY < 1 ? -1 : 1;
5571 }
5572
5573 return {
5574 spinX: sX,
5575 spinY: sY,
5576 pixelX: pX,
5577 pixelY: pY
5578 };
5579 }
5580
5581 function handleMouseEnter() {
5582 if (!swiper.enabled) return;
5583 swiper.mouseEntered = true;
5584 }
5585
5586 function handleMouseLeave() {
5587 if (!swiper.enabled) return;
5588 swiper.mouseEntered = false;
5589 }
5590
5591 function animateSlider(newEvent) {
5592 if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) {
5593 // Prevent if delta of wheel scroll delta is below configured threshold
5594 return false;
5595 }
5596
5597 if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) {
5598 // Prevent if time between scrolls is below configured threshold
5599 return false;
5600 } // If the movement is NOT big enough and
5601 // if the last time the user scrolled was too close to the current one (avoid continuously triggering the slider):
5602 // Don't go any further (avoid insignificant scroll movement).
5603
5604
5605 if (newEvent.delta >= 6 && now() - lastScrollTime < 60) {
5606 // Return false as a default
5607 return true;
5608 } // If user is scrolling towards the end:
5609 // If the slider hasn't hit the latest slide or
5610 // if the slider is a loop and
5611 // if the slider isn't moving right now:
5612 // Go to next slide and
5613 // emit a scroll event.
5614 // Else (the user is scrolling towards the beginning) and
5615 // if the slider hasn't hit the first slide or
5616 // if the slider is a loop and
5617 // if the slider isn't moving right now:
5618 // Go to prev slide and
5619 // emit a scroll event.
5620
5621
5622 if (newEvent.direction < 0) {
5623 if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
5624 swiper.slideNext();
5625 emit('scroll', newEvent.raw);
5626 }
5627 } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
5628 swiper.slidePrev();
5629 emit('scroll', newEvent.raw);
5630 } // If you got here is because an animation has been triggered so store the current time
5631
5632
5633 lastScrollTime = new window.Date().getTime(); // Return false as a default
5634
5635 return false;
5636 }
5637
5638 function releaseScroll(newEvent) {
5639 const params = swiper.params.mousewheel;
5640
5641 if (newEvent.direction < 0) {
5642 if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) {
5643 // Return true to animate scroll on edges
5644 return true;
5645 }
5646 } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) {
5647 // Return true to animate scroll on edges
5648 return true;
5649 }
5650
5651 return false;
5652 }
5653
5654 function handle(event) {
5655 let e = event;
5656 let disableParentSwiper = true;
5657 if (!swiper.enabled) return;
5658 const params = swiper.params.mousewheel;
5659
5660 if (swiper.params.cssMode) {
5661 e.preventDefault();
5662 }
5663
5664 let target = swiper.$el;
5665
5666 if (swiper.params.mousewheel.eventsTarget !== 'container') {
5667 target = $(swiper.params.mousewheel.eventsTarget);
5668 }
5669
5670 if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true;
5671 if (e.originalEvent) e = e.originalEvent; // jquery fix
5672
5673 let delta = 0;
5674 const rtlFactor = swiper.rtlTranslate ? -1 : 1;
5675 const data = normalize(e);
5676
5677 if (params.forceToAxis) {
5678 if (swiper.isHorizontal()) {
5679 if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true;
5680 } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true;
5681 } else {
5682 delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
5683 }
5684
5685 if (delta === 0) return true;
5686 if (params.invert) delta = -delta; // Get the scroll positions
5687
5688 let positions = swiper.getTranslate() + delta * params.sensitivity;
5689 if (positions >= swiper.minTranslate()) positions = swiper.minTranslate();
5690 if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate(); // When loop is true:
5691 // the disableParentSwiper will be true.
5692 // When loop is false:
5693 // if the scroll positions is not on edge,
5694 // then the disableParentSwiper will be true.
5695 // if the scroll on edge positions,
5696 // then the disableParentSwiper will be false.
5697
5698 disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate());
5699 if (disableParentSwiper && swiper.params.nested) e.stopPropagation();
5700
5701 if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) {
5702 // Register the new event in a variable which stores the relevant data
5703 const newEvent = {
5704 time: now(),
5705 delta: Math.abs(delta),
5706 direction: Math.sign(delta),
5707 raw: event
5708 }; // Keep the most recent events
5709
5710 if (recentWheelEvents.length >= 2) {
5711 recentWheelEvents.shift(); // only store the last N events
5712 }
5713
5714 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
5715 recentWheelEvents.push(newEvent); // If there is at least one previous recorded event:
5716 // If direction has changed or
5717 // if the scroll is quicker than the previous one:
5718 // Animate the slider.
5719 // Else (this is the first time the wheel is moved):
5720 // Animate the slider.
5721
5722 if (prevEvent) {
5723 if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
5724 animateSlider(newEvent);
5725 }
5726 } else {
5727 animateSlider(newEvent);
5728 } // If it's time to release the scroll:
5729 // Return now so you don't hit the preventDefault.
5730
5731
5732 if (releaseScroll(newEvent)) {
5733 return true;
5734 }
5735 } else {
5736 // Freemode or scrollContainer:
5737 // If we recently snapped after a momentum scroll, then ignore wheel events
5738 // to give time for the deceleration to finish. Stop ignoring after 500 msecs
5739 // or if it's a new scroll (larger delta or inverse sign as last event before
5740 // an end-of-momentum snap).
5741 const newEvent = {
5742 time: now(),
5743 delta: Math.abs(delta),
5744 direction: Math.sign(delta)
5745 };
5746 const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction;
5747
5748 if (!ignoreWheelEvents) {
5749 lastEventBeforeSnap = undefined;
5750
5751 if (swiper.params.loop) {
5752 swiper.loopFix();
5753 }
5754
5755 let position = swiper.getTranslate() + delta * params.sensitivity;
5756 const wasBeginning = swiper.isBeginning;
5757 const wasEnd = swiper.isEnd;
5758 if (position >= swiper.minTranslate()) position = swiper.minTranslate();
5759 if (position <= swiper.maxTranslate()) position = swiper.maxTranslate();
5760 swiper.setTransition(0);
5761 swiper.setTranslate(position);
5762 swiper.updateProgress();
5763 swiper.updateActiveIndex();
5764 swiper.updateSlidesClasses();
5765
5766 if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) {
5767 swiper.updateSlidesClasses();
5768 }
5769
5770 if (swiper.params.freeMode.sticky) {
5771 // When wheel scrolling starts with sticky (aka snap) enabled, then detect
5772 // the end of a momentum scroll by storing recent (N=15?) wheel events.
5773 // 1. do all N events have decreasing or same (absolute value) delta?
5774 // 2. did all N events arrive in the last M (M=500?) msecs?
5775 // 3. does the earliest event have an (absolute value) delta that's
5776 // at least P (P=1?) larger than the most recent event's delta?
5777 // 4. does the latest event have a delta that's smaller than Q (Q=6?) pixels?
5778 // If 1-4 are "yes" then we're near the end of a momentum scroll deceleration.
5779 // Snap immediately and ignore remaining wheel events in this scroll.
5780 // See comment above for "remaining wheel events in this scroll" determination.
5781 // If 1-4 aren't satisfied, then wait to snap until 500ms after the last event.
5782 clearTimeout(timeout);
5783 timeout = undefined;
5784
5785 if (recentWheelEvents.length >= 15) {
5786 recentWheelEvents.shift(); // only store the last N events
5787 }
5788
5789 const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
5790 const firstEvent = recentWheelEvents[0];
5791 recentWheelEvents.push(newEvent);
5792
5793 if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) {
5794 // Increasing or reverse-sign delta means the user started scrolling again. Clear the wheel event log.
5795 recentWheelEvents.splice(0);
5796 } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) {
5797 // We're at the end of the deceleration of a momentum scroll, so there's no need
5798 // to wait for more events. Snap ASAP on the next tick.
5799 // Also, because there's some remaining momentum we'll bias the snap in the
5800 // direction of the ongoing scroll because it's better UX for the scroll to snap
5801 // in the same direction as the scroll instead of reversing to snap. Therefore,
5802 // if it's already scrolled more than 20% in the current direction, keep going.
5803 const snapToThreshold = delta > 0 ? 0.8 : 0.2;
5804 lastEventBeforeSnap = newEvent;
5805 recentWheelEvents.splice(0);
5806 timeout = nextTick(() => {
5807 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
5808 }, 0); // no delay; move on next tick
5809 }
5810
5811 if (!timeout) {
5812 // if we get here, then we haven't detected the end of a momentum scroll, so
5813 // we'll consider a scroll "complete" when there haven't been any wheel events
5814 // for 500ms.
5815 timeout = nextTick(() => {
5816 const snapToThreshold = 0.5;
5817 lastEventBeforeSnap = newEvent;
5818 recentWheelEvents.splice(0);
5819 swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
5820 }, 500);
5821 }
5822 } // Emit event
5823
5824
5825 if (!ignoreWheelEvents) emit('scroll', e); // Stop autoplay
5826
5827 if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop(); // Return page scroll on edge positions
5828
5829 if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true;
5830 }
5831 }
5832
5833 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
5834 return false;
5835 }
5836
5837 function events(method) {
5838 let target = swiper.$el;
5839
5840 if (swiper.params.mousewheel.eventsTarget !== 'container') {
5841 target = $(swiper.params.mousewheel.eventsTarget);
5842 }
5843
5844 target[method]('mouseenter', handleMouseEnter);
5845 target[method]('mouseleave', handleMouseLeave);
5846 target[method]('wheel', handle);
5847 }
5848
5849 function enable() {
5850 if (swiper.params.cssMode) {
5851 swiper.wrapperEl.removeEventListener('wheel', handle);
5852 return true;
5853 }
5854
5855 if (swiper.mousewheel.enabled) return false;
5856 events('on');
5857 swiper.mousewheel.enabled = true;
5858 return true;
5859 }
5860
5861 function disable() {
5862 if (swiper.params.cssMode) {
5863 swiper.wrapperEl.addEventListener(event, handle);
5864 return true;
5865 }
5866
5867 if (!swiper.mousewheel.enabled) return false;
5868 events('off');
5869 swiper.mousewheel.enabled = false;
5870 return true;
5871 }
5872
5873 on('init', () => {
5874 if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) {
5875 disable();
5876 }
5877
5878 if (swiper.params.mousewheel.enabled) enable();
5879 });
5880 on('destroy', () => {
5881 if (swiper.params.cssMode) {
5882 enable();
5883 }
5884
5885 if (swiper.mousewheel.enabled) disable();
5886 });
5887 Object.assign(swiper.mousewheel, {
5888 enable,
5889 disable
5890 });
5891}
5892
5893function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
5894 const document = getDocument();
5895
5896 if (swiper.params.createElements) {
5897 Object.keys(checkProps).forEach(key => {
5898 if (!params[key] && params.auto === true) {
5899 let element = swiper.$el.children(`.${checkProps[key]}`)[0];
5900
5901 if (!element) {
5902 element = document.createElement('div');
5903 element.className = checkProps[key];
5904 swiper.$el.append(element);
5905 }
5906
5907 params[key] = element;
5908 originalParams[key] = element;
5909 }
5910 });
5911 }
5912
5913 return params;
5914}
5915
5916function Navigation(_ref) {
5917 let {
5918 swiper,
5919 extendParams,
5920 on,
5921 emit
5922 } = _ref;
5923 extendParams({
5924 navigation: {
5925 nextEl: null,
5926 prevEl: null,
5927 hideOnClick: false,
5928 disabledClass: 'swiper-button-disabled',
5929 hiddenClass: 'swiper-button-hidden',
5930 lockClass: 'swiper-button-lock',
5931 navigationDisabledClass: 'swiper-navigation-disabled'
5932 }
5933 });
5934 swiper.navigation = {
5935 nextEl: null,
5936 $nextEl: null,
5937 prevEl: null,
5938 $prevEl: null
5939 };
5940
5941 function getEl(el) {
5942 let $el;
5943
5944 if (el) {
5945 $el = $(el);
5946
5947 if (swiper.params.uniqueNavElements && typeof el === 'string' && $el.length > 1 && swiper.$el.find(el).length === 1) {
5948 $el = swiper.$el.find(el);
5949 }
5950 }
5951
5952 return $el;
5953 }
5954
5955 function toggleEl($el, disabled) {
5956 const params = swiper.params.navigation;
5957
5958 if ($el && $el.length > 0) {
5959 $el[disabled ? 'addClass' : 'removeClass'](params.disabledClass);
5960 if ($el[0] && $el[0].tagName === 'BUTTON') $el[0].disabled = disabled;
5961
5962 if (swiper.params.watchOverflow && swiper.enabled) {
5963 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
5964 }
5965 }
5966 }
5967
5968 function update() {
5969 // Update Navigation Buttons
5970 if (swiper.params.loop) return;
5971 const {
5972 $nextEl,
5973 $prevEl
5974 } = swiper.navigation;
5975 toggleEl($prevEl, swiper.isBeginning && !swiper.params.rewind);
5976 toggleEl($nextEl, swiper.isEnd && !swiper.params.rewind);
5977 }
5978
5979 function onPrevClick(e) {
5980 e.preventDefault();
5981 if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
5982 swiper.slidePrev();
5983 emit('navigationPrev');
5984 }
5985
5986 function onNextClick(e) {
5987 e.preventDefault();
5988 if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
5989 swiper.slideNext();
5990 emit('navigationNext');
5991 }
5992
5993 function init() {
5994 const params = swiper.params.navigation;
5995 swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, {
5996 nextEl: 'swiper-button-next',
5997 prevEl: 'swiper-button-prev'
5998 });
5999 if (!(params.nextEl || params.prevEl)) return;
6000 const $nextEl = getEl(params.nextEl);
6001 const $prevEl = getEl(params.prevEl);
6002
6003 if ($nextEl && $nextEl.length > 0) {
6004 $nextEl.on('click', onNextClick);
6005 }
6006
6007 if ($prevEl && $prevEl.length > 0) {
6008 $prevEl.on('click', onPrevClick);
6009 }
6010
6011 Object.assign(swiper.navigation, {
6012 $nextEl,
6013 nextEl: $nextEl && $nextEl[0],
6014 $prevEl,
6015 prevEl: $prevEl && $prevEl[0]
6016 });
6017
6018 if (!swiper.enabled) {
6019 if ($nextEl) $nextEl.addClass(params.lockClass);
6020 if ($prevEl) $prevEl.addClass(params.lockClass);
6021 }
6022 }
6023
6024 function destroy() {
6025 const {
6026 $nextEl,
6027 $prevEl
6028 } = swiper.navigation;
6029
6030 if ($nextEl && $nextEl.length) {
6031 $nextEl.off('click', onNextClick);
6032 $nextEl.removeClass(swiper.params.navigation.disabledClass);
6033 }
6034
6035 if ($prevEl && $prevEl.length) {
6036 $prevEl.off('click', onPrevClick);
6037 $prevEl.removeClass(swiper.params.navigation.disabledClass);
6038 }
6039 }
6040
6041 on('init', () => {
6042 if (swiper.params.navigation.enabled === false) {
6043 // eslint-disable-next-line
6044 disable();
6045 } else {
6046 init();
6047 update();
6048 }
6049 });
6050 on('toEdge fromEdge lock unlock', () => {
6051 update();
6052 });
6053 on('destroy', () => {
6054 destroy();
6055 });
6056 on('enable disable', () => {
6057 const {
6058 $nextEl,
6059 $prevEl
6060 } = swiper.navigation;
6061
6062 if ($nextEl) {
6063 $nextEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass);
6064 }
6065
6066 if ($prevEl) {
6067 $prevEl[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.navigation.lockClass);
6068 }
6069 });
6070 on('click', (_s, e) => {
6071 const {
6072 $nextEl,
6073 $prevEl
6074 } = swiper.navigation;
6075 const targetEl = e.target;
6076
6077 if (swiper.params.navigation.hideOnClick && !$(targetEl).is($prevEl) && !$(targetEl).is($nextEl)) {
6078 if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return;
6079 let isHidden;
6080
6081 if ($nextEl) {
6082 isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass);
6083 } else if ($prevEl) {
6084 isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass);
6085 }
6086
6087 if (isHidden === true) {
6088 emit('navigationShow');
6089 } else {
6090 emit('navigationHide');
6091 }
6092
6093 if ($nextEl) {
6094 $nextEl.toggleClass(swiper.params.navigation.hiddenClass);
6095 }
6096
6097 if ($prevEl) {
6098 $prevEl.toggleClass(swiper.params.navigation.hiddenClass);
6099 }
6100 }
6101 });
6102
6103 const enable = () => {
6104 swiper.$el.removeClass(swiper.params.navigation.navigationDisabledClass);
6105 init();
6106 update();
6107 };
6108
6109 const disable = () => {
6110 swiper.$el.addClass(swiper.params.navigation.navigationDisabledClass);
6111 destroy();
6112 };
6113
6114 Object.assign(swiper.navigation, {
6115 enable,
6116 disable,
6117 update,
6118 init,
6119 destroy
6120 });
6121}
6122
6123function classesToSelector(classes) {
6124 if (classes === void 0) {
6125 classes = '';
6126 }
6127
6128 return `.${classes.trim().replace(/([\.:!\/])/g, '\\$1') // eslint-disable-line
6129 .replace(/ /g, '.')}`;
6130}
6131
6132function Pagination(_ref) {
6133 let {
6134 swiper,
6135 extendParams,
6136 on,
6137 emit
6138 } = _ref;
6139 const pfx = 'swiper-pagination';
6140 extendParams({
6141 pagination: {
6142 el: null,
6143 bulletElement: 'span',
6144 clickable: false,
6145 hideOnClick: false,
6146 renderBullet: null,
6147 renderProgressbar: null,
6148 renderFraction: null,
6149 renderCustom: null,
6150 progressbarOpposite: false,
6151 type: 'bullets',
6152 // 'bullets' or 'progressbar' or 'fraction' or 'custom'
6153 dynamicBullets: false,
6154 dynamicMainBullets: 1,
6155 formatFractionCurrent: number => number,
6156 formatFractionTotal: number => number,
6157 bulletClass: `${pfx}-bullet`,
6158 bulletActiveClass: `${pfx}-bullet-active`,
6159 modifierClass: `${pfx}-`,
6160 currentClass: `${pfx}-current`,
6161 totalClass: `${pfx}-total`,
6162 hiddenClass: `${pfx}-hidden`,
6163 progressbarFillClass: `${pfx}-progressbar-fill`,
6164 progressbarOppositeClass: `${pfx}-progressbar-opposite`,
6165 clickableClass: `${pfx}-clickable`,
6166 lockClass: `${pfx}-lock`,
6167 horizontalClass: `${pfx}-horizontal`,
6168 verticalClass: `${pfx}-vertical`,
6169 paginationDisabledClass: `${pfx}-disabled`
6170 }
6171 });
6172 swiper.pagination = {
6173 el: null,
6174 $el: null,
6175 bullets: []
6176 };
6177 let bulletSize;
6178 let dynamicBulletIndex = 0;
6179
6180 function isPaginationDisabled() {
6181 return !swiper.params.pagination.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0;
6182 }
6183
6184 function setSideBullets($bulletEl, position) {
6185 const {
6186 bulletActiveClass
6187 } = swiper.params.pagination;
6188 $bulletEl[position]().addClass(`${bulletActiveClass}-${position}`)[position]().addClass(`${bulletActiveClass}-${position}-${position}`);
6189 }
6190
6191 function update() {
6192 // Render || Update Pagination bullets/items
6193 const rtl = swiper.rtl;
6194 const params = swiper.params.pagination;
6195 if (isPaginationDisabled()) return;
6196 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
6197 const $el = swiper.pagination.$el; // Current/Total
6198
6199 let current;
6200 const total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
6201
6202 if (swiper.params.loop) {
6203 current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup);
6204
6205 if (current > slidesLength - 1 - swiper.loopedSlides * 2) {
6206 current -= slidesLength - swiper.loopedSlides * 2;
6207 }
6208
6209 if (current > total - 1) current -= total;
6210 if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current;
6211 } else if (typeof swiper.snapIndex !== 'undefined') {
6212 current = swiper.snapIndex;
6213 } else {
6214 current = swiper.activeIndex || 0;
6215 } // Types
6216
6217
6218 if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
6219 const bullets = swiper.pagination.bullets;
6220 let firstIndex;
6221 let lastIndex;
6222 let midIndex;
6223
6224 if (params.dynamicBullets) {
6225 bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true);
6226 $el.css(swiper.isHorizontal() ? 'width' : 'height', `${bulletSize * (params.dynamicMainBullets + 4)}px`);
6227
6228 if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) {
6229 dynamicBulletIndex += current - (swiper.previousIndex - swiper.loopedSlides || 0);
6230
6231 if (dynamicBulletIndex > params.dynamicMainBullets - 1) {
6232 dynamicBulletIndex = params.dynamicMainBullets - 1;
6233 } else if (dynamicBulletIndex < 0) {
6234 dynamicBulletIndex = 0;
6235 }
6236 }
6237
6238 firstIndex = Math.max(current - dynamicBulletIndex, 0);
6239 lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
6240 midIndex = (lastIndex + firstIndex) / 2;
6241 }
6242
6243 bullets.removeClass(['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletActiveClass}${suffix}`).join(' '));
6244
6245 if ($el.length > 1) {
6246 bullets.each(bullet => {
6247 const $bullet = $(bullet);
6248 const bulletIndex = $bullet.index();
6249
6250 if (bulletIndex === current) {
6251 $bullet.addClass(params.bulletActiveClass);
6252 }
6253
6254 if (params.dynamicBullets) {
6255 if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
6256 $bullet.addClass(`${params.bulletActiveClass}-main`);
6257 }
6258
6259 if (bulletIndex === firstIndex) {
6260 setSideBullets($bullet, 'prev');
6261 }
6262
6263 if (bulletIndex === lastIndex) {
6264 setSideBullets($bullet, 'next');
6265 }
6266 }
6267 });
6268 } else {
6269 const $bullet = bullets.eq(current);
6270 const bulletIndex = $bullet.index();
6271 $bullet.addClass(params.bulletActiveClass);
6272
6273 if (params.dynamicBullets) {
6274 const $firstDisplayedBullet = bullets.eq(firstIndex);
6275 const $lastDisplayedBullet = bullets.eq(lastIndex);
6276
6277 for (let i = firstIndex; i <= lastIndex; i += 1) {
6278 bullets.eq(i).addClass(`${params.bulletActiveClass}-main`);
6279 }
6280
6281 if (swiper.params.loop) {
6282 if (bulletIndex >= bullets.length) {
6283 for (let i = params.dynamicMainBullets; i >= 0; i -= 1) {
6284 bullets.eq(bullets.length - i).addClass(`${params.bulletActiveClass}-main`);
6285 }
6286
6287 bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(`${params.bulletActiveClass}-prev`);
6288 } else {
6289 setSideBullets($firstDisplayedBullet, 'prev');
6290 setSideBullets($lastDisplayedBullet, 'next');
6291 }
6292 } else {
6293 setSideBullets($firstDisplayedBullet, 'prev');
6294 setSideBullets($lastDisplayedBullet, 'next');
6295 }
6296 }
6297 }
6298
6299 if (params.dynamicBullets) {
6300 const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
6301 const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize;
6302 const offsetProp = rtl ? 'right' : 'left';
6303 bullets.css(swiper.isHorizontal() ? offsetProp : 'top', `${bulletsOffset}px`);
6304 }
6305 }
6306
6307 if (params.type === 'fraction') {
6308 $el.find(classesToSelector(params.currentClass)).text(params.formatFractionCurrent(current + 1));
6309 $el.find(classesToSelector(params.totalClass)).text(params.formatFractionTotal(total));
6310 }
6311
6312 if (params.type === 'progressbar') {
6313 let progressbarDirection;
6314
6315 if (params.progressbarOpposite) {
6316 progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
6317 } else {
6318 progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
6319 }
6320
6321 const scale = (current + 1) / total;
6322 let scaleX = 1;
6323 let scaleY = 1;
6324
6325 if (progressbarDirection === 'horizontal') {
6326 scaleX = scale;
6327 } else {
6328 scaleY = scale;
6329 }
6330
6331 $el.find(classesToSelector(params.progressbarFillClass)).transform(`translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`).transition(swiper.params.speed);
6332 }
6333
6334 if (params.type === 'custom' && params.renderCustom) {
6335 $el.html(params.renderCustom(swiper, current + 1, total));
6336 emit('paginationRender', $el[0]);
6337 } else {
6338 emit('paginationUpdate', $el[0]);
6339 }
6340
6341 if (swiper.params.watchOverflow && swiper.enabled) {
6342 $el[swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
6343 }
6344 }
6345
6346 function render() {
6347 // Render Container
6348 const params = swiper.params.pagination;
6349 if (isPaginationDisabled()) return;
6350 const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
6351 const $el = swiper.pagination.$el;
6352 let paginationHTML = '';
6353
6354 if (params.type === 'bullets') {
6355 let numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
6356
6357 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.loop && numberOfBullets > slidesLength) {
6358 numberOfBullets = slidesLength;
6359 }
6360
6361 for (let i = 0; i < numberOfBullets; i += 1) {
6362 if (params.renderBullet) {
6363 paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
6364 } else {
6365 paginationHTML += `<${params.bulletElement} class="${params.bulletClass}"></${params.bulletElement}>`;
6366 }
6367 }
6368
6369 $el.html(paginationHTML);
6370 swiper.pagination.bullets = $el.find(classesToSelector(params.bulletClass));
6371 }
6372
6373 if (params.type === 'fraction') {
6374 if (params.renderFraction) {
6375 paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
6376 } else {
6377 paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`;
6378 }
6379
6380 $el.html(paginationHTML);
6381 }
6382
6383 if (params.type === 'progressbar') {
6384 if (params.renderProgressbar) {
6385 paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
6386 } else {
6387 paginationHTML = `<span class="${params.progressbarFillClass}"></span>`;
6388 }
6389
6390 $el.html(paginationHTML);
6391 }
6392
6393 if (params.type !== 'custom') {
6394 emit('paginationRender', swiper.pagination.$el[0]);
6395 }
6396 }
6397
6398 function init() {
6399 swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, {
6400 el: 'swiper-pagination'
6401 });
6402 const params = swiper.params.pagination;
6403 if (!params.el) return;
6404 let $el = $(params.el);
6405 if ($el.length === 0) return;
6406
6407 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) {
6408 $el = swiper.$el.find(params.el); // check if it belongs to another nested Swiper
6409
6410 if ($el.length > 1) {
6411 $el = $el.filter(el => {
6412 if ($(el).parents('.swiper')[0] !== swiper.el) return false;
6413 return true;
6414 });
6415 }
6416 }
6417
6418 if (params.type === 'bullets' && params.clickable) {
6419 $el.addClass(params.clickableClass);
6420 }
6421
6422 $el.addClass(params.modifierClass + params.type);
6423 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
6424
6425 if (params.type === 'bullets' && params.dynamicBullets) {
6426 $el.addClass(`${params.modifierClass}${params.type}-dynamic`);
6427 dynamicBulletIndex = 0;
6428
6429 if (params.dynamicMainBullets < 1) {
6430 params.dynamicMainBullets = 1;
6431 }
6432 }
6433
6434 if (params.type === 'progressbar' && params.progressbarOpposite) {
6435 $el.addClass(params.progressbarOppositeClass);
6436 }
6437
6438 if (params.clickable) {
6439 $el.on('click', classesToSelector(params.bulletClass), function onClick(e) {
6440 e.preventDefault();
6441 let index = $(this).index() * swiper.params.slidesPerGroup;
6442 if (swiper.params.loop) index += swiper.loopedSlides;
6443 swiper.slideTo(index);
6444 });
6445 }
6446
6447 Object.assign(swiper.pagination, {
6448 $el,
6449 el: $el[0]
6450 });
6451
6452 if (!swiper.enabled) {
6453 $el.addClass(params.lockClass);
6454 }
6455 }
6456
6457 function destroy() {
6458 const params = swiper.params.pagination;
6459 if (isPaginationDisabled()) return;
6460 const $el = swiper.pagination.$el;
6461 $el.removeClass(params.hiddenClass);
6462 $el.removeClass(params.modifierClass + params.type);
6463 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
6464 if (swiper.pagination.bullets && swiper.pagination.bullets.removeClass) swiper.pagination.bullets.removeClass(params.bulletActiveClass);
6465
6466 if (params.clickable) {
6467 $el.off('click', classesToSelector(params.bulletClass));
6468 }
6469 }
6470
6471 on('init', () => {
6472 if (swiper.params.pagination.enabled === false) {
6473 // eslint-disable-next-line
6474 disable();
6475 } else {
6476 init();
6477 render();
6478 update();
6479 }
6480 });
6481 on('activeIndexChange', () => {
6482 if (swiper.params.loop) {
6483 update();
6484 } else if (typeof swiper.snapIndex === 'undefined') {
6485 update();
6486 }
6487 });
6488 on('snapIndexChange', () => {
6489 if (!swiper.params.loop) {
6490 update();
6491 }
6492 });
6493 on('slidesLengthChange', () => {
6494 if (swiper.params.loop) {
6495 render();
6496 update();
6497 }
6498 });
6499 on('snapGridLengthChange', () => {
6500 if (!swiper.params.loop) {
6501 render();
6502 update();
6503 }
6504 });
6505 on('destroy', () => {
6506 destroy();
6507 });
6508 on('enable disable', () => {
6509 const {
6510 $el
6511 } = swiper.pagination;
6512
6513 if ($el) {
6514 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.pagination.lockClass);
6515 }
6516 });
6517 on('lock unlock', () => {
6518 update();
6519 });
6520 on('click', (_s, e) => {
6521 const targetEl = e.target;
6522 const {
6523 $el
6524 } = swiper.pagination;
6525
6526 if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && $el && $el.length > 0 && !$(targetEl).hasClass(swiper.params.pagination.bulletClass)) {
6527 if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return;
6528 const isHidden = $el.hasClass(swiper.params.pagination.hiddenClass);
6529
6530 if (isHidden === true) {
6531 emit('paginationShow');
6532 } else {
6533 emit('paginationHide');
6534 }
6535
6536 $el.toggleClass(swiper.params.pagination.hiddenClass);
6537 }
6538 });
6539
6540 const enable = () => {
6541 swiper.$el.removeClass(swiper.params.pagination.paginationDisabledClass);
6542
6543 if (swiper.pagination.$el) {
6544 swiper.pagination.$el.removeClass(swiper.params.pagination.paginationDisabledClass);
6545 }
6546
6547 init();
6548 render();
6549 update();
6550 };
6551
6552 const disable = () => {
6553 swiper.$el.addClass(swiper.params.pagination.paginationDisabledClass);
6554
6555 if (swiper.pagination.$el) {
6556 swiper.pagination.$el.addClass(swiper.params.pagination.paginationDisabledClass);
6557 }
6558
6559 destroy();
6560 };
6561
6562 Object.assign(swiper.pagination, {
6563 enable,
6564 disable,
6565 render,
6566 update,
6567 init,
6568 destroy
6569 });
6570}
6571
6572function Scrollbar(_ref) {
6573 let {
6574 swiper,
6575 extendParams,
6576 on,
6577 emit
6578 } = _ref;
6579 const document = getDocument();
6580 let isTouched = false;
6581 let timeout = null;
6582 let dragTimeout = null;
6583 let dragStartPos;
6584 let dragSize;
6585 let trackSize;
6586 let divider;
6587 extendParams({
6588 scrollbar: {
6589 el: null,
6590 dragSize: 'auto',
6591 hide: false,
6592 draggable: false,
6593 snapOnRelease: true,
6594 lockClass: 'swiper-scrollbar-lock',
6595 dragClass: 'swiper-scrollbar-drag',
6596 scrollbarDisabledClass: 'swiper-scrollbar-disabled',
6597 horizontalClass: `swiper-scrollbar-horizontal`,
6598 verticalClass: `swiper-scrollbar-vertical`
6599 }
6600 });
6601 swiper.scrollbar = {
6602 el: null,
6603 dragEl: null,
6604 $el: null,
6605 $dragEl: null
6606 };
6607
6608 function setTranslate() {
6609 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
6610 const {
6611 scrollbar,
6612 rtlTranslate: rtl,
6613 progress
6614 } = swiper;
6615 const {
6616 $dragEl,
6617 $el
6618 } = scrollbar;
6619 const params = swiper.params.scrollbar;
6620 let newSize = dragSize;
6621 let newPos = (trackSize - dragSize) * progress;
6622
6623 if (rtl) {
6624 newPos = -newPos;
6625
6626 if (newPos > 0) {
6627 newSize = dragSize - newPos;
6628 newPos = 0;
6629 } else if (-newPos + dragSize > trackSize) {
6630 newSize = trackSize + newPos;
6631 }
6632 } else if (newPos < 0) {
6633 newSize = dragSize + newPos;
6634 newPos = 0;
6635 } else if (newPos + dragSize > trackSize) {
6636 newSize = trackSize - newPos;
6637 }
6638
6639 if (swiper.isHorizontal()) {
6640 $dragEl.transform(`translate3d(${newPos}px, 0, 0)`);
6641 $dragEl[0].style.width = `${newSize}px`;
6642 } else {
6643 $dragEl.transform(`translate3d(0px, ${newPos}px, 0)`);
6644 $dragEl[0].style.height = `${newSize}px`;
6645 }
6646
6647 if (params.hide) {
6648 clearTimeout(timeout);
6649 $el[0].style.opacity = 1;
6650 timeout = setTimeout(() => {
6651 $el[0].style.opacity = 0;
6652 $el.transition(400);
6653 }, 1000);
6654 }
6655 }
6656
6657 function setTransition(duration) {
6658 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
6659 swiper.scrollbar.$dragEl.transition(duration);
6660 }
6661
6662 function updateSize() {
6663 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
6664 const {
6665 scrollbar
6666 } = swiper;
6667 const {
6668 $dragEl,
6669 $el
6670 } = scrollbar;
6671 $dragEl[0].style.width = '';
6672 $dragEl[0].style.height = '';
6673 trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;
6674 divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0));
6675
6676 if (swiper.params.scrollbar.dragSize === 'auto') {
6677 dragSize = trackSize * divider;
6678 } else {
6679 dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
6680 }
6681
6682 if (swiper.isHorizontal()) {
6683 $dragEl[0].style.width = `${dragSize}px`;
6684 } else {
6685 $dragEl[0].style.height = `${dragSize}px`;
6686 }
6687
6688 if (divider >= 1) {
6689 $el[0].style.display = 'none';
6690 } else {
6691 $el[0].style.display = '';
6692 }
6693
6694 if (swiper.params.scrollbar.hide) {
6695 $el[0].style.opacity = 0;
6696 }
6697
6698 if (swiper.params.watchOverflow && swiper.enabled) {
6699 scrollbar.$el[swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
6700 }
6701 }
6702
6703 function getPointerPosition(e) {
6704 if (swiper.isHorizontal()) {
6705 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX;
6706 }
6707
6708 return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY;
6709 }
6710
6711 function setDragPosition(e) {
6712 const {
6713 scrollbar,
6714 rtlTranslate: rtl
6715 } = swiper;
6716 const {
6717 $el
6718 } = scrollbar;
6719 let positionRatio;
6720 positionRatio = (getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
6721 positionRatio = Math.max(Math.min(positionRatio, 1), 0);
6722
6723 if (rtl) {
6724 positionRatio = 1 - positionRatio;
6725 }
6726
6727 const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;
6728 swiper.updateProgress(position);
6729 swiper.setTranslate(position);
6730 swiper.updateActiveIndex();
6731 swiper.updateSlidesClasses();
6732 }
6733
6734 function onDragStart(e) {
6735 const params = swiper.params.scrollbar;
6736 const {
6737 scrollbar,
6738 $wrapperEl
6739 } = swiper;
6740 const {
6741 $el,
6742 $dragEl
6743 } = scrollbar;
6744 isTouched = true;
6745 dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
6746 e.preventDefault();
6747 e.stopPropagation();
6748 $wrapperEl.transition(100);
6749 $dragEl.transition(100);
6750 setDragPosition(e);
6751 clearTimeout(dragTimeout);
6752 $el.transition(0);
6753
6754 if (params.hide) {
6755 $el.css('opacity', 1);
6756 }
6757
6758 if (swiper.params.cssMode) {
6759 swiper.$wrapperEl.css('scroll-snap-type', 'none');
6760 }
6761
6762 emit('scrollbarDragStart', e);
6763 }
6764
6765 function onDragMove(e) {
6766 const {
6767 scrollbar,
6768 $wrapperEl
6769 } = swiper;
6770 const {
6771 $el,
6772 $dragEl
6773 } = scrollbar;
6774 if (!isTouched) return;
6775 if (e.preventDefault) e.preventDefault();else e.returnValue = false;
6776 setDragPosition(e);
6777 $wrapperEl.transition(0);
6778 $el.transition(0);
6779 $dragEl.transition(0);
6780 emit('scrollbarDragMove', e);
6781 }
6782
6783 function onDragEnd(e) {
6784 const params = swiper.params.scrollbar;
6785 const {
6786 scrollbar,
6787 $wrapperEl
6788 } = swiper;
6789 const {
6790 $el
6791 } = scrollbar;
6792 if (!isTouched) return;
6793 isTouched = false;
6794
6795 if (swiper.params.cssMode) {
6796 swiper.$wrapperEl.css('scroll-snap-type', '');
6797 $wrapperEl.transition('');
6798 }
6799
6800 if (params.hide) {
6801 clearTimeout(dragTimeout);
6802 dragTimeout = nextTick(() => {
6803 $el.css('opacity', 0);
6804 $el.transition(400);
6805 }, 1000);
6806 }
6807
6808 emit('scrollbarDragEnd', e);
6809
6810 if (params.snapOnRelease) {
6811 swiper.slideToClosest();
6812 }
6813 }
6814
6815 function events(method) {
6816 const {
6817 scrollbar,
6818 touchEventsTouch,
6819 touchEventsDesktop,
6820 params,
6821 support
6822 } = swiper;
6823 const $el = scrollbar.$el;
6824 if (!$el) return;
6825 const target = $el[0];
6826 const activeListener = support.passiveListener && params.passiveListeners ? {
6827 passive: false,
6828 capture: false
6829 } : false;
6830 const passiveListener = support.passiveListener && params.passiveListeners ? {
6831 passive: true,
6832 capture: false
6833 } : false;
6834 if (!target) return;
6835 const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
6836
6837 if (!support.touch) {
6838 target[eventMethod](touchEventsDesktop.start, onDragStart, activeListener);
6839 document[eventMethod](touchEventsDesktop.move, onDragMove, activeListener);
6840 document[eventMethod](touchEventsDesktop.end, onDragEnd, passiveListener);
6841 } else {
6842 target[eventMethod](touchEventsTouch.start, onDragStart, activeListener);
6843 target[eventMethod](touchEventsTouch.move, onDragMove, activeListener);
6844 target[eventMethod](touchEventsTouch.end, onDragEnd, passiveListener);
6845 }
6846 }
6847
6848 function enableDraggable() {
6849 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
6850 events('on');
6851 }
6852
6853 function disableDraggable() {
6854 if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
6855 events('off');
6856 }
6857
6858 function init() {
6859 const {
6860 scrollbar,
6861 $el: $swiperEl
6862 } = swiper;
6863 swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, {
6864 el: 'swiper-scrollbar'
6865 });
6866 const params = swiper.params.scrollbar;
6867 if (!params.el) return;
6868 let $el = $(params.el);
6869
6870 if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
6871 $el = $swiperEl.find(params.el);
6872 }
6873
6874 $el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
6875 let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`);
6876
6877 if ($dragEl.length === 0) {
6878 $dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`);
6879 $el.append($dragEl);
6880 }
6881
6882 Object.assign(scrollbar, {
6883 $el,
6884 el: $el[0],
6885 $dragEl,
6886 dragEl: $dragEl[0]
6887 });
6888
6889 if (params.draggable) {
6890 enableDraggable();
6891 }
6892
6893 if ($el) {
6894 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass);
6895 }
6896 }
6897
6898 function destroy() {
6899 const params = swiper.params.scrollbar;
6900 const $el = swiper.scrollbar.$el;
6901
6902 if ($el) {
6903 $el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
6904 }
6905
6906 disableDraggable();
6907 }
6908
6909 on('init', () => {
6910 if (swiper.params.scrollbar.enabled === false) {
6911 // eslint-disable-next-line
6912 disable();
6913 } else {
6914 init();
6915 updateSize();
6916 setTranslate();
6917 }
6918 });
6919 on('update resize observerUpdate lock unlock', () => {
6920 updateSize();
6921 });
6922 on('setTranslate', () => {
6923 setTranslate();
6924 });
6925 on('setTransition', (_s, duration) => {
6926 setTransition(duration);
6927 });
6928 on('enable disable', () => {
6929 const {
6930 $el
6931 } = swiper.scrollbar;
6932
6933 if ($el) {
6934 $el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass);
6935 }
6936 });
6937 on('destroy', () => {
6938 destroy();
6939 });
6940
6941 const enable = () => {
6942 swiper.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
6943
6944 if (swiper.scrollbar.$el) {
6945 swiper.scrollbar.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
6946 }
6947
6948 init();
6949 updateSize();
6950 setTranslate();
6951 };
6952
6953 const disable = () => {
6954 swiper.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
6955
6956 if (swiper.scrollbar.$el) {
6957 swiper.scrollbar.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
6958 }
6959
6960 destroy();
6961 };
6962
6963 Object.assign(swiper.scrollbar, {
6964 enable,
6965 disable,
6966 updateSize,
6967 setTranslate,
6968 init,
6969 destroy
6970 });
6971}
6972
6973function Parallax(_ref) {
6974 let {
6975 swiper,
6976 extendParams,
6977 on
6978 } = _ref;
6979 extendParams({
6980 parallax: {
6981 enabled: false
6982 }
6983 });
6984
6985 const setTransform = (el, progress) => {
6986 const {
6987 rtl
6988 } = swiper;
6989 const $el = $(el);
6990 const rtlFactor = rtl ? -1 : 1;
6991 const p = $el.attr('data-swiper-parallax') || '0';
6992 let x = $el.attr('data-swiper-parallax-x');
6993 let y = $el.attr('data-swiper-parallax-y');
6994 const scale = $el.attr('data-swiper-parallax-scale');
6995 const opacity = $el.attr('data-swiper-parallax-opacity');
6996
6997 if (x || y) {
6998 x = x || '0';
6999 y = y || '0';
7000 } else if (swiper.isHorizontal()) {
7001 x = p;
7002 y = '0';
7003 } else {
7004 y = p;
7005 x = '0';
7006 }
7007
7008 if (x.indexOf('%') >= 0) {
7009 x = `${parseInt(x, 10) * progress * rtlFactor}%`;
7010 } else {
7011 x = `${x * progress * rtlFactor}px`;
7012 }
7013
7014 if (y.indexOf('%') >= 0) {
7015 y = `${parseInt(y, 10) * progress}%`;
7016 } else {
7017 y = `${y * progress}px`;
7018 }
7019
7020 if (typeof opacity !== 'undefined' && opacity !== null) {
7021 const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
7022 $el[0].style.opacity = currentOpacity;
7023 }
7024
7025 if (typeof scale === 'undefined' || scale === null) {
7026 $el.transform(`translate3d(${x}, ${y}, 0px)`);
7027 } else {
7028 const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
7029 $el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`);
7030 }
7031 };
7032
7033 const setTranslate = () => {
7034 const {
7035 $el,
7036 slides,
7037 progress,
7038 snapGrid
7039 } = swiper;
7040 $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
7041 setTransform(el, progress);
7042 });
7043 slides.each((slideEl, slideIndex) => {
7044 let slideProgress = slideEl.progress;
7045
7046 if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
7047 slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
7048 }
7049
7050 slideProgress = Math.min(Math.max(slideProgress, -1), 1);
7051 $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
7052 setTransform(el, slideProgress);
7053 });
7054 });
7055 };
7056
7057 const setTransition = function (duration) {
7058 if (duration === void 0) {
7059 duration = swiper.params.speed;
7060 }
7061
7062 const {
7063 $el
7064 } = swiper;
7065 $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => {
7066 const $parallaxEl = $(parallaxEl);
7067 let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
7068 if (duration === 0) parallaxDuration = 0;
7069 $parallaxEl.transition(parallaxDuration);
7070 });
7071 };
7072
7073 on('beforeInit', () => {
7074 if (!swiper.params.parallax.enabled) return;
7075 swiper.params.watchSlidesProgress = true;
7076 swiper.originalParams.watchSlidesProgress = true;
7077 });
7078 on('init', () => {
7079 if (!swiper.params.parallax.enabled) return;
7080 setTranslate();
7081 });
7082 on('setTranslate', () => {
7083 if (!swiper.params.parallax.enabled) return;
7084 setTranslate();
7085 });
7086 on('setTransition', (_swiper, duration) => {
7087 if (!swiper.params.parallax.enabled) return;
7088 setTransition(duration);
7089 });
7090}
7091
7092function Zoom(_ref) {
7093 let {
7094 swiper,
7095 extendParams,
7096 on,
7097 emit
7098 } = _ref;
7099 const window = getWindow();
7100 extendParams({
7101 zoom: {
7102 enabled: false,
7103 maxRatio: 3,
7104 minRatio: 1,
7105 toggle: true,
7106 containerClass: 'swiper-zoom-container',
7107 zoomedSlideClass: 'swiper-slide-zoomed'
7108 }
7109 });
7110 swiper.zoom = {
7111 enabled: false
7112 };
7113 let currentScale = 1;
7114 let isScaling = false;
7115 let gesturesEnabled;
7116 let fakeGestureTouched;
7117 let fakeGestureMoved;
7118 const gesture = {
7119 $slideEl: undefined,
7120 slideWidth: undefined,
7121 slideHeight: undefined,
7122 $imageEl: undefined,
7123 $imageWrapEl: undefined,
7124 maxRatio: 3
7125 };
7126 const image = {
7127 isTouched: undefined,
7128 isMoved: undefined,
7129 currentX: undefined,
7130 currentY: undefined,
7131 minX: undefined,
7132 minY: undefined,
7133 maxX: undefined,
7134 maxY: undefined,
7135 width: undefined,
7136 height: undefined,
7137 startX: undefined,
7138 startY: undefined,
7139 touchesStart: {},
7140 touchesCurrent: {}
7141 };
7142 const velocity = {
7143 x: undefined,
7144 y: undefined,
7145 prevPositionX: undefined,
7146 prevPositionY: undefined,
7147 prevTime: undefined
7148 };
7149 let scale = 1;
7150 Object.defineProperty(swiper.zoom, 'scale', {
7151 get() {
7152 return scale;
7153 },
7154
7155 set(value) {
7156 if (scale !== value) {
7157 const imageEl = gesture.$imageEl ? gesture.$imageEl[0] : undefined;
7158 const slideEl = gesture.$slideEl ? gesture.$slideEl[0] : undefined;
7159 emit('zoomChange', value, imageEl, slideEl);
7160 }
7161
7162 scale = value;
7163 }
7164
7165 });
7166
7167 function getDistanceBetweenTouches(e) {
7168 if (e.targetTouches.length < 2) return 1;
7169 const x1 = e.targetTouches[0].pageX;
7170 const y1 = e.targetTouches[0].pageY;
7171 const x2 = e.targetTouches[1].pageX;
7172 const y2 = e.targetTouches[1].pageY;
7173 const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
7174 return distance;
7175 } // Events
7176
7177
7178 function onGestureStart(e) {
7179 const support = swiper.support;
7180 const params = swiper.params.zoom;
7181 fakeGestureTouched = false;
7182 fakeGestureMoved = false;
7183
7184 if (!support.gestures) {
7185 if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
7186 return;
7187 }
7188
7189 fakeGestureTouched = true;
7190 gesture.scaleStart = getDistanceBetweenTouches(e);
7191 }
7192
7193 if (!gesture.$slideEl || !gesture.$slideEl.length) {
7194 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
7195 if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
7196 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
7197 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
7198 gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
7199
7200 if (gesture.$imageWrapEl.length === 0) {
7201 gesture.$imageEl = undefined;
7202 return;
7203 }
7204 }
7205
7206 if (gesture.$imageEl) {
7207 gesture.$imageEl.transition(0);
7208 }
7209
7210 isScaling = true;
7211 }
7212
7213 function onGestureChange(e) {
7214 const support = swiper.support;
7215 const params = swiper.params.zoom;
7216 const zoom = swiper.zoom;
7217
7218 if (!support.gestures) {
7219 if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
7220 return;
7221 }
7222
7223 fakeGestureMoved = true;
7224 gesture.scaleMove = getDistanceBetweenTouches(e);
7225 }
7226
7227 if (!gesture.$imageEl || gesture.$imageEl.length === 0) {
7228 if (e.type === 'gesturechange') onGestureStart(e);
7229 return;
7230 }
7231
7232 if (support.gestures) {
7233 zoom.scale = e.scale * currentScale;
7234 } else {
7235 zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
7236 }
7237
7238 if (zoom.scale > gesture.maxRatio) {
7239 zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
7240 }
7241
7242 if (zoom.scale < params.minRatio) {
7243 zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
7244 }
7245
7246 gesture.$imageEl.transform(`translate3d(0,0,0) scale(${zoom.scale})`);
7247 }
7248
7249 function onGestureEnd(e) {
7250 const device = swiper.device;
7251 const support = swiper.support;
7252 const params = swiper.params.zoom;
7253 const zoom = swiper.zoom;
7254
7255 if (!support.gestures) {
7256 if (!fakeGestureTouched || !fakeGestureMoved) {
7257 return;
7258 }
7259
7260 if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) {
7261 return;
7262 }
7263
7264 fakeGestureTouched = false;
7265 fakeGestureMoved = false;
7266 }
7267
7268 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
7269 zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
7270 gesture.$imageEl.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
7271 currentScale = zoom.scale;
7272 isScaling = false;
7273 if (zoom.scale === 1) gesture.$slideEl = undefined;
7274 }
7275
7276 function onTouchStart(e) {
7277 const device = swiper.device;
7278 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
7279 if (image.isTouched) return;
7280 if (device.android && e.cancelable) e.preventDefault();
7281 image.isTouched = true;
7282 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
7283 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
7284 }
7285
7286 function onTouchMove(e) {
7287 const zoom = swiper.zoom;
7288 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
7289 swiper.allowClick = false;
7290 if (!image.isTouched || !gesture.$slideEl) return;
7291
7292 if (!image.isMoved) {
7293 image.width = gesture.$imageEl[0].offsetWidth;
7294 image.height = gesture.$imageEl[0].offsetHeight;
7295 image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0;
7296 image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0;
7297 gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
7298 gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
7299 gesture.$imageWrapEl.transition(0);
7300 } // Define if we need image drag
7301
7302
7303 const scaledWidth = image.width * zoom.scale;
7304 const scaledHeight = image.height * zoom.scale;
7305 if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
7306 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
7307 image.maxX = -image.minX;
7308 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
7309 image.maxY = -image.minY;
7310 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
7311 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
7312
7313 if (!image.isMoved && !isScaling) {
7314 if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
7315 image.isTouched = false;
7316 return;
7317 }
7318
7319 if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
7320 image.isTouched = false;
7321 return;
7322 }
7323 }
7324
7325 if (e.cancelable) {
7326 e.preventDefault();
7327 }
7328
7329 e.stopPropagation();
7330 image.isMoved = true;
7331 image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
7332 image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
7333
7334 if (image.currentX < image.minX) {
7335 image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
7336 }
7337
7338 if (image.currentX > image.maxX) {
7339 image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
7340 }
7341
7342 if (image.currentY < image.minY) {
7343 image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
7344 }
7345
7346 if (image.currentY > image.maxY) {
7347 image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
7348 } // Velocity
7349
7350
7351 if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
7352 if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
7353 if (!velocity.prevTime) velocity.prevTime = Date.now();
7354 velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
7355 velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
7356 if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
7357 if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
7358 velocity.prevPositionX = image.touchesCurrent.x;
7359 velocity.prevPositionY = image.touchesCurrent.y;
7360 velocity.prevTime = Date.now();
7361 gesture.$imageWrapEl.transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
7362 }
7363
7364 function onTouchEnd() {
7365 const zoom = swiper.zoom;
7366 if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
7367
7368 if (!image.isTouched || !image.isMoved) {
7369 image.isTouched = false;
7370 image.isMoved = false;
7371 return;
7372 }
7373
7374 image.isTouched = false;
7375 image.isMoved = false;
7376 let momentumDurationX = 300;
7377 let momentumDurationY = 300;
7378 const momentumDistanceX = velocity.x * momentumDurationX;
7379 const newPositionX = image.currentX + momentumDistanceX;
7380 const momentumDistanceY = velocity.y * momentumDurationY;
7381 const newPositionY = image.currentY + momentumDistanceY; // Fix duration
7382
7383 if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
7384 if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
7385 const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
7386 image.currentX = newPositionX;
7387 image.currentY = newPositionY; // Define if we need image drag
7388
7389 const scaledWidth = image.width * zoom.scale;
7390 const scaledHeight = image.height * zoom.scale;
7391 image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
7392 image.maxX = -image.minX;
7393 image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
7394 image.maxY = -image.minY;
7395 image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
7396 image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
7397 gesture.$imageWrapEl.transition(momentumDuration).transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
7398 }
7399
7400 function onTransitionEnd() {
7401 const zoom = swiper.zoom;
7402
7403 if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
7404 if (gesture.$imageEl) {
7405 gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
7406 }
7407
7408 if (gesture.$imageWrapEl) {
7409 gesture.$imageWrapEl.transform('translate3d(0,0,0)');
7410 }
7411
7412 zoom.scale = 1;
7413 currentScale = 1;
7414 gesture.$slideEl = undefined;
7415 gesture.$imageEl = undefined;
7416 gesture.$imageWrapEl = undefined;
7417 }
7418 }
7419
7420 function zoomIn(e) {
7421 const zoom = swiper.zoom;
7422 const params = swiper.params.zoom;
7423
7424 if (!gesture.$slideEl) {
7425 if (e && e.target) {
7426 gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
7427 }
7428
7429 if (!gesture.$slideEl) {
7430 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
7431 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
7432 } else {
7433 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
7434 }
7435 }
7436
7437 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
7438 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
7439 }
7440
7441 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
7442
7443 if (swiper.params.cssMode) {
7444 swiper.wrapperEl.style.overflow = 'hidden';
7445 swiper.wrapperEl.style.touchAction = 'none';
7446 }
7447
7448 gesture.$slideEl.addClass(`${params.zoomedSlideClass}`);
7449 let touchX;
7450 let touchY;
7451 let offsetX;
7452 let offsetY;
7453 let diffX;
7454 let diffY;
7455 let translateX;
7456 let translateY;
7457 let imageWidth;
7458 let imageHeight;
7459 let scaledWidth;
7460 let scaledHeight;
7461 let translateMinX;
7462 let translateMinY;
7463 let translateMaxX;
7464 let translateMaxY;
7465 let slideWidth;
7466 let slideHeight;
7467
7468 if (typeof image.touchesStart.x === 'undefined' && e) {
7469 touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
7470 touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
7471 } else {
7472 touchX = image.touchesStart.x;
7473 touchY = image.touchesStart.y;
7474 }
7475
7476 zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
7477 currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
7478
7479 if (e) {
7480 slideWidth = gesture.$slideEl[0].offsetWidth;
7481 slideHeight = gesture.$slideEl[0].offsetHeight;
7482 offsetX = gesture.$slideEl.offset().left + window.scrollX;
7483 offsetY = gesture.$slideEl.offset().top + window.scrollY;
7484 diffX = offsetX + slideWidth / 2 - touchX;
7485 diffY = offsetY + slideHeight / 2 - touchY;
7486 imageWidth = gesture.$imageEl[0].offsetWidth;
7487 imageHeight = gesture.$imageEl[0].offsetHeight;
7488 scaledWidth = imageWidth * zoom.scale;
7489 scaledHeight = imageHeight * zoom.scale;
7490 translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
7491 translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
7492 translateMaxX = -translateMinX;
7493 translateMaxY = -translateMinY;
7494 translateX = diffX * zoom.scale;
7495 translateY = diffY * zoom.scale;
7496
7497 if (translateX < translateMinX) {
7498 translateX = translateMinX;
7499 }
7500
7501 if (translateX > translateMaxX) {
7502 translateX = translateMaxX;
7503 }
7504
7505 if (translateY < translateMinY) {
7506 translateY = translateMinY;
7507 }
7508
7509 if (translateY > translateMaxY) {
7510 translateY = translateMaxY;
7511 }
7512 } else {
7513 translateX = 0;
7514 translateY = 0;
7515 }
7516
7517 gesture.$imageWrapEl.transition(300).transform(`translate3d(${translateX}px, ${translateY}px,0)`);
7518 gesture.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
7519 }
7520
7521 function zoomOut() {
7522 const zoom = swiper.zoom;
7523 const params = swiper.params.zoom;
7524
7525 if (!gesture.$slideEl) {
7526 if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
7527 gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
7528 } else {
7529 gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
7530 }
7531
7532 gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
7533 gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
7534 }
7535
7536 if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
7537
7538 if (swiper.params.cssMode) {
7539 swiper.wrapperEl.style.overflow = '';
7540 swiper.wrapperEl.style.touchAction = '';
7541 }
7542
7543 zoom.scale = 1;
7544 currentScale = 1;
7545 gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
7546 gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
7547 gesture.$slideEl.removeClass(`${params.zoomedSlideClass}`);
7548 gesture.$slideEl = undefined;
7549 } // Toggle Zoom
7550
7551
7552 function zoomToggle(e) {
7553 const zoom = swiper.zoom;
7554
7555 if (zoom.scale && zoom.scale !== 1) {
7556 // Zoom Out
7557 zoomOut();
7558 } else {
7559 // Zoom In
7560 zoomIn(e);
7561 }
7562 }
7563
7564 function getListeners() {
7565 const support = swiper.support;
7566 const passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
7567 passive: true,
7568 capture: false
7569 } : false;
7570 const activeListenerWithCapture = support.passiveListener ? {
7571 passive: false,
7572 capture: true
7573 } : true;
7574 return {
7575 passiveListener,
7576 activeListenerWithCapture
7577 };
7578 }
7579
7580 function getSlideSelector() {
7581 return `.${swiper.params.slideClass}`;
7582 }
7583
7584 function toggleGestures(method) {
7585 const {
7586 passiveListener
7587 } = getListeners();
7588 const slideSelector = getSlideSelector();
7589 swiper.$wrapperEl[method]('gesturestart', slideSelector, onGestureStart, passiveListener);
7590 swiper.$wrapperEl[method]('gesturechange', slideSelector, onGestureChange, passiveListener);
7591 swiper.$wrapperEl[method]('gestureend', slideSelector, onGestureEnd, passiveListener);
7592 }
7593
7594 function enableGestures() {
7595 if (gesturesEnabled) return;
7596 gesturesEnabled = true;
7597 toggleGestures('on');
7598 }
7599
7600 function disableGestures() {
7601 if (!gesturesEnabled) return;
7602 gesturesEnabled = false;
7603 toggleGestures('off');
7604 } // Attach/Detach Events
7605
7606
7607 function enable() {
7608 const zoom = swiper.zoom;
7609 if (zoom.enabled) return;
7610 zoom.enabled = true;
7611 const support = swiper.support;
7612 const {
7613 passiveListener,
7614 activeListenerWithCapture
7615 } = getListeners();
7616 const slideSelector = getSlideSelector(); // Scale image
7617
7618 if (support.gestures) {
7619 swiper.$wrapperEl.on(swiper.touchEvents.start, enableGestures, passiveListener);
7620 swiper.$wrapperEl.on(swiper.touchEvents.end, disableGestures, passiveListener);
7621 } else if (swiper.touchEvents.start === 'touchstart') {
7622 swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
7623 swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
7624 swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
7625
7626 if (swiper.touchEvents.cancel) {
7627 swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
7628 }
7629 } // Move image
7630
7631
7632 swiper.$wrapperEl.on(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
7633 }
7634
7635 function disable() {
7636 const zoom = swiper.zoom;
7637 if (!zoom.enabled) return;
7638 const support = swiper.support;
7639 zoom.enabled = false;
7640 const {
7641 passiveListener,
7642 activeListenerWithCapture
7643 } = getListeners();
7644 const slideSelector = getSlideSelector(); // Scale image
7645
7646 if (support.gestures) {
7647 swiper.$wrapperEl.off(swiper.touchEvents.start, enableGestures, passiveListener);
7648 swiper.$wrapperEl.off(swiper.touchEvents.end, disableGestures, passiveListener);
7649 } else if (swiper.touchEvents.start === 'touchstart') {
7650 swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
7651 swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
7652 swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
7653
7654 if (swiper.touchEvents.cancel) {
7655 swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
7656 }
7657 } // Move image
7658
7659
7660 swiper.$wrapperEl.off(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
7661 }
7662
7663 on('init', () => {
7664 if (swiper.params.zoom.enabled) {
7665 enable();
7666 }
7667 });
7668 on('destroy', () => {
7669 disable();
7670 });
7671 on('touchStart', (_s, e) => {
7672 if (!swiper.zoom.enabled) return;
7673 onTouchStart(e);
7674 });
7675 on('touchEnd', (_s, e) => {
7676 if (!swiper.zoom.enabled) return;
7677 onTouchEnd();
7678 });
7679 on('doubleTap', (_s, e) => {
7680 if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
7681 zoomToggle(e);
7682 }
7683 });
7684 on('transitionEnd', () => {
7685 if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
7686 onTransitionEnd();
7687 }
7688 });
7689 on('slideChange', () => {
7690 if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
7691 onTransitionEnd();
7692 }
7693 });
7694 Object.assign(swiper.zoom, {
7695 enable,
7696 disable,
7697 in: zoomIn,
7698 out: zoomOut,
7699 toggle: zoomToggle
7700 });
7701}
7702
7703function Lazy(_ref) {
7704 let {
7705 swiper,
7706 extendParams,
7707 on,
7708 emit
7709 } = _ref;
7710 extendParams({
7711 lazy: {
7712 checkInView: false,
7713 enabled: false,
7714 loadPrevNext: false,
7715 loadPrevNextAmount: 1,
7716 loadOnTransitionStart: false,
7717 scrollingElement: '',
7718 elementClass: 'swiper-lazy',
7719 loadingClass: 'swiper-lazy-loading',
7720 loadedClass: 'swiper-lazy-loaded',
7721 preloaderClass: 'swiper-lazy-preloader'
7722 }
7723 });
7724 swiper.lazy = {};
7725 let scrollHandlerAttached = false;
7726 let initialImageLoaded = false;
7727
7728 function loadInSlide(index, loadInDuplicate) {
7729 if (loadInDuplicate === void 0) {
7730 loadInDuplicate = true;
7731 }
7732
7733 const params = swiper.params.lazy;
7734 if (typeof index === 'undefined') return;
7735 if (swiper.slides.length === 0) return;
7736 const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
7737 const $slideEl = isVirtual ? swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index);
7738 const $images = $slideEl.find(`.${params.elementClass}:not(.${params.loadedClass}):not(.${params.loadingClass})`);
7739
7740 if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) {
7741 $images.push($slideEl[0]);
7742 }
7743
7744 if ($images.length === 0) return;
7745 $images.each(imageEl => {
7746 const $imageEl = $(imageEl);
7747 $imageEl.addClass(params.loadingClass);
7748 const background = $imageEl.attr('data-background');
7749 const src = $imageEl.attr('data-src');
7750 const srcset = $imageEl.attr('data-srcset');
7751 const sizes = $imageEl.attr('data-sizes');
7752 const $pictureEl = $imageEl.parent('picture');
7753 swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, () => {
7754 if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return;
7755
7756 if (background) {
7757 $imageEl.css('background-image', `url("${background}")`);
7758 $imageEl.removeAttr('data-background');
7759 } else {
7760 if (srcset) {
7761 $imageEl.attr('srcset', srcset);
7762 $imageEl.removeAttr('data-srcset');
7763 }
7764
7765 if (sizes) {
7766 $imageEl.attr('sizes', sizes);
7767 $imageEl.removeAttr('data-sizes');
7768 }
7769
7770 if ($pictureEl.length) {
7771 $pictureEl.children('source').each(sourceEl => {
7772 const $source = $(sourceEl);
7773
7774 if ($source.attr('data-srcset')) {
7775 $source.attr('srcset', $source.attr('data-srcset'));
7776 $source.removeAttr('data-srcset');
7777 }
7778 });
7779 }
7780
7781 if (src) {
7782 $imageEl.attr('src', src);
7783 $imageEl.removeAttr('data-src');
7784 }
7785 }
7786
7787 $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass);
7788 $slideEl.find(`.${params.preloaderClass}`).remove();
7789
7790 if (swiper.params.loop && loadInDuplicate) {
7791 const slideOriginalIndex = $slideEl.attr('data-swiper-slide-index');
7792
7793 if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) {
7794 const originalSlide = swiper.$wrapperEl.children(`[data-swiper-slide-index="${slideOriginalIndex}"]:not(.${swiper.params.slideDuplicateClass})`);
7795 loadInSlide(originalSlide.index(), false);
7796 } else {
7797 const duplicatedSlide = swiper.$wrapperEl.children(`.${swiper.params.slideDuplicateClass}[data-swiper-slide-index="${slideOriginalIndex}"]`);
7798 loadInSlide(duplicatedSlide.index(), false);
7799 }
7800 }
7801
7802 emit('lazyImageReady', $slideEl[0], $imageEl[0]);
7803
7804 if (swiper.params.autoHeight) {
7805 swiper.updateAutoHeight();
7806 }
7807 });
7808 emit('lazyImageLoad', $slideEl[0], $imageEl[0]);
7809 });
7810 }
7811
7812 function load() {
7813 const {
7814 $wrapperEl,
7815 params: swiperParams,
7816 slides,
7817 activeIndex
7818 } = swiper;
7819 const isVirtual = swiper.virtual && swiperParams.virtual.enabled;
7820 const params = swiperParams.lazy;
7821 let slidesPerView = swiperParams.slidesPerView;
7822
7823 if (slidesPerView === 'auto') {
7824 slidesPerView = 0;
7825 }
7826
7827 function slideExist(index) {
7828 if (isVirtual) {
7829 if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) {
7830 return true;
7831 }
7832 } else if (slides[index]) return true;
7833
7834 return false;
7835 }
7836
7837 function slideIndex(slideEl) {
7838 if (isVirtual) {
7839 return $(slideEl).attr('data-swiper-slide-index');
7840 }
7841
7842 return $(slideEl).index();
7843 }
7844
7845 if (!initialImageLoaded) initialImageLoaded = true;
7846
7847 if (swiper.params.watchSlidesProgress) {
7848 $wrapperEl.children(`.${swiperParams.slideVisibleClass}`).each(slideEl => {
7849 const index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index();
7850 loadInSlide(index);
7851 });
7852 } else if (slidesPerView > 1) {
7853 for (let i = activeIndex; i < activeIndex + slidesPerView; i += 1) {
7854 if (slideExist(i)) loadInSlide(i);
7855 }
7856 } else {
7857 loadInSlide(activeIndex);
7858 }
7859
7860 if (params.loadPrevNext) {
7861 if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) {
7862 const amount = params.loadPrevNextAmount;
7863 const spv = Math.ceil(slidesPerView);
7864 const maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length);
7865 const minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides
7866
7867 for (let i = activeIndex + spv; i < maxIndex; i += 1) {
7868 if (slideExist(i)) loadInSlide(i);
7869 } // Prev Slides
7870
7871
7872 for (let i = minIndex; i < activeIndex; i += 1) {
7873 if (slideExist(i)) loadInSlide(i);
7874 }
7875 } else {
7876 const nextSlide = $wrapperEl.children(`.${swiperParams.slideNextClass}`);
7877 if (nextSlide.length > 0) loadInSlide(slideIndex(nextSlide));
7878 const prevSlide = $wrapperEl.children(`.${swiperParams.slidePrevClass}`);
7879 if (prevSlide.length > 0) loadInSlide(slideIndex(prevSlide));
7880 }
7881 }
7882 }
7883
7884 function checkInViewOnLoad() {
7885 const window = getWindow();
7886 if (!swiper || swiper.destroyed) return;
7887 const $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window);
7888 const isWindow = $scrollElement[0] === window;
7889 const scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth;
7890 const scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight;
7891 const swiperOffset = swiper.$el.offset();
7892 const {
7893 rtlTranslate: rtl
7894 } = swiper;
7895 let inView = false;
7896 if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
7897 const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]];
7898
7899 for (let i = 0; i < swiperCoord.length; i += 1) {
7900 const point = swiperCoord[i];
7901
7902 if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) {
7903 if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
7904
7905 inView = true;
7906 }
7907 }
7908
7909 const passiveListener = swiper.touchEvents.start === 'touchstart' && swiper.support.passiveListener && swiper.params.passiveListeners ? {
7910 passive: true,
7911 capture: false
7912 } : false;
7913
7914 if (inView) {
7915 load();
7916 $scrollElement.off('scroll', checkInViewOnLoad, passiveListener);
7917 } else if (!scrollHandlerAttached) {
7918 scrollHandlerAttached = true;
7919 $scrollElement.on('scroll', checkInViewOnLoad, passiveListener);
7920 }
7921 }
7922
7923 on('beforeInit', () => {
7924 if (swiper.params.lazy.enabled && swiper.params.preloadImages) {
7925 swiper.params.preloadImages = false;
7926 }
7927 });
7928 on('init', () => {
7929 if (swiper.params.lazy.enabled) {
7930 if (swiper.params.lazy.checkInView) {
7931 checkInViewOnLoad();
7932 } else {
7933 load();
7934 }
7935 }
7936 });
7937 on('scroll', () => {
7938 if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.freeMode.sticky) {
7939 load();
7940 }
7941 });
7942 on('scrollbarDragMove resize _freeModeNoMomentumRelease', () => {
7943 if (swiper.params.lazy.enabled) {
7944 if (swiper.params.lazy.checkInView) {
7945 checkInViewOnLoad();
7946 } else {
7947 load();
7948 }
7949 }
7950 });
7951 on('transitionStart', () => {
7952 if (swiper.params.lazy.enabled) {
7953 if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !initialImageLoaded) {
7954 if (swiper.params.lazy.checkInView) {
7955 checkInViewOnLoad();
7956 } else {
7957 load();
7958 }
7959 }
7960 }
7961 });
7962 on('transitionEnd', () => {
7963 if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) {
7964 if (swiper.params.lazy.checkInView) {
7965 checkInViewOnLoad();
7966 } else {
7967 load();
7968 }
7969 }
7970 });
7971 on('slideChange', () => {
7972 const {
7973 lazy,
7974 cssMode,
7975 watchSlidesProgress,
7976 touchReleaseOnEdges,
7977 resistanceRatio
7978 } = swiper.params;
7979
7980 if (lazy.enabled && (cssMode || watchSlidesProgress && (touchReleaseOnEdges || resistanceRatio === 0))) {
7981 load();
7982 }
7983 });
7984 on('destroy', () => {
7985 if (!swiper.$el) return;
7986 swiper.$el.find(`.${swiper.params.lazy.loadingClass}`).removeClass(swiper.params.lazy.loadingClass);
7987 });
7988 Object.assign(swiper.lazy, {
7989 load,
7990 loadInSlide
7991 });
7992}
7993
7994/* eslint no-bitwise: ["error", { "allow": [">>"] }] */
7995function Controller(_ref) {
7996 let {
7997 swiper,
7998 extendParams,
7999 on
8000 } = _ref;
8001 extendParams({
8002 controller: {
8003 control: undefined,
8004 inverse: false,
8005 by: 'slide' // or 'container'
8006
8007 }
8008 });
8009 swiper.controller = {
8010 control: undefined
8011 };
8012
8013 function LinearSpline(x, y) {
8014 const binarySearch = function search() {
8015 let maxIndex;
8016 let minIndex;
8017 let guess;
8018 return (array, val) => {
8019 minIndex = -1;
8020 maxIndex = array.length;
8021
8022 while (maxIndex - minIndex > 1) {
8023 guess = maxIndex + minIndex >> 1;
8024
8025 if (array[guess] <= val) {
8026 minIndex = guess;
8027 } else {
8028 maxIndex = guess;
8029 }
8030 }
8031
8032 return maxIndex;
8033 };
8034 }();
8035
8036 this.x = x;
8037 this.y = y;
8038 this.lastIndex = x.length - 1; // Given an x value (x2), return the expected y2 value:
8039 // (x1,y1) is the known point before given value,
8040 // (x3,y3) is the known point after given value.
8041
8042 let i1;
8043 let i3;
8044
8045 this.interpolate = function interpolate(x2) {
8046 if (!x2) return 0; // Get the indexes of x1 and x3 (the array indexes before and after given x2):
8047
8048 i3 = binarySearch(this.x, x2);
8049 i1 = i3 - 1; // We have our indexes i1 & i3, so we can calculate already:
8050 // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
8051
8052 return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
8053 };
8054
8055 return this;
8056 } // xxx: for now i will just save one spline function to to
8057
8058
8059 function getInterpolateFunction(c) {
8060 if (!swiper.controller.spline) {
8061 swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid);
8062 }
8063 }
8064
8065 function setTranslate(_t, byController) {
8066 const controlled = swiper.controller.control;
8067 let multiplier;
8068 let controlledTranslate;
8069 const Swiper = swiper.constructor;
8070
8071 function setControlledTranslate(c) {
8072 // this will create an Interpolate function based on the snapGrids
8073 // x is the Grid of the scrolled scroller and y will be the controlled scroller
8074 // it makes sense to create this only once and recall it for the interpolation
8075 // the function does a lot of value caching for performance
8076 const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
8077
8078 if (swiper.params.controller.by === 'slide') {
8079 getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
8080 // but it did not work out
8081
8082 controlledTranslate = -swiper.controller.spline.interpolate(-translate);
8083 }
8084
8085 if (!controlledTranslate || swiper.params.controller.by === 'container') {
8086 multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
8087 controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
8088 }
8089
8090 if (swiper.params.controller.inverse) {
8091 controlledTranslate = c.maxTranslate() - controlledTranslate;
8092 }
8093
8094 c.updateProgress(controlledTranslate);
8095 c.setTranslate(controlledTranslate, swiper);
8096 c.updateActiveIndex();
8097 c.updateSlidesClasses();
8098 }
8099
8100 if (Array.isArray(controlled)) {
8101 for (let i = 0; i < controlled.length; i += 1) {
8102 if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
8103 setControlledTranslate(controlled[i]);
8104 }
8105 }
8106 } else if (controlled instanceof Swiper && byController !== controlled) {
8107 setControlledTranslate(controlled);
8108 }
8109 }
8110
8111 function setTransition(duration, byController) {
8112 const Swiper = swiper.constructor;
8113 const controlled = swiper.controller.control;
8114 let i;
8115
8116 function setControlledTransition(c) {
8117 c.setTransition(duration, swiper);
8118
8119 if (duration !== 0) {
8120 c.transitionStart();
8121
8122 if (c.params.autoHeight) {
8123 nextTick(() => {
8124 c.updateAutoHeight();
8125 });
8126 }
8127
8128 c.$wrapperEl.transitionEnd(() => {
8129 if (!controlled) return;
8130
8131 if (c.params.loop && swiper.params.controller.by === 'slide') {
8132 c.loopFix();
8133 }
8134
8135 c.transitionEnd();
8136 });
8137 }
8138 }
8139
8140 if (Array.isArray(controlled)) {
8141 for (i = 0; i < controlled.length; i += 1) {
8142 if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
8143 setControlledTransition(controlled[i]);
8144 }
8145 }
8146 } else if (controlled instanceof Swiper && byController !== controlled) {
8147 setControlledTransition(controlled);
8148 }
8149 }
8150
8151 function removeSpline() {
8152 if (!swiper.controller.control) return;
8153
8154 if (swiper.controller.spline) {
8155 swiper.controller.spline = undefined;
8156 delete swiper.controller.spline;
8157 }
8158 }
8159
8160 on('beforeInit', () => {
8161 swiper.controller.control = swiper.params.controller.control;
8162 });
8163 on('update', () => {
8164 removeSpline();
8165 });
8166 on('resize', () => {
8167 removeSpline();
8168 });
8169 on('observerUpdate', () => {
8170 removeSpline();
8171 });
8172 on('setTranslate', (_s, translate, byController) => {
8173 if (!swiper.controller.control) return;
8174 swiper.controller.setTranslate(translate, byController);
8175 });
8176 on('setTransition', (_s, duration, byController) => {
8177 if (!swiper.controller.control) return;
8178 swiper.controller.setTransition(duration, byController);
8179 });
8180 Object.assign(swiper.controller, {
8181 setTranslate,
8182 setTransition
8183 });
8184}
8185
8186function A11y(_ref) {
8187 let {
8188 swiper,
8189 extendParams,
8190 on
8191 } = _ref;
8192 extendParams({
8193 a11y: {
8194 enabled: true,
8195 notificationClass: 'swiper-notification',
8196 prevSlideMessage: 'Previous slide',
8197 nextSlideMessage: 'Next slide',
8198 firstSlideMessage: 'This is the first slide',
8199 lastSlideMessage: 'This is the last slide',
8200 paginationBulletMessage: 'Go to slide {{index}}',
8201 slideLabelMessage: '{{index}} / {{slidesLength}}',
8202 containerMessage: null,
8203 containerRoleDescriptionMessage: null,
8204 itemRoleDescriptionMessage: null,
8205 slideRole: 'group',
8206 id: null
8207 }
8208 });
8209 swiper.a11y = {
8210 clicked: false
8211 };
8212 let liveRegion = null;
8213
8214 function notify(message) {
8215 const notification = liveRegion;
8216 if (notification.length === 0) return;
8217 notification.html('');
8218 notification.html(message);
8219 }
8220
8221 function getRandomNumber(size) {
8222 if (size === void 0) {
8223 size = 16;
8224 }
8225
8226 const randomChar = () => Math.round(16 * Math.random()).toString(16);
8227
8228 return 'x'.repeat(size).replace(/x/g, randomChar);
8229 }
8230
8231 function makeElFocusable($el) {
8232 $el.attr('tabIndex', '0');
8233 }
8234
8235 function makeElNotFocusable($el) {
8236 $el.attr('tabIndex', '-1');
8237 }
8238
8239 function addElRole($el, role) {
8240 $el.attr('role', role);
8241 }
8242
8243 function addElRoleDescription($el, description) {
8244 $el.attr('aria-roledescription', description);
8245 }
8246
8247 function addElControls($el, controls) {
8248 $el.attr('aria-controls', controls);
8249 }
8250
8251 function addElLabel($el, label) {
8252 $el.attr('aria-label', label);
8253 }
8254
8255 function addElId($el, id) {
8256 $el.attr('id', id);
8257 }
8258
8259 function addElLive($el, live) {
8260 $el.attr('aria-live', live);
8261 }
8262
8263 function disableEl($el) {
8264 $el.attr('aria-disabled', true);
8265 }
8266
8267 function enableEl($el) {
8268 $el.attr('aria-disabled', false);
8269 }
8270
8271 function onEnterOrSpaceKey(e) {
8272 if (e.keyCode !== 13 && e.keyCode !== 32) return;
8273 const params = swiper.params.a11y;
8274 const $targetEl = $(e.target);
8275
8276 if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) {
8277 if (!(swiper.isEnd && !swiper.params.loop)) {
8278 swiper.slideNext();
8279 }
8280
8281 if (swiper.isEnd) {
8282 notify(params.lastSlideMessage);
8283 } else {
8284 notify(params.nextSlideMessage);
8285 }
8286 }
8287
8288 if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) {
8289 if (!(swiper.isBeginning && !swiper.params.loop)) {
8290 swiper.slidePrev();
8291 }
8292
8293 if (swiper.isBeginning) {
8294 notify(params.firstSlideMessage);
8295 } else {
8296 notify(params.prevSlideMessage);
8297 }
8298 }
8299
8300 if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) {
8301 $targetEl[0].click();
8302 }
8303 }
8304
8305 function updateNavigation() {
8306 if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
8307 const {
8308 $nextEl,
8309 $prevEl
8310 } = swiper.navigation;
8311
8312 if ($prevEl && $prevEl.length > 0) {
8313 if (swiper.isBeginning) {
8314 disableEl($prevEl);
8315 makeElNotFocusable($prevEl);
8316 } else {
8317 enableEl($prevEl);
8318 makeElFocusable($prevEl);
8319 }
8320 }
8321
8322 if ($nextEl && $nextEl.length > 0) {
8323 if (swiper.isEnd) {
8324 disableEl($nextEl);
8325 makeElNotFocusable($nextEl);
8326 } else {
8327 enableEl($nextEl);
8328 makeElFocusable($nextEl);
8329 }
8330 }
8331 }
8332
8333 function hasPagination() {
8334 return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
8335 }
8336
8337 function hasClickablePagination() {
8338 return hasPagination() && swiper.params.pagination.clickable;
8339 }
8340
8341 function updatePagination() {
8342 const params = swiper.params.a11y;
8343 if (!hasPagination()) return;
8344 swiper.pagination.bullets.each(bulletEl => {
8345 const $bulletEl = $(bulletEl);
8346
8347 if (swiper.params.pagination.clickable) {
8348 makeElFocusable($bulletEl);
8349
8350 if (!swiper.params.pagination.renderBullet) {
8351 addElRole($bulletEl, 'button');
8352 addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1));
8353 }
8354 }
8355
8356 if ($bulletEl.is(`.${swiper.params.pagination.bulletActiveClass}`)) {
8357 $bulletEl.attr('aria-current', 'true');
8358 } else {
8359 $bulletEl.removeAttr('aria-current');
8360 }
8361 });
8362 }
8363
8364 const initNavEl = ($el, wrapperId, message) => {
8365 makeElFocusable($el);
8366
8367 if ($el[0].tagName !== 'BUTTON') {
8368 addElRole($el, 'button');
8369 $el.on('keydown', onEnterOrSpaceKey);
8370 }
8371
8372 addElLabel($el, message);
8373 addElControls($el, wrapperId);
8374 };
8375
8376 const handlePointerDown = () => {
8377 swiper.a11y.clicked = true;
8378 };
8379
8380 const handlePointerUp = () => {
8381 requestAnimationFrame(() => {
8382 requestAnimationFrame(() => {
8383 if (!swiper.destroyed) {
8384 swiper.a11y.clicked = false;
8385 }
8386 });
8387 });
8388 };
8389
8390 const handleFocus = e => {
8391 if (swiper.a11y.clicked) return;
8392 const slideEl = e.target.closest(`.${swiper.params.slideClass}`);
8393 if (!slideEl || !swiper.slides.includes(slideEl)) return;
8394 const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
8395 const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
8396 if (isActive || isVisible) return;
8397 if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
8398
8399 if (swiper.isHorizontal()) {
8400 swiper.el.scrollLeft = 0;
8401 } else {
8402 swiper.el.scrollTop = 0;
8403 }
8404
8405 swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
8406 };
8407
8408 const initSlides = () => {
8409 const params = swiper.params.a11y;
8410
8411 if (params.itemRoleDescriptionMessage) {
8412 addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage);
8413 }
8414
8415 if (params.slideRole) {
8416 addElRole($(swiper.slides), params.slideRole);
8417 }
8418
8419 const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length;
8420
8421 if (params.slideLabelMessage) {
8422 swiper.slides.each((slideEl, index) => {
8423 const $slideEl = $(slideEl);
8424 const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index;
8425 const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
8426 addElLabel($slideEl, ariaLabelMessage);
8427 });
8428 }
8429 };
8430
8431 const init = () => {
8432 const params = swiper.params.a11y;
8433 swiper.$el.append(liveRegion); // Container
8434
8435 const $containerEl = swiper.$el;
8436
8437 if (params.containerRoleDescriptionMessage) {
8438 addElRoleDescription($containerEl, params.containerRoleDescriptionMessage);
8439 }
8440
8441 if (params.containerMessage) {
8442 addElLabel($containerEl, params.containerMessage);
8443 } // Wrapper
8444
8445
8446 const $wrapperEl = swiper.$wrapperEl;
8447 const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`;
8448 const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
8449 addElId($wrapperEl, wrapperId);
8450 addElLive($wrapperEl, live); // Slide
8451
8452 initSlides(); // Navigation
8453
8454 let $nextEl;
8455 let $prevEl;
8456
8457 if (swiper.navigation && swiper.navigation.$nextEl) {
8458 $nextEl = swiper.navigation.$nextEl;
8459 }
8460
8461 if (swiper.navigation && swiper.navigation.$prevEl) {
8462 $prevEl = swiper.navigation.$prevEl;
8463 }
8464
8465 if ($nextEl && $nextEl.length) {
8466 initNavEl($nextEl, wrapperId, params.nextSlideMessage);
8467 }
8468
8469 if ($prevEl && $prevEl.length) {
8470 initNavEl($prevEl, wrapperId, params.prevSlideMessage);
8471 } // Pagination
8472
8473
8474 if (hasClickablePagination()) {
8475 swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
8476 } // Tab focus
8477
8478
8479 swiper.$el.on('focus', handleFocus, true);
8480 swiper.$el.on('pointerdown', handlePointerDown, true);
8481 swiper.$el.on('pointerup', handlePointerUp, true);
8482 };
8483
8484 function destroy() {
8485 if (liveRegion && liveRegion.length > 0) liveRegion.remove();
8486 let $nextEl;
8487 let $prevEl;
8488
8489 if (swiper.navigation && swiper.navigation.$nextEl) {
8490 $nextEl = swiper.navigation.$nextEl;
8491 }
8492
8493 if (swiper.navigation && swiper.navigation.$prevEl) {
8494 $prevEl = swiper.navigation.$prevEl;
8495 }
8496
8497 if ($nextEl) {
8498 $nextEl.off('keydown', onEnterOrSpaceKey);
8499 }
8500
8501 if ($prevEl) {
8502 $prevEl.off('keydown', onEnterOrSpaceKey);
8503 } // Pagination
8504
8505
8506 if (hasClickablePagination()) {
8507 swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
8508 } // Tab focus
8509
8510
8511 swiper.$el.off('focus', handleFocus, true);
8512 swiper.$el.off('pointerdown', handlePointerDown, true);
8513 swiper.$el.off('pointerup', handlePointerUp, true);
8514 }
8515
8516 on('beforeInit', () => {
8517 liveRegion = $(`<span class="${swiper.params.a11y.notificationClass}" aria-live="assertive" aria-atomic="true"></span>`);
8518 });
8519 on('afterInit', () => {
8520 if (!swiper.params.a11y.enabled) return;
8521 init();
8522 });
8523 on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => {
8524 if (!swiper.params.a11y.enabled) return;
8525 initSlides();
8526 });
8527 on('fromEdge toEdge afterInit lock unlock', () => {
8528 if (!swiper.params.a11y.enabled) return;
8529 updateNavigation();
8530 });
8531 on('paginationUpdate', () => {
8532 if (!swiper.params.a11y.enabled) return;
8533 updatePagination();
8534 });
8535 on('destroy', () => {
8536 if (!swiper.params.a11y.enabled) return;
8537 destroy();
8538 });
8539}
8540
8541function History(_ref) {
8542 let {
8543 swiper,
8544 extendParams,
8545 on
8546 } = _ref;
8547 extendParams({
8548 history: {
8549 enabled: false,
8550 root: '',
8551 replaceState: false,
8552 key: 'slides',
8553 keepQuery: false
8554 }
8555 });
8556 let initialized = false;
8557 let paths = {};
8558
8559 const slugify = text => {
8560 return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
8561 };
8562
8563 const getPathValues = urlOverride => {
8564 const window = getWindow();
8565 let location;
8566
8567 if (urlOverride) {
8568 location = new URL(urlOverride);
8569 } else {
8570 location = window.location;
8571 }
8572
8573 const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
8574 const total = pathArray.length;
8575 const key = pathArray[total - 2];
8576 const value = pathArray[total - 1];
8577 return {
8578 key,
8579 value
8580 };
8581 };
8582
8583 const setHistory = (key, index) => {
8584 const window = getWindow();
8585 if (!initialized || !swiper.params.history.enabled) return;
8586 let location;
8587
8588 if (swiper.params.url) {
8589 location = new URL(swiper.params.url);
8590 } else {
8591 location = window.location;
8592 }
8593
8594 const slide = swiper.slides.eq(index);
8595 let value = slugify(slide.attr('data-history'));
8596
8597 if (swiper.params.history.root.length > 0) {
8598 let root = swiper.params.history.root;
8599 if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
8600 value = `${root}/${key}/${value}`;
8601 } else if (!location.pathname.includes(key)) {
8602 value = `${key}/${value}`;
8603 }
8604
8605 if (swiper.params.history.keepQuery) {
8606 value += location.search;
8607 }
8608
8609 const currentState = window.history.state;
8610
8611 if (currentState && currentState.value === value) {
8612 return;
8613 }
8614
8615 if (swiper.params.history.replaceState) {
8616 window.history.replaceState({
8617 value
8618 }, null, value);
8619 } else {
8620 window.history.pushState({
8621 value
8622 }, null, value);
8623 }
8624 };
8625
8626 const scrollToSlide = (speed, value, runCallbacks) => {
8627 if (value) {
8628 for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
8629 const slide = swiper.slides.eq(i);
8630 const slideHistory = slugify(slide.attr('data-history'));
8631
8632 if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
8633 const index = slide.index();
8634 swiper.slideTo(index, speed, runCallbacks);
8635 }
8636 }
8637 } else {
8638 swiper.slideTo(0, speed, runCallbacks);
8639 }
8640 };
8641
8642 const setHistoryPopState = () => {
8643 paths = getPathValues(swiper.params.url);
8644 scrollToSlide(swiper.params.speed, paths.value, false);
8645 };
8646
8647 const init = () => {
8648 const window = getWindow();
8649 if (!swiper.params.history) return;
8650
8651 if (!window.history || !window.history.pushState) {
8652 swiper.params.history.enabled = false;
8653 swiper.params.hashNavigation.enabled = true;
8654 return;
8655 }
8656
8657 initialized = true;
8658 paths = getPathValues(swiper.params.url);
8659 if (!paths.key && !paths.value) return;
8660 scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
8661
8662 if (!swiper.params.history.replaceState) {
8663 window.addEventListener('popstate', setHistoryPopState);
8664 }
8665 };
8666
8667 const destroy = () => {
8668 const window = getWindow();
8669
8670 if (!swiper.params.history.replaceState) {
8671 window.removeEventListener('popstate', setHistoryPopState);
8672 }
8673 };
8674
8675 on('init', () => {
8676 if (swiper.params.history.enabled) {
8677 init();
8678 }
8679 });
8680 on('destroy', () => {
8681 if (swiper.params.history.enabled) {
8682 destroy();
8683 }
8684 });
8685 on('transitionEnd _freeModeNoMomentumRelease', () => {
8686 if (initialized) {
8687 setHistory(swiper.params.history.key, swiper.activeIndex);
8688 }
8689 });
8690 on('slideChange', () => {
8691 if (initialized && swiper.params.cssMode) {
8692 setHistory(swiper.params.history.key, swiper.activeIndex);
8693 }
8694 });
8695}
8696
8697function HashNavigation(_ref) {
8698 let {
8699 swiper,
8700 extendParams,
8701 emit,
8702 on
8703 } = _ref;
8704 let initialized = false;
8705 const document = getDocument();
8706 const window = getWindow();
8707 extendParams({
8708 hashNavigation: {
8709 enabled: false,
8710 replaceState: false,
8711 watchState: false
8712 }
8713 });
8714
8715 const onHashChange = () => {
8716 emit('hashChange');
8717 const newHash = document.location.hash.replace('#', '');
8718 const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
8719
8720 if (newHash !== activeSlideHash) {
8721 const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index();
8722 if (typeof newIndex === 'undefined') return;
8723 swiper.slideTo(newIndex);
8724 }
8725 };
8726
8727 const setHash = () => {
8728 if (!initialized || !swiper.params.hashNavigation.enabled) return;
8729
8730 if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
8731 window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || '');
8732 emit('hashSet');
8733 } else {
8734 const slide = swiper.slides.eq(swiper.activeIndex);
8735 const hash = slide.attr('data-hash') || slide.attr('data-history');
8736 document.location.hash = hash || '';
8737 emit('hashSet');
8738 }
8739 };
8740
8741 const init = () => {
8742 if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
8743 initialized = true;
8744 const hash = document.location.hash.replace('#', '');
8745
8746 if (hash) {
8747 const speed = 0;
8748
8749 for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
8750 const slide = swiper.slides.eq(i);
8751 const slideHash = slide.attr('data-hash') || slide.attr('data-history');
8752
8753 if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
8754 const index = slide.index();
8755 swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
8756 }
8757 }
8758 }
8759
8760 if (swiper.params.hashNavigation.watchState) {
8761 $(window).on('hashchange', onHashChange);
8762 }
8763 };
8764
8765 const destroy = () => {
8766 if (swiper.params.hashNavigation.watchState) {
8767 $(window).off('hashchange', onHashChange);
8768 }
8769 };
8770
8771 on('init', () => {
8772 if (swiper.params.hashNavigation.enabled) {
8773 init();
8774 }
8775 });
8776 on('destroy', () => {
8777 if (swiper.params.hashNavigation.enabled) {
8778 destroy();
8779 }
8780 });
8781 on('transitionEnd _freeModeNoMomentumRelease', () => {
8782 if (initialized) {
8783 setHash();
8784 }
8785 });
8786 on('slideChange', () => {
8787 if (initialized && swiper.params.cssMode) {
8788 setHash();
8789 }
8790 });
8791}
8792
8793/* eslint no-underscore-dangle: "off" */
8794function Autoplay(_ref) {
8795 let {
8796 swiper,
8797 extendParams,
8798 on,
8799 emit
8800 } = _ref;
8801 let timeout;
8802 swiper.autoplay = {
8803 running: false,
8804 paused: false
8805 };
8806 extendParams({
8807 autoplay: {
8808 enabled: false,
8809 delay: 3000,
8810 waitForTransition: true,
8811 disableOnInteraction: true,
8812 stopOnLastSlide: false,
8813 reverseDirection: false,
8814 pauseOnMouseEnter: false
8815 }
8816 });
8817
8818 function run() {
8819 if (!swiper.size) {
8820 swiper.autoplay.running = false;
8821 swiper.autoplay.paused = false;
8822 return;
8823 }
8824
8825 const $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
8826 let delay = swiper.params.autoplay.delay;
8827
8828 if ($activeSlideEl.attr('data-swiper-autoplay')) {
8829 delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
8830 }
8831
8832 clearTimeout(timeout);
8833 timeout = nextTick(() => {
8834 let autoplayResult;
8835
8836 if (swiper.params.autoplay.reverseDirection) {
8837 if (swiper.params.loop) {
8838 swiper.loopFix();
8839 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
8840 emit('autoplay');
8841 } else if (!swiper.isBeginning) {
8842 autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
8843 emit('autoplay');
8844 } else if (!swiper.params.autoplay.stopOnLastSlide) {
8845 autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
8846 emit('autoplay');
8847 } else {
8848 stop();
8849 }
8850 } else if (swiper.params.loop) {
8851 swiper.loopFix();
8852 autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
8853 emit('autoplay');
8854 } else if (!swiper.isEnd) {
8855 autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
8856 emit('autoplay');
8857 } else if (!swiper.params.autoplay.stopOnLastSlide) {
8858 autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
8859 emit('autoplay');
8860 } else {
8861 stop();
8862 }
8863
8864 if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) {
8865 run();
8866 }
8867 }, delay);
8868 }
8869
8870 function start() {
8871 if (typeof timeout !== 'undefined') return false;
8872 if (swiper.autoplay.running) return false;
8873 swiper.autoplay.running = true;
8874 emit('autoplayStart');
8875 run();
8876 return true;
8877 }
8878
8879 function stop() {
8880 if (!swiper.autoplay.running) return false;
8881 if (typeof timeout === 'undefined') return false;
8882
8883 if (timeout) {
8884 clearTimeout(timeout);
8885 timeout = undefined;
8886 }
8887
8888 swiper.autoplay.running = false;
8889 emit('autoplayStop');
8890 return true;
8891 }
8892
8893 function pause(speed) {
8894 if (!swiper.autoplay.running) return;
8895 if (swiper.autoplay.paused) return;
8896 if (timeout) clearTimeout(timeout);
8897 swiper.autoplay.paused = true;
8898
8899 if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
8900 swiper.autoplay.paused = false;
8901 run();
8902 } else {
8903 ['transitionend', 'webkitTransitionEnd'].forEach(event => {
8904 swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd);
8905 });
8906 }
8907 }
8908
8909 function onVisibilityChange() {
8910 const document = getDocument();
8911
8912 if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
8913 pause();
8914 }
8915
8916 if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
8917 run();
8918 swiper.autoplay.paused = false;
8919 }
8920 }
8921
8922 function onTransitionEnd(e) {
8923 if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
8924 if (e.target !== swiper.$wrapperEl[0]) return;
8925 ['transitionend', 'webkitTransitionEnd'].forEach(event => {
8926 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
8927 });
8928 swiper.autoplay.paused = false;
8929
8930 if (!swiper.autoplay.running) {
8931 stop();
8932 } else {
8933 run();
8934 }
8935 }
8936
8937 function onMouseEnter() {
8938 if (swiper.params.autoplay.disableOnInteraction) {
8939 stop();
8940 } else {
8941 emit('autoplayPause');
8942 pause();
8943 }
8944
8945 ['transitionend', 'webkitTransitionEnd'].forEach(event => {
8946 swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
8947 });
8948 }
8949
8950 function onMouseLeave() {
8951 if (swiper.params.autoplay.disableOnInteraction) {
8952 return;
8953 }
8954
8955 swiper.autoplay.paused = false;
8956 emit('autoplayResume');
8957 run();
8958 }
8959
8960 function attachMouseEvents() {
8961 if (swiper.params.autoplay.pauseOnMouseEnter) {
8962 swiper.$el.on('mouseenter', onMouseEnter);
8963 swiper.$el.on('mouseleave', onMouseLeave);
8964 }
8965 }
8966
8967 function detachMouseEvents() {
8968 swiper.$el.off('mouseenter', onMouseEnter);
8969 swiper.$el.off('mouseleave', onMouseLeave);
8970 }
8971
8972 on('init', () => {
8973 if (swiper.params.autoplay.enabled) {
8974 start();
8975 const document = getDocument();
8976 document.addEventListener('visibilitychange', onVisibilityChange);
8977 attachMouseEvents();
8978 }
8979 });
8980 on('beforeTransitionStart', (_s, speed, internal) => {
8981 if (swiper.autoplay.running) {
8982 if (internal || !swiper.params.autoplay.disableOnInteraction) {
8983 swiper.autoplay.pause(speed);
8984 } else {
8985 stop();
8986 }
8987 }
8988 });
8989 on('sliderFirstMove', () => {
8990 if (swiper.autoplay.running) {
8991 if (swiper.params.autoplay.disableOnInteraction) {
8992 stop();
8993 } else {
8994 pause();
8995 }
8996 }
8997 });
8998 on('touchEnd', () => {
8999 if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
9000 run();
9001 }
9002 });
9003 on('destroy', () => {
9004 detachMouseEvents();
9005
9006 if (swiper.autoplay.running) {
9007 stop();
9008 }
9009
9010 const document = getDocument();
9011 document.removeEventListener('visibilitychange', onVisibilityChange);
9012 });
9013 Object.assign(swiper.autoplay, {
9014 pause,
9015 run,
9016 start,
9017 stop
9018 });
9019}
9020
9021function Thumb(_ref) {
9022 let {
9023 swiper,
9024 extendParams,
9025 on
9026 } = _ref;
9027 extendParams({
9028 thumbs: {
9029 swiper: null,
9030 multipleActiveThumbs: true,
9031 autoScrollOffset: 0,
9032 slideThumbActiveClass: 'swiper-slide-thumb-active',
9033 thumbsContainerClass: 'swiper-thumbs'
9034 }
9035 });
9036 let initialized = false;
9037 let swiperCreated = false;
9038 swiper.thumbs = {
9039 swiper: null
9040 };
9041
9042 function onThumbClick() {
9043 const thumbsSwiper = swiper.thumbs.swiper;
9044 if (!thumbsSwiper || thumbsSwiper.destroyed) return;
9045 const clickedIndex = thumbsSwiper.clickedIndex;
9046 const clickedSlide = thumbsSwiper.clickedSlide;
9047 if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return;
9048 if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
9049 let slideToIndex;
9050
9051 if (thumbsSwiper.params.loop) {
9052 slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10);
9053 } else {
9054 slideToIndex = clickedIndex;
9055 }
9056
9057 if (swiper.params.loop) {
9058 let currentIndex = swiper.activeIndex;
9059
9060 if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) {
9061 swiper.loopFix(); // eslint-disable-next-line
9062
9063 swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
9064 currentIndex = swiper.activeIndex;
9065 }
9066
9067 const prevIndex = swiper.slides.eq(currentIndex).prevAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
9068 const nextIndex = swiper.slides.eq(currentIndex).nextAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
9069 if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex;
9070 }
9071
9072 swiper.slideTo(slideToIndex);
9073 }
9074
9075 function init() {
9076 const {
9077 thumbs: thumbsParams
9078 } = swiper.params;
9079 if (initialized) return false;
9080 initialized = true;
9081 const SwiperClass = swiper.constructor;
9082
9083 if (thumbsParams.swiper instanceof SwiperClass) {
9084 swiper.thumbs.swiper = thumbsParams.swiper;
9085 Object.assign(swiper.thumbs.swiper.originalParams, {
9086 watchSlidesProgress: true,
9087 slideToClickedSlide: false
9088 });
9089 Object.assign(swiper.thumbs.swiper.params, {
9090 watchSlidesProgress: true,
9091 slideToClickedSlide: false
9092 });
9093 } else if (isObject(thumbsParams.swiper)) {
9094 const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
9095 Object.assign(thumbsSwiperParams, {
9096 watchSlidesProgress: true,
9097 slideToClickedSlide: false
9098 });
9099 swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
9100 swiperCreated = true;
9101 }
9102
9103 swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass);
9104 swiper.thumbs.swiper.on('tap', onThumbClick);
9105 return true;
9106 }
9107
9108 function update(initial) {
9109 const thumbsSwiper = swiper.thumbs.swiper;
9110 if (!thumbsSwiper || thumbsSwiper.destroyed) return;
9111 const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; // Activate thumbs
9112
9113 let thumbsToActivate = 1;
9114 const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
9115
9116 if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
9117 thumbsToActivate = swiper.params.slidesPerView;
9118 }
9119
9120 if (!swiper.params.thumbs.multipleActiveThumbs) {
9121 thumbsToActivate = 1;
9122 }
9123
9124 thumbsToActivate = Math.floor(thumbsToActivate);
9125 thumbsSwiper.slides.removeClass(thumbActiveClass);
9126
9127 if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
9128 for (let i = 0; i < thumbsToActivate; i += 1) {
9129 thumbsSwiper.$wrapperEl.children(`[data-swiper-slide-index="${swiper.realIndex + i}"]`).addClass(thumbActiveClass);
9130 }
9131 } else {
9132 for (let i = 0; i < thumbsToActivate; i += 1) {
9133 thumbsSwiper.slides.eq(swiper.realIndex + i).addClass(thumbActiveClass);
9134 }
9135 }
9136
9137 const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
9138 const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
9139
9140 if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
9141 let currentThumbsIndex = thumbsSwiper.activeIndex;
9142 let newThumbsIndex;
9143 let direction;
9144
9145 if (thumbsSwiper.params.loop) {
9146 if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) {
9147 thumbsSwiper.loopFix(); // eslint-disable-next-line
9148
9149 thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft;
9150 currentThumbsIndex = thumbsSwiper.activeIndex;
9151 } // Find actual thumbs index to slide to
9152
9153
9154 const prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
9155 const nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
9156
9157 if (typeof prevThumbsIndex === 'undefined') {
9158 newThumbsIndex = nextThumbsIndex;
9159 } else if (typeof nextThumbsIndex === 'undefined') {
9160 newThumbsIndex = prevThumbsIndex;
9161 } else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) {
9162 newThumbsIndex = thumbsSwiper.params.slidesPerGroup > 1 ? nextThumbsIndex : currentThumbsIndex;
9163 } else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) {
9164 newThumbsIndex = nextThumbsIndex;
9165 } else {
9166 newThumbsIndex = prevThumbsIndex;
9167 }
9168
9169 direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
9170 } else {
9171 newThumbsIndex = swiper.realIndex;
9172 direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
9173 }
9174
9175 if (useOffset) {
9176 newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
9177 }
9178
9179 if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
9180 if (thumbsSwiper.params.centeredSlides) {
9181 if (newThumbsIndex > currentThumbsIndex) {
9182 newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
9183 } else {
9184 newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
9185 }
9186 } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
9187
9188 thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
9189 }
9190 }
9191 }
9192
9193 on('beforeInit', () => {
9194 const {
9195 thumbs
9196 } = swiper.params;
9197 if (!thumbs || !thumbs.swiper) return;
9198 init();
9199 update(true);
9200 });
9201 on('slideChange update resize observerUpdate', () => {
9202 update();
9203 });
9204 on('setTransition', (_s, duration) => {
9205 const thumbsSwiper = swiper.thumbs.swiper;
9206 if (!thumbsSwiper || thumbsSwiper.destroyed) return;
9207 thumbsSwiper.setTransition(duration);
9208 });
9209 on('beforeDestroy', () => {
9210 const thumbsSwiper = swiper.thumbs.swiper;
9211 if (!thumbsSwiper || thumbsSwiper.destroyed) return;
9212
9213 if (swiperCreated) {
9214 thumbsSwiper.destroy();
9215 }
9216 });
9217 Object.assign(swiper.thumbs, {
9218 init,
9219 update
9220 });
9221}
9222
9223function freeMode(_ref) {
9224 let {
9225 swiper,
9226 extendParams,
9227 emit,
9228 once
9229 } = _ref;
9230 extendParams({
9231 freeMode: {
9232 enabled: false,
9233 momentum: true,
9234 momentumRatio: 1,
9235 momentumBounce: true,
9236 momentumBounceRatio: 1,
9237 momentumVelocityRatio: 1,
9238 sticky: false,
9239 minimumVelocity: 0.02
9240 }
9241 });
9242
9243 function onTouchStart() {
9244 const translate = swiper.getTranslate();
9245 swiper.setTranslate(translate);
9246 swiper.setTransition(0);
9247 swiper.touchEventsData.velocities.length = 0;
9248 swiper.freeMode.onTouchEnd({
9249 currentPos: swiper.rtl ? swiper.translate : -swiper.translate
9250 });
9251 }
9252
9253 function onTouchMove() {
9254 const {
9255 touchEventsData: data,
9256 touches
9257 } = swiper; // Velocity
9258
9259 if (data.velocities.length === 0) {
9260 data.velocities.push({
9261 position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
9262 time: data.touchStartTime
9263 });
9264 }
9265
9266 data.velocities.push({
9267 position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
9268 time: now()
9269 });
9270 }
9271
9272 function onTouchEnd(_ref2) {
9273 let {
9274 currentPos
9275 } = _ref2;
9276 const {
9277 params,
9278 $wrapperEl,
9279 rtlTranslate: rtl,
9280 snapGrid,
9281 touchEventsData: data
9282 } = swiper; // Time diff
9283
9284 const touchEndTime = now();
9285 const timeDiff = touchEndTime - data.touchStartTime;
9286
9287 if (currentPos < -swiper.minTranslate()) {
9288 swiper.slideTo(swiper.activeIndex);
9289 return;
9290 }
9291
9292 if (currentPos > -swiper.maxTranslate()) {
9293 if (swiper.slides.length < snapGrid.length) {
9294 swiper.slideTo(snapGrid.length - 1);
9295 } else {
9296 swiper.slideTo(swiper.slides.length - 1);
9297 }
9298
9299 return;
9300 }
9301
9302 if (params.freeMode.momentum) {
9303 if (data.velocities.length > 1) {
9304 const lastMoveEvent = data.velocities.pop();
9305 const velocityEvent = data.velocities.pop();
9306 const distance = lastMoveEvent.position - velocityEvent.position;
9307 const time = lastMoveEvent.time - velocityEvent.time;
9308 swiper.velocity = distance / time;
9309 swiper.velocity /= 2;
9310
9311 if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
9312 swiper.velocity = 0;
9313 } // this implies that the user stopped moving a finger then released.
9314 // There would be no events with distance zero, so the last event is stale.
9315
9316
9317 if (time > 150 || now() - lastMoveEvent.time > 300) {
9318 swiper.velocity = 0;
9319 }
9320 } else {
9321 swiper.velocity = 0;
9322 }
9323
9324 swiper.velocity *= params.freeMode.momentumVelocityRatio;
9325 data.velocities.length = 0;
9326 let momentumDuration = 1000 * params.freeMode.momentumRatio;
9327 const momentumDistance = swiper.velocity * momentumDuration;
9328 let newPosition = swiper.translate + momentumDistance;
9329 if (rtl) newPosition = -newPosition;
9330 let doBounce = false;
9331 let afterBouncePosition;
9332 const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
9333 let needsLoopFix;
9334
9335 if (newPosition < swiper.maxTranslate()) {
9336 if (params.freeMode.momentumBounce) {
9337 if (newPosition + swiper.maxTranslate() < -bounceAmount) {
9338 newPosition = swiper.maxTranslate() - bounceAmount;
9339 }
9340
9341 afterBouncePosition = swiper.maxTranslate();
9342 doBounce = true;
9343 data.allowMomentumBounce = true;
9344 } else {
9345 newPosition = swiper.maxTranslate();
9346 }
9347
9348 if (params.loop && params.centeredSlides) needsLoopFix = true;
9349 } else if (newPosition > swiper.minTranslate()) {
9350 if (params.freeMode.momentumBounce) {
9351 if (newPosition - swiper.minTranslate() > bounceAmount) {
9352 newPosition = swiper.minTranslate() + bounceAmount;
9353 }
9354
9355 afterBouncePosition = swiper.minTranslate();
9356 doBounce = true;
9357 data.allowMomentumBounce = true;
9358 } else {
9359 newPosition = swiper.minTranslate();
9360 }
9361
9362 if (params.loop && params.centeredSlides) needsLoopFix = true;
9363 } else if (params.freeMode.sticky) {
9364 let nextSlide;
9365
9366 for (let j = 0; j < snapGrid.length; j += 1) {
9367 if (snapGrid[j] > -newPosition) {
9368 nextSlide = j;
9369 break;
9370 }
9371 }
9372
9373 if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
9374 newPosition = snapGrid[nextSlide];
9375 } else {
9376 newPosition = snapGrid[nextSlide - 1];
9377 }
9378
9379 newPosition = -newPosition;
9380 }
9381
9382 if (needsLoopFix) {
9383 once('transitionEnd', () => {
9384 swiper.loopFix();
9385 });
9386 } // Fix duration
9387
9388
9389 if (swiper.velocity !== 0) {
9390 if (rtl) {
9391 momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
9392 } else {
9393 momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
9394 }
9395
9396 if (params.freeMode.sticky) {
9397 // If freeMode.sticky is active and the user ends a swipe with a slow-velocity
9398 // event, then durations can be 20+ seconds to slide one (or zero!) slides.
9399 // It's easy to see this when simulating touch with mouse events. To fix this,
9400 // limit single-slide swipes to the default slide duration. This also has the
9401 // nice side effect of matching slide speed if the user stopped moving before
9402 // lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
9403 // For faster swipes, also apply limits (albeit higher ones).
9404 const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
9405 const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
9406
9407 if (moveDistance < currentSlideSize) {
9408 momentumDuration = params.speed;
9409 } else if (moveDistance < 2 * currentSlideSize) {
9410 momentumDuration = params.speed * 1.5;
9411 } else {
9412 momentumDuration = params.speed * 2.5;
9413 }
9414 }
9415 } else if (params.freeMode.sticky) {
9416 swiper.slideToClosest();
9417 return;
9418 }
9419
9420 if (params.freeMode.momentumBounce && doBounce) {
9421 swiper.updateProgress(afterBouncePosition);
9422 swiper.setTransition(momentumDuration);
9423 swiper.setTranslate(newPosition);
9424 swiper.transitionStart(true, swiper.swipeDirection);
9425 swiper.animating = true;
9426 $wrapperEl.transitionEnd(() => {
9427 if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
9428 emit('momentumBounce');
9429 swiper.setTransition(params.speed);
9430 setTimeout(() => {
9431 swiper.setTranslate(afterBouncePosition);
9432 $wrapperEl.transitionEnd(() => {
9433 if (!swiper || swiper.destroyed) return;
9434 swiper.transitionEnd();
9435 });
9436 }, 0);
9437 });
9438 } else if (swiper.velocity) {
9439 emit('_freeModeNoMomentumRelease');
9440 swiper.updateProgress(newPosition);
9441 swiper.setTransition(momentumDuration);
9442 swiper.setTranslate(newPosition);
9443 swiper.transitionStart(true, swiper.swipeDirection);
9444
9445 if (!swiper.animating) {
9446 swiper.animating = true;
9447 $wrapperEl.transitionEnd(() => {
9448 if (!swiper || swiper.destroyed) return;
9449 swiper.transitionEnd();
9450 });
9451 }
9452 } else {
9453 swiper.updateProgress(newPosition);
9454 }
9455
9456 swiper.updateActiveIndex();
9457 swiper.updateSlidesClasses();
9458 } else if (params.freeMode.sticky) {
9459 swiper.slideToClosest();
9460 return;
9461 } else if (params.freeMode) {
9462 emit('_freeModeNoMomentumRelease');
9463 }
9464
9465 if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
9466 swiper.updateProgress();
9467 swiper.updateActiveIndex();
9468 swiper.updateSlidesClasses();
9469 }
9470 }
9471
9472 Object.assign(swiper, {
9473 freeMode: {
9474 onTouchStart,
9475 onTouchMove,
9476 onTouchEnd
9477 }
9478 });
9479}
9480
9481function Grid(_ref) {
9482 let {
9483 swiper,
9484 extendParams
9485 } = _ref;
9486 extendParams({
9487 grid: {
9488 rows: 1,
9489 fill: 'column'
9490 }
9491 });
9492 let slidesNumberEvenToRows;
9493 let slidesPerRow;
9494 let numFullColumns;
9495
9496 const initSlides = slidesLength => {
9497 const {
9498 slidesPerView
9499 } = swiper.params;
9500 const {
9501 rows,
9502 fill
9503 } = swiper.params.grid;
9504 slidesPerRow = slidesNumberEvenToRows / rows;
9505 numFullColumns = Math.floor(slidesLength / rows);
9506
9507 if (Math.floor(slidesLength / rows) === slidesLength / rows) {
9508 slidesNumberEvenToRows = slidesLength;
9509 } else {
9510 slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
9511 }
9512
9513 if (slidesPerView !== 'auto' && fill === 'row') {
9514 slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
9515 }
9516 };
9517
9518 const updateSlide = (i, slide, slidesLength, getDirectionLabel) => {
9519 const {
9520 slidesPerGroup,
9521 spaceBetween
9522 } = swiper.params;
9523 const {
9524 rows,
9525 fill
9526 } = swiper.params.grid; // Set slides order
9527
9528 let newSlideOrderIndex;
9529 let column;
9530 let row;
9531
9532 if (fill === 'row' && slidesPerGroup > 1) {
9533 const groupIndex = Math.floor(i / (slidesPerGroup * rows));
9534 const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
9535 const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
9536 row = Math.floor(slideIndexInGroup / columnsInGroup);
9537 column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
9538 newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
9539 slide.css({
9540 '-webkit-order': newSlideOrderIndex,
9541 order: newSlideOrderIndex
9542 });
9543 } else if (fill === 'column') {
9544 column = Math.floor(i / rows);
9545 row = i - column * rows;
9546
9547 if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
9548 row += 1;
9549
9550 if (row >= rows) {
9551 row = 0;
9552 column += 1;
9553 }
9554 }
9555 } else {
9556 row = Math.floor(i / slidesPerRow);
9557 column = i - row * slidesPerRow;
9558 }
9559
9560 slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : '');
9561 };
9562
9563 const updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => {
9564 const {
9565 spaceBetween,
9566 centeredSlides,
9567 roundLengths
9568 } = swiper.params;
9569 const {
9570 rows
9571 } = swiper.params.grid;
9572 swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
9573 swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
9574 swiper.$wrapperEl.css({
9575 [getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px`
9576 });
9577
9578 if (centeredSlides) {
9579 snapGrid.splice(0, snapGrid.length);
9580 const newSlidesGrid = [];
9581
9582 for (let i = 0; i < snapGrid.length; i += 1) {
9583 let slidesGridItem = snapGrid[i];
9584 if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
9585 if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
9586 }
9587
9588 snapGrid.push(...newSlidesGrid);
9589 }
9590 };
9591
9592 swiper.grid = {
9593 initSlides,
9594 updateSlide,
9595 updateWrapperSize
9596 };
9597}
9598
9599function appendSlide(slides) {
9600 const swiper = this;
9601 const {
9602 $wrapperEl,
9603 params
9604 } = swiper;
9605
9606 if (params.loop) {
9607 swiper.loopDestroy();
9608 }
9609
9610 if (typeof slides === 'object' && 'length' in slides) {
9611 for (let i = 0; i < slides.length; i += 1) {
9612 if (slides[i]) $wrapperEl.append(slides[i]);
9613 }
9614 } else {
9615 $wrapperEl.append(slides);
9616 }
9617
9618 if (params.loop) {
9619 swiper.loopCreate();
9620 }
9621
9622 if (!params.observer) {
9623 swiper.update();
9624 }
9625}
9626
9627function prependSlide(slides) {
9628 const swiper = this;
9629 const {
9630 params,
9631 $wrapperEl,
9632 activeIndex
9633 } = swiper;
9634
9635 if (params.loop) {
9636 swiper.loopDestroy();
9637 }
9638
9639 let newActiveIndex = activeIndex + 1;
9640
9641 if (typeof slides === 'object' && 'length' in slides) {
9642 for (let i = 0; i < slides.length; i += 1) {
9643 if (slides[i]) $wrapperEl.prepend(slides[i]);
9644 }
9645
9646 newActiveIndex = activeIndex + slides.length;
9647 } else {
9648 $wrapperEl.prepend(slides);
9649 }
9650
9651 if (params.loop) {
9652 swiper.loopCreate();
9653 }
9654
9655 if (!params.observer) {
9656 swiper.update();
9657 }
9658
9659 swiper.slideTo(newActiveIndex, 0, false);
9660}
9661
9662function addSlide(index, slides) {
9663 const swiper = this;
9664 const {
9665 $wrapperEl,
9666 params,
9667 activeIndex
9668 } = swiper;
9669 let activeIndexBuffer = activeIndex;
9670
9671 if (params.loop) {
9672 activeIndexBuffer -= swiper.loopedSlides;
9673 swiper.loopDestroy();
9674 swiper.slides = $wrapperEl.children(`.${params.slideClass}`);
9675 }
9676
9677 const baseLength = swiper.slides.length;
9678
9679 if (index <= 0) {
9680 swiper.prependSlide(slides);
9681 return;
9682 }
9683
9684 if (index >= baseLength) {
9685 swiper.appendSlide(slides);
9686 return;
9687 }
9688
9689 let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
9690 const slidesBuffer = [];
9691
9692 for (let i = baseLength - 1; i >= index; i -= 1) {
9693 const currentSlide = swiper.slides.eq(i);
9694 currentSlide.remove();
9695 slidesBuffer.unshift(currentSlide);
9696 }
9697
9698 if (typeof slides === 'object' && 'length' in slides) {
9699 for (let i = 0; i < slides.length; i += 1) {
9700 if (slides[i]) $wrapperEl.append(slides[i]);
9701 }
9702
9703 newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
9704 } else {
9705 $wrapperEl.append(slides);
9706 }
9707
9708 for (let i = 0; i < slidesBuffer.length; i += 1) {
9709 $wrapperEl.append(slidesBuffer[i]);
9710 }
9711
9712 if (params.loop) {
9713 swiper.loopCreate();
9714 }
9715
9716 if (!params.observer) {
9717 swiper.update();
9718 }
9719
9720 if (params.loop) {
9721 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
9722 } else {
9723 swiper.slideTo(newActiveIndex, 0, false);
9724 }
9725}
9726
9727function removeSlide(slidesIndexes) {
9728 const swiper = this;
9729 const {
9730 params,
9731 $wrapperEl,
9732 activeIndex
9733 } = swiper;
9734 let activeIndexBuffer = activeIndex;
9735
9736 if (params.loop) {
9737 activeIndexBuffer -= swiper.loopedSlides;
9738 swiper.loopDestroy();
9739 swiper.slides = $wrapperEl.children(`.${params.slideClass}`);
9740 }
9741
9742 let newActiveIndex = activeIndexBuffer;
9743 let indexToRemove;
9744
9745 if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
9746 for (let i = 0; i < slidesIndexes.length; i += 1) {
9747 indexToRemove = slidesIndexes[i];
9748 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
9749 if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
9750 }
9751
9752 newActiveIndex = Math.max(newActiveIndex, 0);
9753 } else {
9754 indexToRemove = slidesIndexes;
9755 if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
9756 if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
9757 newActiveIndex = Math.max(newActiveIndex, 0);
9758 }
9759
9760 if (params.loop) {
9761 swiper.loopCreate();
9762 }
9763
9764 if (!params.observer) {
9765 swiper.update();
9766 }
9767
9768 if (params.loop) {
9769 swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
9770 } else {
9771 swiper.slideTo(newActiveIndex, 0, false);
9772 }
9773}
9774
9775function removeAllSlides() {
9776 const swiper = this;
9777 const slidesIndexes = [];
9778
9779 for (let i = 0; i < swiper.slides.length; i += 1) {
9780 slidesIndexes.push(i);
9781 }
9782
9783 swiper.removeSlide(slidesIndexes);
9784}
9785
9786function Manipulation(_ref) {
9787 let {
9788 swiper
9789 } = _ref;
9790 Object.assign(swiper, {
9791 appendSlide: appendSlide.bind(swiper),
9792 prependSlide: prependSlide.bind(swiper),
9793 addSlide: addSlide.bind(swiper),
9794 removeSlide: removeSlide.bind(swiper),
9795 removeAllSlides: removeAllSlides.bind(swiper)
9796 });
9797}
9798
9799function effectInit(params) {
9800 const {
9801 effect,
9802 swiper,
9803 on,
9804 setTranslate,
9805 setTransition,
9806 overwriteParams,
9807 perspective,
9808 recreateShadows,
9809 getEffectParams
9810 } = params;
9811 on('beforeInit', () => {
9812 if (swiper.params.effect !== effect) return;
9813 swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
9814
9815 if (perspective && perspective()) {
9816 swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
9817 }
9818
9819 const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
9820 Object.assign(swiper.params, overwriteParamsResult);
9821 Object.assign(swiper.originalParams, overwriteParamsResult);
9822 });
9823 on('setTranslate', () => {
9824 if (swiper.params.effect !== effect) return;
9825 setTranslate();
9826 });
9827 on('setTransition', (_s, duration) => {
9828 if (swiper.params.effect !== effect) return;
9829 setTransition(duration);
9830 });
9831 on('transitionEnd', () => {
9832 if (swiper.params.effect !== effect) return;
9833
9834 if (recreateShadows) {
9835 if (!getEffectParams || !getEffectParams().slideShadows) return; // remove shadows
9836
9837 swiper.slides.each(slideEl => {
9838 const $slideEl = swiper.$(slideEl);
9839 $slideEl.find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').remove();
9840 }); // create new one
9841
9842 recreateShadows();
9843 }
9844 });
9845 let requireUpdateOnVirtual;
9846 on('virtualUpdate', () => {
9847 if (swiper.params.effect !== effect) return;
9848
9849 if (!swiper.slides.length) {
9850 requireUpdateOnVirtual = true;
9851 }
9852
9853 requestAnimationFrame(() => {
9854 if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
9855 setTranslate();
9856 requireUpdateOnVirtual = false;
9857 }
9858 });
9859 });
9860}
9861
9862function effectTarget(effectParams, $slideEl) {
9863 if (effectParams.transformEl) {
9864 return $slideEl.find(effectParams.transformEl).css({
9865 'backface-visibility': 'hidden',
9866 '-webkit-backface-visibility': 'hidden'
9867 });
9868 }
9869
9870 return $slideEl;
9871}
9872
9873function effectVirtualTransitionEnd(_ref) {
9874 let {
9875 swiper,
9876 duration,
9877 transformEl,
9878 allSlides
9879 } = _ref;
9880 const {
9881 slides,
9882 activeIndex,
9883 $wrapperEl
9884 } = swiper;
9885
9886 if (swiper.params.virtualTranslate && duration !== 0) {
9887 let eventTriggered = false;
9888 let $transitionEndTarget;
9889
9890 if (allSlides) {
9891 $transitionEndTarget = transformEl ? slides.find(transformEl) : slides;
9892 } else {
9893 $transitionEndTarget = transformEl ? slides.eq(activeIndex).find(transformEl) : slides.eq(activeIndex);
9894 }
9895
9896 $transitionEndTarget.transitionEnd(() => {
9897 if (eventTriggered) return;
9898 if (!swiper || swiper.destroyed) return;
9899 eventTriggered = true;
9900 swiper.animating = false;
9901 const triggerEvents = ['webkitTransitionEnd', 'transitionend'];
9902
9903 for (let i = 0; i < triggerEvents.length; i += 1) {
9904 $wrapperEl.trigger(triggerEvents[i]);
9905 }
9906 });
9907 }
9908}
9909
9910function EffectFade(_ref) {
9911 let {
9912 swiper,
9913 extendParams,
9914 on
9915 } = _ref;
9916 extendParams({
9917 fadeEffect: {
9918 crossFade: false,
9919 transformEl: null
9920 }
9921 });
9922
9923 const setTranslate = () => {
9924 const {
9925 slides
9926 } = swiper;
9927 const params = swiper.params.fadeEffect;
9928
9929 for (let i = 0; i < slides.length; i += 1) {
9930 const $slideEl = swiper.slides.eq(i);
9931 const offset = $slideEl[0].swiperSlideOffset;
9932 let tx = -offset;
9933 if (!swiper.params.virtualTranslate) tx -= swiper.translate;
9934 let ty = 0;
9935
9936 if (!swiper.isHorizontal()) {
9937 ty = tx;
9938 tx = 0;
9939 }
9940
9941 const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
9942 const $targetEl = effectTarget(params, $slideEl);
9943 $targetEl.css({
9944 opacity: slideOpacity
9945 }).transform(`translate3d(${tx}px, ${ty}px, 0px)`);
9946 }
9947 };
9948
9949 const setTransition = duration => {
9950 const {
9951 transformEl
9952 } = swiper.params.fadeEffect;
9953 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
9954 $transitionElements.transition(duration);
9955 effectVirtualTransitionEnd({
9956 swiper,
9957 duration,
9958 transformEl,
9959 allSlides: true
9960 });
9961 };
9962
9963 effectInit({
9964 effect: 'fade',
9965 swiper,
9966 on,
9967 setTranslate,
9968 setTransition,
9969 overwriteParams: () => ({
9970 slidesPerView: 1,
9971 slidesPerGroup: 1,
9972 watchSlidesProgress: true,
9973 spaceBetween: 0,
9974 virtualTranslate: !swiper.params.cssMode
9975 })
9976 });
9977}
9978
9979function EffectCube(_ref) {
9980 let {
9981 swiper,
9982 extendParams,
9983 on
9984 } = _ref;
9985 extendParams({
9986 cubeEffect: {
9987 slideShadows: true,
9988 shadow: true,
9989 shadowOffset: 20,
9990 shadowScale: 0.94
9991 }
9992 });
9993
9994 const createSlideShadows = ($slideEl, progress, isHorizontal) => {
9995 let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
9996 let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
9997
9998 if (shadowBefore.length === 0) {
9999 shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`);
10000 $slideEl.append(shadowBefore);
10001 }
10002
10003 if (shadowAfter.length === 0) {
10004 shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`);
10005 $slideEl.append(shadowAfter);
10006 }
10007
10008 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
10009 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
10010 };
10011
10012 const recreateShadows = () => {
10013 // create new ones
10014 const isHorizontal = swiper.isHorizontal();
10015 swiper.slides.each(slideEl => {
10016 const progress = Math.max(Math.min(slideEl.progress, 1), -1);
10017 createSlideShadows($(slideEl), progress, isHorizontal);
10018 });
10019 };
10020
10021 const setTranslate = () => {
10022 const {
10023 $el,
10024 $wrapperEl,
10025 slides,
10026 width: swiperWidth,
10027 height: swiperHeight,
10028 rtlTranslate: rtl,
10029 size: swiperSize,
10030 browser
10031 } = swiper;
10032 const params = swiper.params.cubeEffect;
10033 const isHorizontal = swiper.isHorizontal();
10034 const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
10035 let wrapperRotate = 0;
10036 let $cubeShadowEl;
10037
10038 if (params.shadow) {
10039 if (isHorizontal) {
10040 $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
10041
10042 if ($cubeShadowEl.length === 0) {
10043 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
10044 $wrapperEl.append($cubeShadowEl);
10045 }
10046
10047 $cubeShadowEl.css({
10048 height: `${swiperWidth}px`
10049 });
10050 } else {
10051 $cubeShadowEl = $el.find('.swiper-cube-shadow');
10052
10053 if ($cubeShadowEl.length === 0) {
10054 $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
10055 $el.append($cubeShadowEl);
10056 }
10057 }
10058 }
10059
10060 for (let i = 0; i < slides.length; i += 1) {
10061 const $slideEl = slides.eq(i);
10062 let slideIndex = i;
10063
10064 if (isVirtual) {
10065 slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
10066 }
10067
10068 let slideAngle = slideIndex * 90;
10069 let round = Math.floor(slideAngle / 360);
10070
10071 if (rtl) {
10072 slideAngle = -slideAngle;
10073 round = Math.floor(-slideAngle / 360);
10074 }
10075
10076 const progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
10077 let tx = 0;
10078 let ty = 0;
10079 let tz = 0;
10080
10081 if (slideIndex % 4 === 0) {
10082 tx = -round * 4 * swiperSize;
10083 tz = 0;
10084 } else if ((slideIndex - 1) % 4 === 0) {
10085 tx = 0;
10086 tz = -round * 4 * swiperSize;
10087 } else if ((slideIndex - 2) % 4 === 0) {
10088 tx = swiperSize + round * 4 * swiperSize;
10089 tz = swiperSize;
10090 } else if ((slideIndex - 3) % 4 === 0) {
10091 tx = -swiperSize;
10092 tz = 3 * swiperSize + swiperSize * 4 * round;
10093 }
10094
10095 if (rtl) {
10096 tx = -tx;
10097 }
10098
10099 if (!isHorizontal) {
10100 ty = tx;
10101 tx = 0;
10102 }
10103
10104 const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
10105
10106 if (progress <= 1 && progress > -1) {
10107 wrapperRotate = slideIndex * 90 + progress * 90;
10108 if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
10109 }
10110
10111 $slideEl.transform(transform);
10112
10113 if (params.slideShadows) {
10114 createSlideShadows($slideEl, progress, isHorizontal);
10115 }
10116 }
10117
10118 $wrapperEl.css({
10119 '-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`,
10120 'transform-origin': `50% 50% -${swiperSize / 2}px`
10121 });
10122
10123 if (params.shadow) {
10124 if (isHorizontal) {
10125 $cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`);
10126 } else {
10127 const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
10128 const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
10129 const scale1 = params.shadowScale;
10130 const scale2 = params.shadowScale / multiplier;
10131 const offset = params.shadowOffset;
10132 $cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`);
10133 }
10134 }
10135
10136 const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0;
10137 $wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`);
10138 $wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
10139 };
10140
10141 const setTransition = duration => {
10142 const {
10143 $el,
10144 slides
10145 } = swiper;
10146 slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
10147
10148 if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
10149 $el.find('.swiper-cube-shadow').transition(duration);
10150 }
10151 };
10152
10153 effectInit({
10154 effect: 'cube',
10155 swiper,
10156 on,
10157 setTranslate,
10158 setTransition,
10159 recreateShadows,
10160 getEffectParams: () => swiper.params.cubeEffect,
10161 perspective: () => true,
10162 overwriteParams: () => ({
10163 slidesPerView: 1,
10164 slidesPerGroup: 1,
10165 watchSlidesProgress: true,
10166 resistanceRatio: 0,
10167 spaceBetween: 0,
10168 centeredSlides: false,
10169 virtualTranslate: true
10170 })
10171 });
10172}
10173
10174function createShadow(params, $slideEl, side) {
10175 const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}`;
10176 const $shadowContainer = params.transformEl ? $slideEl.find(params.transformEl) : $slideEl;
10177 let $shadowEl = $shadowContainer.children(`.${shadowClass}`);
10178
10179 if (!$shadowEl.length) {
10180 $shadowEl = $(`<div class="swiper-slide-shadow${side ? `-${side}` : ''}"></div>`);
10181 $shadowContainer.append($shadowEl);
10182 }
10183
10184 return $shadowEl;
10185}
10186
10187function EffectFlip(_ref) {
10188 let {
10189 swiper,
10190 extendParams,
10191 on
10192 } = _ref;
10193 extendParams({
10194 flipEffect: {
10195 slideShadows: true,
10196 limitRotation: true,
10197 transformEl: null
10198 }
10199 });
10200
10201 const createSlideShadows = ($slideEl, progress, params) => {
10202 let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
10203 let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
10204
10205 if (shadowBefore.length === 0) {
10206 shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top');
10207 }
10208
10209 if (shadowAfter.length === 0) {
10210 shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
10211 }
10212
10213 if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
10214 if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
10215 };
10216
10217 const recreateShadows = () => {
10218 // Set shadows
10219 const params = swiper.params.flipEffect;
10220 swiper.slides.each(slideEl => {
10221 const $slideEl = $(slideEl);
10222 let progress = $slideEl[0].progress;
10223
10224 if (swiper.params.flipEffect.limitRotation) {
10225 progress = Math.max(Math.min(slideEl.progress, 1), -1);
10226 }
10227
10228 createSlideShadows($slideEl, progress, params);
10229 });
10230 };
10231
10232 const setTranslate = () => {
10233 const {
10234 slides,
10235 rtlTranslate: rtl
10236 } = swiper;
10237 const params = swiper.params.flipEffect;
10238
10239 for (let i = 0; i < slides.length; i += 1) {
10240 const $slideEl = slides.eq(i);
10241 let progress = $slideEl[0].progress;
10242
10243 if (swiper.params.flipEffect.limitRotation) {
10244 progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
10245 }
10246
10247 const offset = $slideEl[0].swiperSlideOffset;
10248 const rotate = -180 * progress;
10249 let rotateY = rotate;
10250 let rotateX = 0;
10251 let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
10252 let ty = 0;
10253
10254 if (!swiper.isHorizontal()) {
10255 ty = tx;
10256 tx = 0;
10257 rotateX = -rotateY;
10258 rotateY = 0;
10259 } else if (rtl) {
10260 rotateY = -rotateY;
10261 }
10262
10263 $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
10264
10265 if (params.slideShadows) {
10266 createSlideShadows($slideEl, progress, params);
10267 }
10268
10269 const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
10270 const $targetEl = effectTarget(params, $slideEl);
10271 $targetEl.transform(transform);
10272 }
10273 };
10274
10275 const setTransition = duration => {
10276 const {
10277 transformEl
10278 } = swiper.params.flipEffect;
10279 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
10280 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
10281 effectVirtualTransitionEnd({
10282 swiper,
10283 duration,
10284 transformEl
10285 });
10286 };
10287
10288 effectInit({
10289 effect: 'flip',
10290 swiper,
10291 on,
10292 setTranslate,
10293 setTransition,
10294 recreateShadows,
10295 getEffectParams: () => swiper.params.flipEffect,
10296 perspective: () => true,
10297 overwriteParams: () => ({
10298 slidesPerView: 1,
10299 slidesPerGroup: 1,
10300 watchSlidesProgress: true,
10301 spaceBetween: 0,
10302 virtualTranslate: !swiper.params.cssMode
10303 })
10304 });
10305}
10306
10307function EffectCoverflow(_ref) {
10308 let {
10309 swiper,
10310 extendParams,
10311 on
10312 } = _ref;
10313 extendParams({
10314 coverflowEffect: {
10315 rotate: 50,
10316 stretch: 0,
10317 depth: 100,
10318 scale: 1,
10319 modifier: 1,
10320 slideShadows: true,
10321 transformEl: null
10322 }
10323 });
10324
10325 const setTranslate = () => {
10326 const {
10327 width: swiperWidth,
10328 height: swiperHeight,
10329 slides,
10330 slidesSizesGrid
10331 } = swiper;
10332 const params = swiper.params.coverflowEffect;
10333 const isHorizontal = swiper.isHorizontal();
10334 const transform = swiper.translate;
10335 const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
10336 const rotate = isHorizontal ? params.rotate : -params.rotate;
10337 const translate = params.depth; // Each slide offset from center
10338
10339 for (let i = 0, length = slides.length; i < length; i += 1) {
10340 const $slideEl = slides.eq(i);
10341 const slideSize = slidesSizesGrid[i];
10342 const slideOffset = $slideEl[0].swiperSlideOffset;
10343 const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
10344 const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
10345 let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
10346 let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0
10347
10348 let translateZ = -translate * Math.abs(offsetMultiplier);
10349 let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders
10350
10351 if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
10352 stretch = parseFloat(params.stretch) / 100 * slideSize;
10353 }
10354
10355 let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
10356 let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
10357 let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values
10358
10359 if (Math.abs(translateX) < 0.001) translateX = 0;
10360 if (Math.abs(translateY) < 0.001) translateY = 0;
10361 if (Math.abs(translateZ) < 0.001) translateZ = 0;
10362 if (Math.abs(rotateY) < 0.001) rotateY = 0;
10363 if (Math.abs(rotateX) < 0.001) rotateX = 0;
10364 if (Math.abs(scale) < 0.001) scale = 0;
10365 const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`;
10366 const $targetEl = effectTarget(params, $slideEl);
10367 $targetEl.transform(slideTransform);
10368 $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
10369
10370 if (params.slideShadows) {
10371 // Set shadows
10372 let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
10373 let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
10374
10375 if ($shadowBeforeEl.length === 0) {
10376 $shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top');
10377 }
10378
10379 if ($shadowAfterEl.length === 0) {
10380 $shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom');
10381 }
10382
10383 if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
10384 if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
10385 }
10386 }
10387 };
10388
10389 const setTransition = duration => {
10390 const {
10391 transformEl
10392 } = swiper.params.coverflowEffect;
10393 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
10394 $transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
10395 };
10396
10397 effectInit({
10398 effect: 'coverflow',
10399 swiper,
10400 on,
10401 setTranslate,
10402 setTransition,
10403 perspective: () => true,
10404 overwriteParams: () => ({
10405 watchSlidesProgress: true
10406 })
10407 });
10408}
10409
10410function EffectCreative(_ref) {
10411 let {
10412 swiper,
10413 extendParams,
10414 on
10415 } = _ref;
10416 extendParams({
10417 creativeEffect: {
10418 transformEl: null,
10419 limitProgress: 1,
10420 shadowPerProgress: false,
10421 progressMultiplier: 1,
10422 perspective: true,
10423 prev: {
10424 translate: [0, 0, 0],
10425 rotate: [0, 0, 0],
10426 opacity: 1,
10427 scale: 1
10428 },
10429 next: {
10430 translate: [0, 0, 0],
10431 rotate: [0, 0, 0],
10432 opacity: 1,
10433 scale: 1
10434 }
10435 }
10436 });
10437
10438 const getTranslateValue = value => {
10439 if (typeof value === 'string') return value;
10440 return `${value}px`;
10441 };
10442
10443 const setTranslate = () => {
10444 const {
10445 slides,
10446 $wrapperEl,
10447 slidesSizesGrid
10448 } = swiper;
10449 const params = swiper.params.creativeEffect;
10450 const {
10451 progressMultiplier: multiplier
10452 } = params;
10453 const isCenteredSlides = swiper.params.centeredSlides;
10454
10455 if (isCenteredSlides) {
10456 const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
10457 $wrapperEl.transform(`translateX(calc(50% - ${margin}px))`);
10458 }
10459
10460 for (let i = 0; i < slides.length; i += 1) {
10461 const $slideEl = slides.eq(i);
10462 const slideProgress = $slideEl[0].progress;
10463 const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress);
10464 let originalProgress = progress;
10465
10466 if (!isCenteredSlides) {
10467 originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress);
10468 }
10469
10470 const offset = $slideEl[0].swiperSlideOffset;
10471 const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
10472 const r = [0, 0, 0];
10473 let custom = false;
10474
10475 if (!swiper.isHorizontal()) {
10476 t[1] = t[0];
10477 t[0] = 0;
10478 }
10479
10480 let data = {
10481 translate: [0, 0, 0],
10482 rotate: [0, 0, 0],
10483 scale: 1,
10484 opacity: 1
10485 };
10486
10487 if (progress < 0) {
10488 data = params.next;
10489 custom = true;
10490 } else if (progress > 0) {
10491 data = params.prev;
10492 custom = true;
10493 } // set translate
10494
10495
10496 t.forEach((value, index) => {
10497 t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
10498 }); // set rotates
10499
10500 r.forEach((value, index) => {
10501 r[index] = data.rotate[index] * Math.abs(progress * multiplier);
10502 });
10503 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
10504 const translateString = t.join(', ');
10505 const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
10506 const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
10507 const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
10508 const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows
10509
10510 if (custom && data.shadow || !custom) {
10511 let $shadowEl = $slideEl.children('.swiper-slide-shadow');
10512
10513 if ($shadowEl.length === 0 && data.shadow) {
10514 $shadowEl = createShadow(params, $slideEl);
10515 }
10516
10517 if ($shadowEl.length) {
10518 const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
10519 $shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
10520 }
10521 }
10522
10523 const $targetEl = effectTarget(params, $slideEl);
10524 $targetEl.transform(transform).css({
10525 opacity: opacityString
10526 });
10527
10528 if (data.origin) {
10529 $targetEl.css('transform-origin', data.origin);
10530 }
10531 }
10532 };
10533
10534 const setTransition = duration => {
10535 const {
10536 transformEl
10537 } = swiper.params.creativeEffect;
10538 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
10539 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
10540 effectVirtualTransitionEnd({
10541 swiper,
10542 duration,
10543 transformEl,
10544 allSlides: true
10545 });
10546 };
10547
10548 effectInit({
10549 effect: 'creative',
10550 swiper,
10551 on,
10552 setTranslate,
10553 setTransition,
10554 perspective: () => swiper.params.creativeEffect.perspective,
10555 overwriteParams: () => ({
10556 watchSlidesProgress: true,
10557 virtualTranslate: !swiper.params.cssMode
10558 })
10559 });
10560}
10561
10562function EffectCards(_ref) {
10563 let {
10564 swiper,
10565 extendParams,
10566 on
10567 } = _ref;
10568 extendParams({
10569 cardsEffect: {
10570 slideShadows: true,
10571 transformEl: null,
10572 rotate: true,
10573 perSlideRotate: 2,
10574 perSlideOffset: 8
10575 }
10576 });
10577
10578 const setTranslate = () => {
10579 const {
10580 slides,
10581 activeIndex
10582 } = swiper;
10583 const params = swiper.params.cardsEffect;
10584 const {
10585 startTranslate,
10586 isTouched
10587 } = swiper.touchEventsData;
10588 const currentTranslate = swiper.translate;
10589
10590 for (let i = 0; i < slides.length; i += 1) {
10591 const $slideEl = slides.eq(i);
10592 const slideProgress = $slideEl[0].progress;
10593 const progress = Math.min(Math.max(slideProgress, -4), 4);
10594 let offset = $slideEl[0].swiperSlideOffset;
10595
10596 if (swiper.params.centeredSlides && !swiper.params.cssMode) {
10597 swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`);
10598 }
10599
10600 if (swiper.params.centeredSlides && swiper.params.cssMode) {
10601 offset -= slides[0].swiperSlideOffset;
10602 }
10603
10604 let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
10605 let tY = 0;
10606 const tZ = -100 * Math.abs(progress);
10607 let scale = 1;
10608 let rotate = -params.perSlideRotate * progress;
10609 let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
10610 const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
10611 const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
10612 const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
10613
10614 if (isSwipeToNext || isSwipeToPrev) {
10615 const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
10616 rotate += -28 * progress * subProgress;
10617 scale += -0.5 * subProgress;
10618 tXAdd += 96 * subProgress;
10619 tY = `${-25 * subProgress * Math.abs(progress)}%`;
10620 }
10621
10622 if (progress < 0) {
10623 // next
10624 tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
10625 } else if (progress > 0) {
10626 // prev
10627 tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`;
10628 } else {
10629 tX = `${tX}px`;
10630 }
10631
10632 if (!swiper.isHorizontal()) {
10633 const prevY = tY;
10634 tY = tX;
10635 tX = prevY;
10636 }
10637
10638 const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
10639 const transform = `
10640 translate3d(${tX}, ${tY}, ${tZ}px)
10641 rotateZ(${params.rotate ? rotate : 0}deg)
10642 scale(${scaleString})
10643 `;
10644
10645 if (params.slideShadows) {
10646 // Set shadows
10647 let $shadowEl = $slideEl.find('.swiper-slide-shadow');
10648
10649 if ($shadowEl.length === 0) {
10650 $shadowEl = createShadow(params, $slideEl);
10651 }
10652
10653 if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
10654 }
10655
10656 $slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
10657 const $targetEl = effectTarget(params, $slideEl);
10658 $targetEl.transform(transform);
10659 }
10660 };
10661
10662 const setTransition = duration => {
10663 const {
10664 transformEl
10665 } = swiper.params.cardsEffect;
10666 const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
10667 $transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
10668 effectVirtualTransitionEnd({
10669 swiper,
10670 duration,
10671 transformEl
10672 });
10673 };
10674
10675 effectInit({
10676 effect: 'cards',
10677 swiper,
10678 on,
10679 setTranslate,
10680 setTransition,
10681 perspective: () => true,
10682 overwriteParams: () => ({
10683 watchSlidesProgress: true,
10684 virtualTranslate: !swiper.params.cssMode
10685 })
10686 });
10687}
10688
10689// Swiper Class
10690const modules = [Virtual, Keyboard, Mousewheel, Navigation, Pagination, Scrollbar, Parallax, Zoom, Lazy, Controller, A11y, History, HashNavigation, Autoplay, Thumb, freeMode, Grid, Manipulation, EffectFade, EffectCube, EffectFlip, EffectCoverflow, EffectCreative, EffectCards];
10691Swiper.use(modules);
10692
10693export { Swiper, Swiper as default };
10694//# sourceMappingURL=swiper-bundle.esm.browser.js.map