1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | (function () {
|
14 | 'use strict';
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | function isObject$2(obj) {
|
29 | return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
|
30 | }
|
31 | function extend$2(target, src) {
|
32 | if (target === void 0) {
|
33 | target = {};
|
34 | }
|
35 | if (src === void 0) {
|
36 | src = {};
|
37 | }
|
38 | Object.keys(src).forEach(key => {
|
39 | if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$2(src[key]) && isObject$2(target[key]) && Object.keys(src[key]).length > 0) {
|
40 | extend$2(target[key], src[key]);
|
41 | }
|
42 | });
|
43 | }
|
44 | const ssrDocument = {
|
45 | body: {},
|
46 | addEventListener() {},
|
47 | removeEventListener() {},
|
48 | activeElement: {
|
49 | blur() {},
|
50 | nodeName: ''
|
51 | },
|
52 | querySelector() {
|
53 | return null;
|
54 | },
|
55 | querySelectorAll() {
|
56 | return [];
|
57 | },
|
58 | getElementById() {
|
59 | return null;
|
60 | },
|
61 | createEvent() {
|
62 | return {
|
63 | initEvent() {}
|
64 | };
|
65 | },
|
66 | createElement() {
|
67 | return {
|
68 | children: [],
|
69 | childNodes: [],
|
70 | style: {},
|
71 | setAttribute() {},
|
72 | getElementsByTagName() {
|
73 | return [];
|
74 | }
|
75 | };
|
76 | },
|
77 | createElementNS() {
|
78 | return {};
|
79 | },
|
80 | importNode() {
|
81 | return null;
|
82 | },
|
83 | location: {
|
84 | hash: '',
|
85 | host: '',
|
86 | hostname: '',
|
87 | href: '',
|
88 | origin: '',
|
89 | pathname: '',
|
90 | protocol: '',
|
91 | search: ''
|
92 | }
|
93 | };
|
94 | function getDocument() {
|
95 | const doc = typeof document !== 'undefined' ? document : {};
|
96 | extend$2(doc, ssrDocument);
|
97 | return doc;
|
98 | }
|
99 | const ssrWindow = {
|
100 | document: ssrDocument,
|
101 | navigator: {
|
102 | userAgent: ''
|
103 | },
|
104 | location: {
|
105 | hash: '',
|
106 | host: '',
|
107 | hostname: '',
|
108 | href: '',
|
109 | origin: '',
|
110 | pathname: '',
|
111 | protocol: '',
|
112 | search: ''
|
113 | },
|
114 | history: {
|
115 | replaceState() {},
|
116 | pushState() {},
|
117 | go() {},
|
118 | back() {}
|
119 | },
|
120 | CustomEvent: function CustomEvent() {
|
121 | return this;
|
122 | },
|
123 | addEventListener() {},
|
124 | removeEventListener() {},
|
125 | getComputedStyle() {
|
126 | return {
|
127 | getPropertyValue() {
|
128 | return '';
|
129 | }
|
130 | };
|
131 | },
|
132 | Image() {},
|
133 | Date() {},
|
134 | screen: {},
|
135 | setTimeout() {},
|
136 | clearTimeout() {},
|
137 | matchMedia() {
|
138 | return {};
|
139 | },
|
140 | requestAnimationFrame(callback) {
|
141 | if (typeof setTimeout === 'undefined') {
|
142 | callback();
|
143 | return null;
|
144 | }
|
145 | return setTimeout(callback, 0);
|
146 | },
|
147 | cancelAnimationFrame(id) {
|
148 | if (typeof setTimeout === 'undefined') {
|
149 | return;
|
150 | }
|
151 | clearTimeout(id);
|
152 | }
|
153 | };
|
154 | function getWindow() {
|
155 | const win = typeof window !== 'undefined' ? window : {};
|
156 | extend$2(win, ssrWindow);
|
157 | return win;
|
158 | }
|
159 |
|
160 | function deleteProps(obj) {
|
161 | const object = obj;
|
162 | Object.keys(object).forEach(key => {
|
163 | try {
|
164 | object[key] = null;
|
165 | } catch (e) {
|
166 |
|
167 | }
|
168 | try {
|
169 | delete object[key];
|
170 | } catch (e) {
|
171 |
|
172 | }
|
173 | });
|
174 | }
|
175 | function nextTick(callback, delay) {
|
176 | if (delay === void 0) {
|
177 | delay = 0;
|
178 | }
|
179 | return setTimeout(callback, delay);
|
180 | }
|
181 | function now() {
|
182 | return Date.now();
|
183 | }
|
184 | function getComputedStyle$1(el) {
|
185 | const window = getWindow();
|
186 | let style;
|
187 | if (window.getComputedStyle) {
|
188 | style = window.getComputedStyle(el, null);
|
189 | }
|
190 | if (!style && el.currentStyle) {
|
191 | style = el.currentStyle;
|
192 | }
|
193 | if (!style) {
|
194 | style = el.style;
|
195 | }
|
196 | return style;
|
197 | }
|
198 | function getTranslate(el, axis) {
|
199 | if (axis === void 0) {
|
200 | axis = 'x';
|
201 | }
|
202 | const window = getWindow();
|
203 | let matrix;
|
204 | let curTransform;
|
205 | let transformMatrix;
|
206 | const curStyle = getComputedStyle$1(el);
|
207 | if (window.WebKitCSSMatrix) {
|
208 | curTransform = curStyle.transform || curStyle.webkitTransform;
|
209 | if (curTransform.split(',').length > 6) {
|
210 | curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
|
211 | }
|
212 |
|
213 |
|
214 | transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
215 | } else {
|
216 | transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
217 | matrix = transformMatrix.toString().split(',');
|
218 | }
|
219 | if (axis === 'x') {
|
220 |
|
221 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
|
222 |
|
223 | else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
|
224 |
|
225 | else curTransform = parseFloat(matrix[4]);
|
226 | }
|
227 | if (axis === 'y') {
|
228 |
|
229 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
|
230 |
|
231 | else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
|
232 |
|
233 | else curTransform = parseFloat(matrix[5]);
|
234 | }
|
235 | return curTransform || 0;
|
236 | }
|
237 | function isObject$1(o) {
|
238 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
239 | }
|
240 | function isNode(node) {
|
241 |
|
242 | if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
|
243 | return node instanceof HTMLElement;
|
244 | }
|
245 | return node && (node.nodeType === 1 || node.nodeType === 11);
|
246 | }
|
247 | function extend$1() {
|
248 | const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
|
249 | const noExtend = ['__proto__', 'constructor', 'prototype'];
|
250 | for (let i = 1; i < arguments.length; i += 1) {
|
251 | const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
252 | if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
|
253 | const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
|
254 | for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
|
255 | const nextKey = keysArray[nextIndex];
|
256 | const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
257 | if (desc !== undefined && desc.enumerable) {
|
258 | if (isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
|
259 | if (nextSource[nextKey].__swiper__) {
|
260 | to[nextKey] = nextSource[nextKey];
|
261 | } else {
|
262 | extend$1(to[nextKey], nextSource[nextKey]);
|
263 | }
|
264 | } else if (!isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
|
265 | to[nextKey] = {};
|
266 | if (nextSource[nextKey].__swiper__) {
|
267 | to[nextKey] = nextSource[nextKey];
|
268 | } else {
|
269 | extend$1(to[nextKey], nextSource[nextKey]);
|
270 | }
|
271 | } else {
|
272 | to[nextKey] = nextSource[nextKey];
|
273 | }
|
274 | }
|
275 | }
|
276 | }
|
277 | }
|
278 | return to;
|
279 | }
|
280 | function setCSSProperty(el, varName, varValue) {
|
281 | el.style.setProperty(varName, varValue);
|
282 | }
|
283 | function animateCSSModeScroll(_ref) {
|
284 | let {
|
285 | swiper,
|
286 | targetPosition,
|
287 | side
|
288 | } = _ref;
|
289 | const window = getWindow();
|
290 | const startPosition = -swiper.translate;
|
291 | let startTime = null;
|
292 | let time;
|
293 | const duration = swiper.params.speed;
|
294 | swiper.wrapperEl.style.scrollSnapType = 'none';
|
295 | window.cancelAnimationFrame(swiper.cssModeFrameID);
|
296 | const dir = targetPosition > startPosition ? 'next' : 'prev';
|
297 | const isOutOfBound = (current, target) => {
|
298 | return dir === 'next' && current >= target || dir === 'prev' && current <= target;
|
299 | };
|
300 | const animate = () => {
|
301 | time = new Date().getTime();
|
302 | if (startTime === null) {
|
303 | startTime = time;
|
304 | }
|
305 | const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
|
306 | const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
|
307 | let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
|
308 | if (isOutOfBound(currentPosition, targetPosition)) {
|
309 | currentPosition = targetPosition;
|
310 | }
|
311 | swiper.wrapperEl.scrollTo({
|
312 | [side]: currentPosition
|
313 | });
|
314 | if (isOutOfBound(currentPosition, targetPosition)) {
|
315 | swiper.wrapperEl.style.overflow = 'hidden';
|
316 | swiper.wrapperEl.style.scrollSnapType = '';
|
317 | setTimeout(() => {
|
318 | swiper.wrapperEl.style.overflow = '';
|
319 | swiper.wrapperEl.scrollTo({
|
320 | [side]: currentPosition
|
321 | });
|
322 | });
|
323 | window.cancelAnimationFrame(swiper.cssModeFrameID);
|
324 | return;
|
325 | }
|
326 | swiper.cssModeFrameID = window.requestAnimationFrame(animate);
|
327 | };
|
328 | animate();
|
329 | }
|
330 | function elementChildren(element, selector) {
|
331 | if (selector === void 0) {
|
332 | selector = '';
|
333 | }
|
334 | return [...element.children].filter(el => el.matches(selector));
|
335 | }
|
336 | function createElement(tag, classes) {
|
337 | if (classes === void 0) {
|
338 | classes = [];
|
339 | }
|
340 | const el = document.createElement(tag);
|
341 | el.classList.add(...(Array.isArray(classes) ? classes : [classes]));
|
342 | return el;
|
343 | }
|
344 | function elementPrevAll(el, selector) {
|
345 | const prevEls = [];
|
346 | while (el.previousElementSibling) {
|
347 | const prev = el.previousElementSibling;
|
348 | if (selector) {
|
349 | if (prev.matches(selector)) prevEls.push(prev);
|
350 | } else prevEls.push(prev);
|
351 | el = prev;
|
352 | }
|
353 | return prevEls;
|
354 | }
|
355 | function elementNextAll(el, selector) {
|
356 | const nextEls = [];
|
357 | while (el.nextElementSibling) {
|
358 | const next = el.nextElementSibling;
|
359 | if (selector) {
|
360 | if (next.matches(selector)) nextEls.push(next);
|
361 | } else nextEls.push(next);
|
362 | el = next;
|
363 | }
|
364 | return nextEls;
|
365 | }
|
366 | function elementStyle(el, prop) {
|
367 | const window = getWindow();
|
368 | return window.getComputedStyle(el, null).getPropertyValue(prop);
|
369 | }
|
370 | function elementIndex(el) {
|
371 | let child = el;
|
372 | let i;
|
373 | if (child) {
|
374 | i = 0;
|
375 |
|
376 | while ((child = child.previousSibling) !== null) {
|
377 | if (child.nodeType === 1) i += 1;
|
378 | }
|
379 | return i;
|
380 | }
|
381 | return undefined;
|
382 | }
|
383 | function elementParents(el, selector) {
|
384 | const parents = [];
|
385 | let parent = el.parentElement;
|
386 | while (parent) {
|
387 | if (selector) {
|
388 | if (parent.matches(selector)) parents.push(parent);
|
389 | } else {
|
390 | parents.push(parent);
|
391 | }
|
392 | parent = parent.parentElement;
|
393 | }
|
394 | return parents;
|
395 | }
|
396 | function elementOuterSize(el, size, includeMargins) {
|
397 | const window = getWindow();
|
398 | if (includeMargins) {
|
399 | return el[size === 'width' ? 'offsetWidth' : 'offsetHeight'] + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-right' : 'margin-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-left' : 'margin-bottom'));
|
400 | }
|
401 | return el.offsetWidth;
|
402 | }
|
403 |
|
404 | let support;
|
405 | function calcSupport() {
|
406 | const window = getWindow();
|
407 | const document = getDocument();
|
408 | return {
|
409 | smoothScroll: document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style,
|
410 | touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
|
411 | };
|
412 | }
|
413 | function getSupport() {
|
414 | if (!support) {
|
415 | support = calcSupport();
|
416 | }
|
417 | return support;
|
418 | }
|
419 |
|
420 | let deviceCached;
|
421 | function calcDevice(_temp) {
|
422 | let {
|
423 | userAgent
|
424 | } = _temp === void 0 ? {} : _temp;
|
425 | const support = getSupport();
|
426 | const window = getWindow();
|
427 | const platform = window.navigator.platform;
|
428 | const ua = userAgent || window.navigator.userAgent;
|
429 | const device = {
|
430 | ios: false,
|
431 | android: false
|
432 | };
|
433 | const screenWidth = window.screen.width;
|
434 | const screenHeight = window.screen.height;
|
435 | const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
|
436 | let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
437 | const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
438 | const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
439 | const windows = platform === 'Win32';
|
440 | let macos = platform === 'MacIntel';
|
441 |
|
442 |
|
443 | const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
|
444 | if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
|
445 | ipad = ua.match(/(Version)\/([\d.]+)/);
|
446 | if (!ipad) ipad = [0, 1, '13_0_0'];
|
447 | macos = false;
|
448 | }
|
449 |
|
450 |
|
451 | if (android && !windows) {
|
452 | device.os = 'android';
|
453 | device.android = true;
|
454 | }
|
455 | if (ipad || iphone || ipod) {
|
456 | device.os = 'ios';
|
457 | device.ios = true;
|
458 | }
|
459 |
|
460 |
|
461 | return device;
|
462 | }
|
463 | function getDevice(overrides) {
|
464 | if (overrides === void 0) {
|
465 | overrides = {};
|
466 | }
|
467 | if (!deviceCached) {
|
468 | deviceCached = calcDevice(overrides);
|
469 | }
|
470 | return deviceCached;
|
471 | }
|
472 |
|
473 | let browser;
|
474 | function calcBrowser() {
|
475 | const window = getWindow();
|
476 | let needPerspectiveFix = false;
|
477 | function isSafari() {
|
478 | const ua = window.navigator.userAgent.toLowerCase();
|
479 | return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
|
480 | }
|
481 | if (isSafari()) {
|
482 | const ua = String(window.navigator.userAgent);
|
483 | if (ua.includes('Version/')) {
|
484 | const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
|
485 | needPerspectiveFix = major < 16 || major === 16 && minor < 2;
|
486 | }
|
487 | }
|
488 | return {
|
489 | isSafari: needPerspectiveFix || isSafari(),
|
490 | needPerspectiveFix,
|
491 | isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
|
492 | };
|
493 | }
|
494 | function getBrowser() {
|
495 | if (!browser) {
|
496 | browser = calcBrowser();
|
497 | }
|
498 | return browser;
|
499 | }
|
500 |
|
501 | function Resize(_ref) {
|
502 | let {
|
503 | swiper,
|
504 | on,
|
505 | emit
|
506 | } = _ref;
|
507 | const window = getWindow();
|
508 | let observer = null;
|
509 | let animationFrame = null;
|
510 | const resizeHandler = () => {
|
511 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
512 | emit('beforeResize');
|
513 | emit('resize');
|
514 | };
|
515 | const createObserver = () => {
|
516 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
517 | observer = new ResizeObserver(entries => {
|
518 | animationFrame = window.requestAnimationFrame(() => {
|
519 | const {
|
520 | width,
|
521 | height
|
522 | } = swiper;
|
523 | let newWidth = width;
|
524 | let newHeight = height;
|
525 | entries.forEach(_ref2 => {
|
526 | let {
|
527 | contentBoxSize,
|
528 | contentRect,
|
529 | target
|
530 | } = _ref2;
|
531 | if (target && target !== swiper.el) return;
|
532 | newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
|
533 | newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
|
534 | });
|
535 | if (newWidth !== width || newHeight !== height) {
|
536 | resizeHandler();
|
537 | }
|
538 | });
|
539 | });
|
540 | observer.observe(swiper.el);
|
541 | };
|
542 | const removeObserver = () => {
|
543 | if (animationFrame) {
|
544 | window.cancelAnimationFrame(animationFrame);
|
545 | }
|
546 | if (observer && observer.unobserve && swiper.el) {
|
547 | observer.unobserve(swiper.el);
|
548 | observer = null;
|
549 | }
|
550 | };
|
551 | const orientationChangeHandler = () => {
|
552 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
553 | emit('orientationchange');
|
554 | };
|
555 | on('init', () => {
|
556 | if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
|
557 | createObserver();
|
558 | return;
|
559 | }
|
560 | window.addEventListener('resize', resizeHandler);
|
561 | window.addEventListener('orientationchange', orientationChangeHandler);
|
562 | });
|
563 | on('destroy', () => {
|
564 | removeObserver();
|
565 | window.removeEventListener('resize', resizeHandler);
|
566 | window.removeEventListener('orientationchange', orientationChangeHandler);
|
567 | });
|
568 | }
|
569 |
|
570 | function Observer(_ref) {
|
571 | let {
|
572 | swiper,
|
573 | extendParams,
|
574 | on,
|
575 | emit
|
576 | } = _ref;
|
577 | const observers = [];
|
578 | const window = getWindow();
|
579 | const attach = function (target, options) {
|
580 | if (options === void 0) {
|
581 | options = {};
|
582 | }
|
583 | const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
|
584 | const observer = new ObserverFunc(mutations => {
|
585 |
|
586 |
|
587 |
|
588 | if (swiper.__preventObserver__) return;
|
589 | if (mutations.length === 1) {
|
590 | emit('observerUpdate', mutations[0]);
|
591 | return;
|
592 | }
|
593 | const observerUpdate = function observerUpdate() {
|
594 | emit('observerUpdate', mutations[0]);
|
595 | };
|
596 | if (window.requestAnimationFrame) {
|
597 | window.requestAnimationFrame(observerUpdate);
|
598 | } else {
|
599 | window.setTimeout(observerUpdate, 0);
|
600 | }
|
601 | });
|
602 | observer.observe(target, {
|
603 | attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
|
604 | childList: typeof options.childList === 'undefined' ? true : options.childList,
|
605 | characterData: typeof options.characterData === 'undefined' ? true : options.characterData
|
606 | });
|
607 | observers.push(observer);
|
608 | };
|
609 | const init = () => {
|
610 | if (!swiper.params.observer) return;
|
611 | if (swiper.params.observeParents) {
|
612 | const containerParents = elementParents(swiper.el);
|
613 | for (let i = 0; i < containerParents.length; i += 1) {
|
614 | attach(containerParents[i]);
|
615 | }
|
616 | }
|
617 |
|
618 | attach(swiper.el, {
|
619 | childList: swiper.params.observeSlideChildren
|
620 | });
|
621 |
|
622 |
|
623 | attach(swiper.wrapperEl, {
|
624 | attributes: false
|
625 | });
|
626 | };
|
627 | const destroy = () => {
|
628 | observers.forEach(observer => {
|
629 | observer.disconnect();
|
630 | });
|
631 | observers.splice(0, observers.length);
|
632 | };
|
633 | extendParams({
|
634 | observer: false,
|
635 | observeParents: false,
|
636 | observeSlideChildren: false
|
637 | });
|
638 | on('init', init);
|
639 | on('destroy', destroy);
|
640 | }
|
641 |
|
642 |
|
643 |
|
644 | var eventsEmitter = {
|
645 | on(events, handler, priority) {
|
646 | const self = this;
|
647 | if (!self.eventsListeners || self.destroyed) return self;
|
648 | if (typeof handler !== 'function') return self;
|
649 | const method = priority ? 'unshift' : 'push';
|
650 | events.split(' ').forEach(event => {
|
651 | if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
|
652 | self.eventsListeners[event][method](handler);
|
653 | });
|
654 | return self;
|
655 | },
|
656 | once(events, handler, priority) {
|
657 | const self = this;
|
658 | if (!self.eventsListeners || self.destroyed) return self;
|
659 | if (typeof handler !== 'function') return self;
|
660 | function onceHandler() {
|
661 | self.off(events, onceHandler);
|
662 | if (onceHandler.__emitterProxy) {
|
663 | delete onceHandler.__emitterProxy;
|
664 | }
|
665 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
666 | args[_key] = arguments[_key];
|
667 | }
|
668 | handler.apply(self, args);
|
669 | }
|
670 | onceHandler.__emitterProxy = handler;
|
671 | return self.on(events, onceHandler, priority);
|
672 | },
|
673 | onAny(handler, priority) {
|
674 | const self = this;
|
675 | if (!self.eventsListeners || self.destroyed) return self;
|
676 | if (typeof handler !== 'function') return self;
|
677 | const method = priority ? 'unshift' : 'push';
|
678 | if (self.eventsAnyListeners.indexOf(handler) < 0) {
|
679 | self.eventsAnyListeners[method](handler);
|
680 | }
|
681 | return self;
|
682 | },
|
683 | offAny(handler) {
|
684 | const self = this;
|
685 | if (!self.eventsListeners || self.destroyed) return self;
|
686 | if (!self.eventsAnyListeners) return self;
|
687 | const index = self.eventsAnyListeners.indexOf(handler);
|
688 | if (index >= 0) {
|
689 | self.eventsAnyListeners.splice(index, 1);
|
690 | }
|
691 | return self;
|
692 | },
|
693 | off(events, handler) {
|
694 | const self = this;
|
695 | if (!self.eventsListeners || self.destroyed) return self;
|
696 | if (!self.eventsListeners) return self;
|
697 | events.split(' ').forEach(event => {
|
698 | if (typeof handler === 'undefined') {
|
699 | self.eventsListeners[event] = [];
|
700 | } else if (self.eventsListeners[event]) {
|
701 | self.eventsListeners[event].forEach((eventHandler, index) => {
|
702 | if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
|
703 | self.eventsListeners[event].splice(index, 1);
|
704 | }
|
705 | });
|
706 | }
|
707 | });
|
708 | return self;
|
709 | },
|
710 | emit() {
|
711 | const self = this;
|
712 | if (!self.eventsListeners || self.destroyed) return self;
|
713 | if (!self.eventsListeners) return self;
|
714 | let events;
|
715 | let data;
|
716 | let context;
|
717 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
718 | args[_key2] = arguments[_key2];
|
719 | }
|
720 | if (typeof args[0] === 'string' || Array.isArray(args[0])) {
|
721 | events = args[0];
|
722 | data = args.slice(1, args.length);
|
723 | context = self;
|
724 | } else {
|
725 | events = args[0].events;
|
726 | data = args[0].data;
|
727 | context = args[0].context || self;
|
728 | }
|
729 | data.unshift(context);
|
730 | const eventsArray = Array.isArray(events) ? events : events.split(' ');
|
731 | eventsArray.forEach(event => {
|
732 | if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
|
733 | self.eventsAnyListeners.forEach(eventHandler => {
|
734 | eventHandler.apply(context, [event, ...data]);
|
735 | });
|
736 | }
|
737 | if (self.eventsListeners && self.eventsListeners[event]) {
|
738 | self.eventsListeners[event].forEach(eventHandler => {
|
739 | eventHandler.apply(context, data);
|
740 | });
|
741 | }
|
742 | });
|
743 | return self;
|
744 | }
|
745 | };
|
746 |
|
747 | function updateSize() {
|
748 | const swiper = this;
|
749 | let width;
|
750 | let height;
|
751 | const el = swiper.el;
|
752 | if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
753 | width = swiper.params.width;
|
754 | } else {
|
755 | width = el.clientWidth;
|
756 | }
|
757 | if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
758 | height = swiper.params.height;
|
759 | } else {
|
760 | height = el.clientHeight;
|
761 | }
|
762 | if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
763 | return;
|
764 | }
|
765 |
|
766 |
|
767 | width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
|
768 | height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
|
769 | if (Number.isNaN(width)) width = 0;
|
770 | if (Number.isNaN(height)) height = 0;
|
771 | Object.assign(swiper, {
|
772 | width,
|
773 | height,
|
774 | size: swiper.isHorizontal() ? width : height
|
775 | });
|
776 | }
|
777 |
|
778 | function updateSlides() {
|
779 | const swiper = this;
|
780 | function getDirectionLabel(property) {
|
781 | if (swiper.isHorizontal()) {
|
782 | return property;
|
783 | }
|
784 |
|
785 | return {
|
786 | 'width': 'height',
|
787 | 'margin-top': 'margin-left',
|
788 | 'margin-bottom ': 'margin-right',
|
789 | 'margin-left': 'margin-top',
|
790 | 'margin-right': 'margin-bottom',
|
791 | 'padding-left': 'padding-top',
|
792 | 'padding-right': 'padding-bottom',
|
793 | 'marginRight': 'marginBottom'
|
794 | }[property];
|
795 | }
|
796 | function getDirectionPropertyValue(node, label) {
|
797 | return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
|
798 | }
|
799 | const params = swiper.params;
|
800 | const {
|
801 | wrapperEl,
|
802 | slidesEl,
|
803 | size: swiperSize,
|
804 | rtlTranslate: rtl,
|
805 | wrongRTL
|
806 | } = swiper;
|
807 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
808 | const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
809 | const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
810 | const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
|
811 | let snapGrid = [];
|
812 | const slidesGrid = [];
|
813 | const slidesSizesGrid = [];
|
814 | let offsetBefore = params.slidesOffsetBefore;
|
815 | if (typeof offsetBefore === 'function') {
|
816 | offsetBefore = params.slidesOffsetBefore.call(swiper);
|
817 | }
|
818 | let offsetAfter = params.slidesOffsetAfter;
|
819 | if (typeof offsetAfter === 'function') {
|
820 | offsetAfter = params.slidesOffsetAfter.call(swiper);
|
821 | }
|
822 | const previousSnapGridLength = swiper.snapGrid.length;
|
823 | const previousSlidesGridLength = swiper.slidesGrid.length;
|
824 | let spaceBetween = params.spaceBetween;
|
825 | let slidePosition = -offsetBefore;
|
826 | let prevSlideSize = 0;
|
827 | let index = 0;
|
828 | if (typeof swiperSize === 'undefined') {
|
829 | return;
|
830 | }
|
831 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
832 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
833 | } else if (typeof spaceBetween === 'string') {
|
834 | spaceBetween = parseFloat(spaceBetween);
|
835 | }
|
836 | swiper.virtualSize = -spaceBetween;
|
837 |
|
838 |
|
839 | slides.forEach(slideEl => {
|
840 | if (rtl) {
|
841 | slideEl.style.marginLeft = '';
|
842 | } else {
|
843 | slideEl.style.marginRight = '';
|
844 | }
|
845 | slideEl.style.marginBottom = '';
|
846 | slideEl.style.marginTop = '';
|
847 | });
|
848 |
|
849 |
|
850 | if (params.centeredSlides && params.cssMode) {
|
851 | setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
852 | setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
853 | }
|
854 | const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
855 | if (gridEnabled) {
|
856 | swiper.grid.initSlides(slidesLength);
|
857 | }
|
858 |
|
859 |
|
860 | let slideSize;
|
861 | const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
|
862 | return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
863 | }).length > 0;
|
864 | for (let i = 0; i < slidesLength; i += 1) {
|
865 | slideSize = 0;
|
866 | let slide;
|
867 | if (slides[i]) slide = slides[i];
|
868 | if (gridEnabled) {
|
869 | swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
|
870 | }
|
871 | if (slides[i] && elementStyle(slide, 'display') === 'none') continue;
|
872 |
|
873 | if (params.slidesPerView === 'auto') {
|
874 | if (shouldResetSlideSize) {
|
875 | slides[i].style[getDirectionLabel('width')] = ``;
|
876 | }
|
877 | const slideStyles = getComputedStyle(slide);
|
878 | const currentTransform = slide.style.transform;
|
879 | const currentWebKitTransform = slide.style.webkitTransform;
|
880 | if (currentTransform) {
|
881 | slide.style.transform = 'none';
|
882 | }
|
883 | if (currentWebKitTransform) {
|
884 | slide.style.webkitTransform = 'none';
|
885 | }
|
886 | if (params.roundLengths) {
|
887 | slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
888 | } else {
|
889 |
|
890 | const width = getDirectionPropertyValue(slideStyles, 'width');
|
891 | const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
892 | const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
893 | const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
894 | const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
895 | const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
896 | if (boxSizing && boxSizing === 'border-box') {
|
897 | slideSize = width + marginLeft + marginRight;
|
898 | } else {
|
899 | const {
|
900 | clientWidth,
|
901 | offsetWidth
|
902 | } = slide;
|
903 | slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
904 | }
|
905 | }
|
906 | if (currentTransform) {
|
907 | slide.style.transform = currentTransform;
|
908 | }
|
909 | if (currentWebKitTransform) {
|
910 | slide.style.webkitTransform = currentWebKitTransform;
|
911 | }
|
912 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
913 | } else {
|
914 | slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
915 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
916 | if (slides[i]) {
|
917 | slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
|
918 | }
|
919 | }
|
920 | if (slides[i]) {
|
921 | slides[i].swiperSlideSize = slideSize;
|
922 | }
|
923 | slidesSizesGrid.push(slideSize);
|
924 | if (params.centeredSlides) {
|
925 | slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
926 | if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
927 | if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
928 | if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
929 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
930 | if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
931 | slidesGrid.push(slidePosition);
|
932 | } else {
|
933 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
934 | if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
935 | slidesGrid.push(slidePosition);
|
936 | slidePosition = slidePosition + slideSize + spaceBetween;
|
937 | }
|
938 | swiper.virtualSize += slideSize + spaceBetween;
|
939 | prevSlideSize = slideSize;
|
940 | index += 1;
|
941 | }
|
942 | swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
|
943 | if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
|
944 | wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
|
945 | }
|
946 | if (params.setWrapperSize) {
|
947 | wrapperEl.style[getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
|
948 | }
|
949 | if (gridEnabled) {
|
950 | swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
|
951 | }
|
952 |
|
953 |
|
954 | if (!params.centeredSlides) {
|
955 | const newSlidesGrid = [];
|
956 | for (let i = 0; i < snapGrid.length; i += 1) {
|
957 | let slidesGridItem = snapGrid[i];
|
958 | if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
959 | if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
|
960 | newSlidesGrid.push(slidesGridItem);
|
961 | }
|
962 | }
|
963 | snapGrid = newSlidesGrid;
|
964 | if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
965 | snapGrid.push(swiper.virtualSize - swiperSize);
|
966 | }
|
967 | }
|
968 | if (isVirtual && params.loop) {
|
969 | const size = slidesSizesGrid[0] + spaceBetween;
|
970 | if (params.slidesPerGroup > 1) {
|
971 | const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
972 | const groupSize = size * params.slidesPerGroup;
|
973 | for (let i = 0; i < groups; i += 1) {
|
974 | snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
975 | }
|
976 | }
|
977 | for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
978 | if (params.slidesPerGroup === 1) {
|
979 | snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
980 | }
|
981 | slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
982 | swiper.virtualSize += size;
|
983 | }
|
984 | }
|
985 | if (snapGrid.length === 0) snapGrid = [0];
|
986 | if (spaceBetween !== 0) {
|
987 | const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
|
988 | slides.filter((_, slideIndex) => {
|
989 | if (!params.cssMode || params.loop) return true;
|
990 | if (slideIndex === slides.length - 1) {
|
991 | return false;
|
992 | }
|
993 | return true;
|
994 | }).forEach(slideEl => {
|
995 | slideEl.style[key] = `${spaceBetween}px`;
|
996 | });
|
997 | }
|
998 | if (params.centeredSlides && params.centeredSlidesBounds) {
|
999 | let allSlidesSize = 0;
|
1000 | slidesSizesGrid.forEach(slideSizeValue => {
|
1001 | allSlidesSize += slideSizeValue + (spaceBetween || 0);
|
1002 | });
|
1003 | allSlidesSize -= spaceBetween;
|
1004 | const maxSnap = allSlidesSize - swiperSize;
|
1005 | snapGrid = snapGrid.map(snap => {
|
1006 | if (snap <= 0) return -offsetBefore;
|
1007 | if (snap > maxSnap) return maxSnap + offsetAfter;
|
1008 | return snap;
|
1009 | });
|
1010 | }
|
1011 | if (params.centerInsufficientSlides) {
|
1012 | let allSlidesSize = 0;
|
1013 | slidesSizesGrid.forEach(slideSizeValue => {
|
1014 | allSlidesSize += slideSizeValue + (spaceBetween || 0);
|
1015 | });
|
1016 | allSlidesSize -= spaceBetween;
|
1017 | if (allSlidesSize < swiperSize) {
|
1018 | const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
|
1019 | snapGrid.forEach((snap, snapIndex) => {
|
1020 | snapGrid[snapIndex] = snap - allSlidesOffset;
|
1021 | });
|
1022 | slidesGrid.forEach((snap, snapIndex) => {
|
1023 | slidesGrid[snapIndex] = snap + allSlidesOffset;
|
1024 | });
|
1025 | }
|
1026 | }
|
1027 | Object.assign(swiper, {
|
1028 | slides,
|
1029 | snapGrid,
|
1030 | slidesGrid,
|
1031 | slidesSizesGrid
|
1032 | });
|
1033 | if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
|
1034 | setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
|
1035 | setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
|
1036 | const addToSnapGrid = -swiper.snapGrid[0];
|
1037 | const addToSlidesGrid = -swiper.slidesGrid[0];
|
1038 | swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
1039 | swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
1040 | }
|
1041 | if (slidesLength !== previousSlidesLength) {
|
1042 | swiper.emit('slidesLengthChange');
|
1043 | }
|
1044 | if (snapGrid.length !== previousSnapGridLength) {
|
1045 | if (swiper.params.watchOverflow) swiper.checkOverflow();
|
1046 | swiper.emit('snapGridLengthChange');
|
1047 | }
|
1048 | if (slidesGrid.length !== previousSlidesGridLength) {
|
1049 | swiper.emit('slidesGridLengthChange');
|
1050 | }
|
1051 | if (params.watchSlidesProgress) {
|
1052 | swiper.updateSlidesOffset();
|
1053 | }
|
1054 | if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
|
1055 | const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
1056 | const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
1057 | if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
1058 | if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
|
1059 | } else if (hasClassBackfaceClassAdded) {
|
1060 | swiper.el.classList.remove(backFaceHiddenClass);
|
1061 | }
|
1062 | }
|
1063 | }
|
1064 |
|
1065 | function updateAutoHeight(speed) {
|
1066 | const swiper = this;
|
1067 | const activeSlides = [];
|
1068 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
1069 | let newHeight = 0;
|
1070 | let i;
|
1071 | if (typeof speed === 'number') {
|
1072 | swiper.setTransition(speed);
|
1073 | } else if (speed === true) {
|
1074 | swiper.setTransition(swiper.params.speed);
|
1075 | }
|
1076 | const getSlideByIndex = index => {
|
1077 | if (isVirtual) {
|
1078 | return swiper.slides[swiper.getSlideIndexByData(index)];
|
1079 | }
|
1080 | return swiper.slides[index];
|
1081 | };
|
1082 |
|
1083 | if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
1084 | if (swiper.params.centeredSlides) {
|
1085 | (swiper.visibleSlides || []).forEach(slide => {
|
1086 | activeSlides.push(slide);
|
1087 | });
|
1088 | } else {
|
1089 | for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
1090 | const index = swiper.activeIndex + i;
|
1091 | if (index > swiper.slides.length && !isVirtual) break;
|
1092 | activeSlides.push(getSlideByIndex(index));
|
1093 | }
|
1094 | }
|
1095 | } else {
|
1096 | activeSlides.push(getSlideByIndex(swiper.activeIndex));
|
1097 | }
|
1098 |
|
1099 |
|
1100 | for (i = 0; i < activeSlides.length; i += 1) {
|
1101 | if (typeof activeSlides[i] !== 'undefined') {
|
1102 | const height = activeSlides[i].offsetHeight;
|
1103 | newHeight = height > newHeight ? height : newHeight;
|
1104 | }
|
1105 | }
|
1106 |
|
1107 |
|
1108 | if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
1109 | }
|
1110 |
|
1111 | function updateSlidesOffset() {
|
1112 | const swiper = this;
|
1113 | const slides = swiper.slides;
|
1114 |
|
1115 | const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
|
1116 | for (let i = 0; i < slides.length; i += 1) {
|
1117 | slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
|
1118 | }
|
1119 | }
|
1120 |
|
1121 | function updateSlidesProgress(translate) {
|
1122 | if (translate === void 0) {
|
1123 | translate = this && this.translate || 0;
|
1124 | }
|
1125 | const swiper = this;
|
1126 | const params = swiper.params;
|
1127 | const {
|
1128 | slides,
|
1129 | rtlTranslate: rtl,
|
1130 | snapGrid
|
1131 | } = swiper;
|
1132 | if (slides.length === 0) return;
|
1133 | if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
|
1134 | let offsetCenter = -translate;
|
1135 | if (rtl) offsetCenter = translate;
|
1136 |
|
1137 |
|
1138 | slides.forEach(slideEl => {
|
1139 | slideEl.classList.remove(params.slideVisibleClass);
|
1140 | });
|
1141 | swiper.visibleSlidesIndexes = [];
|
1142 | swiper.visibleSlides = [];
|
1143 | let spaceBetween = params.spaceBetween;
|
1144 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
1145 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
|
1146 | } else if (typeof spaceBetween === 'string') {
|
1147 | spaceBetween = parseFloat(spaceBetween);
|
1148 | }
|
1149 | for (let i = 0; i < slides.length; i += 1) {
|
1150 | const slide = slides[i];
|
1151 | let slideOffset = slide.swiperSlideOffset;
|
1152 | if (params.cssMode && params.centeredSlides) {
|
1153 | slideOffset -= slides[0].swiperSlideOffset;
|
1154 | }
|
1155 | const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
|
1156 | const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
|
1157 | const slideBefore = -(offsetCenter - slideOffset);
|
1158 | const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
1159 | const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
1160 | if (isVisible) {
|
1161 | swiper.visibleSlides.push(slide);
|
1162 | swiper.visibleSlidesIndexes.push(i);
|
1163 | slides[i].classList.add(params.slideVisibleClass);
|
1164 | }
|
1165 | slide.progress = rtl ? -slideProgress : slideProgress;
|
1166 | slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
1167 | }
|
1168 | }
|
1169 |
|
1170 | function updateProgress(translate) {
|
1171 | const swiper = this;
|
1172 | if (typeof translate === 'undefined') {
|
1173 | const multiplier = swiper.rtlTranslate ? -1 : 1;
|
1174 |
|
1175 | translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
|
1176 | }
|
1177 | const params = swiper.params;
|
1178 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
1179 | let {
|
1180 | progress,
|
1181 | isBeginning,
|
1182 | isEnd,
|
1183 | progressLoop
|
1184 | } = swiper;
|
1185 | const wasBeginning = isBeginning;
|
1186 | const wasEnd = isEnd;
|
1187 | if (translatesDiff === 0) {
|
1188 | progress = 0;
|
1189 | isBeginning = true;
|
1190 | isEnd = true;
|
1191 | } else {
|
1192 | progress = (translate - swiper.minTranslate()) / translatesDiff;
|
1193 | const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
|
1194 | const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
|
1195 | isBeginning = isBeginningRounded || progress <= 0;
|
1196 | isEnd = isEndRounded || progress >= 1;
|
1197 | if (isBeginningRounded) progress = 0;
|
1198 | if (isEndRounded) progress = 1;
|
1199 | }
|
1200 | if (params.loop) {
|
1201 | const firstSlideIndex = swiper.getSlideIndexByData(0);
|
1202 | const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
|
1203 | const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
|
1204 | const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
|
1205 | const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
|
1206 | const translateAbs = Math.abs(translate);
|
1207 | if (translateAbs >= firstSlideTranslate) {
|
1208 | progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
|
1209 | } else {
|
1210 | progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
|
1211 | }
|
1212 | if (progressLoop > 1) progressLoop -= 1;
|
1213 | }
|
1214 | Object.assign(swiper, {
|
1215 | progress,
|
1216 | progressLoop,
|
1217 | isBeginning,
|
1218 | isEnd
|
1219 | });
|
1220 | if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
|
1221 | if (isBeginning && !wasBeginning) {
|
1222 | swiper.emit('reachBeginning toEdge');
|
1223 | }
|
1224 | if (isEnd && !wasEnd) {
|
1225 | swiper.emit('reachEnd toEdge');
|
1226 | }
|
1227 | if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
|
1228 | swiper.emit('fromEdge');
|
1229 | }
|
1230 | swiper.emit('progress', progress);
|
1231 | }
|
1232 |
|
1233 | function updateSlidesClasses() {
|
1234 | const swiper = this;
|
1235 | const {
|
1236 | slides,
|
1237 | params,
|
1238 | slidesEl,
|
1239 | activeIndex
|
1240 | } = swiper;
|
1241 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
1242 | const getFilteredSlide = selector => {
|
1243 | return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
1244 | };
|
1245 | slides.forEach(slideEl => {
|
1246 | slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
1247 | });
|
1248 | let activeSlide;
|
1249 | if (isVirtual) {
|
1250 | if (params.loop) {
|
1251 | let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
1252 | if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
1253 | if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
1254 | activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
1255 | } else {
|
1256 | activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
1257 | }
|
1258 | } else {
|
1259 | activeSlide = slides[activeIndex];
|
1260 | }
|
1261 | if (activeSlide) {
|
1262 |
|
1263 | activeSlide.classList.add(params.slideActiveClass);
|
1264 |
|
1265 |
|
1266 | let nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
1267 | if (params.loop && !nextSlide) {
|
1268 | nextSlide = slides[0];
|
1269 | }
|
1270 | if (nextSlide) {
|
1271 | nextSlide.classList.add(params.slideNextClass);
|
1272 | }
|
1273 |
|
1274 | let prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
1275 | if (params.loop && !prevSlide === 0) {
|
1276 | prevSlide = slides[slides.length - 1];
|
1277 | }
|
1278 | if (prevSlide) {
|
1279 | prevSlide.classList.add(params.slidePrevClass);
|
1280 | }
|
1281 | }
|
1282 | swiper.emitSlidesClasses();
|
1283 | }
|
1284 |
|
1285 | const processLazyPreloader = (swiper, imageEl) => {
|
1286 | if (!swiper || swiper.destroyed || !swiper.params) return;
|
1287 | const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
|
1288 | const slideEl = imageEl.closest(slideSelector());
|
1289 | if (slideEl) {
|
1290 | const lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
|
1291 | if (lazyEl) lazyEl.remove();
|
1292 | }
|
1293 | };
|
1294 | const unlazy = (swiper, index) => {
|
1295 | if (!swiper.slides[index]) return;
|
1296 | const imageEl = swiper.slides[index].querySelector('[loading="lazy"]');
|
1297 | if (imageEl) imageEl.removeAttribute('loading');
|
1298 | };
|
1299 | const preload = swiper => {
|
1300 | if (!swiper || swiper.destroyed || !swiper.params) return;
|
1301 | let amount = swiper.params.lazyPreloadPrevNext;
|
1302 | const len = swiper.slides.length;
|
1303 | if (!len || !amount || amount < 0) return;
|
1304 | amount = Math.min(amount, len);
|
1305 | const slidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView);
|
1306 | const activeIndex = swiper.activeIndex;
|
1307 | if (swiper.params.grid && swiper.params.grid.rows > 1) {
|
1308 | const activeColumn = activeIndex;
|
1309 | const preloadColumns = [activeColumn - amount];
|
1310 | preloadColumns.push(...Array.from({
|
1311 | length: amount
|
1312 | }).map((_, i) => {
|
1313 | return activeColumn + slidesPerView + i;
|
1314 | }));
|
1315 | swiper.slides.forEach((slideEl, i) => {
|
1316 | if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i);
|
1317 | });
|
1318 | return;
|
1319 | }
|
1320 | const slideIndexLastInView = activeIndex + slidesPerView - 1;
|
1321 | if (swiper.params.rewind || swiper.params.loop) {
|
1322 | for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
|
1323 | const realIndex = (i % len + len) % len;
|
1324 | if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex);
|
1325 | }
|
1326 | } else {
|
1327 | for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
|
1328 | if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
|
1329 | unlazy(swiper, i);
|
1330 | }
|
1331 | }
|
1332 | }
|
1333 | };
|
1334 |
|
1335 | function getActiveIndexByTranslate(swiper) {
|
1336 | const {
|
1337 | slidesGrid,
|
1338 | params
|
1339 | } = swiper;
|
1340 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
1341 | let activeIndex;
|
1342 | for (let i = 0; i < slidesGrid.length; i += 1) {
|
1343 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
1344 | if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
|
1345 | activeIndex = i;
|
1346 | } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
|
1347 | activeIndex = i + 1;
|
1348 | }
|
1349 | } else if (translate >= slidesGrid[i]) {
|
1350 | activeIndex = i;
|
1351 | }
|
1352 | }
|
1353 |
|
1354 | if (params.normalizeSlideIndex) {
|
1355 | if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
1356 | }
|
1357 | return activeIndex;
|
1358 | }
|
1359 | function updateActiveIndex(newActiveIndex) {
|
1360 | const swiper = this;
|
1361 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
1362 | const {
|
1363 | snapGrid,
|
1364 | params,
|
1365 | activeIndex: previousIndex,
|
1366 | realIndex: previousRealIndex,
|
1367 | snapIndex: previousSnapIndex
|
1368 | } = swiper;
|
1369 | let activeIndex = newActiveIndex;
|
1370 | let snapIndex;
|
1371 | const getVirtualRealIndex = aIndex => {
|
1372 | let realIndex = aIndex - swiper.virtual.slidesBefore;
|
1373 | if (realIndex < 0) {
|
1374 | realIndex = swiper.virtual.slides.length + realIndex;
|
1375 | }
|
1376 | if (realIndex >= swiper.virtual.slides.length) {
|
1377 | realIndex -= swiper.virtual.slides.length;
|
1378 | }
|
1379 | return realIndex;
|
1380 | };
|
1381 | if (typeof activeIndex === 'undefined') {
|
1382 | activeIndex = getActiveIndexByTranslate(swiper);
|
1383 | }
|
1384 | if (snapGrid.indexOf(translate) >= 0) {
|
1385 | snapIndex = snapGrid.indexOf(translate);
|
1386 | } else {
|
1387 | const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
|
1388 | snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
1389 | }
|
1390 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
1391 | if (activeIndex === previousIndex) {
|
1392 | if (snapIndex !== previousSnapIndex) {
|
1393 | swiper.snapIndex = snapIndex;
|
1394 | swiper.emit('snapIndexChange');
|
1395 | }
|
1396 | if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
1397 | swiper.realIndex = getVirtualRealIndex(activeIndex);
|
1398 | }
|
1399 | return;
|
1400 | }
|
1401 |
|
1402 | let realIndex;
|
1403 | if (swiper.virtual && params.virtual.enabled && params.loop) {
|
1404 | realIndex = getVirtualRealIndex(activeIndex);
|
1405 | } else if (swiper.slides[activeIndex]) {
|
1406 | realIndex = parseInt(swiper.slides[activeIndex].getAttribute('data-swiper-slide-index') || activeIndex, 10);
|
1407 | } else {
|
1408 | realIndex = activeIndex;
|
1409 | }
|
1410 | Object.assign(swiper, {
|
1411 | previousSnapIndex,
|
1412 | snapIndex,
|
1413 | previousRealIndex,
|
1414 | realIndex,
|
1415 | previousIndex,
|
1416 | activeIndex
|
1417 | });
|
1418 | if (swiper.initialized) {
|
1419 | preload(swiper);
|
1420 | }
|
1421 | swiper.emit('activeIndexChange');
|
1422 | swiper.emit('snapIndexChange');
|
1423 | if (previousRealIndex !== realIndex) {
|
1424 | swiper.emit('realIndexChange');
|
1425 | }
|
1426 | if (swiper.initialized || swiper.params.runCallbacksOnInit) {
|
1427 | swiper.emit('slideChange');
|
1428 | }
|
1429 | }
|
1430 |
|
1431 | function updateClickedSlide(e) {
|
1432 | const swiper = this;
|
1433 | const params = swiper.params;
|
1434 | const slide = e.closest(`.${params.slideClass}, swiper-slide`);
|
1435 | let slideFound = false;
|
1436 | let slideIndex;
|
1437 | if (slide) {
|
1438 | for (let i = 0; i < swiper.slides.length; i += 1) {
|
1439 | if (swiper.slides[i] === slide) {
|
1440 | slideFound = true;
|
1441 | slideIndex = i;
|
1442 | break;
|
1443 | }
|
1444 | }
|
1445 | }
|
1446 | if (slide && slideFound) {
|
1447 | swiper.clickedSlide = slide;
|
1448 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
1449 | swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
1450 | } else {
|
1451 | swiper.clickedIndex = slideIndex;
|
1452 | }
|
1453 | } else {
|
1454 | swiper.clickedSlide = undefined;
|
1455 | swiper.clickedIndex = undefined;
|
1456 | return;
|
1457 | }
|
1458 | if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
|
1459 | swiper.slideToClickedSlide();
|
1460 | }
|
1461 | }
|
1462 |
|
1463 | var update = {
|
1464 | updateSize,
|
1465 | updateSlides,
|
1466 | updateAutoHeight,
|
1467 | updateSlidesOffset,
|
1468 | updateSlidesProgress,
|
1469 | updateProgress,
|
1470 | updateSlidesClasses,
|
1471 | updateActiveIndex,
|
1472 | updateClickedSlide
|
1473 | };
|
1474 |
|
1475 | function getSwiperTranslate(axis) {
|
1476 | if (axis === void 0) {
|
1477 | axis = this.isHorizontal() ? 'x' : 'y';
|
1478 | }
|
1479 | const swiper = this;
|
1480 | const {
|
1481 | params,
|
1482 | rtlTranslate: rtl,
|
1483 | translate,
|
1484 | wrapperEl
|
1485 | } = swiper;
|
1486 | if (params.virtualTranslate) {
|
1487 | return rtl ? -translate : translate;
|
1488 | }
|
1489 | if (params.cssMode) {
|
1490 | return translate;
|
1491 | }
|
1492 | let currentTranslate = getTranslate(wrapperEl, axis);
|
1493 | currentTranslate += swiper.cssOverflowAdjustment();
|
1494 | if (rtl) currentTranslate = -currentTranslate;
|
1495 | return currentTranslate || 0;
|
1496 | }
|
1497 |
|
1498 | function setTranslate(translate, byController) {
|
1499 | const swiper = this;
|
1500 | const {
|
1501 | rtlTranslate: rtl,
|
1502 | params,
|
1503 | wrapperEl,
|
1504 | progress
|
1505 | } = swiper;
|
1506 | let x = 0;
|
1507 | let y = 0;
|
1508 | const z = 0;
|
1509 | if (swiper.isHorizontal()) {
|
1510 | x = rtl ? -translate : translate;
|
1511 | } else {
|
1512 | y = translate;
|
1513 | }
|
1514 | if (params.roundLengths) {
|
1515 | x = Math.floor(x);
|
1516 | y = Math.floor(y);
|
1517 | }
|
1518 | swiper.previousTranslate = swiper.translate;
|
1519 | swiper.translate = swiper.isHorizontal() ? x : y;
|
1520 | if (params.cssMode) {
|
1521 | wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
1522 | } else if (!params.virtualTranslate) {
|
1523 | if (swiper.isHorizontal()) {
|
1524 | x -= swiper.cssOverflowAdjustment();
|
1525 | } else {
|
1526 | y -= swiper.cssOverflowAdjustment();
|
1527 | }
|
1528 | wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
|
1529 | }
|
1530 |
|
1531 |
|
1532 | let newProgress;
|
1533 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
1534 | if (translatesDiff === 0) {
|
1535 | newProgress = 0;
|
1536 | } else {
|
1537 | newProgress = (translate - swiper.minTranslate()) / translatesDiff;
|
1538 | }
|
1539 | if (newProgress !== progress) {
|
1540 | swiper.updateProgress(translate);
|
1541 | }
|
1542 | swiper.emit('setTranslate', swiper.translate, byController);
|
1543 | }
|
1544 |
|
1545 | function minTranslate() {
|
1546 | return -this.snapGrid[0];
|
1547 | }
|
1548 |
|
1549 | function maxTranslate() {
|
1550 | return -this.snapGrid[this.snapGrid.length - 1];
|
1551 | }
|
1552 |
|
1553 | function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
|
1554 | if (translate === void 0) {
|
1555 | translate = 0;
|
1556 | }
|
1557 | if (speed === void 0) {
|
1558 | speed = this.params.speed;
|
1559 | }
|
1560 | if (runCallbacks === void 0) {
|
1561 | runCallbacks = true;
|
1562 | }
|
1563 | if (translateBounds === void 0) {
|
1564 | translateBounds = true;
|
1565 | }
|
1566 | const swiper = this;
|
1567 | const {
|
1568 | params,
|
1569 | wrapperEl
|
1570 | } = swiper;
|
1571 | if (swiper.animating && params.preventInteractionOnTransition) {
|
1572 | return false;
|
1573 | }
|
1574 | const minTranslate = swiper.minTranslate();
|
1575 | const maxTranslate = swiper.maxTranslate();
|
1576 | let newTranslate;
|
1577 | if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
|
1578 |
|
1579 |
|
1580 | swiper.updateProgress(newTranslate);
|
1581 | if (params.cssMode) {
|
1582 | const isH = swiper.isHorizontal();
|
1583 | if (speed === 0) {
|
1584 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
1585 | } else {
|
1586 | if (!swiper.support.smoothScroll) {
|
1587 | animateCSSModeScroll({
|
1588 | swiper,
|
1589 | targetPosition: -newTranslate,
|
1590 | side: isH ? 'left' : 'top'
|
1591 | });
|
1592 | return true;
|
1593 | }
|
1594 | wrapperEl.scrollTo({
|
1595 | [isH ? 'left' : 'top']: -newTranslate,
|
1596 | behavior: 'smooth'
|
1597 | });
|
1598 | }
|
1599 | return true;
|
1600 | }
|
1601 | if (speed === 0) {
|
1602 | swiper.setTransition(0);
|
1603 | swiper.setTranslate(newTranslate);
|
1604 | if (runCallbacks) {
|
1605 | swiper.emit('beforeTransitionStart', speed, internal);
|
1606 | swiper.emit('transitionEnd');
|
1607 | }
|
1608 | } else {
|
1609 | swiper.setTransition(speed);
|
1610 | swiper.setTranslate(newTranslate);
|
1611 | if (runCallbacks) {
|
1612 | swiper.emit('beforeTransitionStart', speed, internal);
|
1613 | swiper.emit('transitionStart');
|
1614 | }
|
1615 | if (!swiper.animating) {
|
1616 | swiper.animating = true;
|
1617 | if (!swiper.onTranslateToWrapperTransitionEnd) {
|
1618 | swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
|
1619 | if (!swiper || swiper.destroyed) return;
|
1620 | if (e.target !== this) return;
|
1621 | swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
1622 | swiper.onTranslateToWrapperTransitionEnd = null;
|
1623 | delete swiper.onTranslateToWrapperTransitionEnd;
|
1624 | if (runCallbacks) {
|
1625 | swiper.emit('transitionEnd');
|
1626 | }
|
1627 | };
|
1628 | }
|
1629 | swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
1630 | }
|
1631 | }
|
1632 | return true;
|
1633 | }
|
1634 |
|
1635 | var translate = {
|
1636 | getTranslate: getSwiperTranslate,
|
1637 | setTranslate,
|
1638 | minTranslate,
|
1639 | maxTranslate,
|
1640 | translateTo
|
1641 | };
|
1642 |
|
1643 | function setTransition(duration, byController) {
|
1644 | const swiper = this;
|
1645 | if (!swiper.params.cssMode) {
|
1646 | swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
|
1647 | }
|
1648 | swiper.emit('setTransition', duration, byController);
|
1649 | }
|
1650 |
|
1651 | function transitionEmit(_ref) {
|
1652 | let {
|
1653 | swiper,
|
1654 | runCallbacks,
|
1655 | direction,
|
1656 | step
|
1657 | } = _ref;
|
1658 | const {
|
1659 | activeIndex,
|
1660 | previousIndex
|
1661 | } = swiper;
|
1662 | let dir = direction;
|
1663 | if (!dir) {
|
1664 | if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
|
1665 | }
|
1666 | swiper.emit(`transition${step}`);
|
1667 | if (runCallbacks && activeIndex !== previousIndex) {
|
1668 | if (dir === 'reset') {
|
1669 | swiper.emit(`slideResetTransition${step}`);
|
1670 | return;
|
1671 | }
|
1672 | swiper.emit(`slideChangeTransition${step}`);
|
1673 | if (dir === 'next') {
|
1674 | swiper.emit(`slideNextTransition${step}`);
|
1675 | } else {
|
1676 | swiper.emit(`slidePrevTransition${step}`);
|
1677 | }
|
1678 | }
|
1679 | }
|
1680 |
|
1681 | function transitionStart(runCallbacks, direction) {
|
1682 | if (runCallbacks === void 0) {
|
1683 | runCallbacks = true;
|
1684 | }
|
1685 | const swiper = this;
|
1686 | const {
|
1687 | params
|
1688 | } = swiper;
|
1689 | if (params.cssMode) return;
|
1690 | if (params.autoHeight) {
|
1691 | swiper.updateAutoHeight();
|
1692 | }
|
1693 | transitionEmit({
|
1694 | swiper,
|
1695 | runCallbacks,
|
1696 | direction,
|
1697 | step: 'Start'
|
1698 | });
|
1699 | }
|
1700 |
|
1701 | function transitionEnd(runCallbacks, direction) {
|
1702 | if (runCallbacks === void 0) {
|
1703 | runCallbacks = true;
|
1704 | }
|
1705 | const swiper = this;
|
1706 | const {
|
1707 | params
|
1708 | } = swiper;
|
1709 | swiper.animating = false;
|
1710 | if (params.cssMode) return;
|
1711 | swiper.setTransition(0);
|
1712 | transitionEmit({
|
1713 | swiper,
|
1714 | runCallbacks,
|
1715 | direction,
|
1716 | step: 'End'
|
1717 | });
|
1718 | }
|
1719 |
|
1720 | var transition = {
|
1721 | setTransition,
|
1722 | transitionStart,
|
1723 | transitionEnd
|
1724 | };
|
1725 |
|
1726 | function slideTo(index, speed, runCallbacks, internal, initial) {
|
1727 | if (index === void 0) {
|
1728 | index = 0;
|
1729 | }
|
1730 | if (speed === void 0) {
|
1731 | speed = this.params.speed;
|
1732 | }
|
1733 | if (runCallbacks === void 0) {
|
1734 | runCallbacks = true;
|
1735 | }
|
1736 | if (typeof index === 'string') {
|
1737 | index = parseInt(index, 10);
|
1738 | }
|
1739 | const swiper = this;
|
1740 | let slideIndex = index;
|
1741 | if (slideIndex < 0) slideIndex = 0;
|
1742 | const {
|
1743 | params,
|
1744 | snapGrid,
|
1745 | slidesGrid,
|
1746 | previousIndex,
|
1747 | activeIndex,
|
1748 | rtlTranslate: rtl,
|
1749 | wrapperEl,
|
1750 | enabled
|
1751 | } = swiper;
|
1752 | if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
|
1753 | return false;
|
1754 | }
|
1755 | const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
1756 | let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
1757 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
1758 | const translate = -snapGrid[snapIndex];
|
1759 |
|
1760 | if (params.normalizeSlideIndex) {
|
1761 | for (let i = 0; i < slidesGrid.length; i += 1) {
|
1762 | const normalizedTranslate = -Math.floor(translate * 100);
|
1763 | const normalizedGrid = Math.floor(slidesGrid[i] * 100);
|
1764 | const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
|
1765 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
1766 | if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
|
1767 | slideIndex = i;
|
1768 | } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
|
1769 | slideIndex = i + 1;
|
1770 | }
|
1771 | } else if (normalizedTranslate >= normalizedGrid) {
|
1772 | slideIndex = i;
|
1773 | }
|
1774 | }
|
1775 | }
|
1776 |
|
1777 | if (swiper.initialized && slideIndex !== activeIndex) {
|
1778 | if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
1779 | return false;
|
1780 | }
|
1781 | if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
1782 | if ((activeIndex || 0) !== slideIndex) {
|
1783 | return false;
|
1784 | }
|
1785 | }
|
1786 | }
|
1787 | if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
1788 | swiper.emit('beforeSlideChangeStart');
|
1789 | }
|
1790 |
|
1791 |
|
1792 | swiper.updateProgress(translate);
|
1793 | let direction;
|
1794 | if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
1795 |
|
1796 |
|
1797 | if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
1798 | swiper.updateActiveIndex(slideIndex);
|
1799 |
|
1800 | if (params.autoHeight) {
|
1801 | swiper.updateAutoHeight();
|
1802 | }
|
1803 | swiper.updateSlidesClasses();
|
1804 | if (params.effect !== 'slide') {
|
1805 | swiper.setTranslate(translate);
|
1806 | }
|
1807 | if (direction !== 'reset') {
|
1808 | swiper.transitionStart(runCallbacks, direction);
|
1809 | swiper.transitionEnd(runCallbacks, direction);
|
1810 | }
|
1811 | return false;
|
1812 | }
|
1813 | if (params.cssMode) {
|
1814 | const isH = swiper.isHorizontal();
|
1815 | const t = rtl ? translate : -translate;
|
1816 | if (speed === 0) {
|
1817 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
1818 | if (isVirtual) {
|
1819 | swiper.wrapperEl.style.scrollSnapType = 'none';
|
1820 | swiper._immediateVirtual = true;
|
1821 | }
|
1822 | if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
1823 | swiper._cssModeVirtualInitialSet = true;
|
1824 | requestAnimationFrame(() => {
|
1825 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
1826 | });
|
1827 | } else {
|
1828 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
1829 | }
|
1830 | if (isVirtual) {
|
1831 | requestAnimationFrame(() => {
|
1832 | swiper.wrapperEl.style.scrollSnapType = '';
|
1833 | swiper._immediateVirtual = false;
|
1834 | });
|
1835 | }
|
1836 | } else {
|
1837 | if (!swiper.support.smoothScroll) {
|
1838 | animateCSSModeScroll({
|
1839 | swiper,
|
1840 | targetPosition: t,
|
1841 | side: isH ? 'left' : 'top'
|
1842 | });
|
1843 | return true;
|
1844 | }
|
1845 | wrapperEl.scrollTo({
|
1846 | [isH ? 'left' : 'top']: t,
|
1847 | behavior: 'smooth'
|
1848 | });
|
1849 | }
|
1850 | return true;
|
1851 | }
|
1852 | swiper.setTransition(speed);
|
1853 | swiper.setTranslate(translate);
|
1854 | swiper.updateActiveIndex(slideIndex);
|
1855 | swiper.updateSlidesClasses();
|
1856 | swiper.emit('beforeTransitionStart', speed, internal);
|
1857 | swiper.transitionStart(runCallbacks, direction);
|
1858 | if (speed === 0) {
|
1859 | swiper.transitionEnd(runCallbacks, direction);
|
1860 | } else if (!swiper.animating) {
|
1861 | swiper.animating = true;
|
1862 | if (!swiper.onSlideToWrapperTransitionEnd) {
|
1863 | swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
|
1864 | if (!swiper || swiper.destroyed) return;
|
1865 | if (e.target !== this) return;
|
1866 | swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
1867 | swiper.onSlideToWrapperTransitionEnd = null;
|
1868 | delete swiper.onSlideToWrapperTransitionEnd;
|
1869 | swiper.transitionEnd(runCallbacks, direction);
|
1870 | };
|
1871 | }
|
1872 | swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
1873 | }
|
1874 | return true;
|
1875 | }
|
1876 |
|
1877 | function slideToLoop(index, speed, runCallbacks, internal) {
|
1878 | if (index === void 0) {
|
1879 | index = 0;
|
1880 | }
|
1881 | if (speed === void 0) {
|
1882 | speed = this.params.speed;
|
1883 | }
|
1884 | if (runCallbacks === void 0) {
|
1885 | runCallbacks = true;
|
1886 | }
|
1887 | if (typeof index === 'string') {
|
1888 | const indexAsNumber = parseInt(index, 10);
|
1889 | index = indexAsNumber;
|
1890 | }
|
1891 | const swiper = this;
|
1892 | let newIndex = index;
|
1893 | if (swiper.params.loop) {
|
1894 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
1895 |
|
1896 | newIndex = newIndex + swiper.virtual.slidesBefore;
|
1897 | } else {
|
1898 | newIndex = swiper.getSlideIndexByData(newIndex);
|
1899 | }
|
1900 | }
|
1901 | return swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
1902 | }
|
1903 |
|
1904 |
|
1905 | function slideNext(speed, runCallbacks, internal) {
|
1906 | if (speed === void 0) {
|
1907 | speed = this.params.speed;
|
1908 | }
|
1909 | if (runCallbacks === void 0) {
|
1910 | runCallbacks = true;
|
1911 | }
|
1912 | const swiper = this;
|
1913 | const {
|
1914 | enabled,
|
1915 | params,
|
1916 | animating
|
1917 | } = swiper;
|
1918 | if (!enabled) return swiper;
|
1919 | let perGroup = params.slidesPerGroup;
|
1920 | if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
1921 | perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
1922 | }
|
1923 | const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
1924 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
1925 | if (params.loop) {
|
1926 | if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
1927 | swiper.loopFix({
|
1928 | direction: 'next'
|
1929 | });
|
1930 |
|
1931 | swiper._clientLeft = swiper.wrapperEl.clientLeft;
|
1932 | }
|
1933 | if (params.rewind && swiper.isEnd) {
|
1934 | return swiper.slideTo(0, speed, runCallbacks, internal);
|
1935 | }
|
1936 | return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
1937 | }
|
1938 |
|
1939 |
|
1940 | function slidePrev(speed, runCallbacks, internal) {
|
1941 | if (speed === void 0) {
|
1942 | speed = this.params.speed;
|
1943 | }
|
1944 | if (runCallbacks === void 0) {
|
1945 | runCallbacks = true;
|
1946 | }
|
1947 | const swiper = this;
|
1948 | const {
|
1949 | params,
|
1950 | snapGrid,
|
1951 | slidesGrid,
|
1952 | rtlTranslate,
|
1953 | enabled,
|
1954 | animating
|
1955 | } = swiper;
|
1956 | if (!enabled) return swiper;
|
1957 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
1958 | if (params.loop) {
|
1959 | if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
1960 | swiper.loopFix({
|
1961 | direction: 'prev'
|
1962 | });
|
1963 |
|
1964 | swiper._clientLeft = swiper.wrapperEl.clientLeft;
|
1965 | }
|
1966 | const translate = rtlTranslate ? swiper.translate : -swiper.translate;
|
1967 | function normalize(val) {
|
1968 | if (val < 0) return -Math.floor(Math.abs(val));
|
1969 | return Math.floor(val);
|
1970 | }
|
1971 | const normalizedTranslate = normalize(translate);
|
1972 | const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
1973 | let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
1974 | if (typeof prevSnap === 'undefined' && params.cssMode) {
|
1975 | let prevSnapIndex;
|
1976 | snapGrid.forEach((snap, snapIndex) => {
|
1977 | if (normalizedTranslate >= snap) {
|
1978 |
|
1979 | prevSnapIndex = snapIndex;
|
1980 | }
|
1981 | });
|
1982 | if (typeof prevSnapIndex !== 'undefined') {
|
1983 | prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
1984 | }
|
1985 | }
|
1986 | let prevIndex = 0;
|
1987 | if (typeof prevSnap !== 'undefined') {
|
1988 | prevIndex = slidesGrid.indexOf(prevSnap);
|
1989 | if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
|
1990 | if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
1991 | prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
|
1992 | prevIndex = Math.max(prevIndex, 0);
|
1993 | }
|
1994 | }
|
1995 | if (params.rewind && swiper.isBeginning) {
|
1996 | const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
1997 | return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
1998 | }
|
1999 | return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
2000 | }
|
2001 |
|
2002 |
|
2003 | function slideReset(speed, runCallbacks, internal) {
|
2004 | if (speed === void 0) {
|
2005 | speed = this.params.speed;
|
2006 | }
|
2007 | if (runCallbacks === void 0) {
|
2008 | runCallbacks = true;
|
2009 | }
|
2010 | const swiper = this;
|
2011 | return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
2012 | }
|
2013 |
|
2014 |
|
2015 | function slideToClosest(speed, runCallbacks, internal, threshold) {
|
2016 | if (speed === void 0) {
|
2017 | speed = this.params.speed;
|
2018 | }
|
2019 | if (runCallbacks === void 0) {
|
2020 | runCallbacks = true;
|
2021 | }
|
2022 | if (threshold === void 0) {
|
2023 | threshold = 0.5;
|
2024 | }
|
2025 | const swiper = this;
|
2026 | let index = swiper.activeIndex;
|
2027 | const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
2028 | const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
2029 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
2030 | if (translate >= swiper.snapGrid[snapIndex]) {
|
2031 |
|
2032 |
|
2033 | const currentSnap = swiper.snapGrid[snapIndex];
|
2034 | const nextSnap = swiper.snapGrid[snapIndex + 1];
|
2035 | if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
|
2036 | index += swiper.params.slidesPerGroup;
|
2037 | }
|
2038 | } else {
|
2039 |
|
2040 |
|
2041 | const prevSnap = swiper.snapGrid[snapIndex - 1];
|
2042 | const currentSnap = swiper.snapGrid[snapIndex];
|
2043 | if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
|
2044 | index -= swiper.params.slidesPerGroup;
|
2045 | }
|
2046 | }
|
2047 | index = Math.max(index, 0);
|
2048 | index = Math.min(index, swiper.slidesGrid.length - 1);
|
2049 | return swiper.slideTo(index, speed, runCallbacks, internal);
|
2050 | }
|
2051 |
|
2052 | function slideToClickedSlide() {
|
2053 | const swiper = this;
|
2054 | const {
|
2055 | params,
|
2056 | slidesEl
|
2057 | } = swiper;
|
2058 | const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
2059 | let slideToIndex = swiper.clickedIndex;
|
2060 | let realIndex;
|
2061 | const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
2062 | if (params.loop) {
|
2063 | if (swiper.animating) return;
|
2064 | realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
2065 | if (params.centeredSlides) {
|
2066 | if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
|
2067 | swiper.loopFix();
|
2068 | slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
2069 | nextTick(() => {
|
2070 | swiper.slideTo(slideToIndex);
|
2071 | });
|
2072 | } else {
|
2073 | swiper.slideTo(slideToIndex);
|
2074 | }
|
2075 | } else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
2076 | swiper.loopFix();
|
2077 | slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
2078 | nextTick(() => {
|
2079 | swiper.slideTo(slideToIndex);
|
2080 | });
|
2081 | } else {
|
2082 | swiper.slideTo(slideToIndex);
|
2083 | }
|
2084 | } else {
|
2085 | swiper.slideTo(slideToIndex);
|
2086 | }
|
2087 | }
|
2088 |
|
2089 | var slide = {
|
2090 | slideTo,
|
2091 | slideToLoop,
|
2092 | slideNext,
|
2093 | slidePrev,
|
2094 | slideReset,
|
2095 | slideToClosest,
|
2096 | slideToClickedSlide
|
2097 | };
|
2098 |
|
2099 | function loopCreate(slideRealIndex) {
|
2100 | const swiper = this;
|
2101 | const {
|
2102 | params,
|
2103 | slidesEl
|
2104 | } = swiper;
|
2105 | if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
2106 | const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
2107 | slides.forEach((el, index) => {
|
2108 | el.setAttribute('data-swiper-slide-index', index);
|
2109 | });
|
2110 | swiper.loopFix({
|
2111 | slideRealIndex,
|
2112 | direction: params.centeredSlides ? undefined : 'next'
|
2113 | });
|
2114 | }
|
2115 |
|
2116 | function loopFix(_temp) {
|
2117 | let {
|
2118 | slideRealIndex,
|
2119 | slideTo = true,
|
2120 | direction,
|
2121 | setTranslate,
|
2122 | activeSlideIndex,
|
2123 | byController,
|
2124 | byMousewheel
|
2125 | } = _temp === void 0 ? {} : _temp;
|
2126 | const swiper = this;
|
2127 | if (!swiper.params.loop) return;
|
2128 | swiper.emit('beforeLoopFix');
|
2129 | const {
|
2130 | slides,
|
2131 | allowSlidePrev,
|
2132 | allowSlideNext,
|
2133 | slidesEl,
|
2134 | params
|
2135 | } = swiper;
|
2136 | swiper.allowSlidePrev = true;
|
2137 | swiper.allowSlideNext = true;
|
2138 | if (swiper.virtual && params.virtual.enabled) {
|
2139 | if (slideTo) {
|
2140 | if (!params.centeredSlides && swiper.snapIndex === 0) {
|
2141 | swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
2142 | } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
2143 | swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
2144 | } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
2145 | swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
2146 | }
|
2147 | }
|
2148 | swiper.allowSlidePrev = allowSlidePrev;
|
2149 | swiper.allowSlideNext = allowSlideNext;
|
2150 | swiper.emit('loopFix');
|
2151 | return;
|
2152 | }
|
2153 | const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
2154 | let loopedSlides = params.loopedSlides || slidesPerView;
|
2155 | if (loopedSlides % params.slidesPerGroup !== 0) {
|
2156 | loopedSlides += params.slidesPerGroup - loopedSlides % params.slidesPerGroup;
|
2157 | }
|
2158 | swiper.loopedSlides = loopedSlides;
|
2159 | const prependSlidesIndexes = [];
|
2160 | const appendSlidesIndexes = [];
|
2161 | let activeIndex = swiper.activeIndex;
|
2162 | if (typeof activeSlideIndex === 'undefined') {
|
2163 | activeSlideIndex = swiper.getSlideIndex(swiper.slides.filter(el => el.classList.contains(params.slideActiveClass))[0]);
|
2164 | } else {
|
2165 | activeIndex = activeSlideIndex;
|
2166 | }
|
2167 | const isNext = direction === 'next' || !direction;
|
2168 | const isPrev = direction === 'prev' || !direction;
|
2169 | let slidesPrepended = 0;
|
2170 | let slidesAppended = 0;
|
2171 |
|
2172 | if (activeSlideIndex < loopedSlides) {
|
2173 | slidesPrepended = Math.max(loopedSlides - activeSlideIndex, params.slidesPerGroup);
|
2174 | for (let i = 0; i < loopedSlides - activeSlideIndex; i += 1) {
|
2175 | const index = i - Math.floor(i / slides.length) * slides.length;
|
2176 | prependSlidesIndexes.push(slides.length - index - 1);
|
2177 | }
|
2178 | } else if (activeSlideIndex > swiper.slides.length - loopedSlides * 2) {
|
2179 | slidesAppended = Math.max(activeSlideIndex - (swiper.slides.length - loopedSlides * 2), params.slidesPerGroup);
|
2180 | for (let i = 0; i < slidesAppended; i += 1) {
|
2181 | const index = i - Math.floor(i / slides.length) * slides.length;
|
2182 | appendSlidesIndexes.push(index);
|
2183 | }
|
2184 | }
|
2185 | if (isPrev) {
|
2186 | prependSlidesIndexes.forEach(index => {
|
2187 | swiper.slides[index].swiperLoopMoveDOM = true;
|
2188 | slidesEl.prepend(swiper.slides[index]);
|
2189 | swiper.slides[index].swiperLoopMoveDOM = false;
|
2190 | });
|
2191 | }
|
2192 | if (isNext) {
|
2193 | appendSlidesIndexes.forEach(index => {
|
2194 | swiper.slides[index].swiperLoopMoveDOM = true;
|
2195 | slidesEl.append(swiper.slides[index]);
|
2196 | swiper.slides[index].swiperLoopMoveDOM = false;
|
2197 | });
|
2198 | }
|
2199 | swiper.recalcSlides();
|
2200 | if (params.slidesPerView === 'auto') {
|
2201 | swiper.updateSlides();
|
2202 | }
|
2203 | if (params.watchSlidesProgress) {
|
2204 | swiper.updateSlidesOffset();
|
2205 | }
|
2206 | if (slideTo) {
|
2207 | if (prependSlidesIndexes.length > 0 && isPrev) {
|
2208 | if (typeof slideRealIndex === 'undefined') {
|
2209 | const currentSlideTranslate = swiper.slidesGrid[activeIndex];
|
2210 | const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
|
2211 | const diff = newSlideTranslate - currentSlideTranslate;
|
2212 | if (byMousewheel) {
|
2213 | swiper.setTranslate(swiper.translate - diff);
|
2214 | } else {
|
2215 | swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
|
2216 | if (setTranslate) {
|
2217 | swiper.touches[swiper.isHorizontal() ? 'startX' : 'startY'] += diff;
|
2218 | }
|
2219 | }
|
2220 | } else {
|
2221 | if (setTranslate) {
|
2222 | swiper.slideToLoop(slideRealIndex, 0, false, true);
|
2223 | }
|
2224 | }
|
2225 | } else if (appendSlidesIndexes.length > 0 && isNext) {
|
2226 | if (typeof slideRealIndex === 'undefined') {
|
2227 | const currentSlideTranslate = swiper.slidesGrid[activeIndex];
|
2228 | const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
|
2229 | const diff = newSlideTranslate - currentSlideTranslate;
|
2230 | if (byMousewheel) {
|
2231 | swiper.setTranslate(swiper.translate - diff);
|
2232 | } else {
|
2233 | swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
|
2234 | if (setTranslate) {
|
2235 | swiper.touches[swiper.isHorizontal() ? 'startX' : 'startY'] += diff;
|
2236 | }
|
2237 | }
|
2238 | } else {
|
2239 | swiper.slideToLoop(slideRealIndex, 0, false, true);
|
2240 | }
|
2241 | }
|
2242 | }
|
2243 | swiper.allowSlidePrev = allowSlidePrev;
|
2244 | swiper.allowSlideNext = allowSlideNext;
|
2245 | if (swiper.controller && swiper.controller.control && !byController) {
|
2246 | const loopParams = {
|
2247 | slideRealIndex,
|
2248 | slideTo: false,
|
2249 | direction,
|
2250 | setTranslate,
|
2251 | activeSlideIndex,
|
2252 | byController: true
|
2253 | };
|
2254 | if (Array.isArray(swiper.controller.control)) {
|
2255 | swiper.controller.control.forEach(c => {
|
2256 | if (!c.destroyed && c.params.loop) c.loopFix(loopParams);
|
2257 | });
|
2258 | } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
2259 | swiper.controller.control.loopFix(loopParams);
|
2260 | }
|
2261 | }
|
2262 | swiper.emit('loopFix');
|
2263 | }
|
2264 |
|
2265 | function loopDestroy() {
|
2266 | const swiper = this;
|
2267 | const {
|
2268 | params,
|
2269 | slidesEl
|
2270 | } = swiper;
|
2271 | if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
2272 | swiper.recalcSlides();
|
2273 | const newSlidesOrder = [];
|
2274 | swiper.slides.forEach(slideEl => {
|
2275 | const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
|
2276 | newSlidesOrder[index] = slideEl;
|
2277 | });
|
2278 | swiper.slides.forEach(slideEl => {
|
2279 | slideEl.removeAttribute('data-swiper-slide-index');
|
2280 | });
|
2281 | newSlidesOrder.forEach(slideEl => {
|
2282 | slidesEl.append(slideEl);
|
2283 | });
|
2284 | swiper.recalcSlides();
|
2285 | swiper.slideTo(swiper.realIndex, 0);
|
2286 | }
|
2287 |
|
2288 | var loop = {
|
2289 | loopCreate,
|
2290 | loopFix,
|
2291 | loopDestroy
|
2292 | };
|
2293 |
|
2294 | function setGrabCursor(moving) {
|
2295 | const swiper = this;
|
2296 | if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
|
2297 | const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
|
2298 | if (swiper.isElement) {
|
2299 | swiper.__preventObserver__ = true;
|
2300 | }
|
2301 | el.style.cursor = 'move';
|
2302 | el.style.cursor = moving ? 'grabbing' : 'grab';
|
2303 | if (swiper.isElement) {
|
2304 | requestAnimationFrame(() => {
|
2305 | swiper.__preventObserver__ = false;
|
2306 | });
|
2307 | }
|
2308 | }
|
2309 |
|
2310 | function unsetGrabCursor() {
|
2311 | const swiper = this;
|
2312 | if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
|
2313 | return;
|
2314 | }
|
2315 | if (swiper.isElement) {
|
2316 | swiper.__preventObserver__ = true;
|
2317 | }
|
2318 | swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
|
2319 | if (swiper.isElement) {
|
2320 | requestAnimationFrame(() => {
|
2321 | swiper.__preventObserver__ = false;
|
2322 | });
|
2323 | }
|
2324 | }
|
2325 |
|
2326 | var grabCursor = {
|
2327 | setGrabCursor,
|
2328 | unsetGrabCursor
|
2329 | };
|
2330 |
|
2331 |
|
2332 | function closestElement(selector, base) {
|
2333 | if (base === void 0) {
|
2334 | base = this;
|
2335 | }
|
2336 | function __closestFrom(el) {
|
2337 | if (!el || el === getDocument() || el === getWindow()) return null;
|
2338 | if (el.assignedSlot) el = el.assignedSlot;
|
2339 | const found = el.closest(selector);
|
2340 | if (!found && !el.getRootNode) {
|
2341 | return null;
|
2342 | }
|
2343 | return found || __closestFrom(el.getRootNode().host);
|
2344 | }
|
2345 | return __closestFrom(base);
|
2346 | }
|
2347 | function onTouchStart(event) {
|
2348 | const swiper = this;
|
2349 | const document = getDocument();
|
2350 | const window = getWindow();
|
2351 | const data = swiper.touchEventsData;
|
2352 | data.evCache.push(event);
|
2353 | const {
|
2354 | params,
|
2355 | touches,
|
2356 | enabled
|
2357 | } = swiper;
|
2358 | if (!enabled) return;
|
2359 | if (!params.simulateTouch && event.pointerType === 'mouse') return;
|
2360 | if (swiper.animating && params.preventInteractionOnTransition) {
|
2361 | return;
|
2362 | }
|
2363 | if (!swiper.animating && params.cssMode && params.loop) {
|
2364 | swiper.loopFix();
|
2365 | }
|
2366 | let e = event;
|
2367 | if (e.originalEvent) e = e.originalEvent;
|
2368 | let targetEl = e.target;
|
2369 | if (params.touchEventsTarget === 'wrapper') {
|
2370 | if (!swiper.wrapperEl.contains(targetEl)) return;
|
2371 | }
|
2372 | if ('which' in e && e.which === 3) return;
|
2373 | if ('button' in e && e.button > 0) return;
|
2374 | if (data.isTouched && data.isMoved) return;
|
2375 |
|
2376 |
|
2377 | const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
2378 |
|
2379 | const eventPath = event.composedPath ? event.composedPath() : event.path;
|
2380 | if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
|
2381 | targetEl = eventPath[0];
|
2382 | }
|
2383 | const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
2384 | const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
2385 |
|
2386 |
|
2387 | if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
2388 | swiper.allowClick = true;
|
2389 | return;
|
2390 | }
|
2391 | if (params.swipeHandler) {
|
2392 | if (!targetEl.closest(params.swipeHandler)) return;
|
2393 | }
|
2394 | touches.currentX = e.pageX;
|
2395 | touches.currentY = e.pageY;
|
2396 | const startX = touches.currentX;
|
2397 | const startY = touches.currentY;
|
2398 |
|
2399 |
|
2400 |
|
2401 | const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
|
2402 | const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
|
2403 | if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
2404 | if (edgeSwipeDetection === 'prevent') {
|
2405 | event.preventDefault();
|
2406 | } else {
|
2407 | return;
|
2408 | }
|
2409 | }
|
2410 | Object.assign(data, {
|
2411 | isTouched: true,
|
2412 | isMoved: false,
|
2413 | allowTouchCallbacks: true,
|
2414 | isScrolling: undefined,
|
2415 | startMoving: undefined
|
2416 | });
|
2417 | touches.startX = startX;
|
2418 | touches.startY = startY;
|
2419 | data.touchStartTime = now();
|
2420 | swiper.allowClick = true;
|
2421 | swiper.updateSize();
|
2422 | swiper.swipeDirection = undefined;
|
2423 | if (params.threshold > 0) data.allowThresholdMove = false;
|
2424 | let preventDefault = true;
|
2425 | if (targetEl.matches(data.focusableElements)) {
|
2426 | preventDefault = false;
|
2427 | if (targetEl.nodeName === 'SELECT') {
|
2428 | data.isTouched = false;
|
2429 | }
|
2430 | }
|
2431 | if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl) {
|
2432 | document.activeElement.blur();
|
2433 | }
|
2434 | const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
2435 | if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
2436 | e.preventDefault();
|
2437 | }
|
2438 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
2439 | swiper.freeMode.onTouchStart();
|
2440 | }
|
2441 | swiper.emit('touchStart', e);
|
2442 | }
|
2443 |
|
2444 | function onTouchMove(event) {
|
2445 | const document = getDocument();
|
2446 | const swiper = this;
|
2447 | const data = swiper.touchEventsData;
|
2448 | const {
|
2449 | params,
|
2450 | touches,
|
2451 | rtlTranslate: rtl,
|
2452 | enabled
|
2453 | } = swiper;
|
2454 | if (!enabled) return;
|
2455 | if (!params.simulateTouch && event.pointerType === 'mouse') return;
|
2456 | let e = event;
|
2457 | if (e.originalEvent) e = e.originalEvent;
|
2458 | if (!data.isTouched) {
|
2459 | if (data.startMoving && data.isScrolling) {
|
2460 | swiper.emit('touchMoveOpposite', e);
|
2461 | }
|
2462 | return;
|
2463 | }
|
2464 | const pointerIndex = data.evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
|
2465 | if (pointerIndex >= 0) data.evCache[pointerIndex] = e;
|
2466 | const targetTouch = data.evCache.length > 1 ? data.evCache[0] : e;
|
2467 | const pageX = targetTouch.pageX;
|
2468 | const pageY = targetTouch.pageY;
|
2469 | if (e.preventedByNestedSwiper) {
|
2470 | touches.startX = pageX;
|
2471 | touches.startY = pageY;
|
2472 | return;
|
2473 | }
|
2474 | if (!swiper.allowTouchMove) {
|
2475 | if (!e.target.matches(data.focusableElements)) {
|
2476 | swiper.allowClick = false;
|
2477 | }
|
2478 | if (data.isTouched) {
|
2479 | Object.assign(touches, {
|
2480 | startX: pageX,
|
2481 | startY: pageY,
|
2482 | prevX: swiper.touches.currentX,
|
2483 | prevY: swiper.touches.currentY,
|
2484 | currentX: pageX,
|
2485 | currentY: pageY
|
2486 | });
|
2487 | data.touchStartTime = now();
|
2488 | }
|
2489 | return;
|
2490 | }
|
2491 | if (params.touchReleaseOnEdges && !params.loop) {
|
2492 | if (swiper.isVertical()) {
|
2493 |
|
2494 | if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
2495 | data.isTouched = false;
|
2496 | data.isMoved = false;
|
2497 | return;
|
2498 | }
|
2499 | } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
|
2500 | return;
|
2501 | }
|
2502 | }
|
2503 | if (document.activeElement) {
|
2504 | if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
|
2505 | data.isMoved = true;
|
2506 | swiper.allowClick = false;
|
2507 | return;
|
2508 | }
|
2509 | }
|
2510 | if (data.allowTouchCallbacks) {
|
2511 | swiper.emit('touchMove', e);
|
2512 | }
|
2513 | if (e.targetTouches && e.targetTouches.length > 1) return;
|
2514 | touches.currentX = pageX;
|
2515 | touches.currentY = pageY;
|
2516 | const diffX = touches.currentX - touches.startX;
|
2517 | const diffY = touches.currentY - touches.startY;
|
2518 | if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
|
2519 | if (typeof data.isScrolling === 'undefined') {
|
2520 | let touchAngle;
|
2521 | if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
|
2522 | data.isScrolling = false;
|
2523 | } else {
|
2524 |
|
2525 | if (diffX * diffX + diffY * diffY >= 25) {
|
2526 | touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
|
2527 | data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
|
2528 | }
|
2529 | }
|
2530 | }
|
2531 | if (data.isScrolling) {
|
2532 | swiper.emit('touchMoveOpposite', e);
|
2533 | }
|
2534 | if (typeof data.startMoving === 'undefined') {
|
2535 | if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
|
2536 | data.startMoving = true;
|
2537 | }
|
2538 | }
|
2539 | if (data.isScrolling || swiper.zoom && swiper.params.zoom && swiper.params.zoom.enabled && data.evCache.length > 1) {
|
2540 | data.isTouched = false;
|
2541 | return;
|
2542 | }
|
2543 | if (!data.startMoving) {
|
2544 | return;
|
2545 | }
|
2546 | swiper.allowClick = false;
|
2547 | if (!params.cssMode && e.cancelable) {
|
2548 | e.preventDefault();
|
2549 | }
|
2550 | if (params.touchMoveStopPropagation && !params.nested) {
|
2551 | e.stopPropagation();
|
2552 | }
|
2553 | let diff = swiper.isHorizontal() ? diffX : diffY;
|
2554 | let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
|
2555 | if (params.oneWayMovement) {
|
2556 | diff = Math.abs(diff) * (rtl ? 1 : -1);
|
2557 | touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
|
2558 | }
|
2559 | touches.diff = diff;
|
2560 | diff *= params.touchRatio;
|
2561 | if (rtl) {
|
2562 | diff = -diff;
|
2563 | touchesDiff = -touchesDiff;
|
2564 | }
|
2565 | const prevTouchesDirection = swiper.touchesDirection;
|
2566 | swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
2567 | swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
|
2568 | const isLoop = swiper.params.loop && !params.cssMode;
|
2569 | if (!data.isMoved) {
|
2570 | if (isLoop) {
|
2571 | swiper.loopFix({
|
2572 | direction: swiper.swipeDirection
|
2573 | });
|
2574 | }
|
2575 | data.startTranslate = swiper.getTranslate();
|
2576 | swiper.setTransition(0);
|
2577 | if (swiper.animating) {
|
2578 | const evt = new window.CustomEvent('transitionend', {
|
2579 | bubbles: true,
|
2580 | cancelable: true
|
2581 | });
|
2582 | swiper.wrapperEl.dispatchEvent(evt);
|
2583 | }
|
2584 | data.allowMomentumBounce = false;
|
2585 |
|
2586 | if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
2587 | swiper.setGrabCursor(true);
|
2588 | }
|
2589 | swiper.emit('sliderFirstMove', e);
|
2590 | }
|
2591 | let loopFixed;
|
2592 | if (data.isMoved && prevTouchesDirection !== swiper.touchesDirection && isLoop && Math.abs(diff) >= 1) {
|
2593 |
|
2594 | swiper.loopFix({
|
2595 | direction: swiper.swipeDirection,
|
2596 | setTranslate: true
|
2597 | });
|
2598 | loopFixed = true;
|
2599 | }
|
2600 | swiper.emit('sliderMove', e);
|
2601 | data.isMoved = true;
|
2602 | data.currentTranslate = diff + data.startTranslate;
|
2603 | let disableParentSwiper = true;
|
2604 | let resistanceRatio = params.resistanceRatio;
|
2605 | if (params.touchReleaseOnEdges) {
|
2606 | resistanceRatio = 0;
|
2607 | }
|
2608 | if (diff > 0) {
|
2609 | if (isLoop && !loopFixed && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.size / 2 : swiper.minTranslate())) {
|
2610 | swiper.loopFix({
|
2611 | direction: 'prev',
|
2612 | setTranslate: true,
|
2613 | activeSlideIndex: 0
|
2614 | });
|
2615 | }
|
2616 | if (data.currentTranslate > swiper.minTranslate()) {
|
2617 | disableParentSwiper = false;
|
2618 | if (params.resistance) {
|
2619 | data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
|
2620 | }
|
2621 | }
|
2622 | } else if (diff < 0) {
|
2623 | if (isLoop && !loopFixed && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.size / 2 : swiper.maxTranslate())) {
|
2624 | swiper.loopFix({
|
2625 | direction: 'next',
|
2626 | setTranslate: true,
|
2627 | activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
|
2628 | });
|
2629 | }
|
2630 | if (data.currentTranslate < swiper.maxTranslate()) {
|
2631 | disableParentSwiper = false;
|
2632 | if (params.resistance) {
|
2633 | data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
|
2634 | }
|
2635 | }
|
2636 | }
|
2637 | if (disableParentSwiper) {
|
2638 | e.preventedByNestedSwiper = true;
|
2639 | }
|
2640 |
|
2641 |
|
2642 | if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
|
2643 | data.currentTranslate = data.startTranslate;
|
2644 | }
|
2645 | if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
|
2646 | data.currentTranslate = data.startTranslate;
|
2647 | }
|
2648 | if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
2649 | data.currentTranslate = data.startTranslate;
|
2650 | }
|
2651 |
|
2652 |
|
2653 | if (params.threshold > 0) {
|
2654 | if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
2655 | if (!data.allowThresholdMove) {
|
2656 | data.allowThresholdMove = true;
|
2657 | touches.startX = touches.currentX;
|
2658 | touches.startY = touches.currentY;
|
2659 | data.currentTranslate = data.startTranslate;
|
2660 | touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
|
2661 | return;
|
2662 | }
|
2663 | } else {
|
2664 | data.currentTranslate = data.startTranslate;
|
2665 | return;
|
2666 | }
|
2667 | }
|
2668 | if (!params.followFinger || params.cssMode) return;
|
2669 |
|
2670 |
|
2671 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
|
2672 | swiper.updateActiveIndex();
|
2673 | swiper.updateSlidesClasses();
|
2674 | }
|
2675 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
2676 | swiper.freeMode.onTouchMove();
|
2677 | }
|
2678 |
|
2679 | swiper.updateProgress(data.currentTranslate);
|
2680 |
|
2681 | swiper.setTranslate(data.currentTranslate);
|
2682 | }
|
2683 |
|
2684 | function onTouchEnd(event) {
|
2685 | const swiper = this;
|
2686 | const data = swiper.touchEventsData;
|
2687 | const pointerIndex = data.evCache.findIndex(cachedEv => cachedEv.pointerId === event.pointerId);
|
2688 | if (pointerIndex >= 0) {
|
2689 | data.evCache.splice(pointerIndex, 1);
|
2690 | }
|
2691 | if (['pointercancel', 'pointerout', 'pointerleave'].includes(event.type)) {
|
2692 | const proceed = event.type === 'pointercancel' && (swiper.browser.isSafari || swiper.browser.isWebView);
|
2693 | if (!proceed) {
|
2694 | return;
|
2695 | }
|
2696 | }
|
2697 | const {
|
2698 | params,
|
2699 | touches,
|
2700 | rtlTranslate: rtl,
|
2701 | slidesGrid,
|
2702 | enabled
|
2703 | } = swiper;
|
2704 | if (!enabled) return;
|
2705 | if (!params.simulateTouch && event.pointerType === 'mouse') return;
|
2706 | let e = event;
|
2707 | if (e.originalEvent) e = e.originalEvent;
|
2708 | if (data.allowTouchCallbacks) {
|
2709 | swiper.emit('touchEnd', e);
|
2710 | }
|
2711 | data.allowTouchCallbacks = false;
|
2712 | if (!data.isTouched) {
|
2713 | if (data.isMoved && params.grabCursor) {
|
2714 | swiper.setGrabCursor(false);
|
2715 | }
|
2716 | data.isMoved = false;
|
2717 | data.startMoving = false;
|
2718 | return;
|
2719 | }
|
2720 |
|
2721 | if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
2722 | swiper.setGrabCursor(false);
|
2723 | }
|
2724 |
|
2725 |
|
2726 | const touchEndTime = now();
|
2727 | const timeDiff = touchEndTime - data.touchStartTime;
|
2728 |
|
2729 |
|
2730 | if (swiper.allowClick) {
|
2731 | const pathTree = e.path || e.composedPath && e.composedPath();
|
2732 | swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
|
2733 | swiper.emit('tap click', e);
|
2734 | if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
|
2735 | swiper.emit('doubleTap doubleClick', e);
|
2736 | }
|
2737 | }
|
2738 | data.lastClickTime = now();
|
2739 | nextTick(() => {
|
2740 | if (!swiper.destroyed) swiper.allowClick = true;
|
2741 | });
|
2742 | if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
|
2743 | data.isTouched = false;
|
2744 | data.isMoved = false;
|
2745 | data.startMoving = false;
|
2746 | return;
|
2747 | }
|
2748 | data.isTouched = false;
|
2749 | data.isMoved = false;
|
2750 | data.startMoving = false;
|
2751 | let currentPos;
|
2752 | if (params.followFinger) {
|
2753 | currentPos = rtl ? swiper.translate : -swiper.translate;
|
2754 | } else {
|
2755 | currentPos = -data.currentTranslate;
|
2756 | }
|
2757 | if (params.cssMode) {
|
2758 | return;
|
2759 | }
|
2760 | if (params.freeMode && params.freeMode.enabled) {
|
2761 | swiper.freeMode.onTouchEnd({
|
2762 | currentPos
|
2763 | });
|
2764 | return;
|
2765 | }
|
2766 |
|
2767 |
|
2768 | let stopIndex = 0;
|
2769 | let groupSize = swiper.slidesSizesGrid[0];
|
2770 | for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
2771 | const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
2772 | if (typeof slidesGrid[i + increment] !== 'undefined') {
|
2773 | if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
|
2774 | stopIndex = i;
|
2775 | groupSize = slidesGrid[i + increment] - slidesGrid[i];
|
2776 | }
|
2777 | } else if (currentPos >= slidesGrid[i]) {
|
2778 | stopIndex = i;
|
2779 | groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
2780 | }
|
2781 | }
|
2782 | let rewindFirstIndex = null;
|
2783 | let rewindLastIndex = null;
|
2784 | if (params.rewind) {
|
2785 | if (swiper.isBeginning) {
|
2786 | rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
2787 | } else if (swiper.isEnd) {
|
2788 | rewindFirstIndex = 0;
|
2789 | }
|
2790 | }
|
2791 |
|
2792 | const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
2793 | const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
2794 | if (timeDiff > params.longSwipesMs) {
|
2795 |
|
2796 | if (!params.longSwipes) {
|
2797 | swiper.slideTo(swiper.activeIndex);
|
2798 | return;
|
2799 | }
|
2800 | if (swiper.swipeDirection === 'next') {
|
2801 | if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
|
2802 | }
|
2803 | if (swiper.swipeDirection === 'prev') {
|
2804 | if (ratio > 1 - params.longSwipesRatio) {
|
2805 | swiper.slideTo(stopIndex + increment);
|
2806 | } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
|
2807 | swiper.slideTo(rewindLastIndex);
|
2808 | } else {
|
2809 | swiper.slideTo(stopIndex);
|
2810 | }
|
2811 | }
|
2812 | } else {
|
2813 |
|
2814 | if (!params.shortSwipes) {
|
2815 | swiper.slideTo(swiper.activeIndex);
|
2816 | return;
|
2817 | }
|
2818 | const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
|
2819 | if (!isNavButtonTarget) {
|
2820 | if (swiper.swipeDirection === 'next') {
|
2821 | swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
|
2822 | }
|
2823 | if (swiper.swipeDirection === 'prev') {
|
2824 | swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
|
2825 | }
|
2826 | } else if (e.target === swiper.navigation.nextEl) {
|
2827 | swiper.slideTo(stopIndex + increment);
|
2828 | } else {
|
2829 | swiper.slideTo(stopIndex);
|
2830 | }
|
2831 | }
|
2832 | }
|
2833 |
|
2834 | function onResize() {
|
2835 | const swiper = this;
|
2836 | const {
|
2837 | params,
|
2838 | el
|
2839 | } = swiper;
|
2840 | if (el && el.offsetWidth === 0) return;
|
2841 |
|
2842 |
|
2843 | if (params.breakpoints) {
|
2844 | swiper.setBreakpoint();
|
2845 | }
|
2846 |
|
2847 |
|
2848 | const {
|
2849 | allowSlideNext,
|
2850 | allowSlidePrev,
|
2851 | snapGrid
|
2852 | } = swiper;
|
2853 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
2854 |
|
2855 |
|
2856 | swiper.allowSlideNext = true;
|
2857 | swiper.allowSlidePrev = true;
|
2858 | swiper.updateSize();
|
2859 | swiper.updateSlides();
|
2860 | swiper.updateSlidesClasses();
|
2861 | const isVirtualLoop = isVirtual && params.loop;
|
2862 | if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
2863 | swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
2864 | } else {
|
2865 | if (swiper.params.loop && !isVirtual) {
|
2866 | swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
2867 | } else {
|
2868 | swiper.slideTo(swiper.activeIndex, 0, false, true);
|
2869 | }
|
2870 | }
|
2871 | if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
2872 | clearTimeout(swiper.autoplay.resizeTimeout);
|
2873 | swiper.autoplay.resizeTimeout = setTimeout(() => {
|
2874 | if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
2875 | swiper.autoplay.resume();
|
2876 | }
|
2877 | }, 500);
|
2878 | }
|
2879 |
|
2880 | swiper.allowSlidePrev = allowSlidePrev;
|
2881 | swiper.allowSlideNext = allowSlideNext;
|
2882 | if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
2883 | swiper.checkOverflow();
|
2884 | }
|
2885 | }
|
2886 |
|
2887 | function onClick(e) {
|
2888 | const swiper = this;
|
2889 | if (!swiper.enabled) return;
|
2890 | if (!swiper.allowClick) {
|
2891 | if (swiper.params.preventClicks) e.preventDefault();
|
2892 | if (swiper.params.preventClicksPropagation && swiper.animating) {
|
2893 | e.stopPropagation();
|
2894 | e.stopImmediatePropagation();
|
2895 | }
|
2896 | }
|
2897 | }
|
2898 |
|
2899 | function onScroll() {
|
2900 | const swiper = this;
|
2901 | const {
|
2902 | wrapperEl,
|
2903 | rtlTranslate,
|
2904 | enabled
|
2905 | } = swiper;
|
2906 | if (!enabled) return;
|
2907 | swiper.previousTranslate = swiper.translate;
|
2908 | if (swiper.isHorizontal()) {
|
2909 | swiper.translate = -wrapperEl.scrollLeft;
|
2910 | } else {
|
2911 | swiper.translate = -wrapperEl.scrollTop;
|
2912 | }
|
2913 |
|
2914 | if (swiper.translate === 0) swiper.translate = 0;
|
2915 | swiper.updateActiveIndex();
|
2916 | swiper.updateSlidesClasses();
|
2917 | let newProgress;
|
2918 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
2919 | if (translatesDiff === 0) {
|
2920 | newProgress = 0;
|
2921 | } else {
|
2922 | newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
|
2923 | }
|
2924 | if (newProgress !== swiper.progress) {
|
2925 | swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
|
2926 | }
|
2927 | swiper.emit('setTranslate', swiper.translate, false);
|
2928 | }
|
2929 |
|
2930 | function onLoad(e) {
|
2931 | const swiper = this;
|
2932 | processLazyPreloader(swiper, e.target);
|
2933 | if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
2934 | return;
|
2935 | }
|
2936 | swiper.update();
|
2937 | }
|
2938 |
|
2939 | let dummyEventAttached = false;
|
2940 | function dummyEventListener() {}
|
2941 | const events = (swiper, method) => {
|
2942 | const document = getDocument();
|
2943 | const {
|
2944 | params,
|
2945 | el,
|
2946 | wrapperEl,
|
2947 | device
|
2948 | } = swiper;
|
2949 | const capture = !!params.nested;
|
2950 | const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
|
2951 | const swiperMethod = method;
|
2952 |
|
2953 |
|
2954 | el[domMethod]('pointerdown', swiper.onTouchStart, {
|
2955 | passive: false
|
2956 | });
|
2957 | document[domMethod]('pointermove', swiper.onTouchMove, {
|
2958 | passive: false,
|
2959 | capture
|
2960 | });
|
2961 | document[domMethod]('pointerup', swiper.onTouchEnd, {
|
2962 | passive: true
|
2963 | });
|
2964 | document[domMethod]('pointercancel', swiper.onTouchEnd, {
|
2965 | passive: true
|
2966 | });
|
2967 | document[domMethod]('pointerout', swiper.onTouchEnd, {
|
2968 | passive: true
|
2969 | });
|
2970 | document[domMethod]('pointerleave', swiper.onTouchEnd, {
|
2971 | passive: true
|
2972 | });
|
2973 |
|
2974 |
|
2975 | if (params.preventClicks || params.preventClicksPropagation) {
|
2976 | el[domMethod]('click', swiper.onClick, true);
|
2977 | }
|
2978 | if (params.cssMode) {
|
2979 | wrapperEl[domMethod]('scroll', swiper.onScroll);
|
2980 | }
|
2981 |
|
2982 |
|
2983 | if (params.updateOnWindowResize) {
|
2984 | swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
|
2985 | } else {
|
2986 | swiper[swiperMethod]('observerUpdate', onResize, true);
|
2987 | }
|
2988 |
|
2989 |
|
2990 | el[domMethod]('load', swiper.onLoad, {
|
2991 | capture: true
|
2992 | });
|
2993 | };
|
2994 | function attachEvents() {
|
2995 | const swiper = this;
|
2996 | const document = getDocument();
|
2997 | const {
|
2998 | params
|
2999 | } = swiper;
|
3000 | swiper.onTouchStart = onTouchStart.bind(swiper);
|
3001 | swiper.onTouchMove = onTouchMove.bind(swiper);
|
3002 | swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
3003 | if (params.cssMode) {
|
3004 | swiper.onScroll = onScroll.bind(swiper);
|
3005 | }
|
3006 | swiper.onClick = onClick.bind(swiper);
|
3007 | swiper.onLoad = onLoad.bind(swiper);
|
3008 | if (!dummyEventAttached) {
|
3009 | document.addEventListener('touchstart', dummyEventListener);
|
3010 | dummyEventAttached = true;
|
3011 | }
|
3012 | events(swiper, 'on');
|
3013 | }
|
3014 | function detachEvents() {
|
3015 | const swiper = this;
|
3016 | events(swiper, 'off');
|
3017 | }
|
3018 | var events$1 = {
|
3019 | attachEvents,
|
3020 | detachEvents
|
3021 | };
|
3022 |
|
3023 | const isGridEnabled = (swiper, params) => {
|
3024 | return swiper.grid && params.grid && params.grid.rows > 1;
|
3025 | };
|
3026 | function setBreakpoint() {
|
3027 | const swiper = this;
|
3028 | const {
|
3029 | realIndex,
|
3030 | initialized,
|
3031 | params,
|
3032 | el
|
3033 | } = swiper;
|
3034 | const breakpoints = params.breakpoints;
|
3035 | if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
|
3036 |
|
3037 |
|
3038 | const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
|
3039 | if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
3040 | const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
3041 | const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
3042 | const wasMultiRow = isGridEnabled(swiper, params);
|
3043 | const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
3044 | const wasEnabled = params.enabled;
|
3045 | if (wasMultiRow && !isMultiRow) {
|
3046 | el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
3047 | swiper.emitContainerClasses();
|
3048 | } else if (!wasMultiRow && isMultiRow) {
|
3049 | el.classList.add(`${params.containerModifierClass}grid`);
|
3050 | if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
3051 | el.classList.add(`${params.containerModifierClass}grid-column`);
|
3052 | }
|
3053 | swiper.emitContainerClasses();
|
3054 | }
|
3055 |
|
3056 |
|
3057 | ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
|
3058 | if (typeof breakpointParams[prop] === 'undefined') return;
|
3059 | const wasModuleEnabled = params[prop] && params[prop].enabled;
|
3060 | const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
3061 | if (wasModuleEnabled && !isModuleEnabled) {
|
3062 | swiper[prop].disable();
|
3063 | }
|
3064 | if (!wasModuleEnabled && isModuleEnabled) {
|
3065 | swiper[prop].enable();
|
3066 | }
|
3067 | });
|
3068 | const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
3069 | const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
3070 | if (directionChanged && initialized) {
|
3071 | swiper.changeDirection();
|
3072 | }
|
3073 | extend$1(swiper.params, breakpointParams);
|
3074 | const isEnabled = swiper.params.enabled;
|
3075 | Object.assign(swiper, {
|
3076 | allowTouchMove: swiper.params.allowTouchMove,
|
3077 | allowSlideNext: swiper.params.allowSlideNext,
|
3078 | allowSlidePrev: swiper.params.allowSlidePrev
|
3079 | });
|
3080 | if (wasEnabled && !isEnabled) {
|
3081 | swiper.disable();
|
3082 | } else if (!wasEnabled && isEnabled) {
|
3083 | swiper.enable();
|
3084 | }
|
3085 | swiper.currentBreakpoint = breakpoint;
|
3086 | swiper.emit('_beforeBreakpoint', breakpointParams);
|
3087 | if (needsReLoop && initialized) {
|
3088 | swiper.loopDestroy();
|
3089 | swiper.loopCreate(realIndex);
|
3090 | swiper.updateSlides();
|
3091 | }
|
3092 | swiper.emit('breakpoint', breakpointParams);
|
3093 | }
|
3094 |
|
3095 | function getBreakpoint(breakpoints, base, containerEl) {
|
3096 | if (base === void 0) {
|
3097 | base = 'window';
|
3098 | }
|
3099 | if (!breakpoints || base === 'container' && !containerEl) return undefined;
|
3100 | let breakpoint = false;
|
3101 | const window = getWindow();
|
3102 | const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
|
3103 | const points = Object.keys(breakpoints).map(point => {
|
3104 | if (typeof point === 'string' && point.indexOf('@') === 0) {
|
3105 | const minRatio = parseFloat(point.substr(1));
|
3106 | const value = currentHeight * minRatio;
|
3107 | return {
|
3108 | value,
|
3109 | point
|
3110 | };
|
3111 | }
|
3112 | return {
|
3113 | value: point,
|
3114 | point
|
3115 | };
|
3116 | });
|
3117 | points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
|
3118 | for (let i = 0; i < points.length; i += 1) {
|
3119 | const {
|
3120 | point,
|
3121 | value
|
3122 | } = points[i];
|
3123 | if (base === 'window') {
|
3124 | if (window.matchMedia(`(min-width: ${value}px)`).matches) {
|
3125 | breakpoint = point;
|
3126 | }
|
3127 | } else if (value <= containerEl.clientWidth) {
|
3128 | breakpoint = point;
|
3129 | }
|
3130 | }
|
3131 | return breakpoint || 'max';
|
3132 | }
|
3133 |
|
3134 | var breakpoints = {
|
3135 | setBreakpoint,
|
3136 | getBreakpoint
|
3137 | };
|
3138 |
|
3139 | function prepareClasses(entries, prefix) {
|
3140 | const resultClasses = [];
|
3141 | entries.forEach(item => {
|
3142 | if (typeof item === 'object') {
|
3143 | Object.keys(item).forEach(classNames => {
|
3144 | if (item[classNames]) {
|
3145 | resultClasses.push(prefix + classNames);
|
3146 | }
|
3147 | });
|
3148 | } else if (typeof item === 'string') {
|
3149 | resultClasses.push(prefix + item);
|
3150 | }
|
3151 | });
|
3152 | return resultClasses;
|
3153 | }
|
3154 | function addClasses() {
|
3155 | const swiper = this;
|
3156 | const {
|
3157 | classNames,
|
3158 | params,
|
3159 | rtl,
|
3160 | el,
|
3161 | device
|
3162 | } = swiper;
|
3163 |
|
3164 | const suffixes = prepareClasses(['initialized', params.direction, {
|
3165 | 'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
3166 | }, {
|
3167 | 'autoheight': params.autoHeight
|
3168 | }, {
|
3169 | 'rtl': rtl
|
3170 | }, {
|
3171 | 'grid': params.grid && params.grid.rows > 1
|
3172 | }, {
|
3173 | 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
3174 | }, {
|
3175 | 'android': device.android
|
3176 | }, {
|
3177 | 'ios': device.ios
|
3178 | }, {
|
3179 | 'css-mode': params.cssMode
|
3180 | }, {
|
3181 | 'centered': params.cssMode && params.centeredSlides
|
3182 | }, {
|
3183 | 'watch-progress': params.watchSlidesProgress
|
3184 | }], params.containerModifierClass);
|
3185 | classNames.push(...suffixes);
|
3186 | el.classList.add(...classNames);
|
3187 | swiper.emitContainerClasses();
|
3188 | }
|
3189 |
|
3190 | function removeClasses() {
|
3191 | const swiper = this;
|
3192 | const {
|
3193 | el,
|
3194 | classNames
|
3195 | } = swiper;
|
3196 | el.classList.remove(...classNames);
|
3197 | swiper.emitContainerClasses();
|
3198 | }
|
3199 |
|
3200 | var classes = {
|
3201 | addClasses,
|
3202 | removeClasses
|
3203 | };
|
3204 |
|
3205 | function checkOverflow() {
|
3206 | const swiper = this;
|
3207 | const {
|
3208 | isLocked: wasLocked,
|
3209 | params
|
3210 | } = swiper;
|
3211 | const {
|
3212 | slidesOffsetBefore
|
3213 | } = params;
|
3214 | if (slidesOffsetBefore) {
|
3215 | const lastSlideIndex = swiper.slides.length - 1;
|
3216 | const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
|
3217 | swiper.isLocked = swiper.size > lastSlideRightEdge;
|
3218 | } else {
|
3219 | swiper.isLocked = swiper.snapGrid.length === 1;
|
3220 | }
|
3221 | if (params.allowSlideNext === true) {
|
3222 | swiper.allowSlideNext = !swiper.isLocked;
|
3223 | }
|
3224 | if (params.allowSlidePrev === true) {
|
3225 | swiper.allowSlidePrev = !swiper.isLocked;
|
3226 | }
|
3227 | if (wasLocked && wasLocked !== swiper.isLocked) {
|
3228 | swiper.isEnd = false;
|
3229 | }
|
3230 | if (wasLocked !== swiper.isLocked) {
|
3231 | swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
|
3232 | }
|
3233 | }
|
3234 | var checkOverflow$1 = {
|
3235 | checkOverflow
|
3236 | };
|
3237 |
|
3238 | var defaults = {
|
3239 | init: true,
|
3240 | direction: 'horizontal',
|
3241 | oneWayMovement: false,
|
3242 | touchEventsTarget: 'wrapper',
|
3243 | initialSlide: 0,
|
3244 | speed: 300,
|
3245 | cssMode: false,
|
3246 | updateOnWindowResize: true,
|
3247 | resizeObserver: true,
|
3248 | nested: false,
|
3249 | createElements: false,
|
3250 | enabled: true,
|
3251 | focusableElements: 'input, select, option, textarea, button, video, label',
|
3252 |
|
3253 | width: null,
|
3254 | height: null,
|
3255 |
|
3256 | preventInteractionOnTransition: false,
|
3257 |
|
3258 | userAgent: null,
|
3259 | url: null,
|
3260 |
|
3261 | edgeSwipeDetection: false,
|
3262 | edgeSwipeThreshold: 20,
|
3263 |
|
3264 | autoHeight: false,
|
3265 |
|
3266 | setWrapperSize: false,
|
3267 |
|
3268 | virtualTranslate: false,
|
3269 |
|
3270 | effect: 'slide',
|
3271 |
|
3272 |
|
3273 |
|
3274 | breakpoints: undefined,
|
3275 | breakpointsBase: 'window',
|
3276 |
|
3277 | spaceBetween: 0,
|
3278 | slidesPerView: 1,
|
3279 | slidesPerGroup: 1,
|
3280 | slidesPerGroupSkip: 0,
|
3281 | slidesPerGroupAuto: false,
|
3282 | centeredSlides: false,
|
3283 | centeredSlidesBounds: false,
|
3284 | slidesOffsetBefore: 0,
|
3285 |
|
3286 | slidesOffsetAfter: 0,
|
3287 |
|
3288 | normalizeSlideIndex: true,
|
3289 | centerInsufficientSlides: false,
|
3290 |
|
3291 | watchOverflow: true,
|
3292 |
|
3293 | roundLengths: false,
|
3294 |
|
3295 | touchRatio: 1,
|
3296 | touchAngle: 45,
|
3297 | simulateTouch: true,
|
3298 | shortSwipes: true,
|
3299 | longSwipes: true,
|
3300 | longSwipesRatio: 0.5,
|
3301 | longSwipesMs: 300,
|
3302 | followFinger: true,
|
3303 | allowTouchMove: true,
|
3304 | threshold: 5,
|
3305 | touchMoveStopPropagation: false,
|
3306 | touchStartPreventDefault: true,
|
3307 | touchStartForcePreventDefault: false,
|
3308 | touchReleaseOnEdges: false,
|
3309 |
|
3310 | uniqueNavElements: true,
|
3311 |
|
3312 | resistance: true,
|
3313 | resistanceRatio: 0.85,
|
3314 |
|
3315 | watchSlidesProgress: false,
|
3316 |
|
3317 | grabCursor: false,
|
3318 |
|
3319 | preventClicks: true,
|
3320 | preventClicksPropagation: true,
|
3321 | slideToClickedSlide: false,
|
3322 |
|
3323 | loop: false,
|
3324 | loopedSlides: null,
|
3325 | loopPreventsSliding: true,
|
3326 |
|
3327 | rewind: false,
|
3328 |
|
3329 | allowSlidePrev: true,
|
3330 | allowSlideNext: true,
|
3331 | swipeHandler: null,
|
3332 |
|
3333 | noSwiping: true,
|
3334 | noSwipingClass: 'swiper-no-swiping',
|
3335 | noSwipingSelector: null,
|
3336 |
|
3337 | passiveListeners: true,
|
3338 | maxBackfaceHiddenSlides: 10,
|
3339 |
|
3340 | containerModifierClass: 'swiper-',
|
3341 |
|
3342 | slideClass: 'swiper-slide',
|
3343 | slideActiveClass: 'swiper-slide-active',
|
3344 | slideVisibleClass: 'swiper-slide-visible',
|
3345 | slideNextClass: 'swiper-slide-next',
|
3346 | slidePrevClass: 'swiper-slide-prev',
|
3347 | wrapperClass: 'swiper-wrapper',
|
3348 | lazyPreloaderClass: 'swiper-lazy-preloader',
|
3349 | lazyPreloadPrevNext: 0,
|
3350 |
|
3351 | runCallbacksOnInit: true,
|
3352 |
|
3353 | _emitClasses: false
|
3354 | };
|
3355 |
|
3356 | function moduleExtendParams(params, allModulesParams) {
|
3357 | return function extendParams(obj) {
|
3358 | if (obj === void 0) {
|
3359 | obj = {};
|
3360 | }
|
3361 | const moduleParamName = Object.keys(obj)[0];
|
3362 | const moduleParams = obj[moduleParamName];
|
3363 | if (typeof moduleParams !== 'object' || moduleParams === null) {
|
3364 | extend$1(allModulesParams, obj);
|
3365 | return;
|
3366 | }
|
3367 | if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) {
|
3368 | params[moduleParamName] = {
|
3369 | auto: true
|
3370 | };
|
3371 | }
|
3372 | if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
3373 | extend$1(allModulesParams, obj);
|
3374 | return;
|
3375 | }
|
3376 | if (params[moduleParamName] === true) {
|
3377 | params[moduleParamName] = {
|
3378 | enabled: true
|
3379 | };
|
3380 | }
|
3381 | if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
|
3382 | params[moduleParamName].enabled = true;
|
3383 | }
|
3384 | if (!params[moduleParamName]) params[moduleParamName] = {
|
3385 | enabled: false
|
3386 | };
|
3387 | extend$1(allModulesParams, obj);
|
3388 | };
|
3389 | }
|
3390 |
|
3391 |
|
3392 | const prototypes = {
|
3393 | eventsEmitter,
|
3394 | update,
|
3395 | translate,
|
3396 | transition,
|
3397 | slide,
|
3398 | loop,
|
3399 | grabCursor,
|
3400 | events: events$1,
|
3401 | breakpoints,
|
3402 | checkOverflow: checkOverflow$1,
|
3403 | classes
|
3404 | };
|
3405 | const extendedDefaults = {};
|
3406 | class Swiper {
|
3407 | constructor() {
|
3408 | let el;
|
3409 | let params;
|
3410 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3411 | args[_key] = arguments[_key];
|
3412 | }
|
3413 | if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
|
3414 | params = args[0];
|
3415 | } else {
|
3416 | [el, params] = args;
|
3417 | }
|
3418 | if (!params) params = {};
|
3419 | params = extend$1({}, params);
|
3420 | if (el && !params.el) params.el = el;
|
3421 | const document = getDocument();
|
3422 | if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
|
3423 | const swipers = [];
|
3424 | document.querySelectorAll(params.el).forEach(containerEl => {
|
3425 | const newParams = extend$1({}, params, {
|
3426 | el: containerEl
|
3427 | });
|
3428 | swipers.push(new Swiper(newParams));
|
3429 | });
|
3430 |
|
3431 | return swipers;
|
3432 | }
|
3433 |
|
3434 |
|
3435 | const swiper = this;
|
3436 | swiper.__swiper__ = true;
|
3437 | swiper.support = getSupport();
|
3438 | swiper.device = getDevice({
|
3439 | userAgent: params.userAgent
|
3440 | });
|
3441 | swiper.browser = getBrowser();
|
3442 | swiper.eventsListeners = {};
|
3443 | swiper.eventsAnyListeners = [];
|
3444 | swiper.modules = [...swiper.__modules__];
|
3445 | if (params.modules && Array.isArray(params.modules)) {
|
3446 | swiper.modules.push(...params.modules);
|
3447 | }
|
3448 | const allModulesParams = {};
|
3449 | swiper.modules.forEach(mod => {
|
3450 | mod({
|
3451 | params,
|
3452 | swiper,
|
3453 | extendParams: moduleExtendParams(params, allModulesParams),
|
3454 | on: swiper.on.bind(swiper),
|
3455 | once: swiper.once.bind(swiper),
|
3456 | off: swiper.off.bind(swiper),
|
3457 | emit: swiper.emit.bind(swiper)
|
3458 | });
|
3459 | });
|
3460 |
|
3461 |
|
3462 | const swiperParams = extend$1({}, defaults, allModulesParams);
|
3463 |
|
3464 |
|
3465 | swiper.params = extend$1({}, swiperParams, extendedDefaults, params);
|
3466 | swiper.originalParams = extend$1({}, swiper.params);
|
3467 | swiper.passedParams = extend$1({}, params);
|
3468 |
|
3469 |
|
3470 | if (swiper.params && swiper.params.on) {
|
3471 | Object.keys(swiper.params.on).forEach(eventName => {
|
3472 | swiper.on(eventName, swiper.params.on[eventName]);
|
3473 | });
|
3474 | }
|
3475 | if (swiper.params && swiper.params.onAny) {
|
3476 | swiper.onAny(swiper.params.onAny);
|
3477 | }
|
3478 |
|
3479 |
|
3480 | Object.assign(swiper, {
|
3481 | enabled: swiper.params.enabled,
|
3482 | el,
|
3483 |
|
3484 | classNames: [],
|
3485 |
|
3486 | slides: [],
|
3487 | slidesGrid: [],
|
3488 | snapGrid: [],
|
3489 | slidesSizesGrid: [],
|
3490 |
|
3491 | isHorizontal() {
|
3492 | return swiper.params.direction === 'horizontal';
|
3493 | },
|
3494 | isVertical() {
|
3495 | return swiper.params.direction === 'vertical';
|
3496 | },
|
3497 |
|
3498 | activeIndex: 0,
|
3499 | realIndex: 0,
|
3500 |
|
3501 | isBeginning: true,
|
3502 | isEnd: false,
|
3503 |
|
3504 | translate: 0,
|
3505 | previousTranslate: 0,
|
3506 | progress: 0,
|
3507 | velocity: 0,
|
3508 | animating: false,
|
3509 | cssOverflowAdjustment() {
|
3510 |
|
3511 |
|
3512 | return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
|
3513 | },
|
3514 |
|
3515 | allowSlideNext: swiper.params.allowSlideNext,
|
3516 | allowSlidePrev: swiper.params.allowSlidePrev,
|
3517 |
|
3518 | touchEventsData: {
|
3519 | isTouched: undefined,
|
3520 | isMoved: undefined,
|
3521 | allowTouchCallbacks: undefined,
|
3522 | touchStartTime: undefined,
|
3523 | isScrolling: undefined,
|
3524 | currentTranslate: undefined,
|
3525 | startTranslate: undefined,
|
3526 | allowThresholdMove: undefined,
|
3527 |
|
3528 | focusableElements: swiper.params.focusableElements,
|
3529 |
|
3530 | lastClickTime: 0,
|
3531 | clickTimeout: undefined,
|
3532 |
|
3533 | velocities: [],
|
3534 | allowMomentumBounce: undefined,
|
3535 | startMoving: undefined,
|
3536 | evCache: []
|
3537 | },
|
3538 |
|
3539 | allowClick: true,
|
3540 |
|
3541 | allowTouchMove: swiper.params.allowTouchMove,
|
3542 | touches: {
|
3543 | startX: 0,
|
3544 | startY: 0,
|
3545 | currentX: 0,
|
3546 | currentY: 0,
|
3547 | diff: 0
|
3548 | },
|
3549 |
|
3550 | imagesToLoad: [],
|
3551 | imagesLoaded: 0
|
3552 | });
|
3553 | swiper.emit('_swiper');
|
3554 |
|
3555 |
|
3556 | if (swiper.params.init) {
|
3557 | swiper.init();
|
3558 | }
|
3559 |
|
3560 |
|
3561 |
|
3562 | return swiper;
|
3563 | }
|
3564 | getSlideIndex(slideEl) {
|
3565 | const {
|
3566 | slidesEl,
|
3567 | params
|
3568 | } = this;
|
3569 | const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
3570 | const firstSlideIndex = elementIndex(slides[0]);
|
3571 | return elementIndex(slideEl) - firstSlideIndex;
|
3572 | }
|
3573 | getSlideIndexByData(index) {
|
3574 | return this.getSlideIndex(this.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index)[0]);
|
3575 | }
|
3576 | recalcSlides() {
|
3577 | const swiper = this;
|
3578 | const {
|
3579 | slidesEl,
|
3580 | params
|
3581 | } = swiper;
|
3582 | swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
3583 | }
|
3584 | enable() {
|
3585 | const swiper = this;
|
3586 | if (swiper.enabled) return;
|
3587 | swiper.enabled = true;
|
3588 | if (swiper.params.grabCursor) {
|
3589 | swiper.setGrabCursor();
|
3590 | }
|
3591 | swiper.emit('enable');
|
3592 | }
|
3593 | disable() {
|
3594 | const swiper = this;
|
3595 | if (!swiper.enabled) return;
|
3596 | swiper.enabled = false;
|
3597 | if (swiper.params.grabCursor) {
|
3598 | swiper.unsetGrabCursor();
|
3599 | }
|
3600 | swiper.emit('disable');
|
3601 | }
|
3602 | setProgress(progress, speed) {
|
3603 | const swiper = this;
|
3604 | progress = Math.min(Math.max(progress, 0), 1);
|
3605 | const min = swiper.minTranslate();
|
3606 | const max = swiper.maxTranslate();
|
3607 | const current = (max - min) * progress + min;
|
3608 | swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
|
3609 | swiper.updateActiveIndex();
|
3610 | swiper.updateSlidesClasses();
|
3611 | }
|
3612 | emitContainerClasses() {
|
3613 | const swiper = this;
|
3614 | if (!swiper.params._emitClasses || !swiper.el) return;
|
3615 | const cls = swiper.el.className.split(' ').filter(className => {
|
3616 | return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
|
3617 | });
|
3618 | swiper.emit('_containerClasses', cls.join(' '));
|
3619 | }
|
3620 | getSlideClasses(slideEl) {
|
3621 | const swiper = this;
|
3622 | if (swiper.destroyed) return '';
|
3623 | return slideEl.className.split(' ').filter(className => {
|
3624 | return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
|
3625 | }).join(' ');
|
3626 | }
|
3627 | emitSlidesClasses() {
|
3628 | const swiper = this;
|
3629 | if (!swiper.params._emitClasses || !swiper.el) return;
|
3630 | const updates = [];
|
3631 | swiper.slides.forEach(slideEl => {
|
3632 | const classNames = swiper.getSlideClasses(slideEl);
|
3633 | updates.push({
|
3634 | slideEl,
|
3635 | classNames
|
3636 | });
|
3637 | swiper.emit('_slideClass', slideEl, classNames);
|
3638 | });
|
3639 | swiper.emit('_slideClasses', updates);
|
3640 | }
|
3641 | slidesPerViewDynamic(view, exact) {
|
3642 | if (view === void 0) {
|
3643 | view = 'current';
|
3644 | }
|
3645 | if (exact === void 0) {
|
3646 | exact = false;
|
3647 | }
|
3648 | const swiper = this;
|
3649 | const {
|
3650 | params,
|
3651 | slides,
|
3652 | slidesGrid,
|
3653 | slidesSizesGrid,
|
3654 | size: swiperSize,
|
3655 | activeIndex
|
3656 | } = swiper;
|
3657 | let spv = 1;
|
3658 | if (params.centeredSlides) {
|
3659 | let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0;
|
3660 | let breakLoop;
|
3661 | for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
3662 | if (slides[i] && !breakLoop) {
|
3663 | slideSize += slides[i].swiperSlideSize;
|
3664 | spv += 1;
|
3665 | if (slideSize > swiperSize) breakLoop = true;
|
3666 | }
|
3667 | }
|
3668 | for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
3669 | if (slides[i] && !breakLoop) {
|
3670 | slideSize += slides[i].swiperSlideSize;
|
3671 | spv += 1;
|
3672 | if (slideSize > swiperSize) breakLoop = true;
|
3673 | }
|
3674 | }
|
3675 | } else {
|
3676 |
|
3677 | if (view === 'current') {
|
3678 | for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
3679 | const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
3680 | if (slideInView) {
|
3681 | spv += 1;
|
3682 | }
|
3683 | }
|
3684 | } else {
|
3685 |
|
3686 | for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
3687 | const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
3688 | if (slideInView) {
|
3689 | spv += 1;
|
3690 | }
|
3691 | }
|
3692 | }
|
3693 | }
|
3694 | return spv;
|
3695 | }
|
3696 | update() {
|
3697 | const swiper = this;
|
3698 | if (!swiper || swiper.destroyed) return;
|
3699 | const {
|
3700 | snapGrid,
|
3701 | params
|
3702 | } = swiper;
|
3703 |
|
3704 | if (params.breakpoints) {
|
3705 | swiper.setBreakpoint();
|
3706 | }
|
3707 | [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
3708 | if (imageEl.complete) {
|
3709 | processLazyPreloader(swiper, imageEl);
|
3710 | }
|
3711 | });
|
3712 | swiper.updateSize();
|
3713 | swiper.updateSlides();
|
3714 | swiper.updateProgress();
|
3715 | swiper.updateSlidesClasses();
|
3716 | function setTranslate() {
|
3717 | const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
|
3718 | const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
|
3719 | swiper.setTranslate(newTranslate);
|
3720 | swiper.updateActiveIndex();
|
3721 | swiper.updateSlidesClasses();
|
3722 | }
|
3723 | let translated;
|
3724 | if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
|
3725 | setTranslate();
|
3726 | if (params.autoHeight) {
|
3727 | swiper.updateAutoHeight();
|
3728 | }
|
3729 | } else {
|
3730 | if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
3731 | const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
3732 | translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
3733 | } else {
|
3734 | translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
3735 | }
|
3736 | if (!translated) {
|
3737 | setTranslate();
|
3738 | }
|
3739 | }
|
3740 | if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
3741 | swiper.checkOverflow();
|
3742 | }
|
3743 | swiper.emit('update');
|
3744 | }
|
3745 | changeDirection(newDirection, needUpdate) {
|
3746 | if (needUpdate === void 0) {
|
3747 | needUpdate = true;
|
3748 | }
|
3749 | const swiper = this;
|
3750 | const currentDirection = swiper.params.direction;
|
3751 | if (!newDirection) {
|
3752 |
|
3753 | newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
3754 | }
|
3755 | if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
3756 | return swiper;
|
3757 | }
|
3758 | swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
|
3759 | swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
|
3760 | swiper.emitContainerClasses();
|
3761 | swiper.params.direction = newDirection;
|
3762 | swiper.slides.forEach(slideEl => {
|
3763 | if (newDirection === 'vertical') {
|
3764 | slideEl.style.width = '';
|
3765 | } else {
|
3766 | slideEl.style.height = '';
|
3767 | }
|
3768 | });
|
3769 | swiper.emit('changeDirection');
|
3770 | if (needUpdate) swiper.update();
|
3771 | return swiper;
|
3772 | }
|
3773 | changeLanguageDirection(direction) {
|
3774 | const swiper = this;
|
3775 | if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
|
3776 | swiper.rtl = direction === 'rtl';
|
3777 | swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
|
3778 | if (swiper.rtl) {
|
3779 | swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
|
3780 | swiper.el.dir = 'rtl';
|
3781 | } else {
|
3782 | swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
|
3783 | swiper.el.dir = 'ltr';
|
3784 | }
|
3785 | swiper.update();
|
3786 | }
|
3787 | mount(element) {
|
3788 | const swiper = this;
|
3789 | if (swiper.mounted) return true;
|
3790 |
|
3791 |
|
3792 | let el = element || swiper.params.el;
|
3793 | if (typeof el === 'string') {
|
3794 | el = document.querySelector(el);
|
3795 | }
|
3796 | if (!el) {
|
3797 | return false;
|
3798 | }
|
3799 | el.swiper = swiper;
|
3800 | if (el.parentNode && el.parentNode.host) {
|
3801 | swiper.isElement = true;
|
3802 | }
|
3803 | const getWrapperSelector = () => {
|
3804 | return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
|
3805 | };
|
3806 | const getWrapper = () => {
|
3807 | if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
3808 | const res = el.shadowRoot.querySelector(getWrapperSelector());
|
3809 |
|
3810 | return res;
|
3811 | }
|
3812 | return elementChildren(el, getWrapperSelector())[0];
|
3813 | };
|
3814 |
|
3815 | let wrapperEl = getWrapper();
|
3816 | if (!wrapperEl && swiper.params.createElements) {
|
3817 | wrapperEl = createElement('div', swiper.params.wrapperClass);
|
3818 | el.append(wrapperEl);
|
3819 | elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
|
3820 | wrapperEl.append(slideEl);
|
3821 | });
|
3822 | }
|
3823 | Object.assign(swiper, {
|
3824 | el,
|
3825 | wrapperEl,
|
3826 | slidesEl: swiper.isElement ? el.parentNode.host : wrapperEl,
|
3827 | hostEl: swiper.isElement ? el.parentNode.host : el,
|
3828 | mounted: true,
|
3829 |
|
3830 | rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
3831 | rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
3832 | wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
3833 | });
|
3834 | return true;
|
3835 | }
|
3836 | init(el) {
|
3837 | const swiper = this;
|
3838 | if (swiper.initialized) return swiper;
|
3839 | const mounted = swiper.mount(el);
|
3840 | if (mounted === false) return swiper;
|
3841 | swiper.emit('beforeInit');
|
3842 |
|
3843 |
|
3844 | if (swiper.params.breakpoints) {
|
3845 | swiper.setBreakpoint();
|
3846 | }
|
3847 |
|
3848 |
|
3849 | swiper.addClasses();
|
3850 |
|
3851 |
|
3852 | swiper.updateSize();
|
3853 |
|
3854 |
|
3855 | swiper.updateSlides();
|
3856 | if (swiper.params.watchOverflow) {
|
3857 | swiper.checkOverflow();
|
3858 | }
|
3859 |
|
3860 |
|
3861 | if (swiper.params.grabCursor && swiper.enabled) {
|
3862 | swiper.setGrabCursor();
|
3863 | }
|
3864 |
|
3865 |
|
3866 | if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
3867 | swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
3868 | } else {
|
3869 | swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
3870 | }
|
3871 |
|
3872 |
|
3873 | if (swiper.params.loop) {
|
3874 | swiper.loopCreate();
|
3875 | }
|
3876 |
|
3877 |
|
3878 | swiper.attachEvents();
|
3879 | [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
3880 | if (imageEl.complete) {
|
3881 | processLazyPreloader(swiper, imageEl);
|
3882 | } else {
|
3883 | imageEl.addEventListener('load', e => {
|
3884 | processLazyPreloader(swiper, e.target);
|
3885 | });
|
3886 | }
|
3887 | });
|
3888 | preload(swiper);
|
3889 |
|
3890 |
|
3891 | swiper.initialized = true;
|
3892 | preload(swiper);
|
3893 |
|
3894 |
|
3895 | swiper.emit('init');
|
3896 | swiper.emit('afterInit');
|
3897 | return swiper;
|
3898 | }
|
3899 | destroy(deleteInstance, cleanStyles) {
|
3900 | if (deleteInstance === void 0) {
|
3901 | deleteInstance = true;
|
3902 | }
|
3903 | if (cleanStyles === void 0) {
|
3904 | cleanStyles = true;
|
3905 | }
|
3906 | const swiper = this;
|
3907 | const {
|
3908 | params,
|
3909 | el,
|
3910 | wrapperEl,
|
3911 | slides
|
3912 | } = swiper;
|
3913 | if (typeof swiper.params === 'undefined' || swiper.destroyed) {
|
3914 | return null;
|
3915 | }
|
3916 | swiper.emit('beforeDestroy');
|
3917 |
|
3918 |
|
3919 | swiper.initialized = false;
|
3920 |
|
3921 |
|
3922 | swiper.detachEvents();
|
3923 |
|
3924 |
|
3925 | if (params.loop) {
|
3926 | swiper.loopDestroy();
|
3927 | }
|
3928 |
|
3929 |
|
3930 | if (cleanStyles) {
|
3931 | swiper.removeClasses();
|
3932 | el.removeAttribute('style');
|
3933 | wrapperEl.removeAttribute('style');
|
3934 | if (slides && slides.length) {
|
3935 | slides.forEach(slideEl => {
|
3936 | slideEl.classList.remove(params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
3937 | slideEl.removeAttribute('style');
|
3938 | slideEl.removeAttribute('data-swiper-slide-index');
|
3939 | });
|
3940 | }
|
3941 | }
|
3942 | swiper.emit('destroy');
|
3943 |
|
3944 |
|
3945 | Object.keys(swiper.eventsListeners).forEach(eventName => {
|
3946 | swiper.off(eventName);
|
3947 | });
|
3948 | if (deleteInstance !== false) {
|
3949 | swiper.el.swiper = null;
|
3950 | deleteProps(swiper);
|
3951 | }
|
3952 | swiper.destroyed = true;
|
3953 | return null;
|
3954 | }
|
3955 | static extendDefaults(newDefaults) {
|
3956 | extend$1(extendedDefaults, newDefaults);
|
3957 | }
|
3958 | static get extendedDefaults() {
|
3959 | return extendedDefaults;
|
3960 | }
|
3961 | static get defaults() {
|
3962 | return defaults;
|
3963 | }
|
3964 | static installModule(mod) {
|
3965 | if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
|
3966 | const modules = Swiper.prototype.__modules__;
|
3967 | if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
|
3968 | modules.push(mod);
|
3969 | }
|
3970 | }
|
3971 | static use(module) {
|
3972 | if (Array.isArray(module)) {
|
3973 | module.forEach(m => Swiper.installModule(m));
|
3974 | return Swiper;
|
3975 | }
|
3976 | Swiper.installModule(module);
|
3977 | return Swiper;
|
3978 | }
|
3979 | }
|
3980 | Object.keys(prototypes).forEach(prototypeGroup => {
|
3981 | Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
|
3982 | Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
|
3983 | });
|
3984 | });
|
3985 | Swiper.use([Resize, Observer]);
|
3986 |
|
3987 |
|
3988 | const paramsList = ['eventsPrefix', 'injectStyles', 'injectStylesUrls', 'modules', 'init', '_direction', 'oneWayMovement', 'touchEventsTarget', 'initialSlide', '_speed', 'cssMode', 'updateOnWindowResize', 'resizeObserver', 'nested', 'focusableElements', '_enabled', '_width', '_height', 'preventInteractionOnTransition', 'userAgent', 'url', '_edgeSwipeDetection', '_edgeSwipeThreshold', '_freeMode', '_autoHeight', 'setWrapperSize', 'virtualTranslate', '_effect', 'breakpoints', '_spaceBetween', '_slidesPerView', 'maxBackfaceHiddenSlides', '_grid', '_slidesPerGroup', '_slidesPerGroupSkip', '_slidesPerGroupAuto', '_centeredSlides', '_centeredSlidesBounds', '_slidesOffsetBefore', '_slidesOffsetAfter', 'normalizeSlideIndex', '_centerInsufficientSlides', '_watchOverflow', 'roundLengths', 'touchRatio', 'touchAngle', 'simulateTouch', '_shortSwipes', '_longSwipes', 'longSwipesRatio', 'longSwipesMs', '_followFinger', 'allowTouchMove', '_threshold', 'touchMoveStopPropagation', 'touchStartPreventDefault', 'touchStartForcePreventDefault', 'touchReleaseOnEdges', 'uniqueNavElements', '_resistance', '_resistanceRatio', '_watchSlidesProgress', '_grabCursor', 'preventClicks', 'preventClicksPropagation', '_slideToClickedSlide', '_loop', 'loopedSlides', 'loopPreventsSliding', '_rewind', '_allowSlidePrev', '_allowSlideNext', '_swipeHandler', '_noSwiping', 'noSwipingClass', 'noSwipingSelector', 'passiveListeners', 'containerModifierClass', 'slideClass', 'slideActiveClass', 'slideVisibleClass', 'slideNextClass', 'slidePrevClass', 'wrapperClass', 'lazyPreloaderClass', 'lazyPreloadPrevNext', 'runCallbacksOnInit', 'observer', 'observeParents', 'observeSlideChildren',
|
3989 |
|
3990 | 'a11y', '_autoplay', '_controller', 'coverflowEffect', 'cubeEffect', 'fadeEffect', 'flipEffect', 'creativeEffect', 'cardsEffect', 'hashNavigation', 'history', 'keyboard', 'mousewheel', '_navigation', '_pagination', 'parallax', '_scrollbar', '_thumbs', 'virtual', 'zoom', 'control'];
|
3991 |
|
3992 | function isObject(o) {
|
3993 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
3994 | }
|
3995 | function extend(target, src) {
|
3996 | const noExtend = ['__proto__', 'constructor', 'prototype'];
|
3997 | Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
|
3998 | if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
3999 | if (src[key].__swiper__) target[key] = src[key];else extend(target[key], src[key]);
|
4000 | } else {
|
4001 | target[key] = src[key];
|
4002 | }
|
4003 | });
|
4004 | }
|
4005 | function needsNavigation(params) {
|
4006 | if (params === void 0) {
|
4007 | params = {};
|
4008 | }
|
4009 | return params.navigation && typeof params.navigation.nextEl === 'undefined' && typeof params.navigation.prevEl === 'undefined';
|
4010 | }
|
4011 | function needsPagination(params) {
|
4012 | if (params === void 0) {
|
4013 | params = {};
|
4014 | }
|
4015 | return params.pagination && typeof params.pagination.el === 'undefined';
|
4016 | }
|
4017 | function needsScrollbar(params) {
|
4018 | if (params === void 0) {
|
4019 | params = {};
|
4020 | }
|
4021 | return params.scrollbar && typeof params.scrollbar.el === 'undefined';
|
4022 | }
|
4023 | function attrToProp(attrName) {
|
4024 | if (attrName === void 0) {
|
4025 | attrName = '';
|
4026 | }
|
4027 | return attrName.replace(/-[a-z]/g, l => l.toUpperCase().replace('-', ''));
|
4028 | }
|
4029 |
|
4030 | function updateSwiper(_ref) {
|
4031 | let {
|
4032 | swiper,
|
4033 | slides,
|
4034 | passedParams,
|
4035 | changedParams,
|
4036 | nextEl,
|
4037 | prevEl,
|
4038 | scrollbarEl,
|
4039 | paginationEl
|
4040 | } = _ref;
|
4041 | const updateParams = changedParams.filter(key => key !== 'children' && key !== 'direction' && key !== 'wrapperClass');
|
4042 | const {
|
4043 | params: currentParams,
|
4044 | pagination,
|
4045 | navigation,
|
4046 | scrollbar,
|
4047 | virtual,
|
4048 | thumbs
|
4049 | } = swiper;
|
4050 | let needThumbsInit;
|
4051 | let needControllerInit;
|
4052 | let needPaginationInit;
|
4053 | let needScrollbarInit;
|
4054 | let needNavigationInit;
|
4055 | let loopNeedDestroy;
|
4056 | let loopNeedEnable;
|
4057 | let loopNeedReloop;
|
4058 | if (changedParams.includes('thumbs') && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) {
|
4059 | needThumbsInit = true;
|
4060 | }
|
4061 | if (changedParams.includes('controller') && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) {
|
4062 | needControllerInit = true;
|
4063 | }
|
4064 | if (changedParams.includes('pagination') && passedParams.pagination && (passedParams.pagination.el || paginationEl) && (currentParams.pagination || currentParams.pagination === false) && pagination && !pagination.el) {
|
4065 | needPaginationInit = true;
|
4066 | }
|
4067 | if (changedParams.includes('scrollbar') && passedParams.scrollbar && (passedParams.scrollbar.el || scrollbarEl) && (currentParams.scrollbar || currentParams.scrollbar === false) && scrollbar && !scrollbar.el) {
|
4068 | needScrollbarInit = true;
|
4069 | }
|
4070 | if (changedParams.includes('navigation') && passedParams.navigation && (passedParams.navigation.prevEl || prevEl) && (passedParams.navigation.nextEl || nextEl) && (currentParams.navigation || currentParams.navigation === false) && navigation && !navigation.prevEl && !navigation.nextEl) {
|
4071 | needNavigationInit = true;
|
4072 | }
|
4073 | const destroyModule = mod => {
|
4074 | if (!swiper[mod]) return;
|
4075 | swiper[mod].destroy();
|
4076 | if (mod === 'navigation') {
|
4077 | if (swiper.isElement) {
|
4078 | swiper[mod].prevEl.remove();
|
4079 | swiper[mod].nextEl.remove();
|
4080 | }
|
4081 | currentParams[mod].prevEl = undefined;
|
4082 | currentParams[mod].nextEl = undefined;
|
4083 | swiper[mod].prevEl = undefined;
|
4084 | swiper[mod].nextEl = undefined;
|
4085 | } else {
|
4086 | if (swiper.isElement) {
|
4087 | swiper[mod].el.remove();
|
4088 | }
|
4089 | currentParams[mod].el = undefined;
|
4090 | swiper[mod].el = undefined;
|
4091 | }
|
4092 | };
|
4093 | if (changedParams.includes('loop') && swiper.isElement) {
|
4094 | if (currentParams.loop && !passedParams.loop) {
|
4095 | loopNeedDestroy = true;
|
4096 | } else if (!currentParams.loop && passedParams.loop) {
|
4097 | loopNeedEnable = true;
|
4098 | } else {
|
4099 | loopNeedReloop = true;
|
4100 | }
|
4101 | }
|
4102 | updateParams.forEach(key => {
|
4103 | if (isObject(currentParams[key]) && isObject(passedParams[key])) {
|
4104 | extend(currentParams[key], passedParams[key]);
|
4105 | if ((key === 'navigation' || key === 'pagination' || key === 'scrollbar') && 'enabled' in passedParams[key] && !passedParams[key].enabled) {
|
4106 | destroyModule(key);
|
4107 | }
|
4108 | } else {
|
4109 | const newValue = passedParams[key];
|
4110 | if ((newValue === true || newValue === false) && (key === 'navigation' || key === 'pagination' || key === 'scrollbar')) {
|
4111 | if (newValue === false) {
|
4112 | destroyModule(key);
|
4113 | }
|
4114 | } else {
|
4115 | currentParams[key] = passedParams[key];
|
4116 | }
|
4117 | }
|
4118 | });
|
4119 | if (updateParams.includes('controller') && !needControllerInit && swiper.controller && swiper.controller.control && currentParams.controller && currentParams.controller.control) {
|
4120 | swiper.controller.control = currentParams.controller.control;
|
4121 | }
|
4122 | if (changedParams.includes('children') && slides && virtual && currentParams.virtual.enabled) {
|
4123 | virtual.slides = slides;
|
4124 | virtual.update(true);
|
4125 | }
|
4126 | if (changedParams.includes('children') && slides && currentParams.loop) {
|
4127 | loopNeedReloop = true;
|
4128 | }
|
4129 | if (needThumbsInit) {
|
4130 | const initialized = thumbs.init();
|
4131 | if (initialized) thumbs.update(true);
|
4132 | }
|
4133 | if (needControllerInit) {
|
4134 | swiper.controller.control = currentParams.controller.control;
|
4135 | }
|
4136 | if (needPaginationInit) {
|
4137 | if (swiper.isElement && (!paginationEl || typeof paginationEl === 'string')) {
|
4138 | paginationEl = document.createElement('div');
|
4139 | paginationEl.classList.add('swiper-pagination');
|
4140 | swiper.el.appendChild(paginationEl);
|
4141 | }
|
4142 | if (paginationEl) currentParams.pagination.el = paginationEl;
|
4143 | pagination.init();
|
4144 | pagination.render();
|
4145 | pagination.update();
|
4146 | }
|
4147 | if (needScrollbarInit) {
|
4148 | if (swiper.isElement && (!scrollbarEl || typeof scrollbarEl === 'string')) {
|
4149 | scrollbarEl = document.createElement('div');
|
4150 | scrollbarEl.classList.add('swiper-scrollbar');
|
4151 | swiper.el.appendChild(scrollbarEl);
|
4152 | }
|
4153 | if (scrollbarEl) currentParams.scrollbar.el = scrollbarEl;
|
4154 | scrollbar.init();
|
4155 | scrollbar.updateSize();
|
4156 | scrollbar.setTranslate();
|
4157 | }
|
4158 | if (needNavigationInit) {
|
4159 | if (swiper.isElement) {
|
4160 | if (!nextEl || typeof nextEl === 'string') {
|
4161 | nextEl = document.createElement('div');
|
4162 | nextEl.classList.add('swiper-button-next');
|
4163 | nextEl.innerHTML = swiper.hostEl.nextButtonSvg;
|
4164 | swiper.el.appendChild(nextEl);
|
4165 | }
|
4166 | if (!prevEl || typeof prevEl === 'string') {
|
4167 | prevEl = document.createElement('div');
|
4168 | prevEl.classList.add('swiper-button-prev');
|
4169 | nextEl.innerHTML = swiper.hostEl.prevButtonSvg;
|
4170 | swiper.el.appendChild(prevEl);
|
4171 | }
|
4172 | }
|
4173 | if (nextEl) currentParams.navigation.nextEl = nextEl;
|
4174 | if (prevEl) currentParams.navigation.prevEl = prevEl;
|
4175 | navigation.init();
|
4176 | navigation.update();
|
4177 | }
|
4178 | if (changedParams.includes('allowSlideNext')) {
|
4179 | swiper.allowSlideNext = passedParams.allowSlideNext;
|
4180 | }
|
4181 | if (changedParams.includes('allowSlidePrev')) {
|
4182 | swiper.allowSlidePrev = passedParams.allowSlidePrev;
|
4183 | }
|
4184 | if (changedParams.includes('direction')) {
|
4185 | swiper.changeDirection(passedParams.direction, false);
|
4186 | }
|
4187 | if (loopNeedDestroy || loopNeedReloop) {
|
4188 | swiper.loopDestroy();
|
4189 | }
|
4190 | if (loopNeedEnable || loopNeedReloop) {
|
4191 | swiper.loopCreate();
|
4192 | }
|
4193 | swiper.update();
|
4194 | }
|
4195 |
|
4196 | const formatValue = val => {
|
4197 | if (parseFloat(val) === Number(val)) return Number(val);
|
4198 | if (val === 'true') return true;
|
4199 | if (val === '') return true;
|
4200 | if (val === 'false') return false;
|
4201 | if (val === 'null') return null;
|
4202 | if (val === 'undefined') return undefined;
|
4203 | if (typeof val === 'string' && val.includes('{') && val.includes('}') && val.includes('"')) {
|
4204 | let v;
|
4205 | try {
|
4206 | v = JSON.parse(val);
|
4207 | } catch (err) {
|
4208 | v = val;
|
4209 | }
|
4210 | return v;
|
4211 | }
|
4212 | return val;
|
4213 | };
|
4214 | const modulesParamsList = ['a11y', 'autoplay', 'controller', 'cards-effect', 'coverflow-effect', 'creative-effect', 'cube-effect', 'fade-effect', 'flip-effect', 'free-mode', 'grid', 'hash-navigation', 'history', 'keyboard', 'mousewheel', 'navigation', 'pagination', 'parallax', 'scrollbar', 'thumbs', 'virtual', 'zoom'];
|
4215 | function getParams(element, propName, propValue) {
|
4216 | const params = {};
|
4217 | const passedParams = {};
|
4218 | extend(params, defaults);
|
4219 | const localParamsList = [...paramsList, 'on'];
|
4220 | const allowedParams = localParamsList.map(key => key.replace(/_/, ''));
|
4221 |
|
4222 |
|
4223 | localParamsList.forEach(paramName => {
|
4224 | paramName = paramName.replace('_', '');
|
4225 | if (typeof element[paramName] !== 'undefined') {
|
4226 | passedParams[paramName] = element[paramName];
|
4227 | }
|
4228 | });
|
4229 |
|
4230 |
|
4231 | const attrsList = [...element.attributes];
|
4232 | if (typeof propName === 'string' && typeof propValue !== 'undefined') {
|
4233 | attrsList.push({
|
4234 | name: propName,
|
4235 | value: propValue
|
4236 | });
|
4237 | }
|
4238 | attrsList.forEach(attr => {
|
4239 | const moduleParam = modulesParamsList.filter(mParam => attr.name.indexOf(`${mParam}-`) === 0)[0];
|
4240 | if (moduleParam) {
|
4241 | const parentObjName = attrToProp(moduleParam);
|
4242 | const subObjName = attrToProp(attr.name.split(`${moduleParam}-`)[1]);
|
4243 | if (typeof passedParams[parentObjName] === 'undefined') passedParams[parentObjName] = {};
|
4244 | if (passedParams[parentObjName] === true) {
|
4245 | passedParams[parentObjName] = {
|
4246 | enabled: true
|
4247 | };
|
4248 | }
|
4249 | passedParams[parentObjName][subObjName] = formatValue(attr.value);
|
4250 | } else {
|
4251 | const name = attrToProp(attr.name);
|
4252 | if (!allowedParams.includes(name)) return;
|
4253 | const value = formatValue(attr.value);
|
4254 | if (passedParams[name] && modulesParamsList.includes(attr.name)) {
|
4255 | if (passedParams[name].constructor !== Object) {
|
4256 | passedParams[name] = {};
|
4257 | }
|
4258 | passedParams[name].enabled = value;
|
4259 | } else {
|
4260 | passedParams[name] = value;
|
4261 | }
|
4262 | }
|
4263 | });
|
4264 | extend(params, passedParams);
|
4265 | if (params.navigation) {
|
4266 | params.navigation = {
|
4267 | prevEl: '.swiper-button-prev',
|
4268 | nextEl: '.swiper-button-next',
|
4269 | ...(params.navigation !== true ? params.navigation : {})
|
4270 | };
|
4271 | } else if (params.navigation === false) {
|
4272 | delete params.navigation;
|
4273 | }
|
4274 | if (params.scrollbar) {
|
4275 | params.scrollbar = {
|
4276 | el: '.swiper-scrollbar',
|
4277 | ...(params.scrollbar !== true ? params.scrollbar : {})
|
4278 | };
|
4279 | } else if (params.scrollbar === false) {
|
4280 | delete params.scrollbar;
|
4281 | }
|
4282 | if (params.pagination) {
|
4283 | params.pagination = {
|
4284 | el: '.swiper-pagination',
|
4285 | ...(params.pagination !== true ? params.pagination : {})
|
4286 | };
|
4287 | } else if (params.pagination === false) {
|
4288 | delete params.pagination;
|
4289 | }
|
4290 | return {
|
4291 | params,
|
4292 | passedParams
|
4293 | };
|
4294 | }
|
4295 |
|
4296 | |
4297 |
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 | const SwiperCSS = `:host{--swiper-theme-color:#007aff}:host{position:relative;display:block;margin-left:auto;margin-right:auto;z-index:1}.swiper{width:100%;height:100%;margin-left:auto;margin-right:auto;position:relative;overflow:hidden;overflow:clip;list-style:none;padding:0;z-index:1;display:block}.swiper-vertical>.swiper-wrapper{flex-direction:column}.swiper-wrapper{position:relative;width:100%;height:100%;z-index:1;display:flex;transition-property:transform;transition-timing-function:var(--swiper-wrapper-transition-timing-function,initial);box-sizing:content-box}.swiper-android ::slotted(swiper-slide),.swiper-ios ::slotted(swiper-slide),.swiper-wrapper{transform:translate3d(0px,0,0)}.swiper-horizontal{touch-action:pan-y}.swiper-vertical{touch-action:pan-x}::slotted(swiper-slide){flex-shrink:0;width:100%;height:100%;position:relative;transition-property:transform;display:block}::slotted(.swiper-slide-invisible-blank){visibility:hidden}.swiper-autoheight,.swiper-autoheight ::slotted(swiper-slide){height:auto}.swiper-autoheight .swiper-wrapper{align-items:flex-start;transition-property:transform,height}.swiper-backface-hidden ::slotted(swiper-slide){transform:translateZ(0);-webkit-backface-visibility:hidden;backface-visibility:hidden}.swiper-3d.swiper-css-mode .swiper-wrapper{perspective:1200px}.swiper-3d .swiper-wrapper{transform-style:preserve-3d}.swiper-3d{perspective:1200px}.swiper-3d .swiper-cube-shadow,.swiper-3d ::slotted(swiper-slide){transform-style:preserve-3d}.swiper-css-mode>.swiper-wrapper{overflow:auto;scrollbar-width:none;-ms-overflow-style:none}.swiper-css-mode>.swiper-wrapper::-webkit-scrollbar{display:none}.swiper-css-mode ::slotted(swiper-slide){scroll-snap-align:start start}.swiper-css-mode.swiper-horizontal>.swiper-wrapper{scroll-snap-type:x mandatory}.swiper-css-mode.swiper-vertical>.swiper-wrapper{scroll-snap-type:y mandatory}.swiper-css-mode.swiper-free-mode>.swiper-wrapper{scroll-snap-type:none}.swiper-css-mode.swiper-free-mode ::slotted(swiper-slide){scroll-snap-align:none}.swiper-css-mode.swiper-centered>.swiper-wrapper::before{content:'';flex-shrink:0;order:9999}.swiper-css-mode.swiper-centered ::slotted(swiper-slide){scroll-snap-align:center center;scroll-snap-stop:always}.swiper-css-mode.swiper-centered.swiper-horizontal ::slotted(swiper-slide):first-child{margin-inline-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper::before{height:100%;min-height:1px;width:var(--swiper-centered-offset-after)}.swiper-css-mode.swiper-centered.swiper-vertical ::slotted(swiper-slide):first-child{margin-block-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper::before{width:100%;min-width:1px;height:var(--swiper-centered-offset-after)}`;
|
4312 | const SwiperSlideCSS = `::slotted(.swiper-slide-shadow),::slotted(.swiper-slide-shadow-bottom),::slotted(.swiper-slide-shadow-left),::slotted(.swiper-slide-shadow-right),::slotted(.swiper-slide-shadow-top){position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none;z-index:10}::slotted(.swiper-slide-shadow){background:rgba(0,0,0,.15)}::slotted(.swiper-slide-shadow-left){background-image:linear-gradient(to left,rgba(0,0,0,.5),rgba(0,0,0,0))}::slotted(.swiper-slide-shadow-right){background-image:linear-gradient(to right,rgba(0,0,0,.5),rgba(0,0,0,0))}::slotted(.swiper-slide-shadow-top){background-image:linear-gradient(to top,rgba(0,0,0,.5),rgba(0,0,0,0))}::slotted(.swiper-slide-shadow-bottom){background-image:linear-gradient(to bottom,rgba(0,0,0,.5),rgba(0,0,0,0))}::slotted(.swiper-lazy-preloader){animation:swiper-preloader-spin 1s infinite linear;width:42px;height:42px;position:absolute;left:50%;top:50%;margin-left:-21px;margin-top:-21px;z-index:10;transform-origin:50%;box-sizing:border-box;border:4px solid var(--swiper-preloader-color,var(--swiper-theme-color));border-radius:50%;border-top-color:transparent}@keyframes swiper-preloader-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}::slotted(.swiper-slide-shadow-cube.swiper-slide-shadow-bottom),::slotted(.swiper-slide-shadow-cube.swiper-slide-shadow-left),::slotted(.swiper-slide-shadow-cube.swiper-slide-shadow-right),::slotted(.swiper-slide-shadow-cube.swiper-slide-shadow-top){z-index:0;-webkit-backface-visibility:hidden;backface-visibility:hidden}::slotted(.swiper-slide-shadow-flip.swiper-slide-shadow-bottom),::slotted(.swiper-slide-shadow-flip.swiper-slide-shadow-left),::slotted(.swiper-slide-shadow-flip.swiper-slide-shadow-right),::slotted(.swiper-slide-shadow-flip.swiper-slide-shadow-top){z-index:0;-webkit-backface-visibility:hidden;backface-visibility:hidden}`;
|
4313 |
|
4314 | class DummyHTMLElement {}
|
4315 | const ClassToExtend = typeof window === 'undefined' || typeof HTMLElement === 'undefined' ? DummyHTMLElement : HTMLElement;
|
4316 | const arrowSvg = `<svg width="11" height="20" viewBox="0 0 11 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.38296 20.0762C0.111788 19.805 0.111788 19.3654 0.38296 19.0942L9.19758 10.2796L0.38296 1.46497C0.111788 1.19379 0.111788 0.754138 0.38296 0.482966C0.654131 0.211794 1.09379 0.211794 1.36496 0.482966L10.4341 9.55214C10.8359 9.9539 10.8359 10.6053 10.4341 11.007L1.36496 20.0762C1.09379 20.3474 0.654131 20.3474 0.38296 20.0762Z" fill="currentColor"/></svg>
|
4317 | `;
|
4318 | const addStyle = (shadowRoot, styles) => {
|
4319 | if (typeof CSSStyleSheet !== 'undefined' && shadowRoot.adoptedStyleSheets) {
|
4320 | const styleSheet = new CSSStyleSheet();
|
4321 | styleSheet.replaceSync(styles);
|
4322 | shadowRoot.adoptedStyleSheets = [styleSheet];
|
4323 | } else {
|
4324 | const style = document.createElement('style');
|
4325 | style.rel = 'stylesheet';
|
4326 | style.textContent = styles;
|
4327 | shadowRoot.appendChild(style);
|
4328 | }
|
4329 | };
|
4330 | class SwiperContainer extends ClassToExtend {
|
4331 | constructor() {
|
4332 | super();
|
4333 | this.attachShadow({
|
4334 | mode: 'open'
|
4335 | });
|
4336 | }
|
4337 | static get nextButtonSvg() {
|
4338 | return arrowSvg;
|
4339 | }
|
4340 | static get prevButtonSvg() {
|
4341 | return arrowSvg.replace('/></svg>', ' transform-origin="center" transform="rotate(180)"/></svg>');
|
4342 | }
|
4343 | cssStyles() {
|
4344 | return [SwiperCSS,
|
4345 |
|
4346 | ...(this.injectStyles && Array.isArray(this.injectStyles) ? this.injectStyles : [])].join('\n');
|
4347 | }
|
4348 | cssLinks() {
|
4349 | return this.injectStylesUrls || [];
|
4350 | }
|
4351 | render() {
|
4352 | if (this.rendered) return;
|
4353 |
|
4354 |
|
4355 | const localStyles = this.cssStyles();
|
4356 | if (localStyles.length) {
|
4357 | addStyle(this.shadowRoot, localStyles);
|
4358 | }
|
4359 | this.cssLinks().forEach(url => {
|
4360 | const linkExists = this.shadowRoot.querySelector(`link[href="${url}"]`);
|
4361 | if (linkExists) return;
|
4362 | const linkEl = document.createElement('link');
|
4363 | linkEl.rel = 'stylesheet';
|
4364 | linkEl.href = url;
|
4365 | this.shadowRoot.appendChild(linkEl);
|
4366 | });
|
4367 |
|
4368 | const el = document.createElement('div');
|
4369 | el.classList.add('swiper');
|
4370 | el.part = 'container';
|
4371 |
|
4372 | el.innerHTML = `
|
4373 | <slot name="container-start"></slot>
|
4374 | <div class="swiper-wrapper" part="wrapper">
|
4375 | <slot></slot>
|
4376 | </div>
|
4377 | <slot name="container-end"></slot>
|
4378 | ${needsNavigation(this.passedParams) ? `
|
4379 | <div part="button-prev" class="swiper-button-prev">${this.constructor.prevButtonSvg}</div>
|
4380 | <div part="button-next" class="swiper-button-next">${this.constructor.nextButtonSvg}</div>
|
4381 | ` : ''}
|
4382 | ${needsPagination(this.passedParams) ? `
|
4383 | <div part="pagination" class="swiper-pagination"></div>
|
4384 | ` : ''}
|
4385 | ${needsScrollbar(this.passedParams) ? `
|
4386 | <div part="scrollbar" class="swiper-scrollbar"></div>
|
4387 | ` : ''}
|
4388 | `;
|
4389 | this.shadowRoot.appendChild(el);
|
4390 | this.rendered = true;
|
4391 | }
|
4392 | initialize() {
|
4393 | var _this = this;
|
4394 | if (this.initialized) return;
|
4395 | this.initialized = true;
|
4396 | const {
|
4397 | params: swiperParams,
|
4398 | passedParams
|
4399 | } = getParams(this);
|
4400 | this.swiperParams = swiperParams;
|
4401 | this.passedParams = passedParams;
|
4402 | delete this.swiperParams.init;
|
4403 | this.render();
|
4404 |
|
4405 | this.swiper = new Swiper(this.shadowRoot.querySelector('.swiper'), {
|
4406 | ...swiperParams,
|
4407 | touchEventsTarget: 'container',
|
4408 | ...(swiperParams.virtual ? {} : {
|
4409 | observer: true
|
4410 | }),
|
4411 | onAny: function (name) {
|
4412 | const eventName = swiperParams.eventsPrefix ? `${swiperParams.eventsPrefix}${name.toLowerCase()}` : name.toLowerCase();
|
4413 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
4414 | args[_key - 1] = arguments[_key];
|
4415 | }
|
4416 | const event = new CustomEvent(eventName, {
|
4417 | detail: args,
|
4418 | bubbles: true,
|
4419 | cancelable: true
|
4420 | });
|
4421 | _this.dispatchEvent(event);
|
4422 | }
|
4423 | });
|
4424 | }
|
4425 | connectedCallback() {
|
4426 | if (this.initialized && this.nested && this.closest('swiper-slide') && this.closest('swiper-slide').swiperLoopMoveDOM) {
|
4427 | return;
|
4428 | }
|
4429 | if (this.init === false || this.getAttribute('init') === 'false') {
|
4430 | return;
|
4431 | }
|
4432 | this.initialize();
|
4433 | }
|
4434 | disconnectedCallback() {
|
4435 | if (this.nested && this.closest('swiper-slide') && this.closest('swiper-slide').swiperLoopMoveDOM) {
|
4436 | return;
|
4437 | }
|
4438 | if (this.swiper && this.swiper.destroy) {
|
4439 | this.swiper.destroy();
|
4440 | }
|
4441 | this.initialized = false;
|
4442 | }
|
4443 | updateSwiperOnPropChange(propName, propValue) {
|
4444 | const {
|
4445 | params: swiperParams,
|
4446 | passedParams
|
4447 | } = getParams(this, propName, propValue);
|
4448 | this.passedParams = passedParams;
|
4449 | this.swiperParams = swiperParams;
|
4450 | updateSwiper({
|
4451 | swiper: this.swiper,
|
4452 | passedParams: this.passedParams,
|
4453 | changedParams: [attrToProp(propName)],
|
4454 | ...(propName === 'navigation' && passedParams[propName] ? {
|
4455 | prevEl: '.swiper-button-prev',
|
4456 | nextEl: '.swiper-button-next'
|
4457 | } : {}),
|
4458 | ...(propName === 'pagination' && passedParams[propName] ? {
|
4459 | paginationEl: '.swiper-pagination'
|
4460 | } : {}),
|
4461 | ...(propName === 'scrollbar' && passedParams[propName] ? {
|
4462 | scrollbarEl: '.swiper-scrollbar'
|
4463 | } : {})
|
4464 | });
|
4465 | }
|
4466 | attributeChangedCallback(attr, prevValue, newValue) {
|
4467 | if (!this.initialized) return;
|
4468 | if (prevValue === 'true' && newValue === null) {
|
4469 | newValue = false;
|
4470 | }
|
4471 | this.updateSwiperOnPropChange(attr, newValue);
|
4472 | }
|
4473 | static get observedAttributes() {
|
4474 | const attrs = paramsList.filter(param => param.includes('_')).map(param => param.replace(/[A-Z]/g, v => `-${v}`).replace('_', '').toLowerCase());
|
4475 | return attrs;
|
4476 | }
|
4477 | }
|
4478 | paramsList.forEach(paramName => {
|
4479 | if (paramName === 'init') return;
|
4480 | paramName = paramName.replace('_', '');
|
4481 | Object.defineProperty(SwiperContainer.prototype, paramName, {
|
4482 | configurable: true,
|
4483 | get() {
|
4484 | return (this.passedParams || {})[paramName];
|
4485 | },
|
4486 | set(value) {
|
4487 | if (!this.passedParams) this.passedParams = {};
|
4488 | this.passedParams[paramName] = value;
|
4489 | if (!this.initialized) return;
|
4490 | this.updateSwiperOnPropChange(paramName);
|
4491 | }
|
4492 | });
|
4493 | });
|
4494 | class SwiperSlide extends ClassToExtend {
|
4495 | constructor() {
|
4496 | super();
|
4497 | this.attachShadow({
|
4498 | mode: 'open'
|
4499 | });
|
4500 | }
|
4501 | render() {
|
4502 | const lazy = this.lazy || this.getAttribute('lazy') === '' || this.getAttribute('lazy') === 'true';
|
4503 | addStyle(this.shadowRoot, SwiperSlideCSS);
|
4504 | this.shadowRoot.appendChild(document.createElement('slot'));
|
4505 | if (lazy) {
|
4506 | const lazyDiv = document.createElement('div');
|
4507 | lazyDiv.classList.add('swiper-lazy-preloader');
|
4508 | this.appendChild(lazyDiv);
|
4509 | }
|
4510 | }
|
4511 | initialize() {
|
4512 | this.render();
|
4513 | }
|
4514 | connectedCallback() {
|
4515 | this.initialize();
|
4516 | }
|
4517 | }
|
4518 |
|
4519 |
|
4520 | const register = () => {
|
4521 | if (typeof window === 'undefined') return;
|
4522 | if (!window.customElements.get('swiper-container')) window.customElements.define('swiper-container', SwiperContainer);
|
4523 | if (!window.customElements.get('swiper-slide')) window.customElements.define('swiper-slide', SwiperSlide);
|
4524 | };
|
4525 | if (typeof window !== 'undefined') {
|
4526 | window.SwiperElementRegisterParams = params => {
|
4527 | paramsList.push(...params);
|
4528 | };
|
4529 | }
|
4530 |
|
4531 | register();
|
4532 |
|
4533 | })();
|