UNPKG

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