UNPKG

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