UNPKG

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