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