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 classesToTokens(classes) {
|
161 | if (classes === void 0) {
|
162 | classes = '';
|
163 | }
|
164 | return classes.trim().split(' ').filter(c => !!c.trim());
|
165 | }
|
166 |
|
167 | function deleteProps(obj) {
|
168 | const object = obj;
|
169 | Object.keys(object).forEach(key => {
|
170 | try {
|
171 | object[key] = null;
|
172 | } catch (e) {
|
173 |
|
174 | }
|
175 | try {
|
176 | delete object[key];
|
177 | } catch (e) {
|
178 |
|
179 | }
|
180 | });
|
181 | }
|
182 | function nextTick(callback, delay) {
|
183 | if (delay === void 0) {
|
184 | delay = 0;
|
185 | }
|
186 | return setTimeout(callback, delay);
|
187 | }
|
188 | function now() {
|
189 | return Date.now();
|
190 | }
|
191 | function getComputedStyle$1(el) {
|
192 | const window = getWindow();
|
193 | let style;
|
194 | if (window.getComputedStyle) {
|
195 | style = window.getComputedStyle(el, null);
|
196 | }
|
197 | if (!style && el.currentStyle) {
|
198 | style = el.currentStyle;
|
199 | }
|
200 | if (!style) {
|
201 | style = el.style;
|
202 | }
|
203 | return style;
|
204 | }
|
205 | function getTranslate(el, axis) {
|
206 | if (axis === void 0) {
|
207 | axis = 'x';
|
208 | }
|
209 | const window = getWindow();
|
210 | let matrix;
|
211 | let curTransform;
|
212 | let transformMatrix;
|
213 | const curStyle = getComputedStyle$1(el);
|
214 | if (window.WebKitCSSMatrix) {
|
215 | curTransform = curStyle.transform || curStyle.webkitTransform;
|
216 | if (curTransform.split(',').length > 6) {
|
217 | curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
|
218 | }
|
219 |
|
220 |
|
221 | transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
222 | } else {
|
223 | transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
224 | matrix = transformMatrix.toString().split(',');
|
225 | }
|
226 | if (axis === 'x') {
|
227 |
|
228 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
|
229 |
|
230 | else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
|
231 |
|
232 | else curTransform = parseFloat(matrix[4]);
|
233 | }
|
234 | if (axis === 'y') {
|
235 |
|
236 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
|
237 |
|
238 | else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
|
239 |
|
240 | else curTransform = parseFloat(matrix[5]);
|
241 | }
|
242 | return curTransform || 0;
|
243 | }
|
244 | function isObject$1(o) {
|
245 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
246 | }
|
247 | function isNode(node) {
|
248 |
|
249 | if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
|
250 | return node instanceof HTMLElement;
|
251 | }
|
252 | return node && (node.nodeType === 1 || node.nodeType === 11);
|
253 | }
|
254 | function extend$1() {
|
255 | const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
|
256 | const noExtend = ['__proto__', 'constructor', 'prototype'];
|
257 | for (let i = 1; i < arguments.length; i += 1) {
|
258 | const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
259 | if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
|
260 | const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
|
261 | for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
|
262 | const nextKey = keysArray[nextIndex];
|
263 | const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
264 | if (desc !== undefined && desc.enumerable) {
|
265 | if (isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
|
266 | if (nextSource[nextKey].__swiper__) {
|
267 | to[nextKey] = nextSource[nextKey];
|
268 | } else {
|
269 | extend$1(to[nextKey], nextSource[nextKey]);
|
270 | }
|
271 | } else if (!isObject$1(to[nextKey]) && isObject$1(nextSource[nextKey])) {
|
272 | to[nextKey] = {};
|
273 | if (nextSource[nextKey].__swiper__) {
|
274 | to[nextKey] = nextSource[nextKey];
|
275 | } else {
|
276 | extend$1(to[nextKey], nextSource[nextKey]);
|
277 | }
|
278 | } else {
|
279 | to[nextKey] = nextSource[nextKey];
|
280 | }
|
281 | }
|
282 | }
|
283 | }
|
284 | }
|
285 | return to;
|
286 | }
|
287 | function setCSSProperty(el, varName, varValue) {
|
288 | el.style.setProperty(varName, varValue);
|
289 | }
|
290 | function animateCSSModeScroll(_ref) {
|
291 | let {
|
292 | swiper,
|
293 | targetPosition,
|
294 | side
|
295 | } = _ref;
|
296 | const window = getWindow();
|
297 | const startPosition = -swiper.translate;
|
298 | let startTime = null;
|
299 | let time;
|
300 | const duration = swiper.params.speed;
|
301 | swiper.wrapperEl.style.scrollSnapType = 'none';
|
302 | window.cancelAnimationFrame(swiper.cssModeFrameID);
|
303 | const dir = targetPosition > startPosition ? 'next' : 'prev';
|
304 | const isOutOfBound = (current, target) => {
|
305 | return dir === 'next' && current >= target || dir === 'prev' && current <= target;
|
306 | };
|
307 | const animate = () => {
|
308 | time = new Date().getTime();
|
309 | if (startTime === null) {
|
310 | startTime = time;
|
311 | }
|
312 | const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
|
313 | const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
|
314 | let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
|
315 | if (isOutOfBound(currentPosition, targetPosition)) {
|
316 | currentPosition = targetPosition;
|
317 | }
|
318 | swiper.wrapperEl.scrollTo({
|
319 | [side]: currentPosition
|
320 | });
|
321 | if (isOutOfBound(currentPosition, targetPosition)) {
|
322 | swiper.wrapperEl.style.overflow = 'hidden';
|
323 | swiper.wrapperEl.style.scrollSnapType = '';
|
324 | setTimeout(() => {
|
325 | swiper.wrapperEl.style.overflow = '';
|
326 | swiper.wrapperEl.scrollTo({
|
327 | [side]: currentPosition
|
328 | });
|
329 | });
|
330 | window.cancelAnimationFrame(swiper.cssModeFrameID);
|
331 | return;
|
332 | }
|
333 | swiper.cssModeFrameID = window.requestAnimationFrame(animate);
|
334 | };
|
335 | animate();
|
336 | }
|
337 | function getSlideTransformEl(slideEl) {
|
338 | return slideEl.querySelector('.swiper-slide-transform') || slideEl.shadowRoot && slideEl.shadowRoot.querySelector('.swiper-slide-transform') || slideEl;
|
339 | }
|
340 | function elementChildren(element, selector) {
|
341 | if (selector === void 0) {
|
342 | selector = '';
|
343 | }
|
344 | const children = [...element.children];
|
345 | if (element instanceof HTMLSlotElement) {
|
346 | children.push(...element.assignedElements());
|
347 | }
|
348 | if (!selector) {
|
349 | return children;
|
350 | }
|
351 | return children.filter(el => el.matches(selector));
|
352 | }
|
353 | function elementIsChildOf(el, parent) {
|
354 | const isChild = parent.contains(el);
|
355 | if (!isChild && parent instanceof HTMLSlotElement) {
|
356 | const children = [...parent.assignedElements()];
|
357 | return children.includes(el);
|
358 | }
|
359 | return isChild;
|
360 | }
|
361 | function showWarning(text) {
|
362 | try {
|
363 | console.warn(text);
|
364 | return;
|
365 | } catch (err) {
|
366 |
|
367 | }
|
368 | }
|
369 | function createElement(tag, classes) {
|
370 | if (classes === void 0) {
|
371 | classes = [];
|
372 | }
|
373 | const el = document.createElement(tag);
|
374 | el.classList.add(...(Array.isArray(classes) ? classes : classesToTokens(classes)));
|
375 | return el;
|
376 | }
|
377 | function elementOffset(el) {
|
378 | const window = getWindow();
|
379 | const document = getDocument();
|
380 | const box = el.getBoundingClientRect();
|
381 | const body = document.body;
|
382 | const clientTop = el.clientTop || body.clientTop || 0;
|
383 | const clientLeft = el.clientLeft || body.clientLeft || 0;
|
384 | const scrollTop = el === window ? window.scrollY : el.scrollTop;
|
385 | const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
|
386 | return {
|
387 | top: box.top + scrollTop - clientTop,
|
388 | left: box.left + scrollLeft - clientLeft
|
389 | };
|
390 | }
|
391 | function elementPrevAll(el, selector) {
|
392 | const prevEls = [];
|
393 | while (el.previousElementSibling) {
|
394 | const prev = el.previousElementSibling;
|
395 | if (selector) {
|
396 | if (prev.matches(selector)) prevEls.push(prev);
|
397 | } else prevEls.push(prev);
|
398 | el = prev;
|
399 | }
|
400 | return prevEls;
|
401 | }
|
402 | function elementNextAll(el, selector) {
|
403 | const nextEls = [];
|
404 | while (el.nextElementSibling) {
|
405 | const next = el.nextElementSibling;
|
406 | if (selector) {
|
407 | if (next.matches(selector)) nextEls.push(next);
|
408 | } else nextEls.push(next);
|
409 | el = next;
|
410 | }
|
411 | return nextEls;
|
412 | }
|
413 | function elementStyle(el, prop) {
|
414 | const window = getWindow();
|
415 | return window.getComputedStyle(el, null).getPropertyValue(prop);
|
416 | }
|
417 | function elementIndex(el) {
|
418 | let child = el;
|
419 | let i;
|
420 | if (child) {
|
421 | i = 0;
|
422 |
|
423 | while ((child = child.previousSibling) !== null) {
|
424 | if (child.nodeType === 1) i += 1;
|
425 | }
|
426 | return i;
|
427 | }
|
428 | return undefined;
|
429 | }
|
430 | function elementParents(el, selector) {
|
431 | const parents = [];
|
432 | let parent = el.parentElement;
|
433 | while (parent) {
|
434 | if (selector) {
|
435 | if (parent.matches(selector)) parents.push(parent);
|
436 | } else {
|
437 | parents.push(parent);
|
438 | }
|
439 | parent = parent.parentElement;
|
440 | }
|
441 | return parents;
|
442 | }
|
443 | function elementTransitionEnd(el, callback) {
|
444 | function fireCallBack(e) {
|
445 | if (e.target !== el) return;
|
446 | callback.call(el, e);
|
447 | el.removeEventListener('transitionend', fireCallBack);
|
448 | }
|
449 | if (callback) {
|
450 | el.addEventListener('transitionend', fireCallBack);
|
451 | }
|
452 | }
|
453 | function elementOuterSize(el, size, includeMargins) {
|
454 | const window = getWindow();
|
455 | if (includeMargins) {
|
456 | 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'));
|
457 | }
|
458 | return el.offsetWidth;
|
459 | }
|
460 | function makeElementsArray(el) {
|
461 | return (Array.isArray(el) ? el : [el]).filter(e => !!e);
|
462 | }
|
463 | function getRotateFix(swiper) {
|
464 | return v => {
|
465 | if (Math.abs(v) > 0 && swiper.browser && swiper.browser.need3dFix && Math.abs(v) % 90 === 0) {
|
466 | return v + 0.001;
|
467 | }
|
468 | return v;
|
469 | };
|
470 | }
|
471 |
|
472 | let support;
|
473 | function calcSupport() {
|
474 | const window = getWindow();
|
475 | const document = getDocument();
|
476 | return {
|
477 | smoothScroll: document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style,
|
478 | touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
|
479 | };
|
480 | }
|
481 | function getSupport() {
|
482 | if (!support) {
|
483 | support = calcSupport();
|
484 | }
|
485 | return support;
|
486 | }
|
487 |
|
488 | let deviceCached;
|
489 | function calcDevice(_temp) {
|
490 | let {
|
491 | userAgent
|
492 | } = _temp === void 0 ? {} : _temp;
|
493 | const support = getSupport();
|
494 | const window = getWindow();
|
495 | const platform = window.navigator.platform;
|
496 | const ua = userAgent || window.navigator.userAgent;
|
497 | const device = {
|
498 | ios: false,
|
499 | android: false
|
500 | };
|
501 | const screenWidth = window.screen.width;
|
502 | const screenHeight = window.screen.height;
|
503 | const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
|
504 | let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
505 | const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
506 | const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
507 | const windows = platform === 'Win32';
|
508 | let macos = platform === 'MacIntel';
|
509 |
|
510 |
|
511 | const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
|
512 | if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
|
513 | ipad = ua.match(/(Version)\/([\d.]+)/);
|
514 | if (!ipad) ipad = [0, 1, '13_0_0'];
|
515 | macos = false;
|
516 | }
|
517 |
|
518 |
|
519 | if (android && !windows) {
|
520 | device.os = 'android';
|
521 | device.android = true;
|
522 | }
|
523 | if (ipad || iphone || ipod) {
|
524 | device.os = 'ios';
|
525 | device.ios = true;
|
526 | }
|
527 |
|
528 |
|
529 | return device;
|
530 | }
|
531 | function getDevice(overrides) {
|
532 | if (overrides === void 0) {
|
533 | overrides = {};
|
534 | }
|
535 | if (!deviceCached) {
|
536 | deviceCached = calcDevice(overrides);
|
537 | }
|
538 | return deviceCached;
|
539 | }
|
540 |
|
541 | let browser;
|
542 | function calcBrowser() {
|
543 | const window = getWindow();
|
544 | const device = getDevice();
|
545 | let needPerspectiveFix = false;
|
546 | function isSafari() {
|
547 | const ua = window.navigator.userAgent.toLowerCase();
|
548 | return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
|
549 | }
|
550 | if (isSafari()) {
|
551 | const ua = String(window.navigator.userAgent);
|
552 | if (ua.includes('Version/')) {
|
553 | const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
|
554 | needPerspectiveFix = major < 16 || major === 16 && minor < 2;
|
555 | }
|
556 | }
|
557 | const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent);
|
558 | const isSafariBrowser = isSafari();
|
559 | const need3dFix = isSafariBrowser || isWebView && device.ios;
|
560 | return {
|
561 | isSafari: needPerspectiveFix || isSafariBrowser,
|
562 | needPerspectiveFix,
|
563 | need3dFix,
|
564 | isWebView
|
565 | };
|
566 | }
|
567 | function getBrowser() {
|
568 | if (!browser) {
|
569 | browser = calcBrowser();
|
570 | }
|
571 | return browser;
|
572 | }
|
573 |
|
574 | function Resize(_ref) {
|
575 | let {
|
576 | swiper,
|
577 | on,
|
578 | emit
|
579 | } = _ref;
|
580 | const window = getWindow();
|
581 | let observer = null;
|
582 | let animationFrame = null;
|
583 | const resizeHandler = () => {
|
584 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
585 | emit('beforeResize');
|
586 | emit('resize');
|
587 | };
|
588 | const createObserver = () => {
|
589 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
590 | observer = new ResizeObserver(entries => {
|
591 | animationFrame = window.requestAnimationFrame(() => {
|
592 | const {
|
593 | width,
|
594 | height
|
595 | } = swiper;
|
596 | let newWidth = width;
|
597 | let newHeight = height;
|
598 | entries.forEach(_ref2 => {
|
599 | let {
|
600 | contentBoxSize,
|
601 | contentRect,
|
602 | target
|
603 | } = _ref2;
|
604 | if (target && target !== swiper.el) return;
|
605 | newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
|
606 | newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
|
607 | });
|
608 | if (newWidth !== width || newHeight !== height) {
|
609 | resizeHandler();
|
610 | }
|
611 | });
|
612 | });
|
613 | observer.observe(swiper.el);
|
614 | };
|
615 | const removeObserver = () => {
|
616 | if (animationFrame) {
|
617 | window.cancelAnimationFrame(animationFrame);
|
618 | }
|
619 | if (observer && observer.unobserve && swiper.el) {
|
620 | observer.unobserve(swiper.el);
|
621 | observer = null;
|
622 | }
|
623 | };
|
624 | const orientationChangeHandler = () => {
|
625 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
626 | emit('orientationchange');
|
627 | };
|
628 | on('init', () => {
|
629 | if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
|
630 | createObserver();
|
631 | return;
|
632 | }
|
633 | window.addEventListener('resize', resizeHandler);
|
634 | window.addEventListener('orientationchange', orientationChangeHandler);
|
635 | });
|
636 | on('destroy', () => {
|
637 | removeObserver();
|
638 | window.removeEventListener('resize', resizeHandler);
|
639 | window.removeEventListener('orientationchange', orientationChangeHandler);
|
640 | });
|
641 | }
|
642 |
|
643 | function Observer(_ref) {
|
644 | let {
|
645 | swiper,
|
646 | extendParams,
|
647 | on,
|
648 | emit
|
649 | } = _ref;
|
650 | const observers = [];
|
651 | const window = getWindow();
|
652 | const attach = function (target, options) {
|
653 | if (options === void 0) {
|
654 | options = {};
|
655 | }
|
656 | const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
|
657 | const observer = new ObserverFunc(mutations => {
|
658 |
|
659 |
|
660 |
|
661 | if (swiper.__preventObserver__) return;
|
662 | if (mutations.length === 1) {
|
663 | emit('observerUpdate', mutations[0]);
|
664 | return;
|
665 | }
|
666 | const observerUpdate = function observerUpdate() {
|
667 | emit('observerUpdate', mutations[0]);
|
668 | };
|
669 | if (window.requestAnimationFrame) {
|
670 | window.requestAnimationFrame(observerUpdate);
|
671 | } else {
|
672 | window.setTimeout(observerUpdate, 0);
|
673 | }
|
674 | });
|
675 | observer.observe(target, {
|
676 | attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
|
677 | childList: swiper.isElement || (typeof options.childList === 'undefined' ? true : options).childList,
|
678 | characterData: typeof options.characterData === 'undefined' ? true : options.characterData
|
679 | });
|
680 | observers.push(observer);
|
681 | };
|
682 | const init = () => {
|
683 | if (!swiper.params.observer) return;
|
684 | if (swiper.params.observeParents) {
|
685 | const containerParents = elementParents(swiper.hostEl);
|
686 | for (let i = 0; i < containerParents.length; i += 1) {
|
687 | attach(containerParents[i]);
|
688 | }
|
689 | }
|
690 |
|
691 | attach(swiper.hostEl, {
|
692 | childList: swiper.params.observeSlideChildren
|
693 | });
|
694 |
|
695 |
|
696 | attach(swiper.wrapperEl, {
|
697 | attributes: false
|
698 | });
|
699 | };
|
700 | const destroy = () => {
|
701 | observers.forEach(observer => {
|
702 | observer.disconnect();
|
703 | });
|
704 | observers.splice(0, observers.length);
|
705 | };
|
706 | extendParams({
|
707 | observer: false,
|
708 | observeParents: false,
|
709 | observeSlideChildren: false
|
710 | });
|
711 | on('init', init);
|
712 | on('destroy', destroy);
|
713 | }
|
714 |
|
715 |
|
716 |
|
717 | var eventsEmitter = {
|
718 | on(events, handler, priority) {
|
719 | const self = this;
|
720 | if (!self.eventsListeners || self.destroyed) return self;
|
721 | if (typeof handler !== 'function') return self;
|
722 | const method = priority ? 'unshift' : 'push';
|
723 | events.split(' ').forEach(event => {
|
724 | if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
|
725 | self.eventsListeners[event][method](handler);
|
726 | });
|
727 | return self;
|
728 | },
|
729 | once(events, handler, priority) {
|
730 | const self = this;
|
731 | if (!self.eventsListeners || self.destroyed) return self;
|
732 | if (typeof handler !== 'function') return self;
|
733 | function onceHandler() {
|
734 | self.off(events, onceHandler);
|
735 | if (onceHandler.__emitterProxy) {
|
736 | delete onceHandler.__emitterProxy;
|
737 | }
|
738 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
739 | args[_key] = arguments[_key];
|
740 | }
|
741 | handler.apply(self, args);
|
742 | }
|
743 | onceHandler.__emitterProxy = handler;
|
744 | return self.on(events, onceHandler, priority);
|
745 | },
|
746 | onAny(handler, priority) {
|
747 | const self = this;
|
748 | if (!self.eventsListeners || self.destroyed) return self;
|
749 | if (typeof handler !== 'function') return self;
|
750 | const method = priority ? 'unshift' : 'push';
|
751 | if (self.eventsAnyListeners.indexOf(handler) < 0) {
|
752 | self.eventsAnyListeners[method](handler);
|
753 | }
|
754 | return self;
|
755 | },
|
756 | offAny(handler) {
|
757 | const self = this;
|
758 | if (!self.eventsListeners || self.destroyed) return self;
|
759 | if (!self.eventsAnyListeners) return self;
|
760 | const index = self.eventsAnyListeners.indexOf(handler);
|
761 | if (index >= 0) {
|
762 | self.eventsAnyListeners.splice(index, 1);
|
763 | }
|
764 | return self;
|
765 | },
|
766 | off(events, handler) {
|
767 | const self = this;
|
768 | if (!self.eventsListeners || self.destroyed) return self;
|
769 | if (!self.eventsListeners) return self;
|
770 | events.split(' ').forEach(event => {
|
771 | if (typeof handler === 'undefined') {
|
772 | self.eventsListeners[event] = [];
|
773 | } else if (self.eventsListeners[event]) {
|
774 | self.eventsListeners[event].forEach((eventHandler, index) => {
|
775 | if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
|
776 | self.eventsListeners[event].splice(index, 1);
|
777 | }
|
778 | });
|
779 | }
|
780 | });
|
781 | return self;
|
782 | },
|
783 | emit() {
|
784 | const self = this;
|
785 | if (!self.eventsListeners || self.destroyed) return self;
|
786 | if (!self.eventsListeners) return self;
|
787 | let events;
|
788 | let data;
|
789 | let context;
|
790 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
791 | args[_key2] = arguments[_key2];
|
792 | }
|
793 | if (typeof args[0] === 'string' || Array.isArray(args[0])) {
|
794 | events = args[0];
|
795 | data = args.slice(1, args.length);
|
796 | context = self;
|
797 | } else {
|
798 | events = args[0].events;
|
799 | data = args[0].data;
|
800 | context = args[0].context || self;
|
801 | }
|
802 | data.unshift(context);
|
803 | const eventsArray = Array.isArray(events) ? events : events.split(' ');
|
804 | eventsArray.forEach(event => {
|
805 | if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
|
806 | self.eventsAnyListeners.forEach(eventHandler => {
|
807 | eventHandler.apply(context, [event, ...data]);
|
808 | });
|
809 | }
|
810 | if (self.eventsListeners && self.eventsListeners[event]) {
|
811 | self.eventsListeners[event].forEach(eventHandler => {
|
812 | eventHandler.apply(context, data);
|
813 | });
|
814 | }
|
815 | });
|
816 | return self;
|
817 | }
|
818 | };
|
819 |
|
820 | function updateSize() {
|
821 | const swiper = this;
|
822 | let width;
|
823 | let height;
|
824 | const el = swiper.el;
|
825 | if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
826 | width = swiper.params.width;
|
827 | } else {
|
828 | width = el.clientWidth;
|
829 | }
|
830 | if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
831 | height = swiper.params.height;
|
832 | } else {
|
833 | height = el.clientHeight;
|
834 | }
|
835 | if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
836 | return;
|
837 | }
|
838 |
|
839 |
|
840 | width = width - parseInt(elementStyle(el, 'padding-left') || 0, 10) - parseInt(elementStyle(el, 'padding-right') || 0, 10);
|
841 | height = height - parseInt(elementStyle(el, 'padding-top') || 0, 10) - parseInt(elementStyle(el, 'padding-bottom') || 0, 10);
|
842 | if (Number.isNaN(width)) width = 0;
|
843 | if (Number.isNaN(height)) height = 0;
|
844 | Object.assign(swiper, {
|
845 | width,
|
846 | height,
|
847 | size: swiper.isHorizontal() ? width : height
|
848 | });
|
849 | }
|
850 |
|
851 | function updateSlides() {
|
852 | const swiper = this;
|
853 | function getDirectionPropertyValue(node, label) {
|
854 | return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
855 | }
|
856 | const params = swiper.params;
|
857 | const {
|
858 | wrapperEl,
|
859 | slidesEl,
|
860 | size: swiperSize,
|
861 | rtlTranslate: rtl,
|
862 | wrongRTL
|
863 | } = swiper;
|
864 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
865 | const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
866 | const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
867 | const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
|
868 | let snapGrid = [];
|
869 | const slidesGrid = [];
|
870 | const slidesSizesGrid = [];
|
871 | let offsetBefore = params.slidesOffsetBefore;
|
872 | if (typeof offsetBefore === 'function') {
|
873 | offsetBefore = params.slidesOffsetBefore.call(swiper);
|
874 | }
|
875 | let offsetAfter = params.slidesOffsetAfter;
|
876 | if (typeof offsetAfter === 'function') {
|
877 | offsetAfter = params.slidesOffsetAfter.call(swiper);
|
878 | }
|
879 | const previousSnapGridLength = swiper.snapGrid.length;
|
880 | const previousSlidesGridLength = swiper.slidesGrid.length;
|
881 | let spaceBetween = params.spaceBetween;
|
882 | let slidePosition = -offsetBefore;
|
883 | let prevSlideSize = 0;
|
884 | let index = 0;
|
885 | if (typeof swiperSize === 'undefined') {
|
886 | return;
|
887 | }
|
888 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
889 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
890 | } else if (typeof spaceBetween === 'string') {
|
891 | spaceBetween = parseFloat(spaceBetween);
|
892 | }
|
893 | swiper.virtualSize = -spaceBetween;
|
894 |
|
895 |
|
896 | slides.forEach(slideEl => {
|
897 | if (rtl) {
|
898 | slideEl.style.marginLeft = '';
|
899 | } else {
|
900 | slideEl.style.marginRight = '';
|
901 | }
|
902 | slideEl.style.marginBottom = '';
|
903 | slideEl.style.marginTop = '';
|
904 | });
|
905 |
|
906 |
|
907 | if (params.centeredSlides && params.cssMode) {
|
908 | setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
909 | setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
910 | }
|
911 | const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
912 | if (gridEnabled) {
|
913 | swiper.grid.initSlides(slides);
|
914 | } else if (swiper.grid) {
|
915 | swiper.grid.unsetSlides();
|
916 | }
|
917 |
|
918 |
|
919 | let slideSize;
|
920 | const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
|
921 | return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
922 | }).length > 0;
|
923 | for (let i = 0; i < slidesLength; i += 1) {
|
924 | slideSize = 0;
|
925 | let slide;
|
926 | if (slides[i]) slide = slides[i];
|
927 | if (gridEnabled) {
|
928 | swiper.grid.updateSlide(i, slide, slides);
|
929 | }
|
930 | if (slides[i] && elementStyle(slide, 'display') === 'none') continue;
|
931 |
|
932 | if (params.slidesPerView === 'auto') {
|
933 | if (shouldResetSlideSize) {
|
934 | slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
935 | }
|
936 | const slideStyles = getComputedStyle(slide);
|
937 | const currentTransform = slide.style.transform;
|
938 | const currentWebKitTransform = slide.style.webkitTransform;
|
939 | if (currentTransform) {
|
940 | slide.style.transform = 'none';
|
941 | }
|
942 | if (currentWebKitTransform) {
|
943 | slide.style.webkitTransform = 'none';
|
944 | }
|
945 | if (params.roundLengths) {
|
946 | slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
947 | } else {
|
948 |
|
949 | const width = getDirectionPropertyValue(slideStyles, 'width');
|
950 | const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
951 | const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
952 | const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
953 | const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
954 | const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
955 | if (boxSizing && boxSizing === 'border-box') {
|
956 | slideSize = width + marginLeft + marginRight;
|
957 | } else {
|
958 | const {
|
959 | clientWidth,
|
960 | offsetWidth
|
961 | } = slide;
|
962 | slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
963 | }
|
964 | }
|
965 | if (currentTransform) {
|
966 | slide.style.transform = currentTransform;
|
967 | }
|
968 | if (currentWebKitTransform) {
|
969 | slide.style.webkitTransform = currentWebKitTransform;
|
970 | }
|
971 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
972 | } else {
|
973 | slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
974 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
975 | if (slides[i]) {
|
976 | slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
977 | }
|
978 | }
|
979 | if (slides[i]) {
|
980 | slides[i].swiperSlideSize = slideSize;
|
981 | }
|
982 | slidesSizesGrid.push(slideSize);
|
983 | if (params.centeredSlides) {
|
984 | slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
985 | if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
986 | if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
987 | if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
988 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
989 | if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
990 | slidesGrid.push(slidePosition);
|
991 | } else {
|
992 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
993 | if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
994 | slidesGrid.push(slidePosition);
|
995 | slidePosition = slidePosition + slideSize + spaceBetween;
|
996 | }
|
997 | swiper.virtualSize += slideSize + spaceBetween;
|
998 | prevSlideSize = slideSize;
|
999 | index += 1;
|
1000 | }
|
1001 | swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
|
1002 | if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
|
1003 | wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
|
1004 | }
|
1005 | if (params.setWrapperSize) {
|
1006 | wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
|
1007 | }
|
1008 | if (gridEnabled) {
|
1009 | swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
1010 | }
|
1011 |
|
1012 |
|
1013 | if (!params.centeredSlides) {
|
1014 | const newSlidesGrid = [];
|
1015 | for (let i = 0; i < snapGrid.length; i += 1) {
|
1016 | let slidesGridItem = snapGrid[i];
|
1017 | if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
1018 | if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
|
1019 | newSlidesGrid.push(slidesGridItem);
|
1020 | }
|
1021 | }
|
1022 | snapGrid = newSlidesGrid;
|
1023 | if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
1024 | snapGrid.push(swiper.virtualSize - swiperSize);
|
1025 | }
|
1026 | }
|
1027 | if (isVirtual && params.loop) {
|
1028 | const size = slidesSizesGrid[0] + spaceBetween;
|
1029 | if (params.slidesPerGroup > 1) {
|
1030 | const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
1031 | const groupSize = size * params.slidesPerGroup;
|
1032 | for (let i = 0; i < groups; i += 1) {
|
1033 | snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
1034 | }
|
1035 | }
|
1036 | for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
1037 | if (params.slidesPerGroup === 1) {
|
1038 | snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
1039 | }
|
1040 | slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
1041 | swiper.virtualSize += size;
|
1042 | }
|
1043 | }
|
1044 | if (snapGrid.length === 0) snapGrid = [0];
|
1045 | if (spaceBetween !== 0) {
|
1046 | const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
1047 | slides.filter((_, slideIndex) => {
|
1048 | if (!params.cssMode || params.loop) return true;
|
1049 | if (slideIndex === slides.length - 1) {
|
1050 | return false;
|
1051 | }
|
1052 | return true;
|
1053 | }).forEach(slideEl => {
|
1054 | slideEl.style[key] = `${spaceBetween}px`;
|
1055 | });
|
1056 | }
|
1057 | if (params.centeredSlides && params.centeredSlidesBounds) {
|
1058 | let allSlidesSize = 0;
|
1059 | slidesSizesGrid.forEach(slideSizeValue => {
|
1060 | allSlidesSize += slideSizeValue + (spaceBetween || 0);
|
1061 | });
|
1062 | allSlidesSize -= spaceBetween;
|
1063 | const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0;
|
1064 | snapGrid = snapGrid.map(snap => {
|
1065 | if (snap <= 0) return -offsetBefore;
|
1066 | if (snap > maxSnap) return maxSnap + offsetAfter;
|
1067 | return snap;
|
1068 | });
|
1069 | }
|
1070 | if (params.centerInsufficientSlides) {
|
1071 | let allSlidesSize = 0;
|
1072 | slidesSizesGrid.forEach(slideSizeValue => {
|
1073 | allSlidesSize += slideSizeValue + (spaceBetween || 0);
|
1074 | });
|
1075 | allSlidesSize -= spaceBetween;
|
1076 | const offsetSize = (params.slidesOffsetBefore || 0) + (params.slidesOffsetAfter || 0);
|
1077 | if (allSlidesSize + offsetSize < swiperSize) {
|
1078 | const allSlidesOffset = (swiperSize - allSlidesSize - offsetSize) / 2;
|
1079 | snapGrid.forEach((snap, snapIndex) => {
|
1080 | snapGrid[snapIndex] = snap - allSlidesOffset;
|
1081 | });
|
1082 | slidesGrid.forEach((snap, snapIndex) => {
|
1083 | slidesGrid[snapIndex] = snap + allSlidesOffset;
|
1084 | });
|
1085 | }
|
1086 | }
|
1087 | Object.assign(swiper, {
|
1088 | slides,
|
1089 | snapGrid,
|
1090 | slidesGrid,
|
1091 | slidesSizesGrid
|
1092 | });
|
1093 | if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
|
1094 | setCSSProperty(wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
|
1095 | setCSSProperty(wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
|
1096 | const addToSnapGrid = -swiper.snapGrid[0];
|
1097 | const addToSlidesGrid = -swiper.slidesGrid[0];
|
1098 | swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
1099 | swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
1100 | }
|
1101 | if (slidesLength !== previousSlidesLength) {
|
1102 | swiper.emit('slidesLengthChange');
|
1103 | }
|
1104 | if (snapGrid.length !== previousSnapGridLength) {
|
1105 | if (swiper.params.watchOverflow) swiper.checkOverflow();
|
1106 | swiper.emit('snapGridLengthChange');
|
1107 | }
|
1108 | if (slidesGrid.length !== previousSlidesGridLength) {
|
1109 | swiper.emit('slidesGridLengthChange');
|
1110 | }
|
1111 | if (params.watchSlidesProgress) {
|
1112 | swiper.updateSlidesOffset();
|
1113 | }
|
1114 | swiper.emit('slidesUpdated');
|
1115 | if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
|
1116 | const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
1117 | const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
1118 | if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
1119 | if (!hasClassBackfaceClassAdded) swiper.el.classList.add(backFaceHiddenClass);
|
1120 | } else if (hasClassBackfaceClassAdded) {
|
1121 | swiper.el.classList.remove(backFaceHiddenClass);
|
1122 | }
|
1123 | }
|
1124 | }
|
1125 |
|
1126 | function updateAutoHeight(speed) {
|
1127 | const swiper = this;
|
1128 | const activeSlides = [];
|
1129 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
1130 | let newHeight = 0;
|
1131 | let i;
|
1132 | if (typeof speed === 'number') {
|
1133 | swiper.setTransition(speed);
|
1134 | } else if (speed === true) {
|
1135 | swiper.setTransition(swiper.params.speed);
|
1136 | }
|
1137 | const getSlideByIndex = index => {
|
1138 | if (isVirtual) {
|
1139 | return swiper.slides[swiper.getSlideIndexByData(index)];
|
1140 | }
|
1141 | return swiper.slides[index];
|
1142 | };
|
1143 |
|
1144 | if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
1145 | if (swiper.params.centeredSlides) {
|
1146 | (swiper.visibleSlides || []).forEach(slide => {
|
1147 | activeSlides.push(slide);
|
1148 | });
|
1149 | } else {
|
1150 | for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
1151 | const index = swiper.activeIndex + i;
|
1152 | if (index > swiper.slides.length && !isVirtual) break;
|
1153 | activeSlides.push(getSlideByIndex(index));
|
1154 | }
|
1155 | }
|
1156 | } else {
|
1157 | activeSlides.push(getSlideByIndex(swiper.activeIndex));
|
1158 | }
|
1159 |
|
1160 |
|
1161 | for (i = 0; i < activeSlides.length; i += 1) {
|
1162 | if (typeof activeSlides[i] !== 'undefined') {
|
1163 | const height = activeSlides[i].offsetHeight;
|
1164 | newHeight = height > newHeight ? height : newHeight;
|
1165 | }
|
1166 | }
|
1167 |
|
1168 |
|
1169 | if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
1170 | }
|
1171 |
|
1172 | function updateSlidesOffset() {
|
1173 | const swiper = this;
|
1174 | const slides = swiper.slides;
|
1175 |
|
1176 | const minusOffset = swiper.isElement ? swiper.isHorizontal() ? swiper.wrapperEl.offsetLeft : swiper.wrapperEl.offsetTop : 0;
|
1177 | for (let i = 0; i < slides.length; i += 1) {
|
1178 | slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
|
1179 | }
|
1180 | }
|
1181 |
|
1182 | const toggleSlideClasses$1 = (slideEl, condition, className) => {
|
1183 | if (condition && !slideEl.classList.contains(className)) {
|
1184 | slideEl.classList.add(className);
|
1185 | } else if (!condition && slideEl.classList.contains(className)) {
|
1186 | slideEl.classList.remove(className);
|
1187 | }
|
1188 | };
|
1189 | function updateSlidesProgress(translate) {
|
1190 | if (translate === void 0) {
|
1191 | translate = this && this.translate || 0;
|
1192 | }
|
1193 | const swiper = this;
|
1194 | const params = swiper.params;
|
1195 | const {
|
1196 | slides,
|
1197 | rtlTranslate: rtl,
|
1198 | snapGrid
|
1199 | } = swiper;
|
1200 | if (slides.length === 0) return;
|
1201 | if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
|
1202 | let offsetCenter = -translate;
|
1203 | if (rtl) offsetCenter = translate;
|
1204 | swiper.visibleSlidesIndexes = [];
|
1205 | swiper.visibleSlides = [];
|
1206 | let spaceBetween = params.spaceBetween;
|
1207 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
1208 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
|
1209 | } else if (typeof spaceBetween === 'string') {
|
1210 | spaceBetween = parseFloat(spaceBetween);
|
1211 | }
|
1212 | for (let i = 0; i < slides.length; i += 1) {
|
1213 | const slide = slides[i];
|
1214 | let slideOffset = slide.swiperSlideOffset;
|
1215 | if (params.cssMode && params.centeredSlides) {
|
1216 | slideOffset -= slides[0].swiperSlideOffset;
|
1217 | }
|
1218 | const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
|
1219 | const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
|
1220 | const slideBefore = -(offsetCenter - slideOffset);
|
1221 | const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
1222 | const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
|
1223 | const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
1224 | if (isVisible) {
|
1225 | swiper.visibleSlides.push(slide);
|
1226 | swiper.visibleSlidesIndexes.push(i);
|
1227 | }
|
1228 | toggleSlideClasses$1(slide, isVisible, params.slideVisibleClass);
|
1229 | toggleSlideClasses$1(slide, isFullyVisible, params.slideFullyVisibleClass);
|
1230 | slide.progress = rtl ? -slideProgress : slideProgress;
|
1231 | slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
1232 | }
|
1233 | }
|
1234 |
|
1235 | function updateProgress(translate) {
|
1236 | const swiper = this;
|
1237 | if (typeof translate === 'undefined') {
|
1238 | const multiplier = swiper.rtlTranslate ? -1 : 1;
|
1239 |
|
1240 | translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
|
1241 | }
|
1242 | const params = swiper.params;
|
1243 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
1244 | let {
|
1245 | progress,
|
1246 | isBeginning,
|
1247 | isEnd,
|
1248 | progressLoop
|
1249 | } = swiper;
|
1250 | const wasBeginning = isBeginning;
|
1251 | const wasEnd = isEnd;
|
1252 | if (translatesDiff === 0) {
|
1253 | progress = 0;
|
1254 | isBeginning = true;
|
1255 | isEnd = true;
|
1256 | } else {
|
1257 | progress = (translate - swiper.minTranslate()) / translatesDiff;
|
1258 | const isBeginningRounded = Math.abs(translate - swiper.minTranslate()) < 1;
|
1259 | const isEndRounded = Math.abs(translate - swiper.maxTranslate()) < 1;
|
1260 | isBeginning = isBeginningRounded || progress <= 0;
|
1261 | isEnd = isEndRounded || progress >= 1;
|
1262 | if (isBeginningRounded) progress = 0;
|
1263 | if (isEndRounded) progress = 1;
|
1264 | }
|
1265 | if (params.loop) {
|
1266 | const firstSlideIndex = swiper.getSlideIndexByData(0);
|
1267 | const lastSlideIndex = swiper.getSlideIndexByData(swiper.slides.length - 1);
|
1268 | const firstSlideTranslate = swiper.slidesGrid[firstSlideIndex];
|
1269 | const lastSlideTranslate = swiper.slidesGrid[lastSlideIndex];
|
1270 | const translateMax = swiper.slidesGrid[swiper.slidesGrid.length - 1];
|
1271 | const translateAbs = Math.abs(translate);
|
1272 | if (translateAbs >= firstSlideTranslate) {
|
1273 | progressLoop = (translateAbs - firstSlideTranslate) / translateMax;
|
1274 | } else {
|
1275 | progressLoop = (translateAbs + translateMax - lastSlideTranslate) / translateMax;
|
1276 | }
|
1277 | if (progressLoop > 1) progressLoop -= 1;
|
1278 | }
|
1279 | Object.assign(swiper, {
|
1280 | progress,
|
1281 | progressLoop,
|
1282 | isBeginning,
|
1283 | isEnd
|
1284 | });
|
1285 | if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
|
1286 | if (isBeginning && !wasBeginning) {
|
1287 | swiper.emit('reachBeginning toEdge');
|
1288 | }
|
1289 | if (isEnd && !wasEnd) {
|
1290 | swiper.emit('reachEnd toEdge');
|
1291 | }
|
1292 | if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
|
1293 | swiper.emit('fromEdge');
|
1294 | }
|
1295 | swiper.emit('progress', progress);
|
1296 | }
|
1297 |
|
1298 | const toggleSlideClasses = (slideEl, condition, className) => {
|
1299 | if (condition && !slideEl.classList.contains(className)) {
|
1300 | slideEl.classList.add(className);
|
1301 | } else if (!condition && slideEl.classList.contains(className)) {
|
1302 | slideEl.classList.remove(className);
|
1303 | }
|
1304 | };
|
1305 | function updateSlidesClasses() {
|
1306 | const swiper = this;
|
1307 | const {
|
1308 | slides,
|
1309 | params,
|
1310 | slidesEl,
|
1311 | activeIndex
|
1312 | } = swiper;
|
1313 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
1314 | const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
1315 | const getFilteredSlide = selector => {
|
1316 | return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
1317 | };
|
1318 | let activeSlide;
|
1319 | let prevSlide;
|
1320 | let nextSlide;
|
1321 | if (isVirtual) {
|
1322 | if (params.loop) {
|
1323 | let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
1324 | if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
1325 | if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
1326 | activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
1327 | } else {
|
1328 | activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
1329 | }
|
1330 | } else {
|
1331 | if (gridEnabled) {
|
1332 | activeSlide = slides.filter(slideEl => slideEl.column === activeIndex)[0];
|
1333 | nextSlide = slides.filter(slideEl => slideEl.column === activeIndex + 1)[0];
|
1334 | prevSlide = slides.filter(slideEl => slideEl.column === activeIndex - 1)[0];
|
1335 | } else {
|
1336 | activeSlide = slides[activeIndex];
|
1337 | }
|
1338 | }
|
1339 | if (activeSlide) {
|
1340 | if (!gridEnabled) {
|
1341 |
|
1342 | nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
1343 | if (params.loop && !nextSlide) {
|
1344 | nextSlide = slides[0];
|
1345 | }
|
1346 |
|
1347 |
|
1348 | prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
1349 | if (params.loop && !prevSlide === 0) {
|
1350 | prevSlide = slides[slides.length - 1];
|
1351 | }
|
1352 | }
|
1353 | }
|
1354 | slides.forEach(slideEl => {
|
1355 | toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
1356 | toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
|
1357 | toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
|
1358 | });
|
1359 | swiper.emitSlidesClasses();
|
1360 | }
|
1361 |
|
1362 | const processLazyPreloader = (swiper, imageEl) => {
|
1363 | if (!swiper || swiper.destroyed || !swiper.params) return;
|
1364 | const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
|
1365 | const slideEl = imageEl.closest(slideSelector());
|
1366 | if (slideEl) {
|
1367 | let lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
|
1368 | if (!lazyEl && swiper.isElement) {
|
1369 | if (slideEl.shadowRoot) {
|
1370 | lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
|
1371 | } else {
|
1372 |
|
1373 | requestAnimationFrame(() => {
|
1374 | if (slideEl.shadowRoot) {
|
1375 | lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
|
1376 | if (lazyEl) lazyEl.remove();
|
1377 | }
|
1378 | });
|
1379 | }
|
1380 | }
|
1381 | if (lazyEl) lazyEl.remove();
|
1382 | }
|
1383 | };
|
1384 | const unlazy = (swiper, index) => {
|
1385 | if (!swiper.slides[index]) return;
|
1386 | const imageEl = swiper.slides[index].querySelector('[loading="lazy"]');
|
1387 | if (imageEl) imageEl.removeAttribute('loading');
|
1388 | };
|
1389 | const preload = swiper => {
|
1390 | if (!swiper || swiper.destroyed || !swiper.params) return;
|
1391 | let amount = swiper.params.lazyPreloadPrevNext;
|
1392 | const len = swiper.slides.length;
|
1393 | if (!len || !amount || amount < 0) return;
|
1394 | amount = Math.min(amount, len);
|
1395 | const slidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(swiper.params.slidesPerView);
|
1396 | const activeIndex = swiper.activeIndex;
|
1397 | if (swiper.params.grid && swiper.params.grid.rows > 1) {
|
1398 | const activeColumn = activeIndex;
|
1399 | const preloadColumns = [activeColumn - amount];
|
1400 | preloadColumns.push(...Array.from({
|
1401 | length: amount
|
1402 | }).map((_, i) => {
|
1403 | return activeColumn + slidesPerView + i;
|
1404 | }));
|
1405 | swiper.slides.forEach((slideEl, i) => {
|
1406 | if (preloadColumns.includes(slideEl.column)) unlazy(swiper, i);
|
1407 | });
|
1408 | return;
|
1409 | }
|
1410 | const slideIndexLastInView = activeIndex + slidesPerView - 1;
|
1411 | if (swiper.params.rewind || swiper.params.loop) {
|
1412 | for (let i = activeIndex - amount; i <= slideIndexLastInView + amount; i += 1) {
|
1413 | const realIndex = (i % len + len) % len;
|
1414 | if (realIndex < activeIndex || realIndex > slideIndexLastInView) unlazy(swiper, realIndex);
|
1415 | }
|
1416 | } else {
|
1417 | for (let i = Math.max(activeIndex - amount, 0); i <= Math.min(slideIndexLastInView + amount, len - 1); i += 1) {
|
1418 | if (i !== activeIndex && (i > slideIndexLastInView || i < activeIndex)) {
|
1419 | unlazy(swiper, i);
|
1420 | }
|
1421 | }
|
1422 | }
|
1423 | };
|
1424 |
|
1425 | function getActiveIndexByTranslate(swiper) {
|
1426 | const {
|
1427 | slidesGrid,
|
1428 | params
|
1429 | } = swiper;
|
1430 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
1431 | let activeIndex;
|
1432 | for (let i = 0; i < slidesGrid.length; i += 1) {
|
1433 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
1434 | if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
|
1435 | activeIndex = i;
|
1436 | } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
|
1437 | activeIndex = i + 1;
|
1438 | }
|
1439 | } else if (translate >= slidesGrid[i]) {
|
1440 | activeIndex = i;
|
1441 | }
|
1442 | }
|
1443 |
|
1444 | if (params.normalizeSlideIndex) {
|
1445 | if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
1446 | }
|
1447 | return activeIndex;
|
1448 | }
|
1449 | function updateActiveIndex(newActiveIndex) {
|
1450 | const swiper = this;
|
1451 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
1452 | const {
|
1453 | snapGrid,
|
1454 | params,
|
1455 | activeIndex: previousIndex,
|
1456 | realIndex: previousRealIndex,
|
1457 | snapIndex: previousSnapIndex
|
1458 | } = swiper;
|
1459 | let activeIndex = newActiveIndex;
|
1460 | let snapIndex;
|
1461 | const getVirtualRealIndex = aIndex => {
|
1462 | let realIndex = aIndex - swiper.virtual.slidesBefore;
|
1463 | if (realIndex < 0) {
|
1464 | realIndex = swiper.virtual.slides.length + realIndex;
|
1465 | }
|
1466 | if (realIndex >= swiper.virtual.slides.length) {
|
1467 | realIndex -= swiper.virtual.slides.length;
|
1468 | }
|
1469 | return realIndex;
|
1470 | };
|
1471 | if (typeof activeIndex === 'undefined') {
|
1472 | activeIndex = getActiveIndexByTranslate(swiper);
|
1473 | }
|
1474 | if (snapGrid.indexOf(translate) >= 0) {
|
1475 | snapIndex = snapGrid.indexOf(translate);
|
1476 | } else {
|
1477 | const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
|
1478 | snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
1479 | }
|
1480 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
1481 | if (activeIndex === previousIndex && !swiper.params.loop) {
|
1482 | if (snapIndex !== previousSnapIndex) {
|
1483 | swiper.snapIndex = snapIndex;
|
1484 | swiper.emit('snapIndexChange');
|
1485 | }
|
1486 | return;
|
1487 | }
|
1488 | if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
1489 | swiper.realIndex = getVirtualRealIndex(activeIndex);
|
1490 | return;
|
1491 | }
|
1492 | const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
1493 |
|
1494 |
|
1495 | let realIndex;
|
1496 | if (swiper.virtual && params.virtual.enabled && params.loop) {
|
1497 | realIndex = getVirtualRealIndex(activeIndex);
|
1498 | } else if (gridEnabled) {
|
1499 | const firstSlideInColumn = swiper.slides.filter(slideEl => slideEl.column === activeIndex)[0];
|
1500 | let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
1501 | if (Number.isNaN(activeSlideIndex)) {
|
1502 | activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
1503 | }
|
1504 | realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
1505 | } else if (swiper.slides[activeIndex]) {
|
1506 | const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
1507 | if (slideIndex) {
|
1508 | realIndex = parseInt(slideIndex, 10);
|
1509 | } else {
|
1510 | realIndex = activeIndex;
|
1511 | }
|
1512 | } else {
|
1513 | realIndex = activeIndex;
|
1514 | }
|
1515 | Object.assign(swiper, {
|
1516 | previousSnapIndex,
|
1517 | snapIndex,
|
1518 | previousRealIndex,
|
1519 | realIndex,
|
1520 | previousIndex,
|
1521 | activeIndex
|
1522 | });
|
1523 | if (swiper.initialized) {
|
1524 | preload(swiper);
|
1525 | }
|
1526 | swiper.emit('activeIndexChange');
|
1527 | swiper.emit('snapIndexChange');
|
1528 | if (swiper.initialized || swiper.params.runCallbacksOnInit) {
|
1529 | if (previousRealIndex !== realIndex) {
|
1530 | swiper.emit('realIndexChange');
|
1531 | }
|
1532 | swiper.emit('slideChange');
|
1533 | }
|
1534 | }
|
1535 |
|
1536 | function updateClickedSlide(el, path) {
|
1537 | const swiper = this;
|
1538 | const params = swiper.params;
|
1539 | let slide = el.closest(`.${params.slideClass}, swiper-slide`);
|
1540 | if (!slide && swiper.isElement && path && path.length > 1 && path.includes(el)) {
|
1541 | [...path.slice(path.indexOf(el) + 1, path.length)].forEach(pathEl => {
|
1542 | if (!slide && pathEl.matches && pathEl.matches(`.${params.slideClass}, swiper-slide`)) {
|
1543 | slide = pathEl;
|
1544 | }
|
1545 | });
|
1546 | }
|
1547 | let slideFound = false;
|
1548 | let slideIndex;
|
1549 | if (slide) {
|
1550 | for (let i = 0; i < swiper.slides.length; i += 1) {
|
1551 | if (swiper.slides[i] === slide) {
|
1552 | slideFound = true;
|
1553 | slideIndex = i;
|
1554 | break;
|
1555 | }
|
1556 | }
|
1557 | }
|
1558 | if (slide && slideFound) {
|
1559 | swiper.clickedSlide = slide;
|
1560 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
1561 | swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
1562 | } else {
|
1563 | swiper.clickedIndex = slideIndex;
|
1564 | }
|
1565 | } else {
|
1566 | swiper.clickedSlide = undefined;
|
1567 | swiper.clickedIndex = undefined;
|
1568 | return;
|
1569 | }
|
1570 | if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
|
1571 | swiper.slideToClickedSlide();
|
1572 | }
|
1573 | }
|
1574 |
|
1575 | var update = {
|
1576 | updateSize,
|
1577 | updateSlides,
|
1578 | updateAutoHeight,
|
1579 | updateSlidesOffset,
|
1580 | updateSlidesProgress,
|
1581 | updateProgress,
|
1582 | updateSlidesClasses,
|
1583 | updateActiveIndex,
|
1584 | updateClickedSlide
|
1585 | };
|
1586 |
|
1587 | function getSwiperTranslate(axis) {
|
1588 | if (axis === void 0) {
|
1589 | axis = this.isHorizontal() ? 'x' : 'y';
|
1590 | }
|
1591 | const swiper = this;
|
1592 | const {
|
1593 | params,
|
1594 | rtlTranslate: rtl,
|
1595 | translate,
|
1596 | wrapperEl
|
1597 | } = swiper;
|
1598 | if (params.virtualTranslate) {
|
1599 | return rtl ? -translate : translate;
|
1600 | }
|
1601 | if (params.cssMode) {
|
1602 | return translate;
|
1603 | }
|
1604 | let currentTranslate = getTranslate(wrapperEl, axis);
|
1605 | currentTranslate += swiper.cssOverflowAdjustment();
|
1606 | if (rtl) currentTranslate = -currentTranslate;
|
1607 | return currentTranslate || 0;
|
1608 | }
|
1609 |
|
1610 | function setTranslate(translate, byController) {
|
1611 | const swiper = this;
|
1612 | const {
|
1613 | rtlTranslate: rtl,
|
1614 | params,
|
1615 | wrapperEl,
|
1616 | progress
|
1617 | } = swiper;
|
1618 | let x = 0;
|
1619 | let y = 0;
|
1620 | const z = 0;
|
1621 | if (swiper.isHorizontal()) {
|
1622 | x = rtl ? -translate : translate;
|
1623 | } else {
|
1624 | y = translate;
|
1625 | }
|
1626 | if (params.roundLengths) {
|
1627 | x = Math.floor(x);
|
1628 | y = Math.floor(y);
|
1629 | }
|
1630 | swiper.previousTranslate = swiper.translate;
|
1631 | swiper.translate = swiper.isHorizontal() ? x : y;
|
1632 | if (params.cssMode) {
|
1633 | wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
1634 | } else if (!params.virtualTranslate) {
|
1635 | if (swiper.isHorizontal()) {
|
1636 | x -= swiper.cssOverflowAdjustment();
|
1637 | } else {
|
1638 | y -= swiper.cssOverflowAdjustment();
|
1639 | }
|
1640 | wrapperEl.style.transform = `translate3d(${x}px, ${y}px, ${z}px)`;
|
1641 | }
|
1642 |
|
1643 |
|
1644 | let newProgress;
|
1645 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
1646 | if (translatesDiff === 0) {
|
1647 | newProgress = 0;
|
1648 | } else {
|
1649 | newProgress = (translate - swiper.minTranslate()) / translatesDiff;
|
1650 | }
|
1651 | if (newProgress !== progress) {
|
1652 | swiper.updateProgress(translate);
|
1653 | }
|
1654 | swiper.emit('setTranslate', swiper.translate, byController);
|
1655 | }
|
1656 |
|
1657 | function minTranslate() {
|
1658 | return -this.snapGrid[0];
|
1659 | }
|
1660 |
|
1661 | function maxTranslate() {
|
1662 | return -this.snapGrid[this.snapGrid.length - 1];
|
1663 | }
|
1664 |
|
1665 | function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
|
1666 | if (translate === void 0) {
|
1667 | translate = 0;
|
1668 | }
|
1669 | if (speed === void 0) {
|
1670 | speed = this.params.speed;
|
1671 | }
|
1672 | if (runCallbacks === void 0) {
|
1673 | runCallbacks = true;
|
1674 | }
|
1675 | if (translateBounds === void 0) {
|
1676 | translateBounds = true;
|
1677 | }
|
1678 | const swiper = this;
|
1679 | const {
|
1680 | params,
|
1681 | wrapperEl
|
1682 | } = swiper;
|
1683 | if (swiper.animating && params.preventInteractionOnTransition) {
|
1684 | return false;
|
1685 | }
|
1686 | const minTranslate = swiper.minTranslate();
|
1687 | const maxTranslate = swiper.maxTranslate();
|
1688 | let newTranslate;
|
1689 | if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
|
1690 |
|
1691 |
|
1692 | swiper.updateProgress(newTranslate);
|
1693 | if (params.cssMode) {
|
1694 | const isH = swiper.isHorizontal();
|
1695 | if (speed === 0) {
|
1696 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
1697 | } else {
|
1698 | if (!swiper.support.smoothScroll) {
|
1699 | animateCSSModeScroll({
|
1700 | swiper,
|
1701 | targetPosition: -newTranslate,
|
1702 | side: isH ? 'left' : 'top'
|
1703 | });
|
1704 | return true;
|
1705 | }
|
1706 | wrapperEl.scrollTo({
|
1707 | [isH ? 'left' : 'top']: -newTranslate,
|
1708 | behavior: 'smooth'
|
1709 | });
|
1710 | }
|
1711 | return true;
|
1712 | }
|
1713 | if (speed === 0) {
|
1714 | swiper.setTransition(0);
|
1715 | swiper.setTranslate(newTranslate);
|
1716 | if (runCallbacks) {
|
1717 | swiper.emit('beforeTransitionStart', speed, internal);
|
1718 | swiper.emit('transitionEnd');
|
1719 | }
|
1720 | } else {
|
1721 | swiper.setTransition(speed);
|
1722 | swiper.setTranslate(newTranslate);
|
1723 | if (runCallbacks) {
|
1724 | swiper.emit('beforeTransitionStart', speed, internal);
|
1725 | swiper.emit('transitionStart');
|
1726 | }
|
1727 | if (!swiper.animating) {
|
1728 | swiper.animating = true;
|
1729 | if (!swiper.onTranslateToWrapperTransitionEnd) {
|
1730 | swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
|
1731 | if (!swiper || swiper.destroyed) return;
|
1732 | if (e.target !== this) return;
|
1733 | swiper.wrapperEl.removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
1734 | swiper.onTranslateToWrapperTransitionEnd = null;
|
1735 | delete swiper.onTranslateToWrapperTransitionEnd;
|
1736 | swiper.animating = false;
|
1737 | if (runCallbacks) {
|
1738 | swiper.emit('transitionEnd');
|
1739 | }
|
1740 | };
|
1741 | }
|
1742 | swiper.wrapperEl.addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
1743 | }
|
1744 | }
|
1745 | return true;
|
1746 | }
|
1747 |
|
1748 | var translate = {
|
1749 | getTranslate: getSwiperTranslate,
|
1750 | setTranslate,
|
1751 | minTranslate,
|
1752 | maxTranslate,
|
1753 | translateTo
|
1754 | };
|
1755 |
|
1756 | function setTransition(duration, byController) {
|
1757 | const swiper = this;
|
1758 | if (!swiper.params.cssMode) {
|
1759 | swiper.wrapperEl.style.transitionDuration = `${duration}ms`;
|
1760 | swiper.wrapperEl.style.transitionDelay = duration === 0 ? `0ms` : '';
|
1761 | }
|
1762 | swiper.emit('setTransition', duration, byController);
|
1763 | }
|
1764 |
|
1765 | function transitionEmit(_ref) {
|
1766 | let {
|
1767 | swiper,
|
1768 | runCallbacks,
|
1769 | direction,
|
1770 | step
|
1771 | } = _ref;
|
1772 | const {
|
1773 | activeIndex,
|
1774 | previousIndex
|
1775 | } = swiper;
|
1776 | let dir = direction;
|
1777 | if (!dir) {
|
1778 | if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
|
1779 | }
|
1780 | swiper.emit(`transition${step}`);
|
1781 | if (runCallbacks && activeIndex !== previousIndex) {
|
1782 | if (dir === 'reset') {
|
1783 | swiper.emit(`slideResetTransition${step}`);
|
1784 | return;
|
1785 | }
|
1786 | swiper.emit(`slideChangeTransition${step}`);
|
1787 | if (dir === 'next') {
|
1788 | swiper.emit(`slideNextTransition${step}`);
|
1789 | } else {
|
1790 | swiper.emit(`slidePrevTransition${step}`);
|
1791 | }
|
1792 | }
|
1793 | }
|
1794 |
|
1795 | function transitionStart(runCallbacks, direction) {
|
1796 | if (runCallbacks === void 0) {
|
1797 | runCallbacks = true;
|
1798 | }
|
1799 | const swiper = this;
|
1800 | const {
|
1801 | params
|
1802 | } = swiper;
|
1803 | if (params.cssMode) return;
|
1804 | if (params.autoHeight) {
|
1805 | swiper.updateAutoHeight();
|
1806 | }
|
1807 | transitionEmit({
|
1808 | swiper,
|
1809 | runCallbacks,
|
1810 | direction,
|
1811 | step: 'Start'
|
1812 | });
|
1813 | }
|
1814 |
|
1815 | function transitionEnd(runCallbacks, direction) {
|
1816 | if (runCallbacks === void 0) {
|
1817 | runCallbacks = true;
|
1818 | }
|
1819 | const swiper = this;
|
1820 | const {
|
1821 | params
|
1822 | } = swiper;
|
1823 | swiper.animating = false;
|
1824 | if (params.cssMode) return;
|
1825 | swiper.setTransition(0);
|
1826 | transitionEmit({
|
1827 | swiper,
|
1828 | runCallbacks,
|
1829 | direction,
|
1830 | step: 'End'
|
1831 | });
|
1832 | }
|
1833 |
|
1834 | var transition = {
|
1835 | setTransition,
|
1836 | transitionStart,
|
1837 | transitionEnd
|
1838 | };
|
1839 |
|
1840 | function slideTo(index, speed, runCallbacks, internal, initial) {
|
1841 | if (index === void 0) {
|
1842 | index = 0;
|
1843 | }
|
1844 | if (runCallbacks === void 0) {
|
1845 | runCallbacks = true;
|
1846 | }
|
1847 | if (typeof index === 'string') {
|
1848 | index = parseInt(index, 10);
|
1849 | }
|
1850 | const swiper = this;
|
1851 | let slideIndex = index;
|
1852 | if (slideIndex < 0) slideIndex = 0;
|
1853 | const {
|
1854 | params,
|
1855 | snapGrid,
|
1856 | slidesGrid,
|
1857 | previousIndex,
|
1858 | activeIndex,
|
1859 | rtlTranslate: rtl,
|
1860 | wrapperEl,
|
1861 | enabled
|
1862 | } = swiper;
|
1863 | if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) {
|
1864 | return false;
|
1865 | }
|
1866 | if (typeof speed === 'undefined') {
|
1867 | speed = swiper.params.speed;
|
1868 | }
|
1869 | const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
1870 | let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
1871 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
1872 | const translate = -snapGrid[snapIndex];
|
1873 |
|
1874 | if (params.normalizeSlideIndex) {
|
1875 | for (let i = 0; i < slidesGrid.length; i += 1) {
|
1876 | const normalizedTranslate = -Math.floor(translate * 100);
|
1877 | const normalizedGrid = Math.floor(slidesGrid[i] * 100);
|
1878 | const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
|
1879 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
1880 | if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
|
1881 | slideIndex = i;
|
1882 | } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
|
1883 | slideIndex = i + 1;
|
1884 | }
|
1885 | } else if (normalizedTranslate >= normalizedGrid) {
|
1886 | slideIndex = i;
|
1887 | }
|
1888 | }
|
1889 | }
|
1890 |
|
1891 | if (swiper.initialized && slideIndex !== activeIndex) {
|
1892 | if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
1893 | return false;
|
1894 | }
|
1895 | if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
1896 | if ((activeIndex || 0) !== slideIndex) {
|
1897 | return false;
|
1898 | }
|
1899 | }
|
1900 | }
|
1901 | if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
1902 | swiper.emit('beforeSlideChangeStart');
|
1903 | }
|
1904 |
|
1905 |
|
1906 | swiper.updateProgress(translate);
|
1907 | let direction;
|
1908 | if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
1909 |
|
1910 |
|
1911 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
1912 | const isInitialVirtual = isVirtual && initial;
|
1913 |
|
1914 | if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
1915 | swiper.updateActiveIndex(slideIndex);
|
1916 |
|
1917 | if (params.autoHeight) {
|
1918 | swiper.updateAutoHeight();
|
1919 | }
|
1920 | swiper.updateSlidesClasses();
|
1921 | if (params.effect !== 'slide') {
|
1922 | swiper.setTranslate(translate);
|
1923 | }
|
1924 | if (direction !== 'reset') {
|
1925 | swiper.transitionStart(runCallbacks, direction);
|
1926 | swiper.transitionEnd(runCallbacks, direction);
|
1927 | }
|
1928 | return false;
|
1929 | }
|
1930 | if (params.cssMode) {
|
1931 | const isH = swiper.isHorizontal();
|
1932 | const t = rtl ? translate : -translate;
|
1933 | if (speed === 0) {
|
1934 | if (isVirtual) {
|
1935 | swiper.wrapperEl.style.scrollSnapType = 'none';
|
1936 | swiper._immediateVirtual = true;
|
1937 | }
|
1938 | if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
1939 | swiper._cssModeVirtualInitialSet = true;
|
1940 | requestAnimationFrame(() => {
|
1941 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
1942 | });
|
1943 | } else {
|
1944 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
1945 | }
|
1946 | if (isVirtual) {
|
1947 | requestAnimationFrame(() => {
|
1948 | swiper.wrapperEl.style.scrollSnapType = '';
|
1949 | swiper._immediateVirtual = false;
|
1950 | });
|
1951 | }
|
1952 | } else {
|
1953 | if (!swiper.support.smoothScroll) {
|
1954 | animateCSSModeScroll({
|
1955 | swiper,
|
1956 | targetPosition: t,
|
1957 | side: isH ? 'left' : 'top'
|
1958 | });
|
1959 | return true;
|
1960 | }
|
1961 | wrapperEl.scrollTo({
|
1962 | [isH ? 'left' : 'top']: t,
|
1963 | behavior: 'smooth'
|
1964 | });
|
1965 | }
|
1966 | return true;
|
1967 | }
|
1968 | swiper.setTransition(speed);
|
1969 | swiper.setTranslate(translate);
|
1970 | swiper.updateActiveIndex(slideIndex);
|
1971 | swiper.updateSlidesClasses();
|
1972 | swiper.emit('beforeTransitionStart', speed, internal);
|
1973 | swiper.transitionStart(runCallbacks, direction);
|
1974 | if (speed === 0) {
|
1975 | swiper.transitionEnd(runCallbacks, direction);
|
1976 | } else if (!swiper.animating) {
|
1977 | swiper.animating = true;
|
1978 | if (!swiper.onSlideToWrapperTransitionEnd) {
|
1979 | swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
|
1980 | if (!swiper || swiper.destroyed) return;
|
1981 | if (e.target !== this) return;
|
1982 | swiper.wrapperEl.removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
1983 | swiper.onSlideToWrapperTransitionEnd = null;
|
1984 | delete swiper.onSlideToWrapperTransitionEnd;
|
1985 | swiper.transitionEnd(runCallbacks, direction);
|
1986 | };
|
1987 | }
|
1988 | swiper.wrapperEl.addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
1989 | }
|
1990 | return true;
|
1991 | }
|
1992 |
|
1993 | function slideToLoop(index, speed, runCallbacks, internal) {
|
1994 | if (index === void 0) {
|
1995 | index = 0;
|
1996 | }
|
1997 | if (runCallbacks === void 0) {
|
1998 | runCallbacks = true;
|
1999 | }
|
2000 | if (typeof index === 'string') {
|
2001 | const indexAsNumber = parseInt(index, 10);
|
2002 | index = indexAsNumber;
|
2003 | }
|
2004 | const swiper = this;
|
2005 | if (swiper.destroyed) return;
|
2006 | if (typeof speed === 'undefined') {
|
2007 | speed = swiper.params.speed;
|
2008 | }
|
2009 | const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
2010 | let newIndex = index;
|
2011 | if (swiper.params.loop) {
|
2012 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
2013 |
|
2014 | newIndex = newIndex + swiper.virtual.slidesBefore;
|
2015 | } else {
|
2016 | let targetSlideIndex;
|
2017 | if (gridEnabled) {
|
2018 | const slideIndex = newIndex * swiper.params.grid.rows;
|
2019 | targetSlideIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
|
2020 | } else {
|
2021 | targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
2022 | }
|
2023 | const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
|
2024 | const {
|
2025 | centeredSlides
|
2026 | } = swiper.params;
|
2027 | let slidesPerView = swiper.params.slidesPerView;
|
2028 | if (slidesPerView === 'auto') {
|
2029 | slidesPerView = swiper.slidesPerViewDynamic();
|
2030 | } else {
|
2031 | slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
2032 | if (centeredSlides && slidesPerView % 2 === 0) {
|
2033 | slidesPerView = slidesPerView + 1;
|
2034 | }
|
2035 | }
|
2036 | let needLoopFix = cols - targetSlideIndex < slidesPerView;
|
2037 | if (centeredSlides) {
|
2038 | needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
|
2039 | }
|
2040 | if (internal && centeredSlides && swiper.params.slidesPerView !== 'auto' && !gridEnabled) {
|
2041 | needLoopFix = false;
|
2042 | }
|
2043 | if (needLoopFix) {
|
2044 | const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
|
2045 | swiper.loopFix({
|
2046 | direction,
|
2047 | slideTo: true,
|
2048 | activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
2049 | slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
|
2050 | });
|
2051 | }
|
2052 | if (gridEnabled) {
|
2053 | const slideIndex = newIndex * swiper.params.grid.rows;
|
2054 | newIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
|
2055 | } else {
|
2056 | newIndex = swiper.getSlideIndexByData(newIndex);
|
2057 | }
|
2058 | }
|
2059 | }
|
2060 | requestAnimationFrame(() => {
|
2061 | swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
2062 | });
|
2063 | return swiper;
|
2064 | }
|
2065 |
|
2066 |
|
2067 | function slideNext(speed, runCallbacks, internal) {
|
2068 | if (runCallbacks === void 0) {
|
2069 | runCallbacks = true;
|
2070 | }
|
2071 | const swiper = this;
|
2072 | const {
|
2073 | enabled,
|
2074 | params,
|
2075 | animating
|
2076 | } = swiper;
|
2077 | if (!enabled || swiper.destroyed) return swiper;
|
2078 | if (typeof speed === 'undefined') {
|
2079 | speed = swiper.params.speed;
|
2080 | }
|
2081 | let perGroup = params.slidesPerGroup;
|
2082 | if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
2083 | perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
2084 | }
|
2085 | const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
2086 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
2087 | if (params.loop) {
|
2088 | if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
2089 | swiper.loopFix({
|
2090 | direction: 'next'
|
2091 | });
|
2092 |
|
2093 | swiper._clientLeft = swiper.wrapperEl.clientLeft;
|
2094 | if (swiper.activeIndex === swiper.slides.length - 1 && params.cssMode) {
|
2095 | requestAnimationFrame(() => {
|
2096 | swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
2097 | });
|
2098 | return true;
|
2099 | }
|
2100 | }
|
2101 | if (params.rewind && swiper.isEnd) {
|
2102 | return swiper.slideTo(0, speed, runCallbacks, internal);
|
2103 | }
|
2104 | return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
2105 | }
|
2106 |
|
2107 |
|
2108 | function slidePrev(speed, runCallbacks, internal) {
|
2109 | if (runCallbacks === void 0) {
|
2110 | runCallbacks = true;
|
2111 | }
|
2112 | const swiper = this;
|
2113 | const {
|
2114 | params,
|
2115 | snapGrid,
|
2116 | slidesGrid,
|
2117 | rtlTranslate,
|
2118 | enabled,
|
2119 | animating
|
2120 | } = swiper;
|
2121 | if (!enabled || swiper.destroyed) return swiper;
|
2122 | if (typeof speed === 'undefined') {
|
2123 | speed = swiper.params.speed;
|
2124 | }
|
2125 | const isVirtual = swiper.virtual && params.virtual.enabled;
|
2126 | if (params.loop) {
|
2127 | if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
2128 | swiper.loopFix({
|
2129 | direction: 'prev'
|
2130 | });
|
2131 |
|
2132 | swiper._clientLeft = swiper.wrapperEl.clientLeft;
|
2133 | }
|
2134 | const translate = rtlTranslate ? swiper.translate : -swiper.translate;
|
2135 | function normalize(val) {
|
2136 | if (val < 0) return -Math.floor(Math.abs(val));
|
2137 | return Math.floor(val);
|
2138 | }
|
2139 | const normalizedTranslate = normalize(translate);
|
2140 | const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
2141 | let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
2142 | if (typeof prevSnap === 'undefined' && params.cssMode) {
|
2143 | let prevSnapIndex;
|
2144 | snapGrid.forEach((snap, snapIndex) => {
|
2145 | if (normalizedTranslate >= snap) {
|
2146 |
|
2147 | prevSnapIndex = snapIndex;
|
2148 | }
|
2149 | });
|
2150 | if (typeof prevSnapIndex !== 'undefined') {
|
2151 | prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
2152 | }
|
2153 | }
|
2154 | let prevIndex = 0;
|
2155 | if (typeof prevSnap !== 'undefined') {
|
2156 | prevIndex = slidesGrid.indexOf(prevSnap);
|
2157 | if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
|
2158 | if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
2159 | prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
|
2160 | prevIndex = Math.max(prevIndex, 0);
|
2161 | }
|
2162 | }
|
2163 | if (params.rewind && swiper.isBeginning) {
|
2164 | const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
2165 | return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
2166 | } else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
2167 | requestAnimationFrame(() => {
|
2168 | swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
2169 | });
|
2170 | return true;
|
2171 | }
|
2172 | return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
2173 | }
|
2174 |
|
2175 |
|
2176 | function slideReset(speed, runCallbacks, internal) {
|
2177 | if (runCallbacks === void 0) {
|
2178 | runCallbacks = true;
|
2179 | }
|
2180 | const swiper = this;
|
2181 | if (swiper.destroyed) return;
|
2182 | if (typeof speed === 'undefined') {
|
2183 | speed = swiper.params.speed;
|
2184 | }
|
2185 | return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
2186 | }
|
2187 |
|
2188 |
|
2189 | function slideToClosest(speed, runCallbacks, internal, threshold) {
|
2190 | if (runCallbacks === void 0) {
|
2191 | runCallbacks = true;
|
2192 | }
|
2193 | if (threshold === void 0) {
|
2194 | threshold = 0.5;
|
2195 | }
|
2196 | const swiper = this;
|
2197 | if (swiper.destroyed) return;
|
2198 | if (typeof speed === 'undefined') {
|
2199 | speed = swiper.params.speed;
|
2200 | }
|
2201 | let index = swiper.activeIndex;
|
2202 | const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
2203 | const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
2204 | const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
2205 | if (translate >= swiper.snapGrid[snapIndex]) {
|
2206 |
|
2207 |
|
2208 | const currentSnap = swiper.snapGrid[snapIndex];
|
2209 | const nextSnap = swiper.snapGrid[snapIndex + 1];
|
2210 | if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
|
2211 | index += swiper.params.slidesPerGroup;
|
2212 | }
|
2213 | } else {
|
2214 |
|
2215 |
|
2216 | const prevSnap = swiper.snapGrid[snapIndex - 1];
|
2217 | const currentSnap = swiper.snapGrid[snapIndex];
|
2218 | if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
|
2219 | index -= swiper.params.slidesPerGroup;
|
2220 | }
|
2221 | }
|
2222 | index = Math.max(index, 0);
|
2223 | index = Math.min(index, swiper.slidesGrid.length - 1);
|
2224 | return swiper.slideTo(index, speed, runCallbacks, internal);
|
2225 | }
|
2226 |
|
2227 | function slideToClickedSlide() {
|
2228 | const swiper = this;
|
2229 | if (swiper.destroyed) return;
|
2230 | const {
|
2231 | params,
|
2232 | slidesEl
|
2233 | } = swiper;
|
2234 | const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
2235 | let slideToIndex = swiper.clickedIndex;
|
2236 | let realIndex;
|
2237 | const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
2238 | if (params.loop) {
|
2239 | if (swiper.animating) return;
|
2240 | realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
2241 | if (params.centeredSlides) {
|
2242 | if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
|
2243 | swiper.loopFix();
|
2244 | slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
2245 | nextTick(() => {
|
2246 | swiper.slideTo(slideToIndex);
|
2247 | });
|
2248 | } else {
|
2249 | swiper.slideTo(slideToIndex);
|
2250 | }
|
2251 | } else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
2252 | swiper.loopFix();
|
2253 | slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
2254 | nextTick(() => {
|
2255 | swiper.slideTo(slideToIndex);
|
2256 | });
|
2257 | } else {
|
2258 | swiper.slideTo(slideToIndex);
|
2259 | }
|
2260 | } else {
|
2261 | swiper.slideTo(slideToIndex);
|
2262 | }
|
2263 | }
|
2264 |
|
2265 | var slide = {
|
2266 | slideTo,
|
2267 | slideToLoop,
|
2268 | slideNext,
|
2269 | slidePrev,
|
2270 | slideReset,
|
2271 | slideToClosest,
|
2272 | slideToClickedSlide
|
2273 | };
|
2274 |
|
2275 | function loopCreate(slideRealIndex) {
|
2276 | const swiper = this;
|
2277 | const {
|
2278 | params,
|
2279 | slidesEl
|
2280 | } = swiper;
|
2281 | if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
2282 | const initSlides = () => {
|
2283 | const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
2284 | slides.forEach((el, index) => {
|
2285 | el.setAttribute('data-swiper-slide-index', index);
|
2286 | });
|
2287 | };
|
2288 | const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
2289 | const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
|
2290 | const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
2291 | const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
2292 | const addBlankSlides = amountOfSlides => {
|
2293 | for (let i = 0; i < amountOfSlides; i += 1) {
|
2294 | const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
2295 | swiper.slidesEl.append(slideEl);
|
2296 | }
|
2297 | };
|
2298 | if (shouldFillGroup) {
|
2299 | if (params.loopAddBlankSlides) {
|
2300 | const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
|
2301 | addBlankSlides(slidesToAdd);
|
2302 | swiper.recalcSlides();
|
2303 | swiper.updateSlides();
|
2304 | } else {
|
2305 | showWarning('Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
|
2306 | }
|
2307 | initSlides();
|
2308 | } else if (shouldFillGrid) {
|
2309 | if (params.loopAddBlankSlides) {
|
2310 | const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
2311 | addBlankSlides(slidesToAdd);
|
2312 | swiper.recalcSlides();
|
2313 | swiper.updateSlides();
|
2314 | } else {
|
2315 | showWarning('Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
|
2316 | }
|
2317 | initSlides();
|
2318 | } else {
|
2319 | initSlides();
|
2320 | }
|
2321 | swiper.loopFix({
|
2322 | slideRealIndex,
|
2323 | direction: params.centeredSlides ? undefined : 'next'
|
2324 | });
|
2325 | }
|
2326 |
|
2327 | function loopFix(_temp) {
|
2328 | let {
|
2329 | slideRealIndex,
|
2330 | slideTo = true,
|
2331 | direction,
|
2332 | setTranslate,
|
2333 | activeSlideIndex,
|
2334 | byController,
|
2335 | byMousewheel
|
2336 | } = _temp === void 0 ? {} : _temp;
|
2337 | const swiper = this;
|
2338 | if (!swiper.params.loop) return;
|
2339 | swiper.emit('beforeLoopFix');
|
2340 | const {
|
2341 | slides,
|
2342 | allowSlidePrev,
|
2343 | allowSlideNext,
|
2344 | slidesEl,
|
2345 | params
|
2346 | } = swiper;
|
2347 | const {
|
2348 | centeredSlides
|
2349 | } = params;
|
2350 | swiper.allowSlidePrev = true;
|
2351 | swiper.allowSlideNext = true;
|
2352 | if (swiper.virtual && params.virtual.enabled) {
|
2353 | if (slideTo) {
|
2354 | if (!params.centeredSlides && swiper.snapIndex === 0) {
|
2355 | swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
2356 | } else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
2357 | swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
2358 | } else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
2359 | swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
2360 | }
|
2361 | }
|
2362 | swiper.allowSlidePrev = allowSlidePrev;
|
2363 | swiper.allowSlideNext = allowSlideNext;
|
2364 | swiper.emit('loopFix');
|
2365 | return;
|
2366 | }
|
2367 | let slidesPerView = params.slidesPerView;
|
2368 | if (slidesPerView === 'auto') {
|
2369 | slidesPerView = swiper.slidesPerViewDynamic();
|
2370 | } else {
|
2371 | slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
|
2372 | if (centeredSlides && slidesPerView % 2 === 0) {
|
2373 | slidesPerView = slidesPerView + 1;
|
2374 | }
|
2375 | }
|
2376 | const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
|
2377 | let loopedSlides = slidesPerGroup;
|
2378 | if (loopedSlides % slidesPerGroup !== 0) {
|
2379 | loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
2380 | }
|
2381 | loopedSlides += params.loopAdditionalSlides;
|
2382 | swiper.loopedSlides = loopedSlides;
|
2383 | const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
2384 | if (slides.length < slidesPerView + loopedSlides) {
|
2385 | showWarning('Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters');
|
2386 | } else if (gridEnabled && params.grid.fill === 'row') {
|
2387 | showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
2388 | }
|
2389 | const prependSlidesIndexes = [];
|
2390 | const appendSlidesIndexes = [];
|
2391 | let activeIndex = swiper.activeIndex;
|
2392 | if (typeof activeSlideIndex === 'undefined') {
|
2393 | activeSlideIndex = swiper.getSlideIndex(slides.filter(el => el.classList.contains(params.slideActiveClass))[0]);
|
2394 | } else {
|
2395 | activeIndex = activeSlideIndex;
|
2396 | }
|
2397 | const isNext = direction === 'next' || !direction;
|
2398 | const isPrev = direction === 'prev' || !direction;
|
2399 | let slidesPrepended = 0;
|
2400 | let slidesAppended = 0;
|
2401 | const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
|
2402 | const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
|
2403 | const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
2404 |
|
2405 | if (activeColIndexWithShift < loopedSlides) {
|
2406 | slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
2407 | for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
2408 | const index = i - Math.floor(i / cols) * cols;
|
2409 | if (gridEnabled) {
|
2410 | const colIndexToPrepend = cols - index - 1;
|
2411 | for (let i = slides.length - 1; i >= 0; i -= 1) {
|
2412 | if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
2413 | }
|
2414 |
|
2415 |
|
2416 |
|
2417 | } else {
|
2418 | prependSlidesIndexes.push(cols - index - 1);
|
2419 | }
|
2420 | }
|
2421 | } else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
2422 | slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
2423 | for (let i = 0; i < slidesAppended; i += 1) {
|
2424 | const index = i - Math.floor(i / cols) * cols;
|
2425 | if (gridEnabled) {
|
2426 | slides.forEach((slide, slideIndex) => {
|
2427 | if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
2428 | });
|
2429 | } else {
|
2430 | appendSlidesIndexes.push(index);
|
2431 | }
|
2432 | }
|
2433 | }
|
2434 | swiper.__preventObserver__ = true;
|
2435 | requestAnimationFrame(() => {
|
2436 | swiper.__preventObserver__ = false;
|
2437 | });
|
2438 | if (isPrev) {
|
2439 | prependSlidesIndexes.forEach(index => {
|
2440 | slides[index].swiperLoopMoveDOM = true;
|
2441 | slidesEl.prepend(slides[index]);
|
2442 | slides[index].swiperLoopMoveDOM = false;
|
2443 | });
|
2444 | }
|
2445 | if (isNext) {
|
2446 | appendSlidesIndexes.forEach(index => {
|
2447 | slides[index].swiperLoopMoveDOM = true;
|
2448 | slidesEl.append(slides[index]);
|
2449 | slides[index].swiperLoopMoveDOM = false;
|
2450 | });
|
2451 | }
|
2452 | swiper.recalcSlides();
|
2453 | if (params.slidesPerView === 'auto') {
|
2454 | swiper.updateSlides();
|
2455 | } else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
2456 | swiper.slides.forEach((slide, slideIndex) => {
|
2457 | swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
2458 | });
|
2459 | }
|
2460 | if (params.watchSlidesProgress) {
|
2461 | swiper.updateSlidesOffset();
|
2462 | }
|
2463 | if (slideTo) {
|
2464 | if (prependSlidesIndexes.length > 0 && isPrev) {
|
2465 | if (typeof slideRealIndex === 'undefined') {
|
2466 | const currentSlideTranslate = swiper.slidesGrid[activeIndex];
|
2467 | const newSlideTranslate = swiper.slidesGrid[activeIndex + slidesPrepended];
|
2468 | const diff = newSlideTranslate - currentSlideTranslate;
|
2469 | if (byMousewheel) {
|
2470 | swiper.setTranslate(swiper.translate - diff);
|
2471 | } else {
|
2472 | swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
|
2473 | if (setTranslate) {
|
2474 | swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
2475 | swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
2476 | }
|
2477 | }
|
2478 | } else {
|
2479 | if (setTranslate) {
|
2480 | const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
|
2481 | swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
2482 | swiper.touchEventsData.currentTranslate = swiper.translate;
|
2483 | }
|
2484 | }
|
2485 | } else if (appendSlidesIndexes.length > 0 && isNext) {
|
2486 | if (typeof slideRealIndex === 'undefined') {
|
2487 | const currentSlideTranslate = swiper.slidesGrid[activeIndex];
|
2488 | const newSlideTranslate = swiper.slidesGrid[activeIndex - slidesAppended];
|
2489 | const diff = newSlideTranslate - currentSlideTranslate;
|
2490 | if (byMousewheel) {
|
2491 | swiper.setTranslate(swiper.translate - diff);
|
2492 | } else {
|
2493 | swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
|
2494 | if (setTranslate) {
|
2495 | swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
2496 | swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
2497 | }
|
2498 | }
|
2499 | } else {
|
2500 | const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
|
2501 | swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
2502 | }
|
2503 | }
|
2504 | }
|
2505 | swiper.allowSlidePrev = allowSlidePrev;
|
2506 | swiper.allowSlideNext = allowSlideNext;
|
2507 | if (swiper.controller && swiper.controller.control && !byController) {
|
2508 | const loopParams = {
|
2509 | slideRealIndex,
|
2510 | direction,
|
2511 | setTranslate,
|
2512 | activeSlideIndex,
|
2513 | byController: true
|
2514 | };
|
2515 | if (Array.isArray(swiper.controller.control)) {
|
2516 | swiper.controller.control.forEach(c => {
|
2517 | if (!c.destroyed && c.params.loop) c.loopFix({
|
2518 | ...loopParams,
|
2519 | slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
2520 | });
|
2521 | });
|
2522 | } else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
2523 | swiper.controller.control.loopFix({
|
2524 | ...loopParams,
|
2525 | slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
2526 | });
|
2527 | }
|
2528 | }
|
2529 | swiper.emit('loopFix');
|
2530 | }
|
2531 |
|
2532 | function loopDestroy() {
|
2533 | const swiper = this;
|
2534 | const {
|
2535 | params,
|
2536 | slidesEl
|
2537 | } = swiper;
|
2538 | if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
2539 | swiper.recalcSlides();
|
2540 | const newSlidesOrder = [];
|
2541 | swiper.slides.forEach(slideEl => {
|
2542 | const index = typeof slideEl.swiperSlideIndex === 'undefined' ? slideEl.getAttribute('data-swiper-slide-index') * 1 : slideEl.swiperSlideIndex;
|
2543 | newSlidesOrder[index] = slideEl;
|
2544 | });
|
2545 | swiper.slides.forEach(slideEl => {
|
2546 | slideEl.removeAttribute('data-swiper-slide-index');
|
2547 | });
|
2548 | newSlidesOrder.forEach(slideEl => {
|
2549 | slidesEl.append(slideEl);
|
2550 | });
|
2551 | swiper.recalcSlides();
|
2552 | swiper.slideTo(swiper.realIndex, 0);
|
2553 | }
|
2554 |
|
2555 | var loop = {
|
2556 | loopCreate,
|
2557 | loopFix,
|
2558 | loopDestroy
|
2559 | };
|
2560 |
|
2561 | function setGrabCursor(moving) {
|
2562 | const swiper = this;
|
2563 | if (!swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
|
2564 | const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
|
2565 | if (swiper.isElement) {
|
2566 | swiper.__preventObserver__ = true;
|
2567 | }
|
2568 | el.style.cursor = 'move';
|
2569 | el.style.cursor = moving ? 'grabbing' : 'grab';
|
2570 | if (swiper.isElement) {
|
2571 | requestAnimationFrame(() => {
|
2572 | swiper.__preventObserver__ = false;
|
2573 | });
|
2574 | }
|
2575 | }
|
2576 |
|
2577 | function unsetGrabCursor() {
|
2578 | const swiper = this;
|
2579 | if (swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
|
2580 | return;
|
2581 | }
|
2582 | if (swiper.isElement) {
|
2583 | swiper.__preventObserver__ = true;
|
2584 | }
|
2585 | swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
|
2586 | if (swiper.isElement) {
|
2587 | requestAnimationFrame(() => {
|
2588 | swiper.__preventObserver__ = false;
|
2589 | });
|
2590 | }
|
2591 | }
|
2592 |
|
2593 | var grabCursor = {
|
2594 | setGrabCursor,
|
2595 | unsetGrabCursor
|
2596 | };
|
2597 |
|
2598 |
|
2599 | function closestElement(selector, base) {
|
2600 | if (base === void 0) {
|
2601 | base = this;
|
2602 | }
|
2603 | function __closestFrom(el) {
|
2604 | if (!el || el === getDocument() || el === getWindow()) return null;
|
2605 | if (el.assignedSlot) el = el.assignedSlot;
|
2606 | const found = el.closest(selector);
|
2607 | if (!found && !el.getRootNode) {
|
2608 | return null;
|
2609 | }
|
2610 | return found || __closestFrom(el.getRootNode().host);
|
2611 | }
|
2612 | return __closestFrom(base);
|
2613 | }
|
2614 | function preventEdgeSwipe(swiper, event, startX) {
|
2615 | const window = getWindow();
|
2616 | const {
|
2617 | params
|
2618 | } = swiper;
|
2619 | const edgeSwipeDetection = params.edgeSwipeDetection;
|
2620 | const edgeSwipeThreshold = params.edgeSwipeThreshold;
|
2621 | if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
2622 | if (edgeSwipeDetection === 'prevent') {
|
2623 | event.preventDefault();
|
2624 | return true;
|
2625 | }
|
2626 | return false;
|
2627 | }
|
2628 | return true;
|
2629 | }
|
2630 | function onTouchStart(event) {
|
2631 | const swiper = this;
|
2632 | const document = getDocument();
|
2633 | let e = event;
|
2634 | if (e.originalEvent) e = e.originalEvent;
|
2635 | const data = swiper.touchEventsData;
|
2636 | if (e.type === 'pointerdown') {
|
2637 | if (data.pointerId !== null && data.pointerId !== e.pointerId) {
|
2638 | return;
|
2639 | }
|
2640 | data.pointerId = e.pointerId;
|
2641 | } else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
2642 | data.touchId = e.targetTouches[0].identifier;
|
2643 | }
|
2644 | if (e.type === 'touchstart') {
|
2645 |
|
2646 | preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
|
2647 | return;
|
2648 | }
|
2649 | const {
|
2650 | params,
|
2651 | touches,
|
2652 | enabled
|
2653 | } = swiper;
|
2654 | if (!enabled) return;
|
2655 | if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
2656 | if (swiper.animating && params.preventInteractionOnTransition) {
|
2657 | return;
|
2658 | }
|
2659 | if (!swiper.animating && params.cssMode && params.loop) {
|
2660 | swiper.loopFix();
|
2661 | }
|
2662 | let targetEl = e.target;
|
2663 | if (params.touchEventsTarget === 'wrapper') {
|
2664 | if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
|
2665 | }
|
2666 | if ('which' in e && e.which === 3) return;
|
2667 | if ('button' in e && e.button > 0) return;
|
2668 | if (data.isTouched && data.isMoved) return;
|
2669 |
|
2670 |
|
2671 | const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
2672 |
|
2673 | const eventPath = e.composedPath ? e.composedPath() : e.path;
|
2674 | if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
|
2675 | targetEl = eventPath[0];
|
2676 | }
|
2677 | const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
2678 | const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
2679 |
|
2680 |
|
2681 | if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
2682 | swiper.allowClick = true;
|
2683 | return;
|
2684 | }
|
2685 | if (params.swipeHandler) {
|
2686 | if (!targetEl.closest(params.swipeHandler)) return;
|
2687 | }
|
2688 | touches.currentX = e.pageX;
|
2689 | touches.currentY = e.pageY;
|
2690 | const startX = touches.currentX;
|
2691 | const startY = touches.currentY;
|
2692 |
|
2693 |
|
2694 |
|
2695 | if (!preventEdgeSwipe(swiper, e, startX)) {
|
2696 | return;
|
2697 | }
|
2698 | Object.assign(data, {
|
2699 | isTouched: true,
|
2700 | isMoved: false,
|
2701 | allowTouchCallbacks: true,
|
2702 | isScrolling: undefined,
|
2703 | startMoving: undefined
|
2704 | });
|
2705 | touches.startX = startX;
|
2706 | touches.startY = startY;
|
2707 | data.touchStartTime = now();
|
2708 | swiper.allowClick = true;
|
2709 | swiper.updateSize();
|
2710 | swiper.swipeDirection = undefined;
|
2711 | if (params.threshold > 0) data.allowThresholdMove = false;
|
2712 | let preventDefault = true;
|
2713 | if (targetEl.matches(data.focusableElements)) {
|
2714 | preventDefault = false;
|
2715 | if (targetEl.nodeName === 'SELECT') {
|
2716 | data.isTouched = false;
|
2717 | }
|
2718 | }
|
2719 | if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== targetEl && (e.pointerType === 'mouse' || e.pointerType !== 'mouse' && !targetEl.matches(data.focusableElements))) {
|
2720 | document.activeElement.blur();
|
2721 | }
|
2722 | const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
2723 | if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
2724 | e.preventDefault();
|
2725 | }
|
2726 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
2727 | swiper.freeMode.onTouchStart();
|
2728 | }
|
2729 | swiper.emit('touchStart', e);
|
2730 | }
|
2731 |
|
2732 | function onTouchMove(event) {
|
2733 | const document = getDocument();
|
2734 | const swiper = this;
|
2735 | const data = swiper.touchEventsData;
|
2736 | const {
|
2737 | params,
|
2738 | touches,
|
2739 | rtlTranslate: rtl,
|
2740 | enabled
|
2741 | } = swiper;
|
2742 | if (!enabled) return;
|
2743 | if (!params.simulateTouch && event.pointerType === 'mouse') return;
|
2744 | let e = event;
|
2745 | if (e.originalEvent) e = e.originalEvent;
|
2746 | if (e.type === 'pointermove') {
|
2747 | if (data.touchId !== null) return;
|
2748 | const id = e.pointerId;
|
2749 | if (id !== data.pointerId) return;
|
2750 | }
|
2751 | let targetTouch;
|
2752 | if (e.type === 'touchmove') {
|
2753 | targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
|
2754 | if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
2755 | } else {
|
2756 | targetTouch = e;
|
2757 | }
|
2758 | if (!data.isTouched) {
|
2759 | if (data.startMoving && data.isScrolling) {
|
2760 | swiper.emit('touchMoveOpposite', e);
|
2761 | }
|
2762 | return;
|
2763 | }
|
2764 | const pageX = targetTouch.pageX;
|
2765 | const pageY = targetTouch.pageY;
|
2766 | if (e.preventedByNestedSwiper) {
|
2767 | touches.startX = pageX;
|
2768 | touches.startY = pageY;
|
2769 | return;
|
2770 | }
|
2771 | if (!swiper.allowTouchMove) {
|
2772 | if (!e.target.matches(data.focusableElements)) {
|
2773 | swiper.allowClick = false;
|
2774 | }
|
2775 | if (data.isTouched) {
|
2776 | Object.assign(touches, {
|
2777 | startX: pageX,
|
2778 | startY: pageY,
|
2779 | currentX: pageX,
|
2780 | currentY: pageY
|
2781 | });
|
2782 | data.touchStartTime = now();
|
2783 | }
|
2784 | return;
|
2785 | }
|
2786 | if (params.touchReleaseOnEdges && !params.loop) {
|
2787 | if (swiper.isVertical()) {
|
2788 |
|
2789 | if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
2790 | data.isTouched = false;
|
2791 | data.isMoved = false;
|
2792 | return;
|
2793 | }
|
2794 | } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
|
2795 | return;
|
2796 | }
|
2797 | }
|
2798 | if (document.activeElement && document.activeElement.matches(data.focusableElements) && document.activeElement !== e.target && e.pointerType !== 'mouse') {
|
2799 | document.activeElement.blur();
|
2800 | }
|
2801 | if (document.activeElement) {
|
2802 | if (e.target === document.activeElement && e.target.matches(data.focusableElements)) {
|
2803 | data.isMoved = true;
|
2804 | swiper.allowClick = false;
|
2805 | return;
|
2806 | }
|
2807 | }
|
2808 | if (data.allowTouchCallbacks) {
|
2809 | swiper.emit('touchMove', e);
|
2810 | }
|
2811 | touches.previousX = touches.currentX;
|
2812 | touches.previousY = touches.currentY;
|
2813 | touches.currentX = pageX;
|
2814 | touches.currentY = pageY;
|
2815 | const diffX = touches.currentX - touches.startX;
|
2816 | const diffY = touches.currentY - touches.startY;
|
2817 | if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
|
2818 | if (typeof data.isScrolling === 'undefined') {
|
2819 | let touchAngle;
|
2820 | if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
|
2821 | data.isScrolling = false;
|
2822 | } else {
|
2823 |
|
2824 | if (diffX * diffX + diffY * diffY >= 25) {
|
2825 | touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
|
2826 | data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
|
2827 | }
|
2828 | }
|
2829 | }
|
2830 | if (data.isScrolling) {
|
2831 | swiper.emit('touchMoveOpposite', e);
|
2832 | }
|
2833 | if (typeof data.startMoving === 'undefined') {
|
2834 | if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
|
2835 | data.startMoving = true;
|
2836 | }
|
2837 | }
|
2838 | if (data.isScrolling || e.type === 'touchmove' && data.preventTouchMoveFromPointerMove) {
|
2839 | data.isTouched = false;
|
2840 | return;
|
2841 | }
|
2842 | if (!data.startMoving) {
|
2843 | return;
|
2844 | }
|
2845 | swiper.allowClick = false;
|
2846 | if (!params.cssMode && e.cancelable) {
|
2847 | e.preventDefault();
|
2848 | }
|
2849 | if (params.touchMoveStopPropagation && !params.nested) {
|
2850 | e.stopPropagation();
|
2851 | }
|
2852 | let diff = swiper.isHorizontal() ? diffX : diffY;
|
2853 | let touchesDiff = swiper.isHorizontal() ? touches.currentX - touches.previousX : touches.currentY - touches.previousY;
|
2854 | if (params.oneWayMovement) {
|
2855 | diff = Math.abs(diff) * (rtl ? 1 : -1);
|
2856 | touchesDiff = Math.abs(touchesDiff) * (rtl ? 1 : -1);
|
2857 | }
|
2858 | touches.diff = diff;
|
2859 | diff *= params.touchRatio;
|
2860 | if (rtl) {
|
2861 | diff = -diff;
|
2862 | touchesDiff = -touchesDiff;
|
2863 | }
|
2864 | const prevTouchesDirection = swiper.touchesDirection;
|
2865 | swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
2866 | swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
|
2867 | const isLoop = swiper.params.loop && !params.cssMode;
|
2868 | const allowLoopFix = swiper.touchesDirection === 'next' && swiper.allowSlideNext || swiper.touchesDirection === 'prev' && swiper.allowSlidePrev;
|
2869 | if (!data.isMoved) {
|
2870 | if (isLoop && allowLoopFix) {
|
2871 | swiper.loopFix({
|
2872 | direction: swiper.swipeDirection
|
2873 | });
|
2874 | }
|
2875 | data.startTranslate = swiper.getTranslate();
|
2876 | swiper.setTransition(0);
|
2877 | if (swiper.animating) {
|
2878 | const evt = new window.CustomEvent('transitionend', {
|
2879 | bubbles: true,
|
2880 | cancelable: true,
|
2881 | detail: {
|
2882 | bySwiperTouchMove: true
|
2883 | }
|
2884 | });
|
2885 | swiper.wrapperEl.dispatchEvent(evt);
|
2886 | }
|
2887 | data.allowMomentumBounce = false;
|
2888 |
|
2889 | if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
2890 | swiper.setGrabCursor(true);
|
2891 | }
|
2892 | swiper.emit('sliderFirstMove', e);
|
2893 | }
|
2894 | let loopFixed;
|
2895 | new Date().getTime();
|
2896 | if (data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
|
2897 | Object.assign(touches, {
|
2898 | startX: pageX,
|
2899 | startY: pageY,
|
2900 | currentX: pageX,
|
2901 | currentY: pageY,
|
2902 | startTranslate: data.currentTranslate
|
2903 | });
|
2904 | data.loopSwapReset = true;
|
2905 | data.startTranslate = data.currentTranslate;
|
2906 | return;
|
2907 | }
|
2908 | swiper.emit('sliderMove', e);
|
2909 | data.isMoved = true;
|
2910 | data.currentTranslate = diff + data.startTranslate;
|
2911 | let disableParentSwiper = true;
|
2912 | let resistanceRatio = params.resistanceRatio;
|
2913 | if (params.touchReleaseOnEdges) {
|
2914 | resistanceRatio = 0;
|
2915 | }
|
2916 | if (diff > 0) {
|
2917 | if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) {
|
2918 | swiper.loopFix({
|
2919 | direction: 'prev',
|
2920 | setTranslate: true,
|
2921 | activeSlideIndex: 0
|
2922 | });
|
2923 | }
|
2924 | if (data.currentTranslate > swiper.minTranslate()) {
|
2925 | disableParentSwiper = false;
|
2926 | if (params.resistance) {
|
2927 | data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
|
2928 | }
|
2929 | }
|
2930 | } else if (diff < 0) {
|
2931 | if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== 'auto' && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) {
|
2932 | swiper.loopFix({
|
2933 | direction: 'next',
|
2934 | setTranslate: true,
|
2935 | activeSlideIndex: swiper.slides.length - (params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10)))
|
2936 | });
|
2937 | }
|
2938 | if (data.currentTranslate < swiper.maxTranslate()) {
|
2939 | disableParentSwiper = false;
|
2940 | if (params.resistance) {
|
2941 | data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
|
2942 | }
|
2943 | }
|
2944 | }
|
2945 | if (disableParentSwiper) {
|
2946 | e.preventedByNestedSwiper = true;
|
2947 | }
|
2948 |
|
2949 |
|
2950 | if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
|
2951 | data.currentTranslate = data.startTranslate;
|
2952 | }
|
2953 | if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
|
2954 | data.currentTranslate = data.startTranslate;
|
2955 | }
|
2956 | if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
2957 | data.currentTranslate = data.startTranslate;
|
2958 | }
|
2959 |
|
2960 |
|
2961 | if (params.threshold > 0) {
|
2962 | if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
2963 | if (!data.allowThresholdMove) {
|
2964 | data.allowThresholdMove = true;
|
2965 | touches.startX = touches.currentX;
|
2966 | touches.startY = touches.currentY;
|
2967 | data.currentTranslate = data.startTranslate;
|
2968 | touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
|
2969 | return;
|
2970 | }
|
2971 | } else {
|
2972 | data.currentTranslate = data.startTranslate;
|
2973 | return;
|
2974 | }
|
2975 | }
|
2976 | if (!params.followFinger || params.cssMode) return;
|
2977 |
|
2978 |
|
2979 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
|
2980 | swiper.updateActiveIndex();
|
2981 | swiper.updateSlidesClasses();
|
2982 | }
|
2983 | if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
2984 | swiper.freeMode.onTouchMove();
|
2985 | }
|
2986 |
|
2987 | swiper.updateProgress(data.currentTranslate);
|
2988 |
|
2989 | swiper.setTranslate(data.currentTranslate);
|
2990 | }
|
2991 |
|
2992 | function onTouchEnd(event) {
|
2993 | const swiper = this;
|
2994 | const data = swiper.touchEventsData;
|
2995 | let e = event;
|
2996 | if (e.originalEvent) e = e.originalEvent;
|
2997 | let targetTouch;
|
2998 | const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
2999 | if (!isTouchEvent) {
|
3000 | if (data.touchId !== null) return;
|
3001 | if (e.pointerId !== data.pointerId) return;
|
3002 | targetTouch = e;
|
3003 | } else {
|
3004 | targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
|
3005 | if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
3006 | }
|
3007 | if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
3008 | const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
3009 | if (!proceed) {
|
3010 | return;
|
3011 | }
|
3012 | }
|
3013 | data.pointerId = null;
|
3014 | data.touchId = null;
|
3015 | const {
|
3016 | params,
|
3017 | touches,
|
3018 | rtlTranslate: rtl,
|
3019 | slidesGrid,
|
3020 | enabled
|
3021 | } = swiper;
|
3022 | if (!enabled) return;
|
3023 | if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
3024 | if (data.allowTouchCallbacks) {
|
3025 | swiper.emit('touchEnd', e);
|
3026 | }
|
3027 | data.allowTouchCallbacks = false;
|
3028 | if (!data.isTouched) {
|
3029 | if (data.isMoved && params.grabCursor) {
|
3030 | swiper.setGrabCursor(false);
|
3031 | }
|
3032 | data.isMoved = false;
|
3033 | data.startMoving = false;
|
3034 | return;
|
3035 | }
|
3036 |
|
3037 |
|
3038 | if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
3039 | swiper.setGrabCursor(false);
|
3040 | }
|
3041 |
|
3042 |
|
3043 | const touchEndTime = now();
|
3044 | const timeDiff = touchEndTime - data.touchStartTime;
|
3045 |
|
3046 |
|
3047 | if (swiper.allowClick) {
|
3048 | const pathTree = e.path || e.composedPath && e.composedPath();
|
3049 | swiper.updateClickedSlide(pathTree && pathTree[0] || e.target, pathTree);
|
3050 | swiper.emit('tap click', e);
|
3051 | if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
|
3052 | swiper.emit('doubleTap doubleClick', e);
|
3053 | }
|
3054 | }
|
3055 | data.lastClickTime = now();
|
3056 | nextTick(() => {
|
3057 | if (!swiper.destroyed) swiper.allowClick = true;
|
3058 | });
|
3059 | if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
|
3060 | data.isTouched = false;
|
3061 | data.isMoved = false;
|
3062 | data.startMoving = false;
|
3063 | return;
|
3064 | }
|
3065 | data.isTouched = false;
|
3066 | data.isMoved = false;
|
3067 | data.startMoving = false;
|
3068 | let currentPos;
|
3069 | if (params.followFinger) {
|
3070 | currentPos = rtl ? swiper.translate : -swiper.translate;
|
3071 | } else {
|
3072 | currentPos = -data.currentTranslate;
|
3073 | }
|
3074 | if (params.cssMode) {
|
3075 | return;
|
3076 | }
|
3077 | if (params.freeMode && params.freeMode.enabled) {
|
3078 | swiper.freeMode.onTouchEnd({
|
3079 | currentPos
|
3080 | });
|
3081 | return;
|
3082 | }
|
3083 |
|
3084 |
|
3085 | const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
3086 | let stopIndex = 0;
|
3087 | let groupSize = swiper.slidesSizesGrid[0];
|
3088 | for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
3089 | const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
3090 | if (typeof slidesGrid[i + increment] !== 'undefined') {
|
3091 | if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
|
3092 | stopIndex = i;
|
3093 | groupSize = slidesGrid[i + increment] - slidesGrid[i];
|
3094 | }
|
3095 | } else if (swipeToLast || currentPos >= slidesGrid[i]) {
|
3096 | stopIndex = i;
|
3097 | groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
3098 | }
|
3099 | }
|
3100 | let rewindFirstIndex = null;
|
3101 | let rewindLastIndex = null;
|
3102 | if (params.rewind) {
|
3103 | if (swiper.isBeginning) {
|
3104 | rewindLastIndex = params.virtual && params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
|
3105 | } else if (swiper.isEnd) {
|
3106 | rewindFirstIndex = 0;
|
3107 | }
|
3108 | }
|
3109 |
|
3110 | const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
3111 | const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
3112 | if (timeDiff > params.longSwipesMs) {
|
3113 |
|
3114 | if (!params.longSwipes) {
|
3115 | swiper.slideTo(swiper.activeIndex);
|
3116 | return;
|
3117 | }
|
3118 | if (swiper.swipeDirection === 'next') {
|
3119 | if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
|
3120 | }
|
3121 | if (swiper.swipeDirection === 'prev') {
|
3122 | if (ratio > 1 - params.longSwipesRatio) {
|
3123 | swiper.slideTo(stopIndex + increment);
|
3124 | } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
|
3125 | swiper.slideTo(rewindLastIndex);
|
3126 | } else {
|
3127 | swiper.slideTo(stopIndex);
|
3128 | }
|
3129 | }
|
3130 | } else {
|
3131 |
|
3132 | if (!params.shortSwipes) {
|
3133 | swiper.slideTo(swiper.activeIndex);
|
3134 | return;
|
3135 | }
|
3136 | const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
|
3137 | if (!isNavButtonTarget) {
|
3138 | if (swiper.swipeDirection === 'next') {
|
3139 | swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
|
3140 | }
|
3141 | if (swiper.swipeDirection === 'prev') {
|
3142 | swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
|
3143 | }
|
3144 | } else if (e.target === swiper.navigation.nextEl) {
|
3145 | swiper.slideTo(stopIndex + increment);
|
3146 | } else {
|
3147 | swiper.slideTo(stopIndex);
|
3148 | }
|
3149 | }
|
3150 | }
|
3151 |
|
3152 | function onResize() {
|
3153 | const swiper = this;
|
3154 | const {
|
3155 | params,
|
3156 | el
|
3157 | } = swiper;
|
3158 | if (el && el.offsetWidth === 0) return;
|
3159 |
|
3160 |
|
3161 | if (params.breakpoints) {
|
3162 | swiper.setBreakpoint();
|
3163 | }
|
3164 |
|
3165 |
|
3166 | const {
|
3167 | allowSlideNext,
|
3168 | allowSlidePrev,
|
3169 | snapGrid
|
3170 | } = swiper;
|
3171 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
3172 |
|
3173 |
|
3174 | swiper.allowSlideNext = true;
|
3175 | swiper.allowSlidePrev = true;
|
3176 | swiper.updateSize();
|
3177 | swiper.updateSlides();
|
3178 | swiper.updateSlidesClasses();
|
3179 | const isVirtualLoop = isVirtual && params.loop;
|
3180 | if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
3181 | swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
3182 | } else {
|
3183 | if (swiper.params.loop && !isVirtual) {
|
3184 | swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
3185 | } else {
|
3186 | swiper.slideTo(swiper.activeIndex, 0, false, true);
|
3187 | }
|
3188 | }
|
3189 | if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
3190 | clearTimeout(swiper.autoplay.resizeTimeout);
|
3191 | swiper.autoplay.resizeTimeout = setTimeout(() => {
|
3192 | if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
3193 | swiper.autoplay.resume();
|
3194 | }
|
3195 | }, 500);
|
3196 | }
|
3197 |
|
3198 | swiper.allowSlidePrev = allowSlidePrev;
|
3199 | swiper.allowSlideNext = allowSlideNext;
|
3200 | if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
3201 | swiper.checkOverflow();
|
3202 | }
|
3203 | }
|
3204 |
|
3205 | function onClick(e) {
|
3206 | const swiper = this;
|
3207 | if (!swiper.enabled) return;
|
3208 | if (!swiper.allowClick) {
|
3209 | if (swiper.params.preventClicks) e.preventDefault();
|
3210 | if (swiper.params.preventClicksPropagation && swiper.animating) {
|
3211 | e.stopPropagation();
|
3212 | e.stopImmediatePropagation();
|
3213 | }
|
3214 | }
|
3215 | }
|
3216 |
|
3217 | function onScroll() {
|
3218 | const swiper = this;
|
3219 | const {
|
3220 | wrapperEl,
|
3221 | rtlTranslate,
|
3222 | enabled
|
3223 | } = swiper;
|
3224 | if (!enabled) return;
|
3225 | swiper.previousTranslate = swiper.translate;
|
3226 | if (swiper.isHorizontal()) {
|
3227 | swiper.translate = -wrapperEl.scrollLeft;
|
3228 | } else {
|
3229 | swiper.translate = -wrapperEl.scrollTop;
|
3230 | }
|
3231 |
|
3232 | if (swiper.translate === 0) swiper.translate = 0;
|
3233 | swiper.updateActiveIndex();
|
3234 | swiper.updateSlidesClasses();
|
3235 | let newProgress;
|
3236 | const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
3237 | if (translatesDiff === 0) {
|
3238 | newProgress = 0;
|
3239 | } else {
|
3240 | newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
|
3241 | }
|
3242 | if (newProgress !== swiper.progress) {
|
3243 | swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
|
3244 | }
|
3245 | swiper.emit('setTranslate', swiper.translate, false);
|
3246 | }
|
3247 |
|
3248 | function onLoad(e) {
|
3249 | const swiper = this;
|
3250 | processLazyPreloader(swiper, e.target);
|
3251 | if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
3252 | return;
|
3253 | }
|
3254 | swiper.update();
|
3255 | }
|
3256 |
|
3257 | function onDocumentTouchStart() {
|
3258 | const swiper = this;
|
3259 | if (swiper.documentTouchHandlerProceeded) return;
|
3260 | swiper.documentTouchHandlerProceeded = true;
|
3261 | if (swiper.params.touchReleaseOnEdges) {
|
3262 | swiper.el.style.touchAction = 'auto';
|
3263 | }
|
3264 | }
|
3265 |
|
3266 | const events = (swiper, method) => {
|
3267 | const document = getDocument();
|
3268 | const {
|
3269 | params,
|
3270 | el,
|
3271 | wrapperEl,
|
3272 | device
|
3273 | } = swiper;
|
3274 | const capture = !!params.nested;
|
3275 | const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
|
3276 | const swiperMethod = method;
|
3277 | if (!el || typeof el === 'string') return;
|
3278 |
|
3279 |
|
3280 | document[domMethod]('touchstart', swiper.onDocumentTouchStart, {
|
3281 | passive: false,
|
3282 | capture
|
3283 | });
|
3284 | el[domMethod]('touchstart', swiper.onTouchStart, {
|
3285 | passive: false
|
3286 | });
|
3287 | el[domMethod]('pointerdown', swiper.onTouchStart, {
|
3288 | passive: false
|
3289 | });
|
3290 | document[domMethod]('touchmove', swiper.onTouchMove, {
|
3291 | passive: false,
|
3292 | capture
|
3293 | });
|
3294 | document[domMethod]('pointermove', swiper.onTouchMove, {
|
3295 | passive: false,
|
3296 | capture
|
3297 | });
|
3298 | document[domMethod]('touchend', swiper.onTouchEnd, {
|
3299 | passive: true
|
3300 | });
|
3301 | document[domMethod]('pointerup', swiper.onTouchEnd, {
|
3302 | passive: true
|
3303 | });
|
3304 | document[domMethod]('pointercancel', swiper.onTouchEnd, {
|
3305 | passive: true
|
3306 | });
|
3307 | document[domMethod]('touchcancel', swiper.onTouchEnd, {
|
3308 | passive: true
|
3309 | });
|
3310 | document[domMethod]('pointerout', swiper.onTouchEnd, {
|
3311 | passive: true
|
3312 | });
|
3313 | document[domMethod]('pointerleave', swiper.onTouchEnd, {
|
3314 | passive: true
|
3315 | });
|
3316 | document[domMethod]('contextmenu', swiper.onTouchEnd, {
|
3317 | passive: true
|
3318 | });
|
3319 |
|
3320 |
|
3321 | if (params.preventClicks || params.preventClicksPropagation) {
|
3322 | el[domMethod]('click', swiper.onClick, true);
|
3323 | }
|
3324 | if (params.cssMode) {
|
3325 | wrapperEl[domMethod]('scroll', swiper.onScroll);
|
3326 | }
|
3327 |
|
3328 |
|
3329 | if (params.updateOnWindowResize) {
|
3330 | swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
|
3331 | } else {
|
3332 | swiper[swiperMethod]('observerUpdate', onResize, true);
|
3333 | }
|
3334 |
|
3335 |
|
3336 | el[domMethod]('load', swiper.onLoad, {
|
3337 | capture: true
|
3338 | });
|
3339 | };
|
3340 | function attachEvents() {
|
3341 | const swiper = this;
|
3342 | const {
|
3343 | params
|
3344 | } = swiper;
|
3345 | swiper.onTouchStart = onTouchStart.bind(swiper);
|
3346 | swiper.onTouchMove = onTouchMove.bind(swiper);
|
3347 | swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
3348 | swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
|
3349 | if (params.cssMode) {
|
3350 | swiper.onScroll = onScroll.bind(swiper);
|
3351 | }
|
3352 | swiper.onClick = onClick.bind(swiper);
|
3353 | swiper.onLoad = onLoad.bind(swiper);
|
3354 | events(swiper, 'on');
|
3355 | }
|
3356 | function detachEvents() {
|
3357 | const swiper = this;
|
3358 | events(swiper, 'off');
|
3359 | }
|
3360 | var events$1 = {
|
3361 | attachEvents,
|
3362 | detachEvents
|
3363 | };
|
3364 |
|
3365 | const isGridEnabled = (swiper, params) => {
|
3366 | return swiper.grid && params.grid && params.grid.rows > 1;
|
3367 | };
|
3368 | function setBreakpoint() {
|
3369 | const swiper = this;
|
3370 | const {
|
3371 | realIndex,
|
3372 | initialized,
|
3373 | params,
|
3374 | el
|
3375 | } = swiper;
|
3376 | const breakpoints = params.breakpoints;
|
3377 | if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
|
3378 |
|
3379 |
|
3380 | const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
|
3381 | if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
3382 | const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
3383 | const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
3384 | const wasMultiRow = isGridEnabled(swiper, params);
|
3385 | const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
3386 | const wasGrabCursor = swiper.params.grabCursor;
|
3387 | const isGrabCursor = breakpointParams.grabCursor;
|
3388 | const wasEnabled = params.enabled;
|
3389 | if (wasMultiRow && !isMultiRow) {
|
3390 | el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
3391 | swiper.emitContainerClasses();
|
3392 | } else if (!wasMultiRow && isMultiRow) {
|
3393 | el.classList.add(`${params.containerModifierClass}grid`);
|
3394 | if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
3395 | el.classList.add(`${params.containerModifierClass}grid-column`);
|
3396 | }
|
3397 | swiper.emitContainerClasses();
|
3398 | }
|
3399 | if (wasGrabCursor && !isGrabCursor) {
|
3400 | swiper.unsetGrabCursor();
|
3401 | } else if (!wasGrabCursor && isGrabCursor) {
|
3402 | swiper.setGrabCursor();
|
3403 | }
|
3404 |
|
3405 |
|
3406 | ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
|
3407 | if (typeof breakpointParams[prop] === 'undefined') return;
|
3408 | const wasModuleEnabled = params[prop] && params[prop].enabled;
|
3409 | const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
3410 | if (wasModuleEnabled && !isModuleEnabled) {
|
3411 | swiper[prop].disable();
|
3412 | }
|
3413 | if (!wasModuleEnabled && isModuleEnabled) {
|
3414 | swiper[prop].enable();
|
3415 | }
|
3416 | });
|
3417 | const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
3418 | const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
3419 | const wasLoop = params.loop;
|
3420 | if (directionChanged && initialized) {
|
3421 | swiper.changeDirection();
|
3422 | }
|
3423 | extend$1(swiper.params, breakpointParams);
|
3424 | const isEnabled = swiper.params.enabled;
|
3425 | const hasLoop = swiper.params.loop;
|
3426 | Object.assign(swiper, {
|
3427 | allowTouchMove: swiper.params.allowTouchMove,
|
3428 | allowSlideNext: swiper.params.allowSlideNext,
|
3429 | allowSlidePrev: swiper.params.allowSlidePrev
|
3430 | });
|
3431 | if (wasEnabled && !isEnabled) {
|
3432 | swiper.disable();
|
3433 | } else if (!wasEnabled && isEnabled) {
|
3434 | swiper.enable();
|
3435 | }
|
3436 | swiper.currentBreakpoint = breakpoint;
|
3437 | swiper.emit('_beforeBreakpoint', breakpointParams);
|
3438 | if (initialized) {
|
3439 | if (needsReLoop) {
|
3440 | swiper.loopDestroy();
|
3441 | swiper.loopCreate(realIndex);
|
3442 | swiper.updateSlides();
|
3443 | } else if (!wasLoop && hasLoop) {
|
3444 | swiper.loopCreate(realIndex);
|
3445 | swiper.updateSlides();
|
3446 | } else if (wasLoop && !hasLoop) {
|
3447 | swiper.loopDestroy();
|
3448 | }
|
3449 | }
|
3450 | swiper.emit('breakpoint', breakpointParams);
|
3451 | }
|
3452 |
|
3453 | function getBreakpoint(breakpoints, base, containerEl) {
|
3454 | if (base === void 0) {
|
3455 | base = 'window';
|
3456 | }
|
3457 | if (!breakpoints || base === 'container' && !containerEl) return undefined;
|
3458 | let breakpoint = false;
|
3459 | const window = getWindow();
|
3460 | const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
|
3461 | const points = Object.keys(breakpoints).map(point => {
|
3462 | if (typeof point === 'string' && point.indexOf('@') === 0) {
|
3463 | const minRatio = parseFloat(point.substr(1));
|
3464 | const value = currentHeight * minRatio;
|
3465 | return {
|
3466 | value,
|
3467 | point
|
3468 | };
|
3469 | }
|
3470 | return {
|
3471 | value: point,
|
3472 | point
|
3473 | };
|
3474 | });
|
3475 | points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
|
3476 | for (let i = 0; i < points.length; i += 1) {
|
3477 | const {
|
3478 | point,
|
3479 | value
|
3480 | } = points[i];
|
3481 | if (base === 'window') {
|
3482 | if (window.matchMedia(`(min-width: ${value}px)`).matches) {
|
3483 | breakpoint = point;
|
3484 | }
|
3485 | } else if (value <= containerEl.clientWidth) {
|
3486 | breakpoint = point;
|
3487 | }
|
3488 | }
|
3489 | return breakpoint || 'max';
|
3490 | }
|
3491 |
|
3492 | var breakpoints = {
|
3493 | setBreakpoint,
|
3494 | getBreakpoint
|
3495 | };
|
3496 |
|
3497 | function prepareClasses(entries, prefix) {
|
3498 | const resultClasses = [];
|
3499 | entries.forEach(item => {
|
3500 | if (typeof item === 'object') {
|
3501 | Object.keys(item).forEach(classNames => {
|
3502 | if (item[classNames]) {
|
3503 | resultClasses.push(prefix + classNames);
|
3504 | }
|
3505 | });
|
3506 | } else if (typeof item === 'string') {
|
3507 | resultClasses.push(prefix + item);
|
3508 | }
|
3509 | });
|
3510 | return resultClasses;
|
3511 | }
|
3512 | function addClasses() {
|
3513 | const swiper = this;
|
3514 | const {
|
3515 | classNames,
|
3516 | params,
|
3517 | rtl,
|
3518 | el,
|
3519 | device
|
3520 | } = swiper;
|
3521 |
|
3522 | const suffixes = prepareClasses(['initialized', params.direction, {
|
3523 | 'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
3524 | }, {
|
3525 | 'autoheight': params.autoHeight
|
3526 | }, {
|
3527 | 'rtl': rtl
|
3528 | }, {
|
3529 | 'grid': params.grid && params.grid.rows > 1
|
3530 | }, {
|
3531 | 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
3532 | }, {
|
3533 | 'android': device.android
|
3534 | }, {
|
3535 | 'ios': device.ios
|
3536 | }, {
|
3537 | 'css-mode': params.cssMode
|
3538 | }, {
|
3539 | 'centered': params.cssMode && params.centeredSlides
|
3540 | }, {
|
3541 | 'watch-progress': params.watchSlidesProgress
|
3542 | }], params.containerModifierClass);
|
3543 | classNames.push(...suffixes);
|
3544 | el.classList.add(...classNames);
|
3545 | swiper.emitContainerClasses();
|
3546 | }
|
3547 |
|
3548 | function removeClasses() {
|
3549 | const swiper = this;
|
3550 | const {
|
3551 | el,
|
3552 | classNames
|
3553 | } = swiper;
|
3554 | if (!el || typeof el === 'string') return;
|
3555 | el.classList.remove(...classNames);
|
3556 | swiper.emitContainerClasses();
|
3557 | }
|
3558 |
|
3559 | var classes = {
|
3560 | addClasses,
|
3561 | removeClasses
|
3562 | };
|
3563 |
|
3564 | function checkOverflow() {
|
3565 | const swiper = this;
|
3566 | const {
|
3567 | isLocked: wasLocked,
|
3568 | params
|
3569 | } = swiper;
|
3570 | const {
|
3571 | slidesOffsetBefore
|
3572 | } = params;
|
3573 | if (slidesOffsetBefore) {
|
3574 | const lastSlideIndex = swiper.slides.length - 1;
|
3575 | const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
|
3576 | swiper.isLocked = swiper.size > lastSlideRightEdge;
|
3577 | } else {
|
3578 | swiper.isLocked = swiper.snapGrid.length === 1;
|
3579 | }
|
3580 | if (params.allowSlideNext === true) {
|
3581 | swiper.allowSlideNext = !swiper.isLocked;
|
3582 | }
|
3583 | if (params.allowSlidePrev === true) {
|
3584 | swiper.allowSlidePrev = !swiper.isLocked;
|
3585 | }
|
3586 | if (wasLocked && wasLocked !== swiper.isLocked) {
|
3587 | swiper.isEnd = false;
|
3588 | }
|
3589 | if (wasLocked !== swiper.isLocked) {
|
3590 | swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
|
3591 | }
|
3592 | }
|
3593 | var checkOverflow$1 = {
|
3594 | checkOverflow
|
3595 | };
|
3596 |
|
3597 | var defaults = {
|
3598 | init: true,
|
3599 | direction: 'horizontal',
|
3600 | oneWayMovement: false,
|
3601 | swiperElementNodeName: 'SWIPER-CONTAINER',
|
3602 | touchEventsTarget: 'wrapper',
|
3603 | initialSlide: 0,
|
3604 | speed: 300,
|
3605 | cssMode: false,
|
3606 | updateOnWindowResize: true,
|
3607 | resizeObserver: true,
|
3608 | nested: false,
|
3609 | createElements: false,
|
3610 | eventsPrefix: 'swiper',
|
3611 | enabled: true,
|
3612 | focusableElements: 'input, select, option, textarea, button, video, label',
|
3613 |
|
3614 | width: null,
|
3615 | height: null,
|
3616 |
|
3617 | preventInteractionOnTransition: false,
|
3618 |
|
3619 | userAgent: null,
|
3620 | url: null,
|
3621 |
|
3622 | edgeSwipeDetection: false,
|
3623 | edgeSwipeThreshold: 20,
|
3624 |
|
3625 | autoHeight: false,
|
3626 |
|
3627 | setWrapperSize: false,
|
3628 |
|
3629 | virtualTranslate: false,
|
3630 |
|
3631 | effect: 'slide',
|
3632 |
|
3633 |
|
3634 |
|
3635 | breakpoints: undefined,
|
3636 | breakpointsBase: 'window',
|
3637 |
|
3638 | spaceBetween: 0,
|
3639 | slidesPerView: 1,
|
3640 | slidesPerGroup: 1,
|
3641 | slidesPerGroupSkip: 0,
|
3642 | slidesPerGroupAuto: false,
|
3643 | centeredSlides: false,
|
3644 | centeredSlidesBounds: false,
|
3645 | slidesOffsetBefore: 0,
|
3646 |
|
3647 | slidesOffsetAfter: 0,
|
3648 |
|
3649 | normalizeSlideIndex: true,
|
3650 | centerInsufficientSlides: false,
|
3651 |
|
3652 | watchOverflow: true,
|
3653 |
|
3654 | roundLengths: false,
|
3655 |
|
3656 | touchRatio: 1,
|
3657 | touchAngle: 45,
|
3658 | simulateTouch: true,
|
3659 | shortSwipes: true,
|
3660 | longSwipes: true,
|
3661 | longSwipesRatio: 0.5,
|
3662 | longSwipesMs: 300,
|
3663 | followFinger: true,
|
3664 | allowTouchMove: true,
|
3665 | threshold: 5,
|
3666 | touchMoveStopPropagation: false,
|
3667 | touchStartPreventDefault: true,
|
3668 | touchStartForcePreventDefault: false,
|
3669 | touchReleaseOnEdges: false,
|
3670 |
|
3671 | uniqueNavElements: true,
|
3672 |
|
3673 | resistance: true,
|
3674 | resistanceRatio: 0.85,
|
3675 |
|
3676 | watchSlidesProgress: false,
|
3677 |
|
3678 | grabCursor: false,
|
3679 |
|
3680 | preventClicks: true,
|
3681 | preventClicksPropagation: true,
|
3682 | slideToClickedSlide: false,
|
3683 |
|
3684 | loop: false,
|
3685 | loopAddBlankSlides: true,
|
3686 | loopAdditionalSlides: 0,
|
3687 | loopPreventsSliding: true,
|
3688 |
|
3689 | rewind: false,
|
3690 |
|
3691 | allowSlidePrev: true,
|
3692 | allowSlideNext: true,
|
3693 | swipeHandler: null,
|
3694 |
|
3695 | noSwiping: true,
|
3696 | noSwipingClass: 'swiper-no-swiping',
|
3697 | noSwipingSelector: null,
|
3698 |
|
3699 | passiveListeners: true,
|
3700 | maxBackfaceHiddenSlides: 10,
|
3701 |
|
3702 | containerModifierClass: 'swiper-',
|
3703 |
|
3704 | slideClass: 'swiper-slide',
|
3705 | slideBlankClass: 'swiper-slide-blank',
|
3706 | slideActiveClass: 'swiper-slide-active',
|
3707 | slideVisibleClass: 'swiper-slide-visible',
|
3708 | slideFullyVisibleClass: 'swiper-slide-fully-visible',
|
3709 | slideNextClass: 'swiper-slide-next',
|
3710 | slidePrevClass: 'swiper-slide-prev',
|
3711 | wrapperClass: 'swiper-wrapper',
|
3712 | lazyPreloaderClass: 'swiper-lazy-preloader',
|
3713 | lazyPreloadPrevNext: 0,
|
3714 |
|
3715 | runCallbacksOnInit: true,
|
3716 |
|
3717 | _emitClasses: false
|
3718 | };
|
3719 |
|
3720 | function moduleExtendParams(params, allModulesParams) {
|
3721 | return function extendParams(obj) {
|
3722 | if (obj === void 0) {
|
3723 | obj = {};
|
3724 | }
|
3725 | const moduleParamName = Object.keys(obj)[0];
|
3726 | const moduleParams = obj[moduleParamName];
|
3727 | if (typeof moduleParams !== 'object' || moduleParams === null) {
|
3728 | extend$1(allModulesParams, obj);
|
3729 | return;
|
3730 | }
|
3731 | if (params[moduleParamName] === true) {
|
3732 | params[moduleParamName] = {
|
3733 | enabled: true
|
3734 | };
|
3735 | }
|
3736 | if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
3737 | params[moduleParamName].auto = true;
|
3738 | }
|
3739 | if (['pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
3740 | params[moduleParamName].auto = true;
|
3741 | }
|
3742 | if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
3743 | extend$1(allModulesParams, obj);
|
3744 | return;
|
3745 | }
|
3746 | if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
|
3747 | params[moduleParamName].enabled = true;
|
3748 | }
|
3749 | if (!params[moduleParamName]) params[moduleParamName] = {
|
3750 | enabled: false
|
3751 | };
|
3752 | extend$1(allModulesParams, obj);
|
3753 | };
|
3754 | }
|
3755 |
|
3756 |
|
3757 | const prototypes = {
|
3758 | eventsEmitter,
|
3759 | update,
|
3760 | translate,
|
3761 | transition,
|
3762 | slide,
|
3763 | loop,
|
3764 | grabCursor,
|
3765 | events: events$1,
|
3766 | breakpoints,
|
3767 | checkOverflow: checkOverflow$1,
|
3768 | classes
|
3769 | };
|
3770 | const extendedDefaults = {};
|
3771 | class Swiper {
|
3772 | constructor() {
|
3773 | let el;
|
3774 | let params;
|
3775 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3776 | args[_key] = arguments[_key];
|
3777 | }
|
3778 | if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
|
3779 | params = args[0];
|
3780 | } else {
|
3781 | [el, params] = args;
|
3782 | }
|
3783 | if (!params) params = {};
|
3784 | params = extend$1({}, params);
|
3785 | if (el && !params.el) params.el = el;
|
3786 | const document = getDocument();
|
3787 | if (params.el && typeof params.el === 'string' && document.querySelectorAll(params.el).length > 1) {
|
3788 | const swipers = [];
|
3789 | document.querySelectorAll(params.el).forEach(containerEl => {
|
3790 | const newParams = extend$1({}, params, {
|
3791 | el: containerEl
|
3792 | });
|
3793 | swipers.push(new Swiper(newParams));
|
3794 | });
|
3795 |
|
3796 | return swipers;
|
3797 | }
|
3798 |
|
3799 |
|
3800 | const swiper = this;
|
3801 | swiper.__swiper__ = true;
|
3802 | swiper.support = getSupport();
|
3803 | swiper.device = getDevice({
|
3804 | userAgent: params.userAgent
|
3805 | });
|
3806 | swiper.browser = getBrowser();
|
3807 | swiper.eventsListeners = {};
|
3808 | swiper.eventsAnyListeners = [];
|
3809 | swiper.modules = [...swiper.__modules__];
|
3810 | if (params.modules && Array.isArray(params.modules)) {
|
3811 | swiper.modules.push(...params.modules);
|
3812 | }
|
3813 | const allModulesParams = {};
|
3814 | swiper.modules.forEach(mod => {
|
3815 | mod({
|
3816 | params,
|
3817 | swiper,
|
3818 | extendParams: moduleExtendParams(params, allModulesParams),
|
3819 | on: swiper.on.bind(swiper),
|
3820 | once: swiper.once.bind(swiper),
|
3821 | off: swiper.off.bind(swiper),
|
3822 | emit: swiper.emit.bind(swiper)
|
3823 | });
|
3824 | });
|
3825 |
|
3826 |
|
3827 | const swiperParams = extend$1({}, defaults, allModulesParams);
|
3828 |
|
3829 |
|
3830 | swiper.params = extend$1({}, swiperParams, extendedDefaults, params);
|
3831 | swiper.originalParams = extend$1({}, swiper.params);
|
3832 | swiper.passedParams = extend$1({}, params);
|
3833 |
|
3834 |
|
3835 | if (swiper.params && swiper.params.on) {
|
3836 | Object.keys(swiper.params.on).forEach(eventName => {
|
3837 | swiper.on(eventName, swiper.params.on[eventName]);
|
3838 | });
|
3839 | }
|
3840 | if (swiper.params && swiper.params.onAny) {
|
3841 | swiper.onAny(swiper.params.onAny);
|
3842 | }
|
3843 |
|
3844 |
|
3845 | Object.assign(swiper, {
|
3846 | enabled: swiper.params.enabled,
|
3847 | el,
|
3848 |
|
3849 | classNames: [],
|
3850 |
|
3851 | slides: [],
|
3852 | slidesGrid: [],
|
3853 | snapGrid: [],
|
3854 | slidesSizesGrid: [],
|
3855 |
|
3856 | isHorizontal() {
|
3857 | return swiper.params.direction === 'horizontal';
|
3858 | },
|
3859 | isVertical() {
|
3860 | return swiper.params.direction === 'vertical';
|
3861 | },
|
3862 |
|
3863 | activeIndex: 0,
|
3864 | realIndex: 0,
|
3865 |
|
3866 | isBeginning: true,
|
3867 | isEnd: false,
|
3868 |
|
3869 | translate: 0,
|
3870 | previousTranslate: 0,
|
3871 | progress: 0,
|
3872 | velocity: 0,
|
3873 | animating: false,
|
3874 | cssOverflowAdjustment() {
|
3875 |
|
3876 |
|
3877 | return Math.trunc(this.translate / 2 ** 23) * 2 ** 23;
|
3878 | },
|
3879 |
|
3880 | allowSlideNext: swiper.params.allowSlideNext,
|
3881 | allowSlidePrev: swiper.params.allowSlidePrev,
|
3882 |
|
3883 | touchEventsData: {
|
3884 | isTouched: undefined,
|
3885 | isMoved: undefined,
|
3886 | allowTouchCallbacks: undefined,
|
3887 | touchStartTime: undefined,
|
3888 | isScrolling: undefined,
|
3889 | currentTranslate: undefined,
|
3890 | startTranslate: undefined,
|
3891 | allowThresholdMove: undefined,
|
3892 |
|
3893 | focusableElements: swiper.params.focusableElements,
|
3894 |
|
3895 | lastClickTime: 0,
|
3896 | clickTimeout: undefined,
|
3897 |
|
3898 | velocities: [],
|
3899 | allowMomentumBounce: undefined,
|
3900 | startMoving: undefined,
|
3901 | pointerId: null,
|
3902 | touchId: null
|
3903 | },
|
3904 |
|
3905 | allowClick: true,
|
3906 |
|
3907 | allowTouchMove: swiper.params.allowTouchMove,
|
3908 | touches: {
|
3909 | startX: 0,
|
3910 | startY: 0,
|
3911 | currentX: 0,
|
3912 | currentY: 0,
|
3913 | diff: 0
|
3914 | },
|
3915 |
|
3916 | imagesToLoad: [],
|
3917 | imagesLoaded: 0
|
3918 | });
|
3919 | swiper.emit('_swiper');
|
3920 |
|
3921 |
|
3922 | if (swiper.params.init) {
|
3923 | swiper.init();
|
3924 | }
|
3925 |
|
3926 |
|
3927 |
|
3928 | return swiper;
|
3929 | }
|
3930 | getDirectionLabel(property) {
|
3931 | if (this.isHorizontal()) {
|
3932 | return property;
|
3933 | }
|
3934 |
|
3935 | return {
|
3936 | 'width': 'height',
|
3937 | 'margin-top': 'margin-left',
|
3938 | 'margin-bottom ': 'margin-right',
|
3939 | 'margin-left': 'margin-top',
|
3940 | 'margin-right': 'margin-bottom',
|
3941 | 'padding-left': 'padding-top',
|
3942 | 'padding-right': 'padding-bottom',
|
3943 | 'marginRight': 'marginBottom'
|
3944 | }[property];
|
3945 | }
|
3946 | getSlideIndex(slideEl) {
|
3947 | const {
|
3948 | slidesEl,
|
3949 | params
|
3950 | } = this;
|
3951 | const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
3952 | const firstSlideIndex = elementIndex(slides[0]);
|
3953 | return elementIndex(slideEl) - firstSlideIndex;
|
3954 | }
|
3955 | getSlideIndexByData(index) {
|
3956 | return this.getSlideIndex(this.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index)[0]);
|
3957 | }
|
3958 | recalcSlides() {
|
3959 | const swiper = this;
|
3960 | const {
|
3961 | slidesEl,
|
3962 | params
|
3963 | } = swiper;
|
3964 | swiper.slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
3965 | }
|
3966 | enable() {
|
3967 | const swiper = this;
|
3968 | if (swiper.enabled) return;
|
3969 | swiper.enabled = true;
|
3970 | if (swiper.params.grabCursor) {
|
3971 | swiper.setGrabCursor();
|
3972 | }
|
3973 | swiper.emit('enable');
|
3974 | }
|
3975 | disable() {
|
3976 | const swiper = this;
|
3977 | if (!swiper.enabled) return;
|
3978 | swiper.enabled = false;
|
3979 | if (swiper.params.grabCursor) {
|
3980 | swiper.unsetGrabCursor();
|
3981 | }
|
3982 | swiper.emit('disable');
|
3983 | }
|
3984 | setProgress(progress, speed) {
|
3985 | const swiper = this;
|
3986 | progress = Math.min(Math.max(progress, 0), 1);
|
3987 | const min = swiper.minTranslate();
|
3988 | const max = swiper.maxTranslate();
|
3989 | const current = (max - min) * progress + min;
|
3990 | swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
|
3991 | swiper.updateActiveIndex();
|
3992 | swiper.updateSlidesClasses();
|
3993 | }
|
3994 | emitContainerClasses() {
|
3995 | const swiper = this;
|
3996 | if (!swiper.params._emitClasses || !swiper.el) return;
|
3997 | const cls = swiper.el.className.split(' ').filter(className => {
|
3998 | return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
|
3999 | });
|
4000 | swiper.emit('_containerClasses', cls.join(' '));
|
4001 | }
|
4002 | getSlideClasses(slideEl) {
|
4003 | const swiper = this;
|
4004 | if (swiper.destroyed) return '';
|
4005 | return slideEl.className.split(' ').filter(className => {
|
4006 | return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
|
4007 | }).join(' ');
|
4008 | }
|
4009 | emitSlidesClasses() {
|
4010 | const swiper = this;
|
4011 | if (!swiper.params._emitClasses || !swiper.el) return;
|
4012 | const updates = [];
|
4013 | swiper.slides.forEach(slideEl => {
|
4014 | const classNames = swiper.getSlideClasses(slideEl);
|
4015 | updates.push({
|
4016 | slideEl,
|
4017 | classNames
|
4018 | });
|
4019 | swiper.emit('_slideClass', slideEl, classNames);
|
4020 | });
|
4021 | swiper.emit('_slideClasses', updates);
|
4022 | }
|
4023 | slidesPerViewDynamic(view, exact) {
|
4024 | if (view === void 0) {
|
4025 | view = 'current';
|
4026 | }
|
4027 | if (exact === void 0) {
|
4028 | exact = false;
|
4029 | }
|
4030 | const swiper = this;
|
4031 | const {
|
4032 | params,
|
4033 | slides,
|
4034 | slidesGrid,
|
4035 | slidesSizesGrid,
|
4036 | size: swiperSize,
|
4037 | activeIndex
|
4038 | } = swiper;
|
4039 | let spv = 1;
|
4040 | if (typeof params.slidesPerView === 'number') return params.slidesPerView;
|
4041 | if (params.centeredSlides) {
|
4042 | let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0;
|
4043 | let breakLoop;
|
4044 | for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
4045 | if (slides[i] && !breakLoop) {
|
4046 | slideSize += Math.ceil(slides[i].swiperSlideSize);
|
4047 | spv += 1;
|
4048 | if (slideSize > swiperSize) breakLoop = true;
|
4049 | }
|
4050 | }
|
4051 | for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
4052 | if (slides[i] && !breakLoop) {
|
4053 | slideSize += slides[i].swiperSlideSize;
|
4054 | spv += 1;
|
4055 | if (slideSize > swiperSize) breakLoop = true;
|
4056 | }
|
4057 | }
|
4058 | } else {
|
4059 |
|
4060 | if (view === 'current') {
|
4061 | for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
4062 | const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
4063 | if (slideInView) {
|
4064 | spv += 1;
|
4065 | }
|
4066 | }
|
4067 | } else {
|
4068 |
|
4069 | for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
4070 | const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
4071 | if (slideInView) {
|
4072 | spv += 1;
|
4073 | }
|
4074 | }
|
4075 | }
|
4076 | }
|
4077 | return spv;
|
4078 | }
|
4079 | update() {
|
4080 | const swiper = this;
|
4081 | if (!swiper || swiper.destroyed) return;
|
4082 | const {
|
4083 | snapGrid,
|
4084 | params
|
4085 | } = swiper;
|
4086 |
|
4087 | if (params.breakpoints) {
|
4088 | swiper.setBreakpoint();
|
4089 | }
|
4090 | [...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
4091 | if (imageEl.complete) {
|
4092 | processLazyPreloader(swiper, imageEl);
|
4093 | }
|
4094 | });
|
4095 | swiper.updateSize();
|
4096 | swiper.updateSlides();
|
4097 | swiper.updateProgress();
|
4098 | swiper.updateSlidesClasses();
|
4099 | function setTranslate() {
|
4100 | const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
|
4101 | const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
|
4102 | swiper.setTranslate(newTranslate);
|
4103 | swiper.updateActiveIndex();
|
4104 | swiper.updateSlidesClasses();
|
4105 | }
|
4106 | let translated;
|
4107 | if (params.freeMode && params.freeMode.enabled && !params.cssMode) {
|
4108 | setTranslate();
|
4109 | if (params.autoHeight) {
|
4110 | swiper.updateAutoHeight();
|
4111 | }
|
4112 | } else {
|
4113 | if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
4114 | const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
4115 | translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
4116 | } else {
|
4117 | translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
4118 | }
|
4119 | if (!translated) {
|
4120 | setTranslate();
|
4121 | }
|
4122 | }
|
4123 | if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
4124 | swiper.checkOverflow();
|
4125 | }
|
4126 | swiper.emit('update');
|
4127 | }
|
4128 | changeDirection(newDirection, needUpdate) {
|
4129 | if (needUpdate === void 0) {
|
4130 | needUpdate = true;
|
4131 | }
|
4132 | const swiper = this;
|
4133 | const currentDirection = swiper.params.direction;
|
4134 | if (!newDirection) {
|
4135 |
|
4136 | newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
4137 | }
|
4138 | if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
4139 | return swiper;
|
4140 | }
|
4141 | swiper.el.classList.remove(`${swiper.params.containerModifierClass}${currentDirection}`);
|
4142 | swiper.el.classList.add(`${swiper.params.containerModifierClass}${newDirection}`);
|
4143 | swiper.emitContainerClasses();
|
4144 | swiper.params.direction = newDirection;
|
4145 | swiper.slides.forEach(slideEl => {
|
4146 | if (newDirection === 'vertical') {
|
4147 | slideEl.style.width = '';
|
4148 | } else {
|
4149 | slideEl.style.height = '';
|
4150 | }
|
4151 | });
|
4152 | swiper.emit('changeDirection');
|
4153 | if (needUpdate) swiper.update();
|
4154 | return swiper;
|
4155 | }
|
4156 | changeLanguageDirection(direction) {
|
4157 | const swiper = this;
|
4158 | if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
|
4159 | swiper.rtl = direction === 'rtl';
|
4160 | swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
|
4161 | if (swiper.rtl) {
|
4162 | swiper.el.classList.add(`${swiper.params.containerModifierClass}rtl`);
|
4163 | swiper.el.dir = 'rtl';
|
4164 | } else {
|
4165 | swiper.el.classList.remove(`${swiper.params.containerModifierClass}rtl`);
|
4166 | swiper.el.dir = 'ltr';
|
4167 | }
|
4168 | swiper.update();
|
4169 | }
|
4170 | mount(element) {
|
4171 | const swiper = this;
|
4172 | if (swiper.mounted) return true;
|
4173 |
|
4174 |
|
4175 | let el = element || swiper.params.el;
|
4176 | if (typeof el === 'string') {
|
4177 | el = document.querySelector(el);
|
4178 | }
|
4179 | if (!el) {
|
4180 | return false;
|
4181 | }
|
4182 | el.swiper = swiper;
|
4183 | if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
4184 | swiper.isElement = true;
|
4185 | }
|
4186 | const getWrapperSelector = () => {
|
4187 | return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
|
4188 | };
|
4189 | const getWrapper = () => {
|
4190 | if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
4191 | const res = el.shadowRoot.querySelector(getWrapperSelector());
|
4192 |
|
4193 | return res;
|
4194 | }
|
4195 | return elementChildren(el, getWrapperSelector())[0];
|
4196 | };
|
4197 |
|
4198 | let wrapperEl = getWrapper();
|
4199 | if (!wrapperEl && swiper.params.createElements) {
|
4200 | wrapperEl = createElement('div', swiper.params.wrapperClass);
|
4201 | el.append(wrapperEl);
|
4202 | elementChildren(el, `.${swiper.params.slideClass}`).forEach(slideEl => {
|
4203 | wrapperEl.append(slideEl);
|
4204 | });
|
4205 | }
|
4206 | Object.assign(swiper, {
|
4207 | el,
|
4208 | wrapperEl,
|
4209 | slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
4210 | hostEl: swiper.isElement ? el.parentNode.host : el,
|
4211 | mounted: true,
|
4212 |
|
4213 | rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
4214 | rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
4215 | wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
4216 | });
|
4217 | return true;
|
4218 | }
|
4219 | init(el) {
|
4220 | const swiper = this;
|
4221 | if (swiper.initialized) return swiper;
|
4222 | const mounted = swiper.mount(el);
|
4223 | if (mounted === false) return swiper;
|
4224 | swiper.emit('beforeInit');
|
4225 |
|
4226 |
|
4227 | if (swiper.params.breakpoints) {
|
4228 | swiper.setBreakpoint();
|
4229 | }
|
4230 |
|
4231 |
|
4232 | swiper.addClasses();
|
4233 |
|
4234 |
|
4235 | swiper.updateSize();
|
4236 |
|
4237 |
|
4238 | swiper.updateSlides();
|
4239 | if (swiper.params.watchOverflow) {
|
4240 | swiper.checkOverflow();
|
4241 | }
|
4242 |
|
4243 |
|
4244 | if (swiper.params.grabCursor && swiper.enabled) {
|
4245 | swiper.setGrabCursor();
|
4246 | }
|
4247 |
|
4248 |
|
4249 | if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
4250 | swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
4251 | } else {
|
4252 | swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
4253 | }
|
4254 |
|
4255 |
|
4256 | if (swiper.params.loop) {
|
4257 | swiper.loopCreate();
|
4258 | }
|
4259 |
|
4260 |
|
4261 | swiper.attachEvents();
|
4262 | const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
4263 | if (swiper.isElement) {
|
4264 | lazyElements.push(...swiper.hostEl.querySelectorAll('[loading="lazy"]'));
|
4265 | }
|
4266 | lazyElements.forEach(imageEl => {
|
4267 | if (imageEl.complete) {
|
4268 | processLazyPreloader(swiper, imageEl);
|
4269 | } else {
|
4270 | imageEl.addEventListener('load', e => {
|
4271 | processLazyPreloader(swiper, e.target);
|
4272 | });
|
4273 | }
|
4274 | });
|
4275 | preload(swiper);
|
4276 |
|
4277 |
|
4278 | swiper.initialized = true;
|
4279 | preload(swiper);
|
4280 |
|
4281 |
|
4282 | swiper.emit('init');
|
4283 | swiper.emit('afterInit');
|
4284 | return swiper;
|
4285 | }
|
4286 | destroy(deleteInstance, cleanStyles) {
|
4287 | if (deleteInstance === void 0) {
|
4288 | deleteInstance = true;
|
4289 | }
|
4290 | if (cleanStyles === void 0) {
|
4291 | cleanStyles = true;
|
4292 | }
|
4293 | const swiper = this;
|
4294 | const {
|
4295 | params,
|
4296 | el,
|
4297 | wrapperEl,
|
4298 | slides
|
4299 | } = swiper;
|
4300 | if (typeof swiper.params === 'undefined' || swiper.destroyed) {
|
4301 | return null;
|
4302 | }
|
4303 | swiper.emit('beforeDestroy');
|
4304 |
|
4305 |
|
4306 | swiper.initialized = false;
|
4307 |
|
4308 |
|
4309 | swiper.detachEvents();
|
4310 |
|
4311 |
|
4312 | if (params.loop) {
|
4313 | swiper.loopDestroy();
|
4314 | }
|
4315 |
|
4316 |
|
4317 | if (cleanStyles) {
|
4318 | swiper.removeClasses();
|
4319 | if (el && typeof el !== 'string') {
|
4320 | el.removeAttribute('style');
|
4321 | }
|
4322 | if (wrapperEl) {
|
4323 | wrapperEl.removeAttribute('style');
|
4324 | }
|
4325 | if (slides && slides.length) {
|
4326 | slides.forEach(slideEl => {
|
4327 | slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
4328 | slideEl.removeAttribute('style');
|
4329 | slideEl.removeAttribute('data-swiper-slide-index');
|
4330 | });
|
4331 | }
|
4332 | }
|
4333 | swiper.emit('destroy');
|
4334 |
|
4335 |
|
4336 | Object.keys(swiper.eventsListeners).forEach(eventName => {
|
4337 | swiper.off(eventName);
|
4338 | });
|
4339 | if (deleteInstance !== false) {
|
4340 | if (swiper.el && typeof swiper.el !== 'string') {
|
4341 | swiper.el.swiper = null;
|
4342 | }
|
4343 | deleteProps(swiper);
|
4344 | }
|
4345 | swiper.destroyed = true;
|
4346 | return null;
|
4347 | }
|
4348 | static extendDefaults(newDefaults) {
|
4349 | extend$1(extendedDefaults, newDefaults);
|
4350 | }
|
4351 | static get extendedDefaults() {
|
4352 | return extendedDefaults;
|
4353 | }
|
4354 | static get defaults() {
|
4355 | return defaults;
|
4356 | }
|
4357 | static installModule(mod) {
|
4358 | if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
|
4359 | const modules = Swiper.prototype.__modules__;
|
4360 | if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
|
4361 | modules.push(mod);
|
4362 | }
|
4363 | }
|
4364 | static use(module) {
|
4365 | if (Array.isArray(module)) {
|
4366 | module.forEach(m => Swiper.installModule(m));
|
4367 | return Swiper;
|
4368 | }
|
4369 | Swiper.installModule(module);
|
4370 | return Swiper;
|
4371 | }
|
4372 | }
|
4373 | Object.keys(prototypes).forEach(prototypeGroup => {
|
4374 | Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
|
4375 | Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
|
4376 | });
|
4377 | });
|
4378 | Swiper.use([Resize, Observer]);
|
4379 |
|
4380 | function Virtual(_ref) {
|
4381 | let {
|
4382 | swiper,
|
4383 | extendParams,
|
4384 | on,
|
4385 | emit
|
4386 | } = _ref;
|
4387 | extendParams({
|
4388 | virtual: {
|
4389 | enabled: false,
|
4390 | slides: [],
|
4391 | cache: true,
|
4392 | renderSlide: null,
|
4393 | renderExternal: null,
|
4394 | renderExternalUpdate: true,
|
4395 | addSlidesBefore: 0,
|
4396 | addSlidesAfter: 0
|
4397 | }
|
4398 | });
|
4399 | let cssModeTimeout;
|
4400 | const document = getDocument();
|
4401 | swiper.virtual = {
|
4402 | cache: {},
|
4403 | from: undefined,
|
4404 | to: undefined,
|
4405 | slides: [],
|
4406 | offset: 0,
|
4407 | slidesGrid: []
|
4408 | };
|
4409 | const tempDOM = document.createElement('div');
|
4410 | function renderSlide(slide, index) {
|
4411 | const params = swiper.params.virtual;
|
4412 | if (params.cache && swiper.virtual.cache[index]) {
|
4413 | return swiper.virtual.cache[index];
|
4414 | }
|
4415 |
|
4416 | let slideEl;
|
4417 | if (params.renderSlide) {
|
4418 | slideEl = params.renderSlide.call(swiper, slide, index);
|
4419 | if (typeof slideEl === 'string') {
|
4420 | tempDOM.innerHTML = slideEl;
|
4421 | slideEl = tempDOM.children[0];
|
4422 | }
|
4423 | } else if (swiper.isElement) {
|
4424 | slideEl = createElement('swiper-slide');
|
4425 | } else {
|
4426 | slideEl = createElement('div', swiper.params.slideClass);
|
4427 | }
|
4428 | slideEl.setAttribute('data-swiper-slide-index', index);
|
4429 | if (!params.renderSlide) {
|
4430 | slideEl.innerHTML = slide;
|
4431 | }
|
4432 | if (params.cache) {
|
4433 | swiper.virtual.cache[index] = slideEl;
|
4434 | }
|
4435 | return slideEl;
|
4436 | }
|
4437 | function update(force, beforeInit) {
|
4438 | const {
|
4439 | slidesPerView,
|
4440 | slidesPerGroup,
|
4441 | centeredSlides,
|
4442 | loop: isLoop,
|
4443 | initialSlide
|
4444 | } = swiper.params;
|
4445 | if (beforeInit && !isLoop && initialSlide > 0) {
|
4446 | return;
|
4447 | }
|
4448 | const {
|
4449 | addSlidesBefore,
|
4450 | addSlidesAfter
|
4451 | } = swiper.params.virtual;
|
4452 | const {
|
4453 | from: previousFrom,
|
4454 | to: previousTo,
|
4455 | slides,
|
4456 | slidesGrid: previousSlidesGrid,
|
4457 | offset: previousOffset
|
4458 | } = swiper.virtual;
|
4459 | if (!swiper.params.cssMode) {
|
4460 | swiper.updateActiveIndex();
|
4461 | }
|
4462 | const activeIndex = swiper.activeIndex || 0;
|
4463 | let offsetProp;
|
4464 | if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top';
|
4465 | let slidesAfter;
|
4466 | let slidesBefore;
|
4467 | if (centeredSlides) {
|
4468 | slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter;
|
4469 | slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore;
|
4470 | } else {
|
4471 | slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter;
|
4472 | slidesBefore = (isLoop ? slidesPerView : slidesPerGroup) + addSlidesBefore;
|
4473 | }
|
4474 | let from = activeIndex - slidesBefore;
|
4475 | let to = activeIndex + slidesAfter;
|
4476 | if (!isLoop) {
|
4477 | from = Math.max(from, 0);
|
4478 | to = Math.min(to, slides.length - 1);
|
4479 | }
|
4480 | let offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
|
4481 | if (isLoop && activeIndex >= slidesBefore) {
|
4482 | from -= slidesBefore;
|
4483 | if (!centeredSlides) offset += swiper.slidesGrid[0];
|
4484 | } else if (isLoop && activeIndex < slidesBefore) {
|
4485 | from = -slidesBefore;
|
4486 | if (centeredSlides) offset += swiper.slidesGrid[0];
|
4487 | }
|
4488 | Object.assign(swiper.virtual, {
|
4489 | from,
|
4490 | to,
|
4491 | offset,
|
4492 | slidesGrid: swiper.slidesGrid,
|
4493 | slidesBefore,
|
4494 | slidesAfter
|
4495 | });
|
4496 | function onRendered() {
|
4497 | swiper.updateSlides();
|
4498 | swiper.updateProgress();
|
4499 | swiper.updateSlidesClasses();
|
4500 | emit('virtualUpdate');
|
4501 | }
|
4502 | if (previousFrom === from && previousTo === to && !force) {
|
4503 | if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
|
4504 | swiper.slides.forEach(slideEl => {
|
4505 | slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
|
4506 | });
|
4507 | }
|
4508 | swiper.updateProgress();
|
4509 | emit('virtualUpdate');
|
4510 | return;
|
4511 | }
|
4512 | if (swiper.params.virtual.renderExternal) {
|
4513 | swiper.params.virtual.renderExternal.call(swiper, {
|
4514 | offset,
|
4515 | from,
|
4516 | to,
|
4517 | slides: function getSlides() {
|
4518 | const slidesToRender = [];
|
4519 | for (let i = from; i <= to; i += 1) {
|
4520 | slidesToRender.push(slides[i]);
|
4521 | }
|
4522 | return slidesToRender;
|
4523 | }()
|
4524 | });
|
4525 | if (swiper.params.virtual.renderExternalUpdate) {
|
4526 | onRendered();
|
4527 | } else {
|
4528 | emit('virtualUpdate');
|
4529 | }
|
4530 | return;
|
4531 | }
|
4532 | const prependIndexes = [];
|
4533 | const appendIndexes = [];
|
4534 | const getSlideIndex = index => {
|
4535 | let slideIndex = index;
|
4536 | if (index < 0) {
|
4537 | slideIndex = slides.length + index;
|
4538 | } else if (slideIndex >= slides.length) {
|
4539 |
|
4540 | slideIndex = slideIndex - slides.length;
|
4541 | }
|
4542 | return slideIndex;
|
4543 | };
|
4544 | if (force) {
|
4545 | swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`)).forEach(slideEl => {
|
4546 | slideEl.remove();
|
4547 | });
|
4548 | } else {
|
4549 | for (let i = previousFrom; i <= previousTo; i += 1) {
|
4550 | if (i < from || i > to) {
|
4551 | const slideIndex = getSlideIndex(i);
|
4552 | swiper.slides.filter(el => el.matches(`.${swiper.params.slideClass}[data-swiper-slide-index="${slideIndex}"], swiper-slide[data-swiper-slide-index="${slideIndex}"]`)).forEach(slideEl => {
|
4553 | slideEl.remove();
|
4554 | });
|
4555 | }
|
4556 | }
|
4557 | }
|
4558 | const loopFrom = isLoop ? -slides.length : 0;
|
4559 | const loopTo = isLoop ? slides.length * 2 : slides.length;
|
4560 | for (let i = loopFrom; i < loopTo; i += 1) {
|
4561 | if (i >= from && i <= to) {
|
4562 | const slideIndex = getSlideIndex(i);
|
4563 | if (typeof previousTo === 'undefined' || force) {
|
4564 | appendIndexes.push(slideIndex);
|
4565 | } else {
|
4566 | if (i > previousTo) appendIndexes.push(slideIndex);
|
4567 | if (i < previousFrom) prependIndexes.push(slideIndex);
|
4568 | }
|
4569 | }
|
4570 | }
|
4571 | appendIndexes.forEach(index => {
|
4572 | swiper.slidesEl.append(renderSlide(slides[index], index));
|
4573 | });
|
4574 | if (isLoop) {
|
4575 | for (let i = prependIndexes.length - 1; i >= 0; i -= 1) {
|
4576 | const index = prependIndexes[i];
|
4577 | swiper.slidesEl.prepend(renderSlide(slides[index], index));
|
4578 | }
|
4579 | } else {
|
4580 | prependIndexes.sort((a, b) => b - a);
|
4581 | prependIndexes.forEach(index => {
|
4582 | swiper.slidesEl.prepend(renderSlide(slides[index], index));
|
4583 | });
|
4584 | }
|
4585 | elementChildren(swiper.slidesEl, '.swiper-slide, swiper-slide').forEach(slideEl => {
|
4586 | slideEl.style[offsetProp] = `${offset - Math.abs(swiper.cssOverflowAdjustment())}px`;
|
4587 | });
|
4588 | onRendered();
|
4589 | }
|
4590 | function appendSlide(slides) {
|
4591 | if (typeof slides === 'object' && 'length' in slides) {
|
4592 | for (let i = 0; i < slides.length; i += 1) {
|
4593 | if (slides[i]) swiper.virtual.slides.push(slides[i]);
|
4594 | }
|
4595 | } else {
|
4596 | swiper.virtual.slides.push(slides);
|
4597 | }
|
4598 | update(true);
|
4599 | }
|
4600 | function prependSlide(slides) {
|
4601 | const activeIndex = swiper.activeIndex;
|
4602 | let newActiveIndex = activeIndex + 1;
|
4603 | let numberOfNewSlides = 1;
|
4604 | if (Array.isArray(slides)) {
|
4605 | for (let i = 0; i < slides.length; i += 1) {
|
4606 | if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
|
4607 | }
|
4608 | newActiveIndex = activeIndex + slides.length;
|
4609 | numberOfNewSlides = slides.length;
|
4610 | } else {
|
4611 | swiper.virtual.slides.unshift(slides);
|
4612 | }
|
4613 | if (swiper.params.virtual.cache) {
|
4614 | const cache = swiper.virtual.cache;
|
4615 | const newCache = {};
|
4616 | Object.keys(cache).forEach(cachedIndex => {
|
4617 | const cachedEl = cache[cachedIndex];
|
4618 | const cachedElIndex = cachedEl.getAttribute('data-swiper-slide-index');
|
4619 | if (cachedElIndex) {
|
4620 | cachedEl.setAttribute('data-swiper-slide-index', parseInt(cachedElIndex, 10) + numberOfNewSlides);
|
4621 | }
|
4622 | newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = cachedEl;
|
4623 | });
|
4624 | swiper.virtual.cache = newCache;
|
4625 | }
|
4626 | update(true);
|
4627 | swiper.slideTo(newActiveIndex, 0);
|
4628 | }
|
4629 | function removeSlide(slidesIndexes) {
|
4630 | if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return;
|
4631 | let activeIndex = swiper.activeIndex;
|
4632 | if (Array.isArray(slidesIndexes)) {
|
4633 | for (let i = slidesIndexes.length - 1; i >= 0; i -= 1) {
|
4634 | if (swiper.params.virtual.cache) {
|
4635 | delete swiper.virtual.cache[slidesIndexes[i]];
|
4636 |
|
4637 | Object.keys(swiper.virtual.cache).forEach(key => {
|
4638 | if (key > slidesIndexes) {
|
4639 | swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
|
4640 | swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
|
4641 | delete swiper.virtual.cache[key];
|
4642 | }
|
4643 | });
|
4644 | }
|
4645 | swiper.virtual.slides.splice(slidesIndexes[i], 1);
|
4646 | if (slidesIndexes[i] < activeIndex) activeIndex -= 1;
|
4647 | activeIndex = Math.max(activeIndex, 0);
|
4648 | }
|
4649 | } else {
|
4650 | if (swiper.params.virtual.cache) {
|
4651 | delete swiper.virtual.cache[slidesIndexes];
|
4652 |
|
4653 | Object.keys(swiper.virtual.cache).forEach(key => {
|
4654 | if (key > slidesIndexes) {
|
4655 | swiper.virtual.cache[key - 1] = swiper.virtual.cache[key];
|
4656 | swiper.virtual.cache[key - 1].setAttribute('data-swiper-slide-index', key - 1);
|
4657 | delete swiper.virtual.cache[key];
|
4658 | }
|
4659 | });
|
4660 | }
|
4661 | swiper.virtual.slides.splice(slidesIndexes, 1);
|
4662 | if (slidesIndexes < activeIndex) activeIndex -= 1;
|
4663 | activeIndex = Math.max(activeIndex, 0);
|
4664 | }
|
4665 | update(true);
|
4666 | swiper.slideTo(activeIndex, 0);
|
4667 | }
|
4668 | function removeAllSlides() {
|
4669 | swiper.virtual.slides = [];
|
4670 | if (swiper.params.virtual.cache) {
|
4671 | swiper.virtual.cache = {};
|
4672 | }
|
4673 | update(true);
|
4674 | swiper.slideTo(0, 0);
|
4675 | }
|
4676 | on('beforeInit', () => {
|
4677 | if (!swiper.params.virtual.enabled) return;
|
4678 | let domSlidesAssigned;
|
4679 | if (typeof swiper.passedParams.virtual.slides === 'undefined') {
|
4680 | const slides = [...swiper.slidesEl.children].filter(el => el.matches(`.${swiper.params.slideClass}, swiper-slide`));
|
4681 | if (slides && slides.length) {
|
4682 | swiper.virtual.slides = [...slides];
|
4683 | domSlidesAssigned = true;
|
4684 | slides.forEach((slideEl, slideIndex) => {
|
4685 | slideEl.setAttribute('data-swiper-slide-index', slideIndex);
|
4686 | swiper.virtual.cache[slideIndex] = slideEl;
|
4687 | slideEl.remove();
|
4688 | });
|
4689 | }
|
4690 | }
|
4691 | if (!domSlidesAssigned) {
|
4692 | swiper.virtual.slides = swiper.params.virtual.slides;
|
4693 | }
|
4694 | swiper.classNames.push(`${swiper.params.containerModifierClass}virtual`);
|
4695 | swiper.params.watchSlidesProgress = true;
|
4696 | swiper.originalParams.watchSlidesProgress = true;
|
4697 | update(false, true);
|
4698 | });
|
4699 | on('setTranslate', () => {
|
4700 | if (!swiper.params.virtual.enabled) return;
|
4701 | if (swiper.params.cssMode && !swiper._immediateVirtual) {
|
4702 | clearTimeout(cssModeTimeout);
|
4703 | cssModeTimeout = setTimeout(() => {
|
4704 | update();
|
4705 | }, 100);
|
4706 | } else {
|
4707 | update();
|
4708 | }
|
4709 | });
|
4710 | on('init update resize', () => {
|
4711 | if (!swiper.params.virtual.enabled) return;
|
4712 | if (swiper.params.cssMode) {
|
4713 | setCSSProperty(swiper.wrapperEl, '--swiper-virtual-size', `${swiper.virtualSize}px`);
|
4714 | }
|
4715 | });
|
4716 | Object.assign(swiper.virtual, {
|
4717 | appendSlide,
|
4718 | prependSlide,
|
4719 | removeSlide,
|
4720 | removeAllSlides,
|
4721 | update
|
4722 | });
|
4723 | }
|
4724 |
|
4725 |
|
4726 | function Keyboard(_ref) {
|
4727 | let {
|
4728 | swiper,
|
4729 | extendParams,
|
4730 | on,
|
4731 | emit
|
4732 | } = _ref;
|
4733 | const document = getDocument();
|
4734 | const window = getWindow();
|
4735 | swiper.keyboard = {
|
4736 | enabled: false
|
4737 | };
|
4738 | extendParams({
|
4739 | keyboard: {
|
4740 | enabled: false,
|
4741 | onlyInViewport: true,
|
4742 | pageUpDown: true
|
4743 | }
|
4744 | });
|
4745 | function handle(event) {
|
4746 | if (!swiper.enabled) return;
|
4747 | const {
|
4748 | rtlTranslate: rtl
|
4749 | } = swiper;
|
4750 | let e = event;
|
4751 | if (e.originalEvent) e = e.originalEvent;
|
4752 | const kc = e.keyCode || e.charCode;
|
4753 | const pageUpDown = swiper.params.keyboard.pageUpDown;
|
4754 | const isPageUp = pageUpDown && kc === 33;
|
4755 | const isPageDown = pageUpDown && kc === 34;
|
4756 | const isArrowLeft = kc === 37;
|
4757 | const isArrowRight = kc === 39;
|
4758 | const isArrowUp = kc === 38;
|
4759 | const isArrowDown = kc === 40;
|
4760 |
|
4761 | if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) {
|
4762 | return false;
|
4763 | }
|
4764 | if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) {
|
4765 | return false;
|
4766 | }
|
4767 | if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
|
4768 | return undefined;
|
4769 | }
|
4770 | if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
|
4771 | return undefined;
|
4772 | }
|
4773 | if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) {
|
4774 | let inView = false;
|
4775 |
|
4776 | if (elementParents(swiper.el, `.${swiper.params.slideClass}, swiper-slide`).length > 0 && elementParents(swiper.el, `.${swiper.params.slideActiveClass}`).length === 0) {
|
4777 | return undefined;
|
4778 | }
|
4779 | const el = swiper.el;
|
4780 | const swiperWidth = el.clientWidth;
|
4781 | const swiperHeight = el.clientHeight;
|
4782 | const windowWidth = window.innerWidth;
|
4783 | const windowHeight = window.innerHeight;
|
4784 | const swiperOffset = elementOffset(el);
|
4785 | if (rtl) swiperOffset.left -= el.scrollLeft;
|
4786 | const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]];
|
4787 | for (let i = 0; i < swiperCoord.length; i += 1) {
|
4788 | const point = swiperCoord[i];
|
4789 | if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) {
|
4790 | if (point[0] === 0 && point[1] === 0) continue;
|
4791 | inView = true;
|
4792 | }
|
4793 | }
|
4794 | if (!inView) return undefined;
|
4795 | }
|
4796 | if (swiper.isHorizontal()) {
|
4797 | if (isPageUp || isPageDown || isArrowLeft || isArrowRight) {
|
4798 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
4799 | }
|
4800 | if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext();
|
4801 | if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev();
|
4802 | } else {
|
4803 | if (isPageUp || isPageDown || isArrowUp || isArrowDown) {
|
4804 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
4805 | }
|
4806 | if (isPageDown || isArrowDown) swiper.slideNext();
|
4807 | if (isPageUp || isArrowUp) swiper.slidePrev();
|
4808 | }
|
4809 | emit('keyPress', kc);
|
4810 | return undefined;
|
4811 | }
|
4812 | function enable() {
|
4813 | if (swiper.keyboard.enabled) return;
|
4814 | document.addEventListener('keydown', handle);
|
4815 | swiper.keyboard.enabled = true;
|
4816 | }
|
4817 | function disable() {
|
4818 | if (!swiper.keyboard.enabled) return;
|
4819 | document.removeEventListener('keydown', handle);
|
4820 | swiper.keyboard.enabled = false;
|
4821 | }
|
4822 | on('init', () => {
|
4823 | if (swiper.params.keyboard.enabled) {
|
4824 | enable();
|
4825 | }
|
4826 | });
|
4827 | on('destroy', () => {
|
4828 | if (swiper.keyboard.enabled) {
|
4829 | disable();
|
4830 | }
|
4831 | });
|
4832 | Object.assign(swiper.keyboard, {
|
4833 | enable,
|
4834 | disable
|
4835 | });
|
4836 | }
|
4837 |
|
4838 |
|
4839 | function Mousewheel(_ref) {
|
4840 | let {
|
4841 | swiper,
|
4842 | extendParams,
|
4843 | on,
|
4844 | emit
|
4845 | } = _ref;
|
4846 | const window = getWindow();
|
4847 | extendParams({
|
4848 | mousewheel: {
|
4849 | enabled: false,
|
4850 | releaseOnEdges: false,
|
4851 | invert: false,
|
4852 | forceToAxis: false,
|
4853 | sensitivity: 1,
|
4854 | eventsTarget: 'container',
|
4855 | thresholdDelta: null,
|
4856 | thresholdTime: null,
|
4857 | noMousewheelClass: 'swiper-no-mousewheel'
|
4858 | }
|
4859 | });
|
4860 | swiper.mousewheel = {
|
4861 | enabled: false
|
4862 | };
|
4863 | let timeout;
|
4864 | let lastScrollTime = now();
|
4865 | let lastEventBeforeSnap;
|
4866 | const recentWheelEvents = [];
|
4867 | function normalize(e) {
|
4868 |
|
4869 | const PIXEL_STEP = 10;
|
4870 | const LINE_HEIGHT = 40;
|
4871 | const PAGE_HEIGHT = 800;
|
4872 | let sX = 0;
|
4873 | let sY = 0;
|
4874 | let pX = 0;
|
4875 | let pY = 0;
|
4876 |
|
4877 |
|
4878 | if ('detail' in e) {
|
4879 | sY = e.detail;
|
4880 | }
|
4881 | if ('wheelDelta' in e) {
|
4882 | sY = -e.wheelDelta / 120;
|
4883 | }
|
4884 | if ('wheelDeltaY' in e) {
|
4885 | sY = -e.wheelDeltaY / 120;
|
4886 | }
|
4887 | if ('wheelDeltaX' in e) {
|
4888 | sX = -e.wheelDeltaX / 120;
|
4889 | }
|
4890 |
|
4891 |
|
4892 | if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
|
4893 | sX = sY;
|
4894 | sY = 0;
|
4895 | }
|
4896 | pX = sX * PIXEL_STEP;
|
4897 | pY = sY * PIXEL_STEP;
|
4898 | if ('deltaY' in e) {
|
4899 | pY = e.deltaY;
|
4900 | }
|
4901 | if ('deltaX' in e) {
|
4902 | pX = e.deltaX;
|
4903 | }
|
4904 | if (e.shiftKey && !pX) {
|
4905 |
|
4906 | pX = pY;
|
4907 | pY = 0;
|
4908 | }
|
4909 | if ((pX || pY) && e.deltaMode) {
|
4910 | if (e.deltaMode === 1) {
|
4911 |
|
4912 | pX *= LINE_HEIGHT;
|
4913 | pY *= LINE_HEIGHT;
|
4914 | } else {
|
4915 |
|
4916 | pX *= PAGE_HEIGHT;
|
4917 | pY *= PAGE_HEIGHT;
|
4918 | }
|
4919 | }
|
4920 |
|
4921 |
|
4922 | if (pX && !sX) {
|
4923 | sX = pX < 1 ? -1 : 1;
|
4924 | }
|
4925 | if (pY && !sY) {
|
4926 | sY = pY < 1 ? -1 : 1;
|
4927 | }
|
4928 | return {
|
4929 | spinX: sX,
|
4930 | spinY: sY,
|
4931 | pixelX: pX,
|
4932 | pixelY: pY
|
4933 | };
|
4934 | }
|
4935 | function handleMouseEnter() {
|
4936 | if (!swiper.enabled) return;
|
4937 | swiper.mouseEntered = true;
|
4938 | }
|
4939 | function handleMouseLeave() {
|
4940 | if (!swiper.enabled) return;
|
4941 | swiper.mouseEntered = false;
|
4942 | }
|
4943 | function animateSlider(newEvent) {
|
4944 | if (swiper.params.mousewheel.thresholdDelta && newEvent.delta < swiper.params.mousewheel.thresholdDelta) {
|
4945 |
|
4946 | return false;
|
4947 | }
|
4948 | if (swiper.params.mousewheel.thresholdTime && now() - lastScrollTime < swiper.params.mousewheel.thresholdTime) {
|
4949 |
|
4950 | return false;
|
4951 | }
|
4952 |
|
4953 |
|
4954 |
|
4955 |
|
4956 | if (newEvent.delta >= 6 && now() - lastScrollTime < 60) {
|
4957 |
|
4958 | return true;
|
4959 | }
|
4960 |
|
4961 |
|
4962 |
|
4963 |
|
4964 |
|
4965 |
|
4966 |
|
4967 |
|
4968 |
|
4969 |
|
4970 |
|
4971 |
|
4972 | if (newEvent.direction < 0) {
|
4973 | if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
|
4974 | swiper.slideNext();
|
4975 | emit('scroll', newEvent.raw);
|
4976 | }
|
4977 | } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
|
4978 | swiper.slidePrev();
|
4979 | emit('scroll', newEvent.raw);
|
4980 | }
|
4981 |
|
4982 | lastScrollTime = new window.Date().getTime();
|
4983 |
|
4984 | return false;
|
4985 | }
|
4986 | function releaseScroll(newEvent) {
|
4987 | const params = swiper.params.mousewheel;
|
4988 | if (newEvent.direction < 0) {
|
4989 | if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) {
|
4990 |
|
4991 | return true;
|
4992 | }
|
4993 | } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) {
|
4994 |
|
4995 | return true;
|
4996 | }
|
4997 | return false;
|
4998 | }
|
4999 | function handle(event) {
|
5000 | let e = event;
|
5001 | let disableParentSwiper = true;
|
5002 | if (!swiper.enabled) return;
|
5003 |
|
5004 |
|
5005 | if (event.target.closest(`.${swiper.params.mousewheel.noMousewheelClass}`)) return;
|
5006 | const params = swiper.params.mousewheel;
|
5007 | if (swiper.params.cssMode) {
|
5008 | e.preventDefault();
|
5009 | }
|
5010 | let targetEl = swiper.el;
|
5011 | if (swiper.params.mousewheel.eventsTarget !== 'container') {
|
5012 | targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
|
5013 | }
|
5014 | const targetElContainsTarget = targetEl && targetEl.contains(e.target);
|
5015 | if (!swiper.mouseEntered && !targetElContainsTarget && !params.releaseOnEdges) return true;
|
5016 | if (e.originalEvent) e = e.originalEvent;
|
5017 | let delta = 0;
|
5018 | const rtlFactor = swiper.rtlTranslate ? -1 : 1;
|
5019 | const data = normalize(e);
|
5020 | if (params.forceToAxis) {
|
5021 | if (swiper.isHorizontal()) {
|
5022 | if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true;
|
5023 | } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true;
|
5024 | } else {
|
5025 | delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
|
5026 | }
|
5027 | if (delta === 0) return true;
|
5028 | if (params.invert) delta = -delta;
|
5029 |
|
5030 |
|
5031 | let positions = swiper.getTranslate() + delta * params.sensitivity;
|
5032 | if (positions >= swiper.minTranslate()) positions = swiper.minTranslate();
|
5033 | if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate();
|
5034 |
|
5035 |
|
5036 |
|
5037 |
|
5038 |
|
5039 |
|
5040 |
|
5041 |
|
5042 | disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate());
|
5043 | if (disableParentSwiper && swiper.params.nested) e.stopPropagation();
|
5044 | if (!swiper.params.freeMode || !swiper.params.freeMode.enabled) {
|
5045 |
|
5046 | const newEvent = {
|
5047 | time: now(),
|
5048 | delta: Math.abs(delta),
|
5049 | direction: Math.sign(delta),
|
5050 | raw: event
|
5051 | };
|
5052 |
|
5053 |
|
5054 | if (recentWheelEvents.length >= 2) {
|
5055 | recentWheelEvents.shift();
|
5056 | }
|
5057 |
|
5058 | const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
|
5059 | recentWheelEvents.push(newEvent);
|
5060 |
|
5061 |
|
5062 |
|
5063 |
|
5064 |
|
5065 |
|
5066 |
|
5067 | if (prevEvent) {
|
5068 | if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
|
5069 | animateSlider(newEvent);
|
5070 | }
|
5071 | } else {
|
5072 | animateSlider(newEvent);
|
5073 | }
|
5074 |
|
5075 |
|
5076 |
|
5077 | if (releaseScroll(newEvent)) {
|
5078 | return true;
|
5079 | }
|
5080 | } else {
|
5081 |
|
5082 |
|
5083 |
|
5084 |
|
5085 |
|
5086 |
|
5087 | const newEvent = {
|
5088 | time: now(),
|
5089 | delta: Math.abs(delta),
|
5090 | direction: Math.sign(delta)
|
5091 | };
|
5092 | const ignoreWheelEvents = lastEventBeforeSnap && newEvent.time < lastEventBeforeSnap.time + 500 && newEvent.delta <= lastEventBeforeSnap.delta && newEvent.direction === lastEventBeforeSnap.direction;
|
5093 | if (!ignoreWheelEvents) {
|
5094 | lastEventBeforeSnap = undefined;
|
5095 | let position = swiper.getTranslate() + delta * params.sensitivity;
|
5096 | const wasBeginning = swiper.isBeginning;
|
5097 | const wasEnd = swiper.isEnd;
|
5098 | if (position >= swiper.minTranslate()) position = swiper.minTranslate();
|
5099 | if (position <= swiper.maxTranslate()) position = swiper.maxTranslate();
|
5100 | swiper.setTransition(0);
|
5101 | swiper.setTranslate(position);
|
5102 | swiper.updateProgress();
|
5103 | swiper.updateActiveIndex();
|
5104 | swiper.updateSlidesClasses();
|
5105 | if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) {
|
5106 | swiper.updateSlidesClasses();
|
5107 | }
|
5108 | if (swiper.params.loop) {
|
5109 | swiper.loopFix({
|
5110 | direction: newEvent.direction < 0 ? 'next' : 'prev',
|
5111 | byMousewheel: true
|
5112 | });
|
5113 | }
|
5114 | if (swiper.params.freeMode.sticky) {
|
5115 |
|
5116 |
|
5117 |
|
5118 |
|
5119 |
|
5120 |
|
5121 |
|
5122 |
|
5123 |
|
5124 |
|
5125 |
|
5126 | clearTimeout(timeout);
|
5127 | timeout = undefined;
|
5128 | if (recentWheelEvents.length >= 15) {
|
5129 | recentWheelEvents.shift();
|
5130 | }
|
5131 |
|
5132 | const prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
|
5133 | const firstEvent = recentWheelEvents[0];
|
5134 | recentWheelEvents.push(newEvent);
|
5135 | if (prevEvent && (newEvent.delta > prevEvent.delta || newEvent.direction !== prevEvent.direction)) {
|
5136 |
|
5137 | recentWheelEvents.splice(0);
|
5138 | } else if (recentWheelEvents.length >= 15 && newEvent.time - firstEvent.time < 500 && firstEvent.delta - newEvent.delta >= 1 && newEvent.delta <= 6) {
|
5139 |
|
5140 |
|
5141 |
|
5142 |
|
5143 |
|
5144 |
|
5145 | const snapToThreshold = delta > 0 ? 0.8 : 0.2;
|
5146 | lastEventBeforeSnap = newEvent;
|
5147 | recentWheelEvents.splice(0);
|
5148 | timeout = nextTick(() => {
|
5149 | if (swiper.destroyed || !swiper.params) return;
|
5150 | swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
|
5151 | }, 0);
|
5152 | }
|
5153 |
|
5154 | if (!timeout) {
|
5155 |
|
5156 |
|
5157 |
|
5158 | timeout = nextTick(() => {
|
5159 | if (swiper.destroyed || !swiper.params) return;
|
5160 | const snapToThreshold = 0.5;
|
5161 | lastEventBeforeSnap = newEvent;
|
5162 | recentWheelEvents.splice(0);
|
5163 | swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
|
5164 | }, 500);
|
5165 | }
|
5166 | }
|
5167 |
|
5168 |
|
5169 | if (!ignoreWheelEvents) emit('scroll', e);
|
5170 |
|
5171 |
|
5172 | if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop();
|
5173 |
|
5174 | if (params.releaseOnEdges && (position === swiper.minTranslate() || position === swiper.maxTranslate())) {
|
5175 | return true;
|
5176 | }
|
5177 | }
|
5178 | }
|
5179 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
5180 | return false;
|
5181 | }
|
5182 | function events(method) {
|
5183 | let targetEl = swiper.el;
|
5184 | if (swiper.params.mousewheel.eventsTarget !== 'container') {
|
5185 | targetEl = document.querySelector(swiper.params.mousewheel.eventsTarget);
|
5186 | }
|
5187 | targetEl[method]('mouseenter', handleMouseEnter);
|
5188 | targetEl[method]('mouseleave', handleMouseLeave);
|
5189 | targetEl[method]('wheel', handle);
|
5190 | }
|
5191 | function enable() {
|
5192 | if (swiper.params.cssMode) {
|
5193 | swiper.wrapperEl.removeEventListener('wheel', handle);
|
5194 | return true;
|
5195 | }
|
5196 | if (swiper.mousewheel.enabled) return false;
|
5197 | events('addEventListener');
|
5198 | swiper.mousewheel.enabled = true;
|
5199 | return true;
|
5200 | }
|
5201 | function disable() {
|
5202 | if (swiper.params.cssMode) {
|
5203 | swiper.wrapperEl.addEventListener(event, handle);
|
5204 | return true;
|
5205 | }
|
5206 | if (!swiper.mousewheel.enabled) return false;
|
5207 | events('removeEventListener');
|
5208 | swiper.mousewheel.enabled = false;
|
5209 | return true;
|
5210 | }
|
5211 | on('init', () => {
|
5212 | if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) {
|
5213 | disable();
|
5214 | }
|
5215 | if (swiper.params.mousewheel.enabled) enable();
|
5216 | });
|
5217 | on('destroy', () => {
|
5218 | if (swiper.params.cssMode) {
|
5219 | enable();
|
5220 | }
|
5221 | if (swiper.mousewheel.enabled) disable();
|
5222 | });
|
5223 | Object.assign(swiper.mousewheel, {
|
5224 | enable,
|
5225 | disable
|
5226 | });
|
5227 | }
|
5228 |
|
5229 | function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
|
5230 | if (swiper.params.createElements) {
|
5231 | Object.keys(checkProps).forEach(key => {
|
5232 | if (!params[key] && params.auto === true) {
|
5233 | let element = elementChildren(swiper.el, `.${checkProps[key]}`)[0];
|
5234 | if (!element) {
|
5235 | element = createElement('div', checkProps[key]);
|
5236 | element.className = checkProps[key];
|
5237 | swiper.el.append(element);
|
5238 | }
|
5239 | params[key] = element;
|
5240 | originalParams[key] = element;
|
5241 | }
|
5242 | });
|
5243 | }
|
5244 | return params;
|
5245 | }
|
5246 |
|
5247 | function Navigation(_ref) {
|
5248 | let {
|
5249 | swiper,
|
5250 | extendParams,
|
5251 | on,
|
5252 | emit
|
5253 | } = _ref;
|
5254 | extendParams({
|
5255 | navigation: {
|
5256 | nextEl: null,
|
5257 | prevEl: null,
|
5258 | hideOnClick: false,
|
5259 | disabledClass: 'swiper-button-disabled',
|
5260 | hiddenClass: 'swiper-button-hidden',
|
5261 | lockClass: 'swiper-button-lock',
|
5262 | navigationDisabledClass: 'swiper-navigation-disabled'
|
5263 | }
|
5264 | });
|
5265 | swiper.navigation = {
|
5266 | nextEl: null,
|
5267 | prevEl: null
|
5268 | };
|
5269 | function getEl(el) {
|
5270 | let res;
|
5271 | if (el && typeof el === 'string' && swiper.isElement) {
|
5272 | res = swiper.el.querySelector(el) || swiper.hostEl.querySelector(el);
|
5273 | if (res) return res;
|
5274 | }
|
5275 | if (el) {
|
5276 | if (typeof el === 'string') res = [...document.querySelectorAll(el)];
|
5277 | if (swiper.params.uniqueNavElements && typeof el === 'string' && res && res.length > 1 && swiper.el.querySelectorAll(el).length === 1) {
|
5278 | res = swiper.el.querySelector(el);
|
5279 | } else if (res && res.length === 1) {
|
5280 | res = res[0];
|
5281 | }
|
5282 | }
|
5283 | if (el && !res) return el;
|
5284 |
|
5285 | return res;
|
5286 | }
|
5287 | function toggleEl(el, disabled) {
|
5288 | const params = swiper.params.navigation;
|
5289 | el = makeElementsArray(el);
|
5290 | el.forEach(subEl => {
|
5291 | if (subEl) {
|
5292 | subEl.classList[disabled ? 'add' : 'remove'](...params.disabledClass.split(' '));
|
5293 | if (subEl.tagName === 'BUTTON') subEl.disabled = disabled;
|
5294 | if (swiper.params.watchOverflow && swiper.enabled) {
|
5295 | subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
|
5296 | }
|
5297 | }
|
5298 | });
|
5299 | }
|
5300 | function update() {
|
5301 |
|
5302 | const {
|
5303 | nextEl,
|
5304 | prevEl
|
5305 | } = swiper.navigation;
|
5306 | if (swiper.params.loop) {
|
5307 | toggleEl(prevEl, false);
|
5308 | toggleEl(nextEl, false);
|
5309 | return;
|
5310 | }
|
5311 | toggleEl(prevEl, swiper.isBeginning && !swiper.params.rewind);
|
5312 | toggleEl(nextEl, swiper.isEnd && !swiper.params.rewind);
|
5313 | }
|
5314 | function onPrevClick(e) {
|
5315 | e.preventDefault();
|
5316 | if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
|
5317 | swiper.slidePrev();
|
5318 | emit('navigationPrev');
|
5319 | }
|
5320 | function onNextClick(e) {
|
5321 | e.preventDefault();
|
5322 | if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
|
5323 | swiper.slideNext();
|
5324 | emit('navigationNext');
|
5325 | }
|
5326 | function init() {
|
5327 | const params = swiper.params.navigation;
|
5328 | swiper.params.navigation = createElementIfNotDefined(swiper, swiper.originalParams.navigation, swiper.params.navigation, {
|
5329 | nextEl: 'swiper-button-next',
|
5330 | prevEl: 'swiper-button-prev'
|
5331 | });
|
5332 | if (!(params.nextEl || params.prevEl)) return;
|
5333 | let nextEl = getEl(params.nextEl);
|
5334 | let prevEl = getEl(params.prevEl);
|
5335 | Object.assign(swiper.navigation, {
|
5336 | nextEl,
|
5337 | prevEl
|
5338 | });
|
5339 | nextEl = makeElementsArray(nextEl);
|
5340 | prevEl = makeElementsArray(prevEl);
|
5341 | const initButton = (el, dir) => {
|
5342 | if (el) {
|
5343 | el.addEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
|
5344 | }
|
5345 | if (!swiper.enabled && el) {
|
5346 | el.classList.add(...params.lockClass.split(' '));
|
5347 | }
|
5348 | };
|
5349 | nextEl.forEach(el => initButton(el, 'next'));
|
5350 | prevEl.forEach(el => initButton(el, 'prev'));
|
5351 | }
|
5352 | function destroy() {
|
5353 | let {
|
5354 | nextEl,
|
5355 | prevEl
|
5356 | } = swiper.navigation;
|
5357 | nextEl = makeElementsArray(nextEl);
|
5358 | prevEl = makeElementsArray(prevEl);
|
5359 | const destroyButton = (el, dir) => {
|
5360 | el.removeEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
|
5361 | el.classList.remove(...swiper.params.navigation.disabledClass.split(' '));
|
5362 | };
|
5363 | nextEl.forEach(el => destroyButton(el, 'next'));
|
5364 | prevEl.forEach(el => destroyButton(el, 'prev'));
|
5365 | }
|
5366 | on('init', () => {
|
5367 | if (swiper.params.navigation.enabled === false) {
|
5368 |
|
5369 | disable();
|
5370 | } else {
|
5371 | init();
|
5372 | update();
|
5373 | }
|
5374 | });
|
5375 | on('toEdge fromEdge lock unlock', () => {
|
5376 | update();
|
5377 | });
|
5378 | on('destroy', () => {
|
5379 | destroy();
|
5380 | });
|
5381 | on('enable disable', () => {
|
5382 | let {
|
5383 | nextEl,
|
5384 | prevEl
|
5385 | } = swiper.navigation;
|
5386 | nextEl = makeElementsArray(nextEl);
|
5387 | prevEl = makeElementsArray(prevEl);
|
5388 | if (swiper.enabled) {
|
5389 | update();
|
5390 | return;
|
5391 | }
|
5392 | [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.add(swiper.params.navigation.lockClass));
|
5393 | });
|
5394 | on('click', (_s, e) => {
|
5395 | let {
|
5396 | nextEl,
|
5397 | prevEl
|
5398 | } = swiper.navigation;
|
5399 | nextEl = makeElementsArray(nextEl);
|
5400 | prevEl = makeElementsArray(prevEl);
|
5401 | const targetEl = e.target;
|
5402 | let targetIsButton = prevEl.includes(targetEl) || nextEl.includes(targetEl);
|
5403 | if (swiper.isElement && !targetIsButton) {
|
5404 | const path = e.path || e.composedPath && e.composedPath();
|
5405 | if (path) {
|
5406 | targetIsButton = path.find(pathEl => nextEl.includes(pathEl) || prevEl.includes(pathEl));
|
5407 | }
|
5408 | }
|
5409 | if (swiper.params.navigation.hideOnClick && !targetIsButton) {
|
5410 | if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return;
|
5411 | let isHidden;
|
5412 | if (nextEl.length) {
|
5413 | isHidden = nextEl[0].classList.contains(swiper.params.navigation.hiddenClass);
|
5414 | } else if (prevEl.length) {
|
5415 | isHidden = prevEl[0].classList.contains(swiper.params.navigation.hiddenClass);
|
5416 | }
|
5417 | if (isHidden === true) {
|
5418 | emit('navigationShow');
|
5419 | } else {
|
5420 | emit('navigationHide');
|
5421 | }
|
5422 | [...nextEl, ...prevEl].filter(el => !!el).forEach(el => el.classList.toggle(swiper.params.navigation.hiddenClass));
|
5423 | }
|
5424 | });
|
5425 | const enable = () => {
|
5426 | swiper.el.classList.remove(...swiper.params.navigation.navigationDisabledClass.split(' '));
|
5427 | init();
|
5428 | update();
|
5429 | };
|
5430 | const disable = () => {
|
5431 | swiper.el.classList.add(...swiper.params.navigation.navigationDisabledClass.split(' '));
|
5432 | destroy();
|
5433 | };
|
5434 | Object.assign(swiper.navigation, {
|
5435 | enable,
|
5436 | disable,
|
5437 | update,
|
5438 | init,
|
5439 | destroy
|
5440 | });
|
5441 | }
|
5442 |
|
5443 | function classesToSelector(classes) {
|
5444 | if (classes === void 0) {
|
5445 | classes = '';
|
5446 | }
|
5447 | return `.${classes.trim().replace(/([\.:!+\/])/g, '\\$1') // eslint-disable-line
|
5448 | .replace(/ /g, '.')}`;
|
5449 | }
|
5450 |
|
5451 | function Pagination(_ref) {
|
5452 | let {
|
5453 | swiper,
|
5454 | extendParams,
|
5455 | on,
|
5456 | emit
|
5457 | } = _ref;
|
5458 | const pfx = 'swiper-pagination';
|
5459 | extendParams({
|
5460 | pagination: {
|
5461 | el: null,
|
5462 | bulletElement: 'span',
|
5463 | clickable: false,
|
5464 | hideOnClick: false,
|
5465 | renderBullet: null,
|
5466 | renderProgressbar: null,
|
5467 | renderFraction: null,
|
5468 | renderCustom: null,
|
5469 | progressbarOpposite: false,
|
5470 | type: 'bullets',
|
5471 |
|
5472 | dynamicBullets: false,
|
5473 | dynamicMainBullets: 1,
|
5474 | formatFractionCurrent: number => number,
|
5475 | formatFractionTotal: number => number,
|
5476 | bulletClass: `${pfx}-bullet`,
|
5477 | bulletActiveClass: `${pfx}-bullet-active`,
|
5478 | modifierClass: `${pfx}-`,
|
5479 | currentClass: `${pfx}-current`,
|
5480 | totalClass: `${pfx}-total`,
|
5481 | hiddenClass: `${pfx}-hidden`,
|
5482 | progressbarFillClass: `${pfx}-progressbar-fill`,
|
5483 | progressbarOppositeClass: `${pfx}-progressbar-opposite`,
|
5484 | clickableClass: `${pfx}-clickable`,
|
5485 | lockClass: `${pfx}-lock`,
|
5486 | horizontalClass: `${pfx}-horizontal`,
|
5487 | verticalClass: `${pfx}-vertical`,
|
5488 | paginationDisabledClass: `${pfx}-disabled`
|
5489 | }
|
5490 | });
|
5491 | swiper.pagination = {
|
5492 | el: null,
|
5493 | bullets: []
|
5494 | };
|
5495 | let bulletSize;
|
5496 | let dynamicBulletIndex = 0;
|
5497 | function isPaginationDisabled() {
|
5498 | return !swiper.params.pagination.el || !swiper.pagination.el || Array.isArray(swiper.pagination.el) && swiper.pagination.el.length === 0;
|
5499 | }
|
5500 | function setSideBullets(bulletEl, position) {
|
5501 | const {
|
5502 | bulletActiveClass
|
5503 | } = swiper.params.pagination;
|
5504 | if (!bulletEl) return;
|
5505 | bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
|
5506 | if (bulletEl) {
|
5507 | bulletEl.classList.add(`${bulletActiveClass}-${position}`);
|
5508 | bulletEl = bulletEl[`${position === 'prev' ? 'previous' : 'next'}ElementSibling`];
|
5509 | if (bulletEl) {
|
5510 | bulletEl.classList.add(`${bulletActiveClass}-${position}-${position}`);
|
5511 | }
|
5512 | }
|
5513 | }
|
5514 | function getMoveDirection(prevIndex, nextIndex, length) {
|
5515 | prevIndex = prevIndex % length;
|
5516 | nextIndex = nextIndex % length;
|
5517 | if (nextIndex === prevIndex + 1) {
|
5518 | return 'next';
|
5519 | } else if (nextIndex === prevIndex - 1) {
|
5520 | return 'previous';
|
5521 | }
|
5522 | return;
|
5523 | }
|
5524 | function onBulletClick(e) {
|
5525 | const bulletEl = e.target.closest(classesToSelector(swiper.params.pagination.bulletClass));
|
5526 | if (!bulletEl) {
|
5527 | return;
|
5528 | }
|
5529 | e.preventDefault();
|
5530 | const index = elementIndex(bulletEl) * swiper.params.slidesPerGroup;
|
5531 | if (swiper.params.loop) {
|
5532 | if (swiper.realIndex === index) return;
|
5533 | const moveDirection = getMoveDirection(swiper.realIndex, index, swiper.slides.length);
|
5534 | if (moveDirection === 'next') {
|
5535 | swiper.slideNext();
|
5536 | } else if (moveDirection === 'previous') {
|
5537 | swiper.slidePrev();
|
5538 | } else {
|
5539 | swiper.slideToLoop(index);
|
5540 | }
|
5541 | } else {
|
5542 | swiper.slideTo(index);
|
5543 | }
|
5544 | }
|
5545 | function update() {
|
5546 |
|
5547 | const rtl = swiper.rtl;
|
5548 | const params = swiper.params.pagination;
|
5549 | if (isPaginationDisabled()) return;
|
5550 | let el = swiper.pagination.el;
|
5551 | el = makeElementsArray(el);
|
5552 |
|
5553 | let current;
|
5554 | let previousIndex;
|
5555 | const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
|
5556 | const total = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
|
5557 | if (swiper.params.loop) {
|
5558 | previousIndex = swiper.previousRealIndex || 0;
|
5559 | current = swiper.params.slidesPerGroup > 1 ? Math.floor(swiper.realIndex / swiper.params.slidesPerGroup) : swiper.realIndex;
|
5560 | } else if (typeof swiper.snapIndex !== 'undefined') {
|
5561 | current = swiper.snapIndex;
|
5562 | previousIndex = swiper.previousSnapIndex;
|
5563 | } else {
|
5564 | previousIndex = swiper.previousIndex || 0;
|
5565 | current = swiper.activeIndex || 0;
|
5566 | }
|
5567 |
|
5568 | if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
|
5569 | const bullets = swiper.pagination.bullets;
|
5570 | let firstIndex;
|
5571 | let lastIndex;
|
5572 | let midIndex;
|
5573 | if (params.dynamicBullets) {
|
5574 | bulletSize = elementOuterSize(bullets[0], swiper.isHorizontal() ? 'width' : 'height', true);
|
5575 | el.forEach(subEl => {
|
5576 | subEl.style[swiper.isHorizontal() ? 'width' : 'height'] = `${bulletSize * (params.dynamicMainBullets + 4)}px`;
|
5577 | });
|
5578 | if (params.dynamicMainBullets > 1 && previousIndex !== undefined) {
|
5579 | dynamicBulletIndex += current - (previousIndex || 0);
|
5580 | if (dynamicBulletIndex > params.dynamicMainBullets - 1) {
|
5581 | dynamicBulletIndex = params.dynamicMainBullets - 1;
|
5582 | } else if (dynamicBulletIndex < 0) {
|
5583 | dynamicBulletIndex = 0;
|
5584 | }
|
5585 | }
|
5586 | firstIndex = Math.max(current - dynamicBulletIndex, 0);
|
5587 | lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
|
5588 | midIndex = (lastIndex + firstIndex) / 2;
|
5589 | }
|
5590 | bullets.forEach(bulletEl => {
|
5591 | const classesToRemove = [...['', '-next', '-next-next', '-prev', '-prev-prev', '-main'].map(suffix => `${params.bulletActiveClass}${suffix}`)].map(s => typeof s === 'string' && s.includes(' ') ? s.split(' ') : s).flat();
|
5592 | bulletEl.classList.remove(...classesToRemove);
|
5593 | });
|
5594 | if (el.length > 1) {
|
5595 | bullets.forEach(bullet => {
|
5596 | const bulletIndex = elementIndex(bullet);
|
5597 | if (bulletIndex === current) {
|
5598 | bullet.classList.add(...params.bulletActiveClass.split(' '));
|
5599 | } else if (swiper.isElement) {
|
5600 | bullet.setAttribute('part', 'bullet');
|
5601 | }
|
5602 | if (params.dynamicBullets) {
|
5603 | if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
|
5604 | bullet.classList.add(...`${params.bulletActiveClass}-main`.split(' '));
|
5605 | }
|
5606 | if (bulletIndex === firstIndex) {
|
5607 | setSideBullets(bullet, 'prev');
|
5608 | }
|
5609 | if (bulletIndex === lastIndex) {
|
5610 | setSideBullets(bullet, 'next');
|
5611 | }
|
5612 | }
|
5613 | });
|
5614 | } else {
|
5615 | const bullet = bullets[current];
|
5616 | if (bullet) {
|
5617 | bullet.classList.add(...params.bulletActiveClass.split(' '));
|
5618 | }
|
5619 | if (swiper.isElement) {
|
5620 | bullets.forEach((bulletEl, bulletIndex) => {
|
5621 | bulletEl.setAttribute('part', bulletIndex === current ? 'bullet-active' : 'bullet');
|
5622 | });
|
5623 | }
|
5624 | if (params.dynamicBullets) {
|
5625 | const firstDisplayedBullet = bullets[firstIndex];
|
5626 | const lastDisplayedBullet = bullets[lastIndex];
|
5627 | for (let i = firstIndex; i <= lastIndex; i += 1) {
|
5628 | if (bullets[i]) {
|
5629 | bullets[i].classList.add(...`${params.bulletActiveClass}-main`.split(' '));
|
5630 | }
|
5631 | }
|
5632 | setSideBullets(firstDisplayedBullet, 'prev');
|
5633 | setSideBullets(lastDisplayedBullet, 'next');
|
5634 | }
|
5635 | }
|
5636 | if (params.dynamicBullets) {
|
5637 | const dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
|
5638 | const bulletsOffset = (bulletSize * dynamicBulletsLength - bulletSize) / 2 - midIndex * bulletSize;
|
5639 | const offsetProp = rtl ? 'right' : 'left';
|
5640 | bullets.forEach(bullet => {
|
5641 | bullet.style[swiper.isHorizontal() ? offsetProp : 'top'] = `${bulletsOffset}px`;
|
5642 | });
|
5643 | }
|
5644 | }
|
5645 | el.forEach((subEl, subElIndex) => {
|
5646 | if (params.type === 'fraction') {
|
5647 | subEl.querySelectorAll(classesToSelector(params.currentClass)).forEach(fractionEl => {
|
5648 | fractionEl.textContent = params.formatFractionCurrent(current + 1);
|
5649 | });
|
5650 | subEl.querySelectorAll(classesToSelector(params.totalClass)).forEach(totalEl => {
|
5651 | totalEl.textContent = params.formatFractionTotal(total);
|
5652 | });
|
5653 | }
|
5654 | if (params.type === 'progressbar') {
|
5655 | let progressbarDirection;
|
5656 | if (params.progressbarOpposite) {
|
5657 | progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
|
5658 | } else {
|
5659 | progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
|
5660 | }
|
5661 | const scale = (current + 1) / total;
|
5662 | let scaleX = 1;
|
5663 | let scaleY = 1;
|
5664 | if (progressbarDirection === 'horizontal') {
|
5665 | scaleX = scale;
|
5666 | } else {
|
5667 | scaleY = scale;
|
5668 | }
|
5669 | subEl.querySelectorAll(classesToSelector(params.progressbarFillClass)).forEach(progressEl => {
|
5670 | progressEl.style.transform = `translate3d(0,0,0) scaleX(${scaleX}) scaleY(${scaleY})`;
|
5671 | progressEl.style.transitionDuration = `${swiper.params.speed}ms`;
|
5672 | });
|
5673 | }
|
5674 | if (params.type === 'custom' && params.renderCustom) {
|
5675 | subEl.innerHTML = params.renderCustom(swiper, current + 1, total);
|
5676 | if (subElIndex === 0) emit('paginationRender', subEl);
|
5677 | } else {
|
5678 | if (subElIndex === 0) emit('paginationRender', subEl);
|
5679 | emit('paginationUpdate', subEl);
|
5680 | }
|
5681 | if (swiper.params.watchOverflow && swiper.enabled) {
|
5682 | subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
|
5683 | }
|
5684 | });
|
5685 | }
|
5686 | function render() {
|
5687 |
|
5688 | const params = swiper.params.pagination;
|
5689 | if (isPaginationDisabled()) return;
|
5690 | const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.grid && swiper.params.grid.rows > 1 ? swiper.slides.length / Math.ceil(swiper.params.grid.rows) : swiper.slides.length;
|
5691 | let el = swiper.pagination.el;
|
5692 | el = makeElementsArray(el);
|
5693 | let paginationHTML = '';
|
5694 | if (params.type === 'bullets') {
|
5695 | let numberOfBullets = swiper.params.loop ? Math.ceil(slidesLength / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
|
5696 | if (swiper.params.freeMode && swiper.params.freeMode.enabled && numberOfBullets > slidesLength) {
|
5697 | numberOfBullets = slidesLength;
|
5698 | }
|
5699 | for (let i = 0; i < numberOfBullets; i += 1) {
|
5700 | if (params.renderBullet) {
|
5701 | paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
|
5702 | } else {
|
5703 |
|
5704 | paginationHTML += `<${params.bulletElement} ${swiper.isElement ? 'part="bullet"' : ''} class="${params.bulletClass}"></${params.bulletElement}>`;
|
5705 | }
|
5706 | }
|
5707 | }
|
5708 | if (params.type === 'fraction') {
|
5709 | if (params.renderFraction) {
|
5710 | paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
|
5711 | } else {
|
5712 | paginationHTML = `<span class="${params.currentClass}"></span>` + ' / ' + `<span class="${params.totalClass}"></span>`;
|
5713 | }
|
5714 | }
|
5715 | if (params.type === 'progressbar') {
|
5716 | if (params.renderProgressbar) {
|
5717 | paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
|
5718 | } else {
|
5719 | paginationHTML = `<span class="${params.progressbarFillClass}"></span>`;
|
5720 | }
|
5721 | }
|
5722 | swiper.pagination.bullets = [];
|
5723 | el.forEach(subEl => {
|
5724 | if (params.type !== 'custom') {
|
5725 | subEl.innerHTML = paginationHTML || '';
|
5726 | }
|
5727 | if (params.type === 'bullets') {
|
5728 | swiper.pagination.bullets.push(...subEl.querySelectorAll(classesToSelector(params.bulletClass)));
|
5729 | }
|
5730 | });
|
5731 | if (params.type !== 'custom') {
|
5732 | emit('paginationRender', el[0]);
|
5733 | }
|
5734 | }
|
5735 | function init() {
|
5736 | swiper.params.pagination = createElementIfNotDefined(swiper, swiper.originalParams.pagination, swiper.params.pagination, {
|
5737 | el: 'swiper-pagination'
|
5738 | });
|
5739 | const params = swiper.params.pagination;
|
5740 | if (!params.el) return;
|
5741 | let el;
|
5742 | if (typeof params.el === 'string' && swiper.isElement) {
|
5743 | el = swiper.el.querySelector(params.el);
|
5744 | }
|
5745 | if (!el && typeof params.el === 'string') {
|
5746 | el = [...document.querySelectorAll(params.el)];
|
5747 | }
|
5748 | if (!el) {
|
5749 | el = params.el;
|
5750 | }
|
5751 | if (!el || el.length === 0) return;
|
5752 | if (swiper.params.uniqueNavElements && typeof params.el === 'string' && Array.isArray(el) && el.length > 1) {
|
5753 | el = [...swiper.el.querySelectorAll(params.el)];
|
5754 |
|
5755 | if (el.length > 1) {
|
5756 | el = el.filter(subEl => {
|
5757 | if (elementParents(subEl, '.swiper')[0] !== swiper.el) return false;
|
5758 | return true;
|
5759 | })[0];
|
5760 | }
|
5761 | }
|
5762 | if (Array.isArray(el) && el.length === 1) el = el[0];
|
5763 | Object.assign(swiper.pagination, {
|
5764 | el
|
5765 | });
|
5766 | el = makeElementsArray(el);
|
5767 | el.forEach(subEl => {
|
5768 | if (params.type === 'bullets' && params.clickable) {
|
5769 | subEl.classList.add(...(params.clickableClass || '').split(' '));
|
5770 | }
|
5771 | subEl.classList.add(params.modifierClass + params.type);
|
5772 | subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
|
5773 | if (params.type === 'bullets' && params.dynamicBullets) {
|
5774 | subEl.classList.add(`${params.modifierClass}${params.type}-dynamic`);
|
5775 | dynamicBulletIndex = 0;
|
5776 | if (params.dynamicMainBullets < 1) {
|
5777 | params.dynamicMainBullets = 1;
|
5778 | }
|
5779 | }
|
5780 | if (params.type === 'progressbar' && params.progressbarOpposite) {
|
5781 | subEl.classList.add(params.progressbarOppositeClass);
|
5782 | }
|
5783 | if (params.clickable) {
|
5784 | subEl.addEventListener('click', onBulletClick);
|
5785 | }
|
5786 | if (!swiper.enabled) {
|
5787 | subEl.classList.add(params.lockClass);
|
5788 | }
|
5789 | });
|
5790 | }
|
5791 | function destroy() {
|
5792 | const params = swiper.params.pagination;
|
5793 | if (isPaginationDisabled()) return;
|
5794 | let el = swiper.pagination.el;
|
5795 | if (el) {
|
5796 | el = makeElementsArray(el);
|
5797 | el.forEach(subEl => {
|
5798 | subEl.classList.remove(params.hiddenClass);
|
5799 | subEl.classList.remove(params.modifierClass + params.type);
|
5800 | subEl.classList.remove(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
|
5801 | if (params.clickable) {
|
5802 | subEl.classList.remove(...(params.clickableClass || '').split(' '));
|
5803 | subEl.removeEventListener('click', onBulletClick);
|
5804 | }
|
5805 | });
|
5806 | }
|
5807 | if (swiper.pagination.bullets) swiper.pagination.bullets.forEach(subEl => subEl.classList.remove(...params.bulletActiveClass.split(' ')));
|
5808 | }
|
5809 | on('changeDirection', () => {
|
5810 | if (!swiper.pagination || !swiper.pagination.el) return;
|
5811 | const params = swiper.params.pagination;
|
5812 | let {
|
5813 | el
|
5814 | } = swiper.pagination;
|
5815 | el = makeElementsArray(el);
|
5816 | el.forEach(subEl => {
|
5817 | subEl.classList.remove(params.horizontalClass, params.verticalClass);
|
5818 | subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
|
5819 | });
|
5820 | });
|
5821 | on('init', () => {
|
5822 | if (swiper.params.pagination.enabled === false) {
|
5823 |
|
5824 | disable();
|
5825 | } else {
|
5826 | init();
|
5827 | render();
|
5828 | update();
|
5829 | }
|
5830 | });
|
5831 | on('activeIndexChange', () => {
|
5832 | if (typeof swiper.snapIndex === 'undefined') {
|
5833 | update();
|
5834 | }
|
5835 | });
|
5836 | on('snapIndexChange', () => {
|
5837 | update();
|
5838 | });
|
5839 | on('snapGridLengthChange', () => {
|
5840 | render();
|
5841 | update();
|
5842 | });
|
5843 | on('destroy', () => {
|
5844 | destroy();
|
5845 | });
|
5846 | on('enable disable', () => {
|
5847 | let {
|
5848 | el
|
5849 | } = swiper.pagination;
|
5850 | if (el) {
|
5851 | el = makeElementsArray(el);
|
5852 | el.forEach(subEl => subEl.classList[swiper.enabled ? 'remove' : 'add'](swiper.params.pagination.lockClass));
|
5853 | }
|
5854 | });
|
5855 | on('lock unlock', () => {
|
5856 | update();
|
5857 | });
|
5858 | on('click', (_s, e) => {
|
5859 | const targetEl = e.target;
|
5860 | const el = makeElementsArray(swiper.pagination.el);
|
5861 | if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && el && el.length > 0 && !targetEl.classList.contains(swiper.params.pagination.bulletClass)) {
|
5862 | if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return;
|
5863 | const isHidden = el[0].classList.contains(swiper.params.pagination.hiddenClass);
|
5864 | if (isHidden === true) {
|
5865 | emit('paginationShow');
|
5866 | } else {
|
5867 | emit('paginationHide');
|
5868 | }
|
5869 | el.forEach(subEl => subEl.classList.toggle(swiper.params.pagination.hiddenClass));
|
5870 | }
|
5871 | });
|
5872 | const enable = () => {
|
5873 | swiper.el.classList.remove(swiper.params.pagination.paginationDisabledClass);
|
5874 | let {
|
5875 | el
|
5876 | } = swiper.pagination;
|
5877 | if (el) {
|
5878 | el = makeElementsArray(el);
|
5879 | el.forEach(subEl => subEl.classList.remove(swiper.params.pagination.paginationDisabledClass));
|
5880 | }
|
5881 | init();
|
5882 | render();
|
5883 | update();
|
5884 | };
|
5885 | const disable = () => {
|
5886 | swiper.el.classList.add(swiper.params.pagination.paginationDisabledClass);
|
5887 | let {
|
5888 | el
|
5889 | } = swiper.pagination;
|
5890 | if (el) {
|
5891 | el = makeElementsArray(el);
|
5892 | el.forEach(subEl => subEl.classList.add(swiper.params.pagination.paginationDisabledClass));
|
5893 | }
|
5894 | destroy();
|
5895 | };
|
5896 | Object.assign(swiper.pagination, {
|
5897 | enable,
|
5898 | disable,
|
5899 | render,
|
5900 | update,
|
5901 | init,
|
5902 | destroy
|
5903 | });
|
5904 | }
|
5905 |
|
5906 | function Scrollbar(_ref) {
|
5907 | let {
|
5908 | swiper,
|
5909 | extendParams,
|
5910 | on,
|
5911 | emit
|
5912 | } = _ref;
|
5913 | const document = getDocument();
|
5914 | let isTouched = false;
|
5915 | let timeout = null;
|
5916 | let dragTimeout = null;
|
5917 | let dragStartPos;
|
5918 | let dragSize;
|
5919 | let trackSize;
|
5920 | let divider;
|
5921 | extendParams({
|
5922 | scrollbar: {
|
5923 | el: null,
|
5924 | dragSize: 'auto',
|
5925 | hide: false,
|
5926 | draggable: false,
|
5927 | snapOnRelease: true,
|
5928 | lockClass: 'swiper-scrollbar-lock',
|
5929 | dragClass: 'swiper-scrollbar-drag',
|
5930 | scrollbarDisabledClass: 'swiper-scrollbar-disabled',
|
5931 | horizontalClass: `swiper-scrollbar-horizontal`,
|
5932 | verticalClass: `swiper-scrollbar-vertical`
|
5933 | }
|
5934 | });
|
5935 | swiper.scrollbar = {
|
5936 | el: null,
|
5937 | dragEl: null
|
5938 | };
|
5939 | function setTranslate() {
|
5940 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
5941 | const {
|
5942 | scrollbar,
|
5943 | rtlTranslate: rtl
|
5944 | } = swiper;
|
5945 | const {
|
5946 | dragEl,
|
5947 | el
|
5948 | } = scrollbar;
|
5949 | const params = swiper.params.scrollbar;
|
5950 | const progress = swiper.params.loop ? swiper.progressLoop : swiper.progress;
|
5951 | let newSize = dragSize;
|
5952 | let newPos = (trackSize - dragSize) * progress;
|
5953 | if (rtl) {
|
5954 | newPos = -newPos;
|
5955 | if (newPos > 0) {
|
5956 | newSize = dragSize - newPos;
|
5957 | newPos = 0;
|
5958 | } else if (-newPos + dragSize > trackSize) {
|
5959 | newSize = trackSize + newPos;
|
5960 | }
|
5961 | } else if (newPos < 0) {
|
5962 | newSize = dragSize + newPos;
|
5963 | newPos = 0;
|
5964 | } else if (newPos + dragSize > trackSize) {
|
5965 | newSize = trackSize - newPos;
|
5966 | }
|
5967 | if (swiper.isHorizontal()) {
|
5968 | dragEl.style.transform = `translate3d(${newPos}px, 0, 0)`;
|
5969 | dragEl.style.width = `${newSize}px`;
|
5970 | } else {
|
5971 | dragEl.style.transform = `translate3d(0px, ${newPos}px, 0)`;
|
5972 | dragEl.style.height = `${newSize}px`;
|
5973 | }
|
5974 | if (params.hide) {
|
5975 | clearTimeout(timeout);
|
5976 | el.style.opacity = 1;
|
5977 | timeout = setTimeout(() => {
|
5978 | el.style.opacity = 0;
|
5979 | el.style.transitionDuration = '400ms';
|
5980 | }, 1000);
|
5981 | }
|
5982 | }
|
5983 | function setTransition(duration) {
|
5984 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
5985 | swiper.scrollbar.dragEl.style.transitionDuration = `${duration}ms`;
|
5986 | }
|
5987 | function updateSize() {
|
5988 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
5989 | const {
|
5990 | scrollbar
|
5991 | } = swiper;
|
5992 | const {
|
5993 | dragEl,
|
5994 | el
|
5995 | } = scrollbar;
|
5996 | dragEl.style.width = '';
|
5997 | dragEl.style.height = '';
|
5998 | trackSize = swiper.isHorizontal() ? el.offsetWidth : el.offsetHeight;
|
5999 | divider = swiper.size / (swiper.virtualSize + swiper.params.slidesOffsetBefore - (swiper.params.centeredSlides ? swiper.snapGrid[0] : 0));
|
6000 | if (swiper.params.scrollbar.dragSize === 'auto') {
|
6001 | dragSize = trackSize * divider;
|
6002 | } else {
|
6003 | dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
|
6004 | }
|
6005 | if (swiper.isHorizontal()) {
|
6006 | dragEl.style.width = `${dragSize}px`;
|
6007 | } else {
|
6008 | dragEl.style.height = `${dragSize}px`;
|
6009 | }
|
6010 | if (divider >= 1) {
|
6011 | el.style.display = 'none';
|
6012 | } else {
|
6013 | el.style.display = '';
|
6014 | }
|
6015 | if (swiper.params.scrollbar.hide) {
|
6016 | el.style.opacity = 0;
|
6017 | }
|
6018 | if (swiper.params.watchOverflow && swiper.enabled) {
|
6019 | scrollbar.el.classList[swiper.isLocked ? 'add' : 'remove'](swiper.params.scrollbar.lockClass);
|
6020 | }
|
6021 | }
|
6022 | function getPointerPosition(e) {
|
6023 | return swiper.isHorizontal() ? e.clientX : e.clientY;
|
6024 | }
|
6025 | function setDragPosition(e) {
|
6026 | const {
|
6027 | scrollbar,
|
6028 | rtlTranslate: rtl
|
6029 | } = swiper;
|
6030 | const {
|
6031 | el
|
6032 | } = scrollbar;
|
6033 | let positionRatio;
|
6034 | positionRatio = (getPointerPosition(e) - elementOffset(el)[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
|
6035 | positionRatio = Math.max(Math.min(positionRatio, 1), 0);
|
6036 | if (rtl) {
|
6037 | positionRatio = 1 - positionRatio;
|
6038 | }
|
6039 | const position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;
|
6040 | swiper.updateProgress(position);
|
6041 | swiper.setTranslate(position);
|
6042 | swiper.updateActiveIndex();
|
6043 | swiper.updateSlidesClasses();
|
6044 | }
|
6045 | function onDragStart(e) {
|
6046 | const params = swiper.params.scrollbar;
|
6047 | const {
|
6048 | scrollbar,
|
6049 | wrapperEl
|
6050 | } = swiper;
|
6051 | const {
|
6052 | el,
|
6053 | dragEl
|
6054 | } = scrollbar;
|
6055 | isTouched = true;
|
6056 | dragStartPos = e.target === dragEl ? getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
|
6057 | e.preventDefault();
|
6058 | e.stopPropagation();
|
6059 | wrapperEl.style.transitionDuration = '100ms';
|
6060 | dragEl.style.transitionDuration = '100ms';
|
6061 | setDragPosition(e);
|
6062 | clearTimeout(dragTimeout);
|
6063 | el.style.transitionDuration = '0ms';
|
6064 | if (params.hide) {
|
6065 | el.style.opacity = 1;
|
6066 | }
|
6067 | if (swiper.params.cssMode) {
|
6068 | swiper.wrapperEl.style['scroll-snap-type'] = 'none';
|
6069 | }
|
6070 | emit('scrollbarDragStart', e);
|
6071 | }
|
6072 | function onDragMove(e) {
|
6073 | const {
|
6074 | scrollbar,
|
6075 | wrapperEl
|
6076 | } = swiper;
|
6077 | const {
|
6078 | el,
|
6079 | dragEl
|
6080 | } = scrollbar;
|
6081 | if (!isTouched) return;
|
6082 | if (e.preventDefault && e.cancelable) e.preventDefault();else e.returnValue = false;
|
6083 | setDragPosition(e);
|
6084 | wrapperEl.style.transitionDuration = '0ms';
|
6085 | el.style.transitionDuration = '0ms';
|
6086 | dragEl.style.transitionDuration = '0ms';
|
6087 | emit('scrollbarDragMove', e);
|
6088 | }
|
6089 | function onDragEnd(e) {
|
6090 | const params = swiper.params.scrollbar;
|
6091 | const {
|
6092 | scrollbar,
|
6093 | wrapperEl
|
6094 | } = swiper;
|
6095 | const {
|
6096 | el
|
6097 | } = scrollbar;
|
6098 | if (!isTouched) return;
|
6099 | isTouched = false;
|
6100 | if (swiper.params.cssMode) {
|
6101 | swiper.wrapperEl.style['scroll-snap-type'] = '';
|
6102 | wrapperEl.style.transitionDuration = '';
|
6103 | }
|
6104 | if (params.hide) {
|
6105 | clearTimeout(dragTimeout);
|
6106 | dragTimeout = nextTick(() => {
|
6107 | el.style.opacity = 0;
|
6108 | el.style.transitionDuration = '400ms';
|
6109 | }, 1000);
|
6110 | }
|
6111 | emit('scrollbarDragEnd', e);
|
6112 | if (params.snapOnRelease) {
|
6113 | swiper.slideToClosest();
|
6114 | }
|
6115 | }
|
6116 | function events(method) {
|
6117 | const {
|
6118 | scrollbar,
|
6119 | params
|
6120 | } = swiper;
|
6121 | const el = scrollbar.el;
|
6122 | if (!el) return;
|
6123 | const target = el;
|
6124 | const activeListener = params.passiveListeners ? {
|
6125 | passive: false,
|
6126 | capture: false
|
6127 | } : false;
|
6128 | const passiveListener = params.passiveListeners ? {
|
6129 | passive: true,
|
6130 | capture: false
|
6131 | } : false;
|
6132 | if (!target) return;
|
6133 | const eventMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
|
6134 | target[eventMethod]('pointerdown', onDragStart, activeListener);
|
6135 | document[eventMethod]('pointermove', onDragMove, activeListener);
|
6136 | document[eventMethod]('pointerup', onDragEnd, passiveListener);
|
6137 | }
|
6138 | function enableDraggable() {
|
6139 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
6140 | events('on');
|
6141 | }
|
6142 | function disableDraggable() {
|
6143 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
6144 | events('off');
|
6145 | }
|
6146 | function init() {
|
6147 | const {
|
6148 | scrollbar,
|
6149 | el: swiperEl
|
6150 | } = swiper;
|
6151 | swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, {
|
6152 | el: 'swiper-scrollbar'
|
6153 | });
|
6154 | const params = swiper.params.scrollbar;
|
6155 | if (!params.el) return;
|
6156 | let el;
|
6157 | if (typeof params.el === 'string' && swiper.isElement) {
|
6158 | el = swiper.el.querySelector(params.el);
|
6159 | }
|
6160 | if (!el && typeof params.el === 'string') {
|
6161 | el = document.querySelectorAll(params.el);
|
6162 | if (!el.length) return;
|
6163 | } else if (!el) {
|
6164 | el = params.el;
|
6165 | }
|
6166 | if (swiper.params.uniqueNavElements && typeof params.el === 'string' && el.length > 1 && swiperEl.querySelectorAll(params.el).length === 1) {
|
6167 | el = swiperEl.querySelector(params.el);
|
6168 | }
|
6169 | if (el.length > 0) el = el[0];
|
6170 | el.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
|
6171 | let dragEl;
|
6172 | if (el) {
|
6173 | dragEl = el.querySelector(classesToSelector(swiper.params.scrollbar.dragClass));
|
6174 | if (!dragEl) {
|
6175 | dragEl = createElement('div', swiper.params.scrollbar.dragClass);
|
6176 | el.append(dragEl);
|
6177 | }
|
6178 | }
|
6179 | Object.assign(scrollbar, {
|
6180 | el,
|
6181 | dragEl
|
6182 | });
|
6183 | if (params.draggable) {
|
6184 | enableDraggable();
|
6185 | }
|
6186 | if (el) {
|
6187 | el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
|
6188 | }
|
6189 | }
|
6190 | function destroy() {
|
6191 | const params = swiper.params.scrollbar;
|
6192 | const el = swiper.scrollbar.el;
|
6193 | if (el) {
|
6194 | el.classList.remove(...classesToTokens(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass));
|
6195 | }
|
6196 | disableDraggable();
|
6197 | }
|
6198 | on('changeDirection', () => {
|
6199 | if (!swiper.scrollbar || !swiper.scrollbar.el) return;
|
6200 | const params = swiper.params.scrollbar;
|
6201 | let {
|
6202 | el
|
6203 | } = swiper.scrollbar;
|
6204 | el = makeElementsArray(el);
|
6205 | el.forEach(subEl => {
|
6206 | subEl.classList.remove(params.horizontalClass, params.verticalClass);
|
6207 | subEl.classList.add(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
|
6208 | });
|
6209 | });
|
6210 | on('init', () => {
|
6211 | if (swiper.params.scrollbar.enabled === false) {
|
6212 |
|
6213 | disable();
|
6214 | } else {
|
6215 | init();
|
6216 | updateSize();
|
6217 | setTranslate();
|
6218 | }
|
6219 | });
|
6220 | on('update resize observerUpdate lock unlock changeDirection', () => {
|
6221 | updateSize();
|
6222 | });
|
6223 | on('setTranslate', () => {
|
6224 | setTranslate();
|
6225 | });
|
6226 | on('setTransition', (_s, duration) => {
|
6227 | setTransition(duration);
|
6228 | });
|
6229 | on('enable disable', () => {
|
6230 | const {
|
6231 | el
|
6232 | } = swiper.scrollbar;
|
6233 | if (el) {
|
6234 | el.classList[swiper.enabled ? 'remove' : 'add'](...classesToTokens(swiper.params.scrollbar.lockClass));
|
6235 | }
|
6236 | });
|
6237 | on('destroy', () => {
|
6238 | destroy();
|
6239 | });
|
6240 | const enable = () => {
|
6241 | swiper.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
|
6242 | if (swiper.scrollbar.el) {
|
6243 | swiper.scrollbar.el.classList.remove(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
|
6244 | }
|
6245 | init();
|
6246 | updateSize();
|
6247 | setTranslate();
|
6248 | };
|
6249 | const disable = () => {
|
6250 | swiper.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
|
6251 | if (swiper.scrollbar.el) {
|
6252 | swiper.scrollbar.el.classList.add(...classesToTokens(swiper.params.scrollbar.scrollbarDisabledClass));
|
6253 | }
|
6254 | destroy();
|
6255 | };
|
6256 | Object.assign(swiper.scrollbar, {
|
6257 | enable,
|
6258 | disable,
|
6259 | updateSize,
|
6260 | setTranslate,
|
6261 | init,
|
6262 | destroy
|
6263 | });
|
6264 | }
|
6265 |
|
6266 | function Parallax(_ref) {
|
6267 | let {
|
6268 | swiper,
|
6269 | extendParams,
|
6270 | on
|
6271 | } = _ref;
|
6272 | extendParams({
|
6273 | parallax: {
|
6274 | enabled: false
|
6275 | }
|
6276 | });
|
6277 | const elementsSelector = '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]';
|
6278 | const setTransform = (el, progress) => {
|
6279 | const {
|
6280 | rtl
|
6281 | } = swiper;
|
6282 | const rtlFactor = rtl ? -1 : 1;
|
6283 | const p = el.getAttribute('data-swiper-parallax') || '0';
|
6284 | let x = el.getAttribute('data-swiper-parallax-x');
|
6285 | let y = el.getAttribute('data-swiper-parallax-y');
|
6286 | const scale = el.getAttribute('data-swiper-parallax-scale');
|
6287 | const opacity = el.getAttribute('data-swiper-parallax-opacity');
|
6288 | const rotate = el.getAttribute('data-swiper-parallax-rotate');
|
6289 | if (x || y) {
|
6290 | x = x || '0';
|
6291 | y = y || '0';
|
6292 | } else if (swiper.isHorizontal()) {
|
6293 | x = p;
|
6294 | y = '0';
|
6295 | } else {
|
6296 | y = p;
|
6297 | x = '0';
|
6298 | }
|
6299 | if (x.indexOf('%') >= 0) {
|
6300 | x = `${parseInt(x, 10) * progress * rtlFactor}%`;
|
6301 | } else {
|
6302 | x = `${x * progress * rtlFactor}px`;
|
6303 | }
|
6304 | if (y.indexOf('%') >= 0) {
|
6305 | y = `${parseInt(y, 10) * progress}%`;
|
6306 | } else {
|
6307 | y = `${y * progress}px`;
|
6308 | }
|
6309 | if (typeof opacity !== 'undefined' && opacity !== null) {
|
6310 | const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
|
6311 | el.style.opacity = currentOpacity;
|
6312 | }
|
6313 | let transform = `translate3d(${x}, ${y}, 0px)`;
|
6314 | if (typeof scale !== 'undefined' && scale !== null) {
|
6315 | const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
|
6316 | transform += ` scale(${currentScale})`;
|
6317 | }
|
6318 | if (rotate && typeof rotate !== 'undefined' && rotate !== null) {
|
6319 | const currentRotate = rotate * progress * -1;
|
6320 | transform += ` rotate(${currentRotate}deg)`;
|
6321 | }
|
6322 | el.style.transform = transform;
|
6323 | };
|
6324 | const setTranslate = () => {
|
6325 | const {
|
6326 | el,
|
6327 | slides,
|
6328 | progress,
|
6329 | snapGrid,
|
6330 | isElement
|
6331 | } = swiper;
|
6332 | const elements = elementChildren(el, elementsSelector);
|
6333 | if (swiper.isElement) {
|
6334 | elements.push(...elementChildren(swiper.hostEl, elementsSelector));
|
6335 | }
|
6336 | elements.forEach(subEl => {
|
6337 | setTransform(subEl, progress);
|
6338 | });
|
6339 | slides.forEach((slideEl, slideIndex) => {
|
6340 | let slideProgress = slideEl.progress;
|
6341 | if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
|
6342 | slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
|
6343 | }
|
6344 | slideProgress = Math.min(Math.max(slideProgress, -1), 1);
|
6345 | slideEl.querySelectorAll(`${elementsSelector}, [data-swiper-parallax-rotate]`).forEach(subEl => {
|
6346 | setTransform(subEl, slideProgress);
|
6347 | });
|
6348 | });
|
6349 | };
|
6350 | const setTransition = function (duration) {
|
6351 | if (duration === void 0) {
|
6352 | duration = swiper.params.speed;
|
6353 | }
|
6354 | const {
|
6355 | el,
|
6356 | hostEl
|
6357 | } = swiper;
|
6358 | const elements = [...el.querySelectorAll(elementsSelector)];
|
6359 | if (swiper.isElement) {
|
6360 | elements.push(...hostEl.querySelectorAll(elementsSelector));
|
6361 | }
|
6362 | elements.forEach(parallaxEl => {
|
6363 | let parallaxDuration = parseInt(parallaxEl.getAttribute('data-swiper-parallax-duration'), 10) || duration;
|
6364 | if (duration === 0) parallaxDuration = 0;
|
6365 | parallaxEl.style.transitionDuration = `${parallaxDuration}ms`;
|
6366 | });
|
6367 | };
|
6368 | on('beforeInit', () => {
|
6369 | if (!swiper.params.parallax.enabled) return;
|
6370 | swiper.params.watchSlidesProgress = true;
|
6371 | swiper.originalParams.watchSlidesProgress = true;
|
6372 | });
|
6373 | on('init', () => {
|
6374 | if (!swiper.params.parallax.enabled) return;
|
6375 | setTranslate();
|
6376 | });
|
6377 | on('setTranslate', () => {
|
6378 | if (!swiper.params.parallax.enabled) return;
|
6379 | setTranslate();
|
6380 | });
|
6381 | on('setTransition', (_swiper, duration) => {
|
6382 | if (!swiper.params.parallax.enabled) return;
|
6383 | setTransition(duration);
|
6384 | });
|
6385 | }
|
6386 |
|
6387 | function Zoom(_ref) {
|
6388 | let {
|
6389 | swiper,
|
6390 | extendParams,
|
6391 | on,
|
6392 | emit
|
6393 | } = _ref;
|
6394 | const window = getWindow();
|
6395 | extendParams({
|
6396 | zoom: {
|
6397 | enabled: false,
|
6398 | limitToOriginalSize: false,
|
6399 | maxRatio: 3,
|
6400 | minRatio: 1,
|
6401 | toggle: true,
|
6402 | containerClass: 'swiper-zoom-container',
|
6403 | zoomedSlideClass: 'swiper-slide-zoomed'
|
6404 | }
|
6405 | });
|
6406 | swiper.zoom = {
|
6407 | enabled: false
|
6408 | };
|
6409 | let currentScale = 1;
|
6410 | let isScaling = false;
|
6411 | let fakeGestureTouched;
|
6412 | let fakeGestureMoved;
|
6413 | const evCache = [];
|
6414 | const gesture = {
|
6415 | originX: 0,
|
6416 | originY: 0,
|
6417 | slideEl: undefined,
|
6418 | slideWidth: undefined,
|
6419 | slideHeight: undefined,
|
6420 | imageEl: undefined,
|
6421 | imageWrapEl: undefined,
|
6422 | maxRatio: 3
|
6423 | };
|
6424 | const image = {
|
6425 | isTouched: undefined,
|
6426 | isMoved: undefined,
|
6427 | currentX: undefined,
|
6428 | currentY: undefined,
|
6429 | minX: undefined,
|
6430 | minY: undefined,
|
6431 | maxX: undefined,
|
6432 | maxY: undefined,
|
6433 | width: undefined,
|
6434 | height: undefined,
|
6435 | startX: undefined,
|
6436 | startY: undefined,
|
6437 | touchesStart: {},
|
6438 | touchesCurrent: {}
|
6439 | };
|
6440 | const velocity = {
|
6441 | x: undefined,
|
6442 | y: undefined,
|
6443 | prevPositionX: undefined,
|
6444 | prevPositionY: undefined,
|
6445 | prevTime: undefined
|
6446 | };
|
6447 | let scale = 1;
|
6448 | Object.defineProperty(swiper.zoom, 'scale', {
|
6449 | get() {
|
6450 | return scale;
|
6451 | },
|
6452 | set(value) {
|
6453 | if (scale !== value) {
|
6454 | const imageEl = gesture.imageEl;
|
6455 | const slideEl = gesture.slideEl;
|
6456 | emit('zoomChange', value, imageEl, slideEl);
|
6457 | }
|
6458 | scale = value;
|
6459 | }
|
6460 | });
|
6461 | function getDistanceBetweenTouches() {
|
6462 | if (evCache.length < 2) return 1;
|
6463 | const x1 = evCache[0].pageX;
|
6464 | const y1 = evCache[0].pageY;
|
6465 | const x2 = evCache[1].pageX;
|
6466 | const y2 = evCache[1].pageY;
|
6467 | const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
|
6468 | return distance;
|
6469 | }
|
6470 | function getMaxRatio() {
|
6471 | const params = swiper.params.zoom;
|
6472 | const maxRatio = gesture.imageWrapEl.getAttribute('data-swiper-zoom') || params.maxRatio;
|
6473 | if (params.limitToOriginalSize && gesture.imageEl && gesture.imageEl.naturalWidth) {
|
6474 | const imageMaxRatio = gesture.imageEl.naturalWidth / gesture.imageEl.offsetWidth;
|
6475 | return Math.min(imageMaxRatio, maxRatio);
|
6476 | }
|
6477 | return maxRatio;
|
6478 | }
|
6479 | function getScaleOrigin() {
|
6480 | if (evCache.length < 2) return {
|
6481 | x: null,
|
6482 | y: null
|
6483 | };
|
6484 | const box = gesture.imageEl.getBoundingClientRect();
|
6485 | return [(evCache[0].pageX + (evCache[1].pageX - evCache[0].pageX) / 2 - box.x - window.scrollX) / currentScale, (evCache[0].pageY + (evCache[1].pageY - evCache[0].pageY) / 2 - box.y - window.scrollY) / currentScale];
|
6486 | }
|
6487 | function getSlideSelector() {
|
6488 | return swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
|
6489 | }
|
6490 | function eventWithinSlide(e) {
|
6491 | const slideSelector = getSlideSelector();
|
6492 | if (e.target.matches(slideSelector)) return true;
|
6493 | if (swiper.slides.filter(slideEl => slideEl.contains(e.target)).length > 0) return true;
|
6494 | return false;
|
6495 | }
|
6496 | function eventWithinZoomContainer(e) {
|
6497 | const selector = `.${swiper.params.zoom.containerClass}`;
|
6498 | if (e.target.matches(selector)) return true;
|
6499 | if ([...swiper.hostEl.querySelectorAll(selector)].filter(containerEl => containerEl.contains(e.target)).length > 0) return true;
|
6500 | return false;
|
6501 | }
|
6502 |
|
6503 |
|
6504 | function onGestureStart(e) {
|
6505 | if (e.pointerType === 'mouse') {
|
6506 | evCache.splice(0, evCache.length);
|
6507 | }
|
6508 | if (!eventWithinSlide(e)) return;
|
6509 | const params = swiper.params.zoom;
|
6510 | fakeGestureTouched = false;
|
6511 | fakeGestureMoved = false;
|
6512 | evCache.push(e);
|
6513 | if (evCache.length < 2) {
|
6514 | return;
|
6515 | }
|
6516 | fakeGestureTouched = true;
|
6517 | gesture.scaleStart = getDistanceBetweenTouches();
|
6518 | if (!gesture.slideEl) {
|
6519 | gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
|
6520 | if (!gesture.slideEl) gesture.slideEl = swiper.slides[swiper.activeIndex];
|
6521 | let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
|
6522 | if (imageEl) {
|
6523 | imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
|
6524 | }
|
6525 | gesture.imageEl = imageEl;
|
6526 | if (imageEl) {
|
6527 | gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
|
6528 | } else {
|
6529 | gesture.imageWrapEl = undefined;
|
6530 | }
|
6531 | if (!gesture.imageWrapEl) {
|
6532 | gesture.imageEl = undefined;
|
6533 | return;
|
6534 | }
|
6535 | gesture.maxRatio = getMaxRatio();
|
6536 | }
|
6537 | if (gesture.imageEl) {
|
6538 | const [originX, originY] = getScaleOrigin();
|
6539 | gesture.originX = originX;
|
6540 | gesture.originY = originY;
|
6541 | gesture.imageEl.style.transitionDuration = '0ms';
|
6542 | }
|
6543 | isScaling = true;
|
6544 | }
|
6545 | function onGestureChange(e) {
|
6546 | if (!eventWithinSlide(e)) return;
|
6547 | const params = swiper.params.zoom;
|
6548 | const zoom = swiper.zoom;
|
6549 | const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
|
6550 | if (pointerIndex >= 0) evCache[pointerIndex] = e;
|
6551 | if (evCache.length < 2) {
|
6552 | return;
|
6553 | }
|
6554 | fakeGestureMoved = true;
|
6555 | gesture.scaleMove = getDistanceBetweenTouches();
|
6556 | if (!gesture.imageEl) {
|
6557 | return;
|
6558 | }
|
6559 | zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
|
6560 | if (zoom.scale > gesture.maxRatio) {
|
6561 | zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
|
6562 | }
|
6563 | if (zoom.scale < params.minRatio) {
|
6564 | zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
|
6565 | }
|
6566 | gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
|
6567 | }
|
6568 | function onGestureEnd(e) {
|
6569 | if (!eventWithinSlide(e)) return;
|
6570 | if (e.pointerType === 'mouse' && e.type === 'pointerout') return;
|
6571 | const params = swiper.params.zoom;
|
6572 | const zoom = swiper.zoom;
|
6573 | const pointerIndex = evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
|
6574 | if (pointerIndex >= 0) evCache.splice(pointerIndex, 1);
|
6575 | if (!fakeGestureTouched || !fakeGestureMoved) {
|
6576 | return;
|
6577 | }
|
6578 | fakeGestureTouched = false;
|
6579 | fakeGestureMoved = false;
|
6580 | if (!gesture.imageEl) return;
|
6581 | zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
|
6582 | gesture.imageEl.style.transitionDuration = `${swiper.params.speed}ms`;
|
6583 | gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
|
6584 | currentScale = zoom.scale;
|
6585 | isScaling = false;
|
6586 | if (zoom.scale > 1 && gesture.slideEl) {
|
6587 | gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
|
6588 | } else if (zoom.scale <= 1 && gesture.slideEl) {
|
6589 | gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
|
6590 | }
|
6591 | if (zoom.scale === 1) {
|
6592 | gesture.originX = 0;
|
6593 | gesture.originY = 0;
|
6594 | gesture.slideEl = undefined;
|
6595 | }
|
6596 | }
|
6597 | let allowTouchMoveTimeout;
|
6598 | function allowTouchMove() {
|
6599 | swiper.touchEventsData.preventTouchMoveFromPointerMove = false;
|
6600 | }
|
6601 | function preventTouchMove() {
|
6602 | clearTimeout(allowTouchMoveTimeout);
|
6603 | swiper.touchEventsData.preventTouchMoveFromPointerMove = true;
|
6604 | allowTouchMoveTimeout = setTimeout(() => {
|
6605 | if (swiper.destroyed) return;
|
6606 | allowTouchMove();
|
6607 | });
|
6608 | }
|
6609 | function onTouchStart(e) {
|
6610 | const device = swiper.device;
|
6611 | if (!gesture.imageEl) return;
|
6612 | if (image.isTouched) return;
|
6613 | if (device.android && e.cancelable) e.preventDefault();
|
6614 | image.isTouched = true;
|
6615 | const event = evCache.length > 0 ? evCache[0] : e;
|
6616 | image.touchesStart.x = event.pageX;
|
6617 | image.touchesStart.y = event.pageY;
|
6618 | }
|
6619 | function onTouchMove(e) {
|
6620 | if (!eventWithinSlide(e) || !eventWithinZoomContainer(e)) {
|
6621 | return;
|
6622 | }
|
6623 | const zoom = swiper.zoom;
|
6624 | if (!gesture.imageEl) {
|
6625 | return;
|
6626 | }
|
6627 | if (!image.isTouched || !gesture.slideEl) {
|
6628 | return;
|
6629 | }
|
6630 | if (!image.isMoved) {
|
6631 | image.width = gesture.imageEl.offsetWidth || gesture.imageEl.clientWidth;
|
6632 | image.height = gesture.imageEl.offsetHeight || gesture.imageEl.clientHeight;
|
6633 | image.startX = getTranslate(gesture.imageWrapEl, 'x') || 0;
|
6634 | image.startY = getTranslate(gesture.imageWrapEl, 'y') || 0;
|
6635 | gesture.slideWidth = gesture.slideEl.offsetWidth;
|
6636 | gesture.slideHeight = gesture.slideEl.offsetHeight;
|
6637 | gesture.imageWrapEl.style.transitionDuration = '0ms';
|
6638 | }
|
6639 |
|
6640 | const scaledWidth = image.width * zoom.scale;
|
6641 | const scaledHeight = image.height * zoom.scale;
|
6642 | image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
|
6643 | image.maxX = -image.minX;
|
6644 | image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
|
6645 | image.maxY = -image.minY;
|
6646 | image.touchesCurrent.x = evCache.length > 0 ? evCache[0].pageX : e.pageX;
|
6647 | image.touchesCurrent.y = evCache.length > 0 ? evCache[0].pageY : e.pageY;
|
6648 | const touchesDiff = Math.max(Math.abs(image.touchesCurrent.x - image.touchesStart.x), Math.abs(image.touchesCurrent.y - image.touchesStart.y));
|
6649 | if (touchesDiff > 5) {
|
6650 | swiper.allowClick = false;
|
6651 | }
|
6652 | if (!image.isMoved && !isScaling) {
|
6653 | if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
|
6654 | image.isTouched = false;
|
6655 | allowTouchMove();
|
6656 | return;
|
6657 | }
|
6658 | if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
|
6659 | image.isTouched = false;
|
6660 | allowTouchMove();
|
6661 | return;
|
6662 | }
|
6663 | }
|
6664 | if (e.cancelable) {
|
6665 | e.preventDefault();
|
6666 | }
|
6667 | e.stopPropagation();
|
6668 | preventTouchMove();
|
6669 | image.isMoved = true;
|
6670 | const scaleRatio = (zoom.scale - currentScale) / (gesture.maxRatio - swiper.params.zoom.minRatio);
|
6671 | const {
|
6672 | originX,
|
6673 | originY
|
6674 | } = gesture;
|
6675 | image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX + scaleRatio * (image.width - originX * 2);
|
6676 | image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY + scaleRatio * (image.height - originY * 2);
|
6677 | if (image.currentX < image.minX) {
|
6678 | image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
|
6679 | }
|
6680 | if (image.currentX > image.maxX) {
|
6681 | image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
|
6682 | }
|
6683 | if (image.currentY < image.minY) {
|
6684 | image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
|
6685 | }
|
6686 | if (image.currentY > image.maxY) {
|
6687 | image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
|
6688 | }
|
6689 |
|
6690 |
|
6691 | if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
|
6692 | if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
|
6693 | if (!velocity.prevTime) velocity.prevTime = Date.now();
|
6694 | velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
|
6695 | velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
|
6696 | if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
|
6697 | if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
|
6698 | velocity.prevPositionX = image.touchesCurrent.x;
|
6699 | velocity.prevPositionY = image.touchesCurrent.y;
|
6700 | velocity.prevTime = Date.now();
|
6701 | gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
|
6702 | }
|
6703 | function onTouchEnd() {
|
6704 | const zoom = swiper.zoom;
|
6705 | if (!gesture.imageEl) return;
|
6706 | if (!image.isTouched || !image.isMoved) {
|
6707 | image.isTouched = false;
|
6708 | image.isMoved = false;
|
6709 | return;
|
6710 | }
|
6711 | image.isTouched = false;
|
6712 | image.isMoved = false;
|
6713 | let momentumDurationX = 300;
|
6714 | let momentumDurationY = 300;
|
6715 | const momentumDistanceX = velocity.x * momentumDurationX;
|
6716 | const newPositionX = image.currentX + momentumDistanceX;
|
6717 | const momentumDistanceY = velocity.y * momentumDurationY;
|
6718 | const newPositionY = image.currentY + momentumDistanceY;
|
6719 |
|
6720 |
|
6721 | if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
|
6722 | if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
|
6723 | const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
|
6724 | image.currentX = newPositionX;
|
6725 | image.currentY = newPositionY;
|
6726 |
|
6727 | const scaledWidth = image.width * zoom.scale;
|
6728 | const scaledHeight = image.height * zoom.scale;
|
6729 | image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
|
6730 | image.maxX = -image.minX;
|
6731 | image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
|
6732 | image.maxY = -image.minY;
|
6733 | image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
|
6734 | image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
|
6735 | gesture.imageWrapEl.style.transitionDuration = `${momentumDuration}ms`;
|
6736 | gesture.imageWrapEl.style.transform = `translate3d(${image.currentX}px, ${image.currentY}px,0)`;
|
6737 | }
|
6738 | function onTransitionEnd() {
|
6739 | const zoom = swiper.zoom;
|
6740 | if (gesture.slideEl && swiper.activeIndex !== swiper.slides.indexOf(gesture.slideEl)) {
|
6741 | if (gesture.imageEl) {
|
6742 | gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
|
6743 | }
|
6744 | if (gesture.imageWrapEl) {
|
6745 | gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
|
6746 | }
|
6747 | gesture.slideEl.classList.remove(`${swiper.params.zoom.zoomedSlideClass}`);
|
6748 | zoom.scale = 1;
|
6749 | currentScale = 1;
|
6750 | gesture.slideEl = undefined;
|
6751 | gesture.imageEl = undefined;
|
6752 | gesture.imageWrapEl = undefined;
|
6753 | gesture.originX = 0;
|
6754 | gesture.originY = 0;
|
6755 | }
|
6756 | }
|
6757 | function zoomIn(e) {
|
6758 | const zoom = swiper.zoom;
|
6759 | const params = swiper.params.zoom;
|
6760 | if (!gesture.slideEl) {
|
6761 | if (e && e.target) {
|
6762 | gesture.slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
|
6763 | }
|
6764 | if (!gesture.slideEl) {
|
6765 | if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
|
6766 | gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
|
6767 | } else {
|
6768 | gesture.slideEl = swiper.slides[swiper.activeIndex];
|
6769 | }
|
6770 | }
|
6771 | let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
|
6772 | if (imageEl) {
|
6773 | imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
|
6774 | }
|
6775 | gesture.imageEl = imageEl;
|
6776 | if (imageEl) {
|
6777 | gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
|
6778 | } else {
|
6779 | gesture.imageWrapEl = undefined;
|
6780 | }
|
6781 | }
|
6782 | if (!gesture.imageEl || !gesture.imageWrapEl) return;
|
6783 | if (swiper.params.cssMode) {
|
6784 | swiper.wrapperEl.style.overflow = 'hidden';
|
6785 | swiper.wrapperEl.style.touchAction = 'none';
|
6786 | }
|
6787 | gesture.slideEl.classList.add(`${params.zoomedSlideClass}`);
|
6788 | let touchX;
|
6789 | let touchY;
|
6790 | let offsetX;
|
6791 | let offsetY;
|
6792 | let diffX;
|
6793 | let diffY;
|
6794 | let translateX;
|
6795 | let translateY;
|
6796 | let imageWidth;
|
6797 | let imageHeight;
|
6798 | let scaledWidth;
|
6799 | let scaledHeight;
|
6800 | let translateMinX;
|
6801 | let translateMinY;
|
6802 | let translateMaxX;
|
6803 | let translateMaxY;
|
6804 | let slideWidth;
|
6805 | let slideHeight;
|
6806 | if (typeof image.touchesStart.x === 'undefined' && e) {
|
6807 | touchX = e.pageX;
|
6808 | touchY = e.pageY;
|
6809 | } else {
|
6810 | touchX = image.touchesStart.x;
|
6811 | touchY = image.touchesStart.y;
|
6812 | }
|
6813 | const forceZoomRatio = typeof e === 'number' ? e : null;
|
6814 | if (currentScale === 1 && forceZoomRatio) {
|
6815 | touchX = undefined;
|
6816 | touchY = undefined;
|
6817 | image.touchesStart.x = undefined;
|
6818 | image.touchesStart.y = undefined;
|
6819 | }
|
6820 | const maxRatio = getMaxRatio();
|
6821 | zoom.scale = forceZoomRatio || maxRatio;
|
6822 | currentScale = forceZoomRatio || maxRatio;
|
6823 | if (e && !(currentScale === 1 && forceZoomRatio)) {
|
6824 | slideWidth = gesture.slideEl.offsetWidth;
|
6825 | slideHeight = gesture.slideEl.offsetHeight;
|
6826 | offsetX = elementOffset(gesture.slideEl).left + window.scrollX;
|
6827 | offsetY = elementOffset(gesture.slideEl).top + window.scrollY;
|
6828 | diffX = offsetX + slideWidth / 2 - touchX;
|
6829 | diffY = offsetY + slideHeight / 2 - touchY;
|
6830 | imageWidth = gesture.imageEl.offsetWidth || gesture.imageEl.clientWidth;
|
6831 | imageHeight = gesture.imageEl.offsetHeight || gesture.imageEl.clientHeight;
|
6832 | scaledWidth = imageWidth * zoom.scale;
|
6833 | scaledHeight = imageHeight * zoom.scale;
|
6834 | translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
|
6835 | translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
|
6836 | translateMaxX = -translateMinX;
|
6837 | translateMaxY = -translateMinY;
|
6838 | translateX = diffX * zoom.scale;
|
6839 | translateY = diffY * zoom.scale;
|
6840 | if (translateX < translateMinX) {
|
6841 | translateX = translateMinX;
|
6842 | }
|
6843 | if (translateX > translateMaxX) {
|
6844 | translateX = translateMaxX;
|
6845 | }
|
6846 | if (translateY < translateMinY) {
|
6847 | translateY = translateMinY;
|
6848 | }
|
6849 | if (translateY > translateMaxY) {
|
6850 | translateY = translateMaxY;
|
6851 | }
|
6852 | } else {
|
6853 | translateX = 0;
|
6854 | translateY = 0;
|
6855 | }
|
6856 | if (forceZoomRatio && zoom.scale === 1) {
|
6857 | gesture.originX = 0;
|
6858 | gesture.originY = 0;
|
6859 | }
|
6860 | gesture.imageWrapEl.style.transitionDuration = '300ms';
|
6861 | gesture.imageWrapEl.style.transform = `translate3d(${translateX}px, ${translateY}px,0)`;
|
6862 | gesture.imageEl.style.transitionDuration = '300ms';
|
6863 | gesture.imageEl.style.transform = `translate3d(0,0,0) scale(${zoom.scale})`;
|
6864 | }
|
6865 | function zoomOut() {
|
6866 | const zoom = swiper.zoom;
|
6867 | const params = swiper.params.zoom;
|
6868 | if (!gesture.slideEl) {
|
6869 | if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
|
6870 | gesture.slideEl = elementChildren(swiper.slidesEl, `.${swiper.params.slideActiveClass}`)[0];
|
6871 | } else {
|
6872 | gesture.slideEl = swiper.slides[swiper.activeIndex];
|
6873 | }
|
6874 | let imageEl = gesture.slideEl.querySelector(`.${params.containerClass}`);
|
6875 | if (imageEl) {
|
6876 | imageEl = imageEl.querySelectorAll('picture, img, svg, canvas, .swiper-zoom-target')[0];
|
6877 | }
|
6878 | gesture.imageEl = imageEl;
|
6879 | if (imageEl) {
|
6880 | gesture.imageWrapEl = elementParents(gesture.imageEl, `.${params.containerClass}`)[0];
|
6881 | } else {
|
6882 | gesture.imageWrapEl = undefined;
|
6883 | }
|
6884 | }
|
6885 | if (!gesture.imageEl || !gesture.imageWrapEl) return;
|
6886 | if (swiper.params.cssMode) {
|
6887 | swiper.wrapperEl.style.overflow = '';
|
6888 | swiper.wrapperEl.style.touchAction = '';
|
6889 | }
|
6890 | zoom.scale = 1;
|
6891 | currentScale = 1;
|
6892 | image.touchesStart.x = undefined;
|
6893 | image.touchesStart.y = undefined;
|
6894 | gesture.imageWrapEl.style.transitionDuration = '300ms';
|
6895 | gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
|
6896 | gesture.imageEl.style.transitionDuration = '300ms';
|
6897 | gesture.imageEl.style.transform = 'translate3d(0,0,0) scale(1)';
|
6898 | gesture.slideEl.classList.remove(`${params.zoomedSlideClass}`);
|
6899 | gesture.slideEl = undefined;
|
6900 | gesture.originX = 0;
|
6901 | gesture.originY = 0;
|
6902 | }
|
6903 |
|
6904 |
|
6905 | function zoomToggle(e) {
|
6906 | const zoom = swiper.zoom;
|
6907 | if (zoom.scale && zoom.scale !== 1) {
|
6908 |
|
6909 | zoomOut();
|
6910 | } else {
|
6911 |
|
6912 | zoomIn(e);
|
6913 | }
|
6914 | }
|
6915 | function getListeners() {
|
6916 | const passiveListener = swiper.params.passiveListeners ? {
|
6917 | passive: true,
|
6918 | capture: false
|
6919 | } : false;
|
6920 | const activeListenerWithCapture = swiper.params.passiveListeners ? {
|
6921 | passive: false,
|
6922 | capture: true
|
6923 | } : true;
|
6924 | return {
|
6925 | passiveListener,
|
6926 | activeListenerWithCapture
|
6927 | };
|
6928 | }
|
6929 |
|
6930 |
|
6931 | function enable() {
|
6932 | const zoom = swiper.zoom;
|
6933 | if (zoom.enabled) return;
|
6934 | zoom.enabled = true;
|
6935 | const {
|
6936 | passiveListener,
|
6937 | activeListenerWithCapture
|
6938 | } = getListeners();
|
6939 |
|
6940 |
|
6941 | swiper.wrapperEl.addEventListener('pointerdown', onGestureStart, passiveListener);
|
6942 | swiper.wrapperEl.addEventListener('pointermove', onGestureChange, activeListenerWithCapture);
|
6943 | ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
|
6944 | swiper.wrapperEl.addEventListener(eventName, onGestureEnd, passiveListener);
|
6945 | });
|
6946 |
|
6947 |
|
6948 | swiper.wrapperEl.addEventListener('pointermove', onTouchMove, activeListenerWithCapture);
|
6949 | }
|
6950 | function disable() {
|
6951 | const zoom = swiper.zoom;
|
6952 | if (!zoom.enabled) return;
|
6953 | zoom.enabled = false;
|
6954 | const {
|
6955 | passiveListener,
|
6956 | activeListenerWithCapture
|
6957 | } = getListeners();
|
6958 |
|
6959 |
|
6960 | swiper.wrapperEl.removeEventListener('pointerdown', onGestureStart, passiveListener);
|
6961 | swiper.wrapperEl.removeEventListener('pointermove', onGestureChange, activeListenerWithCapture);
|
6962 | ['pointerup', 'pointercancel', 'pointerout'].forEach(eventName => {
|
6963 | swiper.wrapperEl.removeEventListener(eventName, onGestureEnd, passiveListener);
|
6964 | });
|
6965 |
|
6966 |
|
6967 | swiper.wrapperEl.removeEventListener('pointermove', onTouchMove, activeListenerWithCapture);
|
6968 | }
|
6969 | on('init', () => {
|
6970 | if (swiper.params.zoom.enabled) {
|
6971 | enable();
|
6972 | }
|
6973 | });
|
6974 | on('destroy', () => {
|
6975 | disable();
|
6976 | });
|
6977 | on('touchStart', (_s, e) => {
|
6978 | if (!swiper.zoom.enabled) return;
|
6979 | onTouchStart(e);
|
6980 | });
|
6981 | on('touchEnd', (_s, e) => {
|
6982 | if (!swiper.zoom.enabled) return;
|
6983 | onTouchEnd();
|
6984 | });
|
6985 | on('doubleTap', (_s, e) => {
|
6986 | if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
|
6987 | zoomToggle(e);
|
6988 | }
|
6989 | });
|
6990 | on('transitionEnd', () => {
|
6991 | if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
|
6992 | onTransitionEnd();
|
6993 | }
|
6994 | });
|
6995 | on('slideChange', () => {
|
6996 | if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
|
6997 | onTransitionEnd();
|
6998 | }
|
6999 | });
|
7000 | Object.assign(swiper.zoom, {
|
7001 | enable,
|
7002 | disable,
|
7003 | in: zoomIn,
|
7004 | out: zoomOut,
|
7005 | toggle: zoomToggle
|
7006 | });
|
7007 | }
|
7008 |
|
7009 |
|
7010 | function Controller(_ref) {
|
7011 | let {
|
7012 | swiper,
|
7013 | extendParams,
|
7014 | on
|
7015 | } = _ref;
|
7016 | extendParams({
|
7017 | controller: {
|
7018 | control: undefined,
|
7019 | inverse: false,
|
7020 | by: 'slide'
|
7021 | }
|
7022 | });
|
7023 |
|
7024 | swiper.controller = {
|
7025 | control: undefined
|
7026 | };
|
7027 | function LinearSpline(x, y) {
|
7028 | const binarySearch = function search() {
|
7029 | let maxIndex;
|
7030 | let minIndex;
|
7031 | let guess;
|
7032 | return (array, val) => {
|
7033 | minIndex = -1;
|
7034 | maxIndex = array.length;
|
7035 | while (maxIndex - minIndex > 1) {
|
7036 | guess = maxIndex + minIndex >> 1;
|
7037 | if (array[guess] <= val) {
|
7038 | minIndex = guess;
|
7039 | } else {
|
7040 | maxIndex = guess;
|
7041 | }
|
7042 | }
|
7043 | return maxIndex;
|
7044 | };
|
7045 | }();
|
7046 | this.x = x;
|
7047 | this.y = y;
|
7048 | this.lastIndex = x.length - 1;
|
7049 |
|
7050 |
|
7051 |
|
7052 | let i1;
|
7053 | let i3;
|
7054 | this.interpolate = function interpolate(x2) {
|
7055 | if (!x2) return 0;
|
7056 |
|
7057 |
|
7058 | i3 = binarySearch(this.x, x2);
|
7059 | i1 = i3 - 1;
|
7060 |
|
7061 |
|
7062 |
|
7063 | return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
|
7064 | };
|
7065 | return this;
|
7066 | }
|
7067 | function getInterpolateFunction(c) {
|
7068 | swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid);
|
7069 | }
|
7070 | function setTranslate(_t, byController) {
|
7071 | const controlled = swiper.controller.control;
|
7072 | let multiplier;
|
7073 | let controlledTranslate;
|
7074 | const Swiper = swiper.constructor;
|
7075 | function setControlledTranslate(c) {
|
7076 | if (c.destroyed) return;
|
7077 |
|
7078 |
|
7079 |
|
7080 |
|
7081 |
|
7082 | const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
|
7083 | if (swiper.params.controller.by === 'slide') {
|
7084 | getInterpolateFunction(c);
|
7085 |
|
7086 |
|
7087 | controlledTranslate = -swiper.controller.spline.interpolate(-translate);
|
7088 | }
|
7089 | if (!controlledTranslate || swiper.params.controller.by === 'container') {
|
7090 | multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
|
7091 | if (Number.isNaN(multiplier) || !Number.isFinite(multiplier)) {
|
7092 | multiplier = 1;
|
7093 | }
|
7094 | controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
|
7095 | }
|
7096 | if (swiper.params.controller.inverse) {
|
7097 | controlledTranslate = c.maxTranslate() - controlledTranslate;
|
7098 | }
|
7099 | c.updateProgress(controlledTranslate);
|
7100 | c.setTranslate(controlledTranslate, swiper);
|
7101 | c.updateActiveIndex();
|
7102 | c.updateSlidesClasses();
|
7103 | }
|
7104 | if (Array.isArray(controlled)) {
|
7105 | for (let i = 0; i < controlled.length; i += 1) {
|
7106 | if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
|
7107 | setControlledTranslate(controlled[i]);
|
7108 | }
|
7109 | }
|
7110 | } else if (controlled instanceof Swiper && byController !== controlled) {
|
7111 | setControlledTranslate(controlled);
|
7112 | }
|
7113 | }
|
7114 | function setTransition(duration, byController) {
|
7115 | const Swiper = swiper.constructor;
|
7116 | const controlled = swiper.controller.control;
|
7117 | let i;
|
7118 | function setControlledTransition(c) {
|
7119 | if (c.destroyed) return;
|
7120 | c.setTransition(duration, swiper);
|
7121 | if (duration !== 0) {
|
7122 | c.transitionStart();
|
7123 | if (c.params.autoHeight) {
|
7124 | nextTick(() => {
|
7125 | c.updateAutoHeight();
|
7126 | });
|
7127 | }
|
7128 | elementTransitionEnd(c.wrapperEl, () => {
|
7129 | if (!controlled) return;
|
7130 | c.transitionEnd();
|
7131 | });
|
7132 | }
|
7133 | }
|
7134 | if (Array.isArray(controlled)) {
|
7135 | for (i = 0; i < controlled.length; i += 1) {
|
7136 | if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
|
7137 | setControlledTransition(controlled[i]);
|
7138 | }
|
7139 | }
|
7140 | } else if (controlled instanceof Swiper && byController !== controlled) {
|
7141 | setControlledTransition(controlled);
|
7142 | }
|
7143 | }
|
7144 | function removeSpline() {
|
7145 | if (!swiper.controller.control) return;
|
7146 | if (swiper.controller.spline) {
|
7147 | swiper.controller.spline = undefined;
|
7148 | delete swiper.controller.spline;
|
7149 | }
|
7150 | }
|
7151 | on('beforeInit', () => {
|
7152 | if (typeof window !== 'undefined' && (
|
7153 |
|
7154 | typeof swiper.params.controller.control === 'string' || swiper.params.controller.control instanceof HTMLElement)) {
|
7155 | const controlElements = typeof swiper.params.controller.control === 'string' ? [...document.querySelectorAll(swiper.params.controller.control)] : [swiper.params.controller.control];
|
7156 | controlElements.forEach(controlElement => {
|
7157 | if (!swiper.controller.control) swiper.controller.control = [];
|
7158 | if (controlElement && controlElement.swiper) {
|
7159 | swiper.controller.control.push(controlElement.swiper);
|
7160 | } else if (controlElement) {
|
7161 | const eventName = `${swiper.params.eventsPrefix}init`;
|
7162 | const onControllerSwiper = e => {
|
7163 | swiper.controller.control.push(e.detail[0]);
|
7164 | swiper.update();
|
7165 | controlElement.removeEventListener(eventName, onControllerSwiper);
|
7166 | };
|
7167 | controlElement.addEventListener(eventName, onControllerSwiper);
|
7168 | }
|
7169 | });
|
7170 | return;
|
7171 | }
|
7172 | swiper.controller.control = swiper.params.controller.control;
|
7173 | });
|
7174 | on('update', () => {
|
7175 | removeSpline();
|
7176 | });
|
7177 | on('resize', () => {
|
7178 | removeSpline();
|
7179 | });
|
7180 | on('observerUpdate', () => {
|
7181 | removeSpline();
|
7182 | });
|
7183 | on('setTranslate', (_s, translate, byController) => {
|
7184 | if (!swiper.controller.control || swiper.controller.control.destroyed) return;
|
7185 | swiper.controller.setTranslate(translate, byController);
|
7186 | });
|
7187 | on('setTransition', (_s, duration, byController) => {
|
7188 | if (!swiper.controller.control || swiper.controller.control.destroyed) return;
|
7189 | swiper.controller.setTransition(duration, byController);
|
7190 | });
|
7191 | Object.assign(swiper.controller, {
|
7192 | setTranslate,
|
7193 | setTransition
|
7194 | });
|
7195 | }
|
7196 |
|
7197 | function A11y(_ref) {
|
7198 | let {
|
7199 | swiper,
|
7200 | extendParams,
|
7201 | on
|
7202 | } = _ref;
|
7203 | extendParams({
|
7204 | a11y: {
|
7205 | enabled: true,
|
7206 | notificationClass: 'swiper-notification',
|
7207 | prevSlideMessage: 'Previous slide',
|
7208 | nextSlideMessage: 'Next slide',
|
7209 | firstSlideMessage: 'This is the first slide',
|
7210 | lastSlideMessage: 'This is the last slide',
|
7211 | paginationBulletMessage: 'Go to slide {{index}}',
|
7212 | slideLabelMessage: '{{index}} / {{slidesLength}}',
|
7213 | containerMessage: null,
|
7214 | containerRoleDescriptionMessage: null,
|
7215 | containerRole: null,
|
7216 | itemRoleDescriptionMessage: null,
|
7217 | slideRole: 'group',
|
7218 | id: null,
|
7219 | scrollOnFocus: true
|
7220 | }
|
7221 | });
|
7222 | swiper.a11y = {
|
7223 | clicked: false
|
7224 | };
|
7225 | let liveRegion = null;
|
7226 | let preventFocusHandler;
|
7227 | let focusTargetSlideEl;
|
7228 | let visibilityChangedTimestamp = new Date().getTime();
|
7229 | function notify(message) {
|
7230 | const notification = liveRegion;
|
7231 | if (notification.length === 0) return;
|
7232 | notification.innerHTML = '';
|
7233 | notification.innerHTML = message;
|
7234 | }
|
7235 | function getRandomNumber(size) {
|
7236 | if (size === void 0) {
|
7237 | size = 16;
|
7238 | }
|
7239 | const randomChar = () => Math.round(16 * Math.random()).toString(16);
|
7240 | return 'x'.repeat(size).replace(/x/g, randomChar);
|
7241 | }
|
7242 | function makeElFocusable(el) {
|
7243 | el = makeElementsArray(el);
|
7244 | el.forEach(subEl => {
|
7245 | subEl.setAttribute('tabIndex', '0');
|
7246 | });
|
7247 | }
|
7248 | function makeElNotFocusable(el) {
|
7249 | el = makeElementsArray(el);
|
7250 | el.forEach(subEl => {
|
7251 | subEl.setAttribute('tabIndex', '-1');
|
7252 | });
|
7253 | }
|
7254 | function addElRole(el, role) {
|
7255 | el = makeElementsArray(el);
|
7256 | el.forEach(subEl => {
|
7257 | subEl.setAttribute('role', role);
|
7258 | });
|
7259 | }
|
7260 | function addElRoleDescription(el, description) {
|
7261 | el = makeElementsArray(el);
|
7262 | el.forEach(subEl => {
|
7263 | subEl.setAttribute('aria-roledescription', description);
|
7264 | });
|
7265 | }
|
7266 | function addElControls(el, controls) {
|
7267 | el = makeElementsArray(el);
|
7268 | el.forEach(subEl => {
|
7269 | subEl.setAttribute('aria-controls', controls);
|
7270 | });
|
7271 | }
|
7272 | function addElLabel(el, label) {
|
7273 | el = makeElementsArray(el);
|
7274 | el.forEach(subEl => {
|
7275 | subEl.setAttribute('aria-label', label);
|
7276 | });
|
7277 | }
|
7278 | function addElId(el, id) {
|
7279 | el = makeElementsArray(el);
|
7280 | el.forEach(subEl => {
|
7281 | subEl.setAttribute('id', id);
|
7282 | });
|
7283 | }
|
7284 | function addElLive(el, live) {
|
7285 | el = makeElementsArray(el);
|
7286 | el.forEach(subEl => {
|
7287 | subEl.setAttribute('aria-live', live);
|
7288 | });
|
7289 | }
|
7290 | function disableEl(el) {
|
7291 | el = makeElementsArray(el);
|
7292 | el.forEach(subEl => {
|
7293 | subEl.setAttribute('aria-disabled', true);
|
7294 | });
|
7295 | }
|
7296 | function enableEl(el) {
|
7297 | el = makeElementsArray(el);
|
7298 | el.forEach(subEl => {
|
7299 | subEl.setAttribute('aria-disabled', false);
|
7300 | });
|
7301 | }
|
7302 | function onEnterOrSpaceKey(e) {
|
7303 | if (e.keyCode !== 13 && e.keyCode !== 32) return;
|
7304 | const params = swiper.params.a11y;
|
7305 | const targetEl = e.target;
|
7306 | if (swiper.pagination && swiper.pagination.el && (targetEl === swiper.pagination.el || swiper.pagination.el.contains(e.target))) {
|
7307 | if (!e.target.matches(classesToSelector(swiper.params.pagination.bulletClass))) return;
|
7308 | }
|
7309 | if (swiper.navigation && swiper.navigation.prevEl && swiper.navigation.nextEl) {
|
7310 | const prevEls = makeElementsArray(swiper.navigation.prevEl);
|
7311 | const nextEls = makeElementsArray(swiper.navigation.nextEl);
|
7312 | if (nextEls.includes(targetEl)) {
|
7313 | if (!(swiper.isEnd && !swiper.params.loop)) {
|
7314 | swiper.slideNext();
|
7315 | }
|
7316 | if (swiper.isEnd) {
|
7317 | notify(params.lastSlideMessage);
|
7318 | } else {
|
7319 | notify(params.nextSlideMessage);
|
7320 | }
|
7321 | }
|
7322 | if (prevEls.includes(targetEl)) {
|
7323 | if (!(swiper.isBeginning && !swiper.params.loop)) {
|
7324 | swiper.slidePrev();
|
7325 | }
|
7326 | if (swiper.isBeginning) {
|
7327 | notify(params.firstSlideMessage);
|
7328 | } else {
|
7329 | notify(params.prevSlideMessage);
|
7330 | }
|
7331 | }
|
7332 | }
|
7333 | if (swiper.pagination && targetEl.matches(classesToSelector(swiper.params.pagination.bulletClass))) {
|
7334 | targetEl.click();
|
7335 | }
|
7336 | }
|
7337 | function updateNavigation() {
|
7338 | if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
|
7339 | const {
|
7340 | nextEl,
|
7341 | prevEl
|
7342 | } = swiper.navigation;
|
7343 | if (prevEl) {
|
7344 | if (swiper.isBeginning) {
|
7345 | disableEl(prevEl);
|
7346 | makeElNotFocusable(prevEl);
|
7347 | } else {
|
7348 | enableEl(prevEl);
|
7349 | makeElFocusable(prevEl);
|
7350 | }
|
7351 | }
|
7352 | if (nextEl) {
|
7353 | if (swiper.isEnd) {
|
7354 | disableEl(nextEl);
|
7355 | makeElNotFocusable(nextEl);
|
7356 | } else {
|
7357 | enableEl(nextEl);
|
7358 | makeElFocusable(nextEl);
|
7359 | }
|
7360 | }
|
7361 | }
|
7362 | function hasPagination() {
|
7363 | return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
|
7364 | }
|
7365 | function hasClickablePagination() {
|
7366 | return hasPagination() && swiper.params.pagination.clickable;
|
7367 | }
|
7368 | function updatePagination() {
|
7369 | const params = swiper.params.a11y;
|
7370 | if (!hasPagination()) return;
|
7371 | swiper.pagination.bullets.forEach(bulletEl => {
|
7372 | if (swiper.params.pagination.clickable) {
|
7373 | makeElFocusable(bulletEl);
|
7374 | if (!swiper.params.pagination.renderBullet) {
|
7375 | addElRole(bulletEl, 'button');
|
7376 | addElLabel(bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, elementIndex(bulletEl) + 1));
|
7377 | }
|
7378 | }
|
7379 | if (bulletEl.matches(classesToSelector(swiper.params.pagination.bulletActiveClass))) {
|
7380 | bulletEl.setAttribute('aria-current', 'true');
|
7381 | } else {
|
7382 | bulletEl.removeAttribute('aria-current');
|
7383 | }
|
7384 | });
|
7385 | }
|
7386 | const initNavEl = (el, wrapperId, message) => {
|
7387 | makeElFocusable(el);
|
7388 | if (el.tagName !== 'BUTTON') {
|
7389 | addElRole(el, 'button');
|
7390 | el.addEventListener('keydown', onEnterOrSpaceKey);
|
7391 | }
|
7392 | addElLabel(el, message);
|
7393 | addElControls(el, wrapperId);
|
7394 | };
|
7395 | const handlePointerDown = e => {
|
7396 | if (focusTargetSlideEl && focusTargetSlideEl !== e.target && !focusTargetSlideEl.contains(e.target)) {
|
7397 | preventFocusHandler = true;
|
7398 | }
|
7399 | swiper.a11y.clicked = true;
|
7400 | };
|
7401 | const handlePointerUp = () => {
|
7402 | preventFocusHandler = false;
|
7403 | requestAnimationFrame(() => {
|
7404 | requestAnimationFrame(() => {
|
7405 | if (!swiper.destroyed) {
|
7406 | swiper.a11y.clicked = false;
|
7407 | }
|
7408 | });
|
7409 | });
|
7410 | };
|
7411 | const onVisibilityChange = e => {
|
7412 | visibilityChangedTimestamp = new Date().getTime();
|
7413 | };
|
7414 | const handleFocus = e => {
|
7415 | if (swiper.a11y.clicked || !swiper.params.a11y.scrollOnFocus) return;
|
7416 | if (new Date().getTime() - visibilityChangedTimestamp < 100) return;
|
7417 | const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
|
7418 | if (!slideEl || !swiper.slides.includes(slideEl)) return;
|
7419 | focusTargetSlideEl = slideEl;
|
7420 | const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
|
7421 | const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
|
7422 | if (isActive || isVisible) return;
|
7423 | if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
|
7424 | if (swiper.isHorizontal()) {
|
7425 | swiper.el.scrollLeft = 0;
|
7426 | } else {
|
7427 | swiper.el.scrollTop = 0;
|
7428 | }
|
7429 | requestAnimationFrame(() => {
|
7430 | if (preventFocusHandler) return;
|
7431 | if (swiper.params.loop) {
|
7432 | swiper.slideToLoop(parseInt(slideEl.getAttribute('data-swiper-slide-index')), 0);
|
7433 | } else {
|
7434 | swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
|
7435 | }
|
7436 | preventFocusHandler = false;
|
7437 | });
|
7438 | };
|
7439 | const initSlides = () => {
|
7440 | const params = swiper.params.a11y;
|
7441 | if (params.itemRoleDescriptionMessage) {
|
7442 | addElRoleDescription(swiper.slides, params.itemRoleDescriptionMessage);
|
7443 | }
|
7444 | if (params.slideRole) {
|
7445 | addElRole(swiper.slides, params.slideRole);
|
7446 | }
|
7447 | const slidesLength = swiper.slides.length;
|
7448 | if (params.slideLabelMessage) {
|
7449 | swiper.slides.forEach((slideEl, index) => {
|
7450 | const slideIndex = swiper.params.loop ? parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10) : index;
|
7451 | const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
|
7452 | addElLabel(slideEl, ariaLabelMessage);
|
7453 | });
|
7454 | }
|
7455 | };
|
7456 | const init = () => {
|
7457 | const params = swiper.params.a11y;
|
7458 | swiper.el.append(liveRegion);
|
7459 |
|
7460 |
|
7461 | const containerEl = swiper.el;
|
7462 | if (params.containerRoleDescriptionMessage) {
|
7463 | addElRoleDescription(containerEl, params.containerRoleDescriptionMessage);
|
7464 | }
|
7465 | if (params.containerMessage) {
|
7466 | addElLabel(containerEl, params.containerMessage);
|
7467 | }
|
7468 | if (params.containerRole) {
|
7469 | addElRole(containerEl, params.containerRole);
|
7470 | }
|
7471 |
|
7472 |
|
7473 | const wrapperEl = swiper.wrapperEl;
|
7474 | const wrapperId = params.id || wrapperEl.getAttribute('id') || `swiper-wrapper-${getRandomNumber(16)}`;
|
7475 | const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
|
7476 | addElId(wrapperEl, wrapperId);
|
7477 | addElLive(wrapperEl, live);
|
7478 |
|
7479 |
|
7480 | initSlides();
|
7481 |
|
7482 |
|
7483 | let {
|
7484 | nextEl,
|
7485 | prevEl
|
7486 | } = swiper.navigation ? swiper.navigation : {};
|
7487 | nextEl = makeElementsArray(nextEl);
|
7488 | prevEl = makeElementsArray(prevEl);
|
7489 | if (nextEl) {
|
7490 | nextEl.forEach(el => initNavEl(el, wrapperId, params.nextSlideMessage));
|
7491 | }
|
7492 | if (prevEl) {
|
7493 | prevEl.forEach(el => initNavEl(el, wrapperId, params.prevSlideMessage));
|
7494 | }
|
7495 |
|
7496 |
|
7497 | if (hasClickablePagination()) {
|
7498 | const paginationEl = makeElementsArray(swiper.pagination.el);
|
7499 | paginationEl.forEach(el => {
|
7500 | el.addEventListener('keydown', onEnterOrSpaceKey);
|
7501 | });
|
7502 | }
|
7503 |
|
7504 |
|
7505 | const document = getDocument();
|
7506 | document.addEventListener('visibilitychange', onVisibilityChange);
|
7507 | swiper.el.addEventListener('focus', handleFocus, true);
|
7508 | swiper.el.addEventListener('focus', handleFocus, true);
|
7509 | swiper.el.addEventListener('pointerdown', handlePointerDown, true);
|
7510 | swiper.el.addEventListener('pointerup', handlePointerUp, true);
|
7511 | };
|
7512 | function destroy() {
|
7513 | if (liveRegion) liveRegion.remove();
|
7514 | let {
|
7515 | nextEl,
|
7516 | prevEl
|
7517 | } = swiper.navigation ? swiper.navigation : {};
|
7518 | nextEl = makeElementsArray(nextEl);
|
7519 | prevEl = makeElementsArray(prevEl);
|
7520 | if (nextEl) {
|
7521 | nextEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
|
7522 | }
|
7523 | if (prevEl) {
|
7524 | prevEl.forEach(el => el.removeEventListener('keydown', onEnterOrSpaceKey));
|
7525 | }
|
7526 |
|
7527 |
|
7528 | if (hasClickablePagination()) {
|
7529 | const paginationEl = makeElementsArray(swiper.pagination.el);
|
7530 | paginationEl.forEach(el => {
|
7531 | el.removeEventListener('keydown', onEnterOrSpaceKey);
|
7532 | });
|
7533 | }
|
7534 | const document = getDocument();
|
7535 | document.removeEventListener('visibilitychange', onVisibilityChange);
|
7536 |
|
7537 | if (swiper.el && typeof swiper.el !== 'string') {
|
7538 | swiper.el.removeEventListener('focus', handleFocus, true);
|
7539 | swiper.el.removeEventListener('pointerdown', handlePointerDown, true);
|
7540 | swiper.el.removeEventListener('pointerup', handlePointerUp, true);
|
7541 | }
|
7542 | }
|
7543 | on('beforeInit', () => {
|
7544 | liveRegion = createElement('span', swiper.params.a11y.notificationClass);
|
7545 | liveRegion.setAttribute('aria-live', 'assertive');
|
7546 | liveRegion.setAttribute('aria-atomic', 'true');
|
7547 | });
|
7548 | on('afterInit', () => {
|
7549 | if (!swiper.params.a11y.enabled) return;
|
7550 | init();
|
7551 | });
|
7552 | on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => {
|
7553 | if (!swiper.params.a11y.enabled) return;
|
7554 | initSlides();
|
7555 | });
|
7556 | on('fromEdge toEdge afterInit lock unlock', () => {
|
7557 | if (!swiper.params.a11y.enabled) return;
|
7558 | updateNavigation();
|
7559 | });
|
7560 | on('paginationUpdate', () => {
|
7561 | if (!swiper.params.a11y.enabled) return;
|
7562 | updatePagination();
|
7563 | });
|
7564 | on('destroy', () => {
|
7565 | if (!swiper.params.a11y.enabled) return;
|
7566 | destroy();
|
7567 | });
|
7568 | }
|
7569 |
|
7570 | function History(_ref) {
|
7571 | let {
|
7572 | swiper,
|
7573 | extendParams,
|
7574 | on
|
7575 | } = _ref;
|
7576 | extendParams({
|
7577 | history: {
|
7578 | enabled: false,
|
7579 | root: '',
|
7580 | replaceState: false,
|
7581 | key: 'slides',
|
7582 | keepQuery: false
|
7583 | }
|
7584 | });
|
7585 | let initialized = false;
|
7586 | let paths = {};
|
7587 | const slugify = text => {
|
7588 | return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
7589 | };
|
7590 | const getPathValues = urlOverride => {
|
7591 | const window = getWindow();
|
7592 | let location;
|
7593 | if (urlOverride) {
|
7594 | location = new URL(urlOverride);
|
7595 | } else {
|
7596 | location = window.location;
|
7597 | }
|
7598 | const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
|
7599 | const total = pathArray.length;
|
7600 | const key = pathArray[total - 2];
|
7601 | const value = pathArray[total - 1];
|
7602 | return {
|
7603 | key,
|
7604 | value
|
7605 | };
|
7606 | };
|
7607 | const setHistory = (key, index) => {
|
7608 | const window = getWindow();
|
7609 | if (!initialized || !swiper.params.history.enabled) return;
|
7610 | let location;
|
7611 | if (swiper.params.url) {
|
7612 | location = new URL(swiper.params.url);
|
7613 | } else {
|
7614 | location = window.location;
|
7615 | }
|
7616 | const slide = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${index}"]`) : swiper.slides[index];
|
7617 | let value = slugify(slide.getAttribute('data-history'));
|
7618 | if (swiper.params.history.root.length > 0) {
|
7619 | let root = swiper.params.history.root;
|
7620 | if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
|
7621 | value = `${root}/${key ? `${key}/` : ''}${value}`;
|
7622 | } else if (!location.pathname.includes(key)) {
|
7623 | value = `${key ? `${key}/` : ''}${value}`;
|
7624 | }
|
7625 | if (swiper.params.history.keepQuery) {
|
7626 | value += location.search;
|
7627 | }
|
7628 | const currentState = window.history.state;
|
7629 | if (currentState && currentState.value === value) {
|
7630 | return;
|
7631 | }
|
7632 | if (swiper.params.history.replaceState) {
|
7633 | window.history.replaceState({
|
7634 | value
|
7635 | }, null, value);
|
7636 | } else {
|
7637 | window.history.pushState({
|
7638 | value
|
7639 | }, null, value);
|
7640 | }
|
7641 | };
|
7642 | const scrollToSlide = (speed, value, runCallbacks) => {
|
7643 | if (value) {
|
7644 | for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
|
7645 | const slide = swiper.slides[i];
|
7646 | const slideHistory = slugify(slide.getAttribute('data-history'));
|
7647 | if (slideHistory === value) {
|
7648 | const index = swiper.getSlideIndex(slide);
|
7649 | swiper.slideTo(index, speed, runCallbacks);
|
7650 | }
|
7651 | }
|
7652 | } else {
|
7653 | swiper.slideTo(0, speed, runCallbacks);
|
7654 | }
|
7655 | };
|
7656 | const setHistoryPopState = () => {
|
7657 | paths = getPathValues(swiper.params.url);
|
7658 | scrollToSlide(swiper.params.speed, paths.value, false);
|
7659 | };
|
7660 | const init = () => {
|
7661 | const window = getWindow();
|
7662 | if (!swiper.params.history) return;
|
7663 | if (!window.history || !window.history.pushState) {
|
7664 | swiper.params.history.enabled = false;
|
7665 | swiper.params.hashNavigation.enabled = true;
|
7666 | return;
|
7667 | }
|
7668 | initialized = true;
|
7669 | paths = getPathValues(swiper.params.url);
|
7670 | if (!paths.key && !paths.value) {
|
7671 | if (!swiper.params.history.replaceState) {
|
7672 | window.addEventListener('popstate', setHistoryPopState);
|
7673 | }
|
7674 | return;
|
7675 | }
|
7676 | scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
|
7677 | if (!swiper.params.history.replaceState) {
|
7678 | window.addEventListener('popstate', setHistoryPopState);
|
7679 | }
|
7680 | };
|
7681 | const destroy = () => {
|
7682 | const window = getWindow();
|
7683 | if (!swiper.params.history.replaceState) {
|
7684 | window.removeEventListener('popstate', setHistoryPopState);
|
7685 | }
|
7686 | };
|
7687 | on('init', () => {
|
7688 | if (swiper.params.history.enabled) {
|
7689 | init();
|
7690 | }
|
7691 | });
|
7692 | on('destroy', () => {
|
7693 | if (swiper.params.history.enabled) {
|
7694 | destroy();
|
7695 | }
|
7696 | });
|
7697 | on('transitionEnd _freeModeNoMomentumRelease', () => {
|
7698 | if (initialized) {
|
7699 | setHistory(swiper.params.history.key, swiper.activeIndex);
|
7700 | }
|
7701 | });
|
7702 | on('slideChange', () => {
|
7703 | if (initialized && swiper.params.cssMode) {
|
7704 | setHistory(swiper.params.history.key, swiper.activeIndex);
|
7705 | }
|
7706 | });
|
7707 | }
|
7708 |
|
7709 | function HashNavigation(_ref) {
|
7710 | let {
|
7711 | swiper,
|
7712 | extendParams,
|
7713 | emit,
|
7714 | on
|
7715 | } = _ref;
|
7716 | let initialized = false;
|
7717 | const document = getDocument();
|
7718 | const window = getWindow();
|
7719 | extendParams({
|
7720 | hashNavigation: {
|
7721 | enabled: false,
|
7722 | replaceState: false,
|
7723 | watchState: false,
|
7724 | getSlideIndex(_s, hash) {
|
7725 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
7726 | const slideWithHash = swiper.slides.filter(slideEl => slideEl.getAttribute('data-hash') === hash)[0];
|
7727 | if (!slideWithHash) return 0;
|
7728 | const index = parseInt(slideWithHash.getAttribute('data-swiper-slide-index'), 10);
|
7729 | return index;
|
7730 | }
|
7731 | return swiper.getSlideIndex(elementChildren(swiper.slidesEl, `.${swiper.params.slideClass}[data-hash="${hash}"], swiper-slide[data-hash="${hash}"]`)[0]);
|
7732 | }
|
7733 | }
|
7734 | });
|
7735 | const onHashChange = () => {
|
7736 | emit('hashChange');
|
7737 | const newHash = document.location.hash.replace('#', '');
|
7738 | const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
|
7739 | const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') : '';
|
7740 | if (newHash !== activeSlideHash) {
|
7741 | const newIndex = swiper.params.hashNavigation.getSlideIndex(swiper, newHash);
|
7742 | if (typeof newIndex === 'undefined' || Number.isNaN(newIndex)) return;
|
7743 | swiper.slideTo(newIndex);
|
7744 | }
|
7745 | };
|
7746 | const setHash = () => {
|
7747 | if (!initialized || !swiper.params.hashNavigation.enabled) return;
|
7748 | const activeSlideEl = swiper.virtual && swiper.params.virtual.enabled ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${swiper.activeIndex}"]`) : swiper.slides[swiper.activeIndex];
|
7749 | const activeSlideHash = activeSlideEl ? activeSlideEl.getAttribute('data-hash') || activeSlideEl.getAttribute('data-history') : '';
|
7750 | if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
|
7751 | window.history.replaceState(null, null, `#${activeSlideHash}` || '');
|
7752 | emit('hashSet');
|
7753 | } else {
|
7754 | document.location.hash = activeSlideHash || '';
|
7755 | emit('hashSet');
|
7756 | }
|
7757 | };
|
7758 | const init = () => {
|
7759 | if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
|
7760 | initialized = true;
|
7761 | const hash = document.location.hash.replace('#', '');
|
7762 | if (hash) {
|
7763 | const speed = 0;
|
7764 | const index = swiper.params.hashNavigation.getSlideIndex(swiper, hash);
|
7765 | swiper.slideTo(index || 0, speed, swiper.params.runCallbacksOnInit, true);
|
7766 | }
|
7767 | if (swiper.params.hashNavigation.watchState) {
|
7768 | window.addEventListener('hashchange', onHashChange);
|
7769 | }
|
7770 | };
|
7771 | const destroy = () => {
|
7772 | if (swiper.params.hashNavigation.watchState) {
|
7773 | window.removeEventListener('hashchange', onHashChange);
|
7774 | }
|
7775 | };
|
7776 | on('init', () => {
|
7777 | if (swiper.params.hashNavigation.enabled) {
|
7778 | init();
|
7779 | }
|
7780 | });
|
7781 | on('destroy', () => {
|
7782 | if (swiper.params.hashNavigation.enabled) {
|
7783 | destroy();
|
7784 | }
|
7785 | });
|
7786 | on('transitionEnd _freeModeNoMomentumRelease', () => {
|
7787 | if (initialized) {
|
7788 | setHash();
|
7789 | }
|
7790 | });
|
7791 | on('slideChange', () => {
|
7792 | if (initialized && swiper.params.cssMode) {
|
7793 | setHash();
|
7794 | }
|
7795 | });
|
7796 | }
|
7797 |
|
7798 |
|
7799 |
|
7800 | function Autoplay(_ref) {
|
7801 | let {
|
7802 | swiper,
|
7803 | extendParams,
|
7804 | on,
|
7805 | emit,
|
7806 | params
|
7807 | } = _ref;
|
7808 | swiper.autoplay = {
|
7809 | running: false,
|
7810 | paused: false,
|
7811 | timeLeft: 0
|
7812 | };
|
7813 | extendParams({
|
7814 | autoplay: {
|
7815 | enabled: false,
|
7816 | delay: 3000,
|
7817 | waitForTransition: true,
|
7818 | disableOnInteraction: false,
|
7819 | stopOnLastSlide: false,
|
7820 | reverseDirection: false,
|
7821 | pauseOnMouseEnter: false
|
7822 | }
|
7823 | });
|
7824 | let timeout;
|
7825 | let raf;
|
7826 | let autoplayDelayTotal = params && params.autoplay ? params.autoplay.delay : 3000;
|
7827 | let autoplayDelayCurrent = params && params.autoplay ? params.autoplay.delay : 3000;
|
7828 | let autoplayTimeLeft;
|
7829 | let autoplayStartTime = new Date().getTime();
|
7830 | let wasPaused;
|
7831 | let isTouched;
|
7832 | let pausedByTouch;
|
7833 | let touchStartTimeout;
|
7834 | let slideChanged;
|
7835 | let pausedByInteraction;
|
7836 | let pausedByPointerEnter;
|
7837 | function onTransitionEnd(e) {
|
7838 | if (!swiper || swiper.destroyed || !swiper.wrapperEl) return;
|
7839 | if (e.target !== swiper.wrapperEl) return;
|
7840 | swiper.wrapperEl.removeEventListener('transitionend', onTransitionEnd);
|
7841 | if (pausedByPointerEnter || e.detail && e.detail.bySwiperTouchMove) {
|
7842 | return;
|
7843 | }
|
7844 | resume();
|
7845 | }
|
7846 | const calcTimeLeft = () => {
|
7847 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
7848 | if (swiper.autoplay.paused) {
|
7849 | wasPaused = true;
|
7850 | } else if (wasPaused) {
|
7851 | autoplayDelayCurrent = autoplayTimeLeft;
|
7852 | wasPaused = false;
|
7853 | }
|
7854 | const timeLeft = swiper.autoplay.paused ? autoplayTimeLeft : autoplayStartTime + autoplayDelayCurrent - new Date().getTime();
|
7855 | swiper.autoplay.timeLeft = timeLeft;
|
7856 | emit('autoplayTimeLeft', timeLeft, timeLeft / autoplayDelayTotal);
|
7857 | raf = requestAnimationFrame(() => {
|
7858 | calcTimeLeft();
|
7859 | });
|
7860 | };
|
7861 | const getSlideDelay = () => {
|
7862 | let activeSlideEl;
|
7863 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
7864 | activeSlideEl = swiper.slides.filter(slideEl => slideEl.classList.contains('swiper-slide-active'))[0];
|
7865 | } else {
|
7866 | activeSlideEl = swiper.slides[swiper.activeIndex];
|
7867 | }
|
7868 | if (!activeSlideEl) return undefined;
|
7869 | const currentSlideDelay = parseInt(activeSlideEl.getAttribute('data-swiper-autoplay'), 10);
|
7870 | return currentSlideDelay;
|
7871 | };
|
7872 | const run = delayForce => {
|
7873 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
7874 | cancelAnimationFrame(raf);
|
7875 | calcTimeLeft();
|
7876 | let delay = typeof delayForce === 'undefined' ? swiper.params.autoplay.delay : delayForce;
|
7877 | autoplayDelayTotal = swiper.params.autoplay.delay;
|
7878 | autoplayDelayCurrent = swiper.params.autoplay.delay;
|
7879 | const currentSlideDelay = getSlideDelay();
|
7880 | if (!Number.isNaN(currentSlideDelay) && currentSlideDelay > 0 && typeof delayForce === 'undefined') {
|
7881 | delay = currentSlideDelay;
|
7882 | autoplayDelayTotal = currentSlideDelay;
|
7883 | autoplayDelayCurrent = currentSlideDelay;
|
7884 | }
|
7885 | autoplayTimeLeft = delay;
|
7886 | const speed = swiper.params.speed;
|
7887 | const proceed = () => {
|
7888 | if (!swiper || swiper.destroyed) return;
|
7889 | if (swiper.params.autoplay.reverseDirection) {
|
7890 | if (!swiper.isBeginning || swiper.params.loop || swiper.params.rewind) {
|
7891 | swiper.slidePrev(speed, true, true);
|
7892 | emit('autoplay');
|
7893 | } else if (!swiper.params.autoplay.stopOnLastSlide) {
|
7894 | swiper.slideTo(swiper.slides.length - 1, speed, true, true);
|
7895 | emit('autoplay');
|
7896 | }
|
7897 | } else {
|
7898 | if (!swiper.isEnd || swiper.params.loop || swiper.params.rewind) {
|
7899 | swiper.slideNext(speed, true, true);
|
7900 | emit('autoplay');
|
7901 | } else if (!swiper.params.autoplay.stopOnLastSlide) {
|
7902 | swiper.slideTo(0, speed, true, true);
|
7903 | emit('autoplay');
|
7904 | }
|
7905 | }
|
7906 | if (swiper.params.cssMode) {
|
7907 | autoplayStartTime = new Date().getTime();
|
7908 | requestAnimationFrame(() => {
|
7909 | run();
|
7910 | });
|
7911 | }
|
7912 | };
|
7913 | if (delay > 0) {
|
7914 | clearTimeout(timeout);
|
7915 | timeout = setTimeout(() => {
|
7916 | proceed();
|
7917 | }, delay);
|
7918 | } else {
|
7919 | requestAnimationFrame(() => {
|
7920 | proceed();
|
7921 | });
|
7922 | }
|
7923 |
|
7924 |
|
7925 | return delay;
|
7926 | };
|
7927 | const start = () => {
|
7928 | autoplayStartTime = new Date().getTime();
|
7929 | swiper.autoplay.running = true;
|
7930 | run();
|
7931 | emit('autoplayStart');
|
7932 | };
|
7933 | const stop = () => {
|
7934 | swiper.autoplay.running = false;
|
7935 | clearTimeout(timeout);
|
7936 | cancelAnimationFrame(raf);
|
7937 | emit('autoplayStop');
|
7938 | };
|
7939 | const pause = (internal, reset) => {
|
7940 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
7941 | clearTimeout(timeout);
|
7942 | if (!internal) {
|
7943 | pausedByInteraction = true;
|
7944 | }
|
7945 | const proceed = () => {
|
7946 | emit('autoplayPause');
|
7947 | if (swiper.params.autoplay.waitForTransition) {
|
7948 | swiper.wrapperEl.addEventListener('transitionend', onTransitionEnd);
|
7949 | } else {
|
7950 | resume();
|
7951 | }
|
7952 | };
|
7953 | swiper.autoplay.paused = true;
|
7954 | if (reset) {
|
7955 | if (slideChanged) {
|
7956 | autoplayTimeLeft = swiper.params.autoplay.delay;
|
7957 | }
|
7958 | slideChanged = false;
|
7959 | proceed();
|
7960 | return;
|
7961 | }
|
7962 | const delay = autoplayTimeLeft || swiper.params.autoplay.delay;
|
7963 | autoplayTimeLeft = delay - (new Date().getTime() - autoplayStartTime);
|
7964 | if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop) return;
|
7965 | if (autoplayTimeLeft < 0) autoplayTimeLeft = 0;
|
7966 | proceed();
|
7967 | };
|
7968 | const resume = () => {
|
7969 | if (swiper.isEnd && autoplayTimeLeft < 0 && !swiper.params.loop || swiper.destroyed || !swiper.autoplay.running) return;
|
7970 | autoplayStartTime = new Date().getTime();
|
7971 | if (pausedByInteraction) {
|
7972 | pausedByInteraction = false;
|
7973 | run(autoplayTimeLeft);
|
7974 | } else {
|
7975 | run();
|
7976 | }
|
7977 | swiper.autoplay.paused = false;
|
7978 | emit('autoplayResume');
|
7979 | };
|
7980 | const onVisibilityChange = () => {
|
7981 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
7982 | const document = getDocument();
|
7983 | if (document.visibilityState === 'hidden') {
|
7984 | pausedByInteraction = true;
|
7985 | pause(true);
|
7986 | }
|
7987 | if (document.visibilityState === 'visible') {
|
7988 | resume();
|
7989 | }
|
7990 | };
|
7991 | const onPointerEnter = e => {
|
7992 | if (e.pointerType !== 'mouse') return;
|
7993 | pausedByInteraction = true;
|
7994 | pausedByPointerEnter = true;
|
7995 | if (swiper.animating || swiper.autoplay.paused) return;
|
7996 | pause(true);
|
7997 | };
|
7998 | const onPointerLeave = e => {
|
7999 | if (e.pointerType !== 'mouse') return;
|
8000 | pausedByPointerEnter = false;
|
8001 | if (swiper.autoplay.paused) {
|
8002 | resume();
|
8003 | }
|
8004 | };
|
8005 | const attachMouseEvents = () => {
|
8006 | if (swiper.params.autoplay.pauseOnMouseEnter) {
|
8007 | swiper.el.addEventListener('pointerenter', onPointerEnter);
|
8008 | swiper.el.addEventListener('pointerleave', onPointerLeave);
|
8009 | }
|
8010 | };
|
8011 | const detachMouseEvents = () => {
|
8012 | if (swiper.el && typeof swiper.el !== 'string') {
|
8013 | swiper.el.removeEventListener('pointerenter', onPointerEnter);
|
8014 | swiper.el.removeEventListener('pointerleave', onPointerLeave);
|
8015 | }
|
8016 | };
|
8017 | const attachDocumentEvents = () => {
|
8018 | const document = getDocument();
|
8019 | document.addEventListener('visibilitychange', onVisibilityChange);
|
8020 | };
|
8021 | const detachDocumentEvents = () => {
|
8022 | const document = getDocument();
|
8023 | document.removeEventListener('visibilitychange', onVisibilityChange);
|
8024 | };
|
8025 | on('init', () => {
|
8026 | if (swiper.params.autoplay.enabled) {
|
8027 | attachMouseEvents();
|
8028 | attachDocumentEvents();
|
8029 | start();
|
8030 | }
|
8031 | });
|
8032 | on('destroy', () => {
|
8033 | detachMouseEvents();
|
8034 | detachDocumentEvents();
|
8035 | if (swiper.autoplay.running) {
|
8036 | stop();
|
8037 | }
|
8038 | });
|
8039 | on('_freeModeStaticRelease', () => {
|
8040 | if (pausedByTouch || pausedByInteraction) {
|
8041 | resume();
|
8042 | }
|
8043 | });
|
8044 | on('_freeModeNoMomentumRelease', () => {
|
8045 | if (!swiper.params.autoplay.disableOnInteraction) {
|
8046 | pause(true, true);
|
8047 | } else {
|
8048 | stop();
|
8049 | }
|
8050 | });
|
8051 | on('beforeTransitionStart', (_s, speed, internal) => {
|
8052 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
8053 | if (internal || !swiper.params.autoplay.disableOnInteraction) {
|
8054 | pause(true, true);
|
8055 | } else {
|
8056 | stop();
|
8057 | }
|
8058 | });
|
8059 | on('sliderFirstMove', () => {
|
8060 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
8061 | if (swiper.params.autoplay.disableOnInteraction) {
|
8062 | stop();
|
8063 | return;
|
8064 | }
|
8065 | isTouched = true;
|
8066 | pausedByTouch = false;
|
8067 | pausedByInteraction = false;
|
8068 | touchStartTimeout = setTimeout(() => {
|
8069 | pausedByInteraction = true;
|
8070 | pausedByTouch = true;
|
8071 | pause(true);
|
8072 | }, 200);
|
8073 | });
|
8074 | on('touchEnd', () => {
|
8075 | if (swiper.destroyed || !swiper.autoplay.running || !isTouched) return;
|
8076 | clearTimeout(touchStartTimeout);
|
8077 | clearTimeout(timeout);
|
8078 | if (swiper.params.autoplay.disableOnInteraction) {
|
8079 | pausedByTouch = false;
|
8080 | isTouched = false;
|
8081 | return;
|
8082 | }
|
8083 | if (pausedByTouch && swiper.params.cssMode) resume();
|
8084 | pausedByTouch = false;
|
8085 | isTouched = false;
|
8086 | });
|
8087 | on('slideChange', () => {
|
8088 | if (swiper.destroyed || !swiper.autoplay.running) return;
|
8089 | slideChanged = true;
|
8090 | });
|
8091 | Object.assign(swiper.autoplay, {
|
8092 | start,
|
8093 | stop,
|
8094 | pause,
|
8095 | resume
|
8096 | });
|
8097 | }
|
8098 |
|
8099 | function Thumb(_ref) {
|
8100 | let {
|
8101 | swiper,
|
8102 | extendParams,
|
8103 | on
|
8104 | } = _ref;
|
8105 | extendParams({
|
8106 | thumbs: {
|
8107 | swiper: null,
|
8108 | multipleActiveThumbs: true,
|
8109 | autoScrollOffset: 0,
|
8110 | slideThumbActiveClass: 'swiper-slide-thumb-active',
|
8111 | thumbsContainerClass: 'swiper-thumbs'
|
8112 | }
|
8113 | });
|
8114 | let initialized = false;
|
8115 | let swiperCreated = false;
|
8116 | swiper.thumbs = {
|
8117 | swiper: null
|
8118 | };
|
8119 | function onThumbClick() {
|
8120 | const thumbsSwiper = swiper.thumbs.swiper;
|
8121 | if (!thumbsSwiper || thumbsSwiper.destroyed) return;
|
8122 | const clickedIndex = thumbsSwiper.clickedIndex;
|
8123 | const clickedSlide = thumbsSwiper.clickedSlide;
|
8124 | if (clickedSlide && clickedSlide.classList.contains(swiper.params.thumbs.slideThumbActiveClass)) return;
|
8125 | if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
|
8126 | let slideToIndex;
|
8127 | if (thumbsSwiper.params.loop) {
|
8128 | slideToIndex = parseInt(thumbsSwiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
8129 | } else {
|
8130 | slideToIndex = clickedIndex;
|
8131 | }
|
8132 | if (swiper.params.loop) {
|
8133 | swiper.slideToLoop(slideToIndex);
|
8134 | } else {
|
8135 | swiper.slideTo(slideToIndex);
|
8136 | }
|
8137 | }
|
8138 | function init() {
|
8139 | const {
|
8140 | thumbs: thumbsParams
|
8141 | } = swiper.params;
|
8142 | if (initialized) return false;
|
8143 | initialized = true;
|
8144 | const SwiperClass = swiper.constructor;
|
8145 | if (thumbsParams.swiper instanceof SwiperClass) {
|
8146 | swiper.thumbs.swiper = thumbsParams.swiper;
|
8147 | Object.assign(swiper.thumbs.swiper.originalParams, {
|
8148 | watchSlidesProgress: true,
|
8149 | slideToClickedSlide: false
|
8150 | });
|
8151 | Object.assign(swiper.thumbs.swiper.params, {
|
8152 | watchSlidesProgress: true,
|
8153 | slideToClickedSlide: false
|
8154 | });
|
8155 | swiper.thumbs.swiper.update();
|
8156 | } else if (isObject$1(thumbsParams.swiper)) {
|
8157 | const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
|
8158 | Object.assign(thumbsSwiperParams, {
|
8159 | watchSlidesProgress: true,
|
8160 | slideToClickedSlide: false
|
8161 | });
|
8162 | swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
|
8163 | swiperCreated = true;
|
8164 | }
|
8165 | swiper.thumbs.swiper.el.classList.add(swiper.params.thumbs.thumbsContainerClass);
|
8166 | swiper.thumbs.swiper.on('tap', onThumbClick);
|
8167 | return true;
|
8168 | }
|
8169 | function update(initial) {
|
8170 | const thumbsSwiper = swiper.thumbs.swiper;
|
8171 | if (!thumbsSwiper || thumbsSwiper.destroyed) return;
|
8172 | const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView;
|
8173 |
|
8174 |
|
8175 | let thumbsToActivate = 1;
|
8176 | const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
|
8177 | if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
|
8178 | thumbsToActivate = swiper.params.slidesPerView;
|
8179 | }
|
8180 | if (!swiper.params.thumbs.multipleActiveThumbs) {
|
8181 | thumbsToActivate = 1;
|
8182 | }
|
8183 | thumbsToActivate = Math.floor(thumbsToActivate);
|
8184 | thumbsSwiper.slides.forEach(slideEl => slideEl.classList.remove(thumbActiveClass));
|
8185 | if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
|
8186 | for (let i = 0; i < thumbsToActivate; i += 1) {
|
8187 | elementChildren(thumbsSwiper.slidesEl, `[data-swiper-slide-index="${swiper.realIndex + i}"]`).forEach(slideEl => {
|
8188 | slideEl.classList.add(thumbActiveClass);
|
8189 | });
|
8190 | }
|
8191 | } else {
|
8192 | for (let i = 0; i < thumbsToActivate; i += 1) {
|
8193 | if (thumbsSwiper.slides[swiper.realIndex + i]) {
|
8194 | thumbsSwiper.slides[swiper.realIndex + i].classList.add(thumbActiveClass);
|
8195 | }
|
8196 | }
|
8197 | }
|
8198 | const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
|
8199 | const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
|
8200 | if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
|
8201 | const currentThumbsIndex = thumbsSwiper.activeIndex;
|
8202 | let newThumbsIndex;
|
8203 | let direction;
|
8204 | if (thumbsSwiper.params.loop) {
|
8205 | const newThumbsSlide = thumbsSwiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') === `${swiper.realIndex}`)[0];
|
8206 | newThumbsIndex = thumbsSwiper.slides.indexOf(newThumbsSlide);
|
8207 | direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
|
8208 | } else {
|
8209 | newThumbsIndex = swiper.realIndex;
|
8210 | direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
|
8211 | }
|
8212 | if (useOffset) {
|
8213 | newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
|
8214 | }
|
8215 | if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
|
8216 | if (thumbsSwiper.params.centeredSlides) {
|
8217 | if (newThumbsIndex > currentThumbsIndex) {
|
8218 | newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
|
8219 | } else {
|
8220 | newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
|
8221 | }
|
8222 | } else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
|
8223 | thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
|
8224 | }
|
8225 | }
|
8226 | }
|
8227 | on('beforeInit', () => {
|
8228 | const {
|
8229 | thumbs
|
8230 | } = swiper.params;
|
8231 | if (!thumbs || !thumbs.swiper) return;
|
8232 | if (typeof thumbs.swiper === 'string' || thumbs.swiper instanceof HTMLElement) {
|
8233 | const document = getDocument();
|
8234 | const getThumbsElementAndInit = () => {
|
8235 | const thumbsElement = typeof thumbs.swiper === 'string' ? document.querySelector(thumbs.swiper) : thumbs.swiper;
|
8236 | if (thumbsElement && thumbsElement.swiper) {
|
8237 | thumbs.swiper = thumbsElement.swiper;
|
8238 | init();
|
8239 | update(true);
|
8240 | } else if (thumbsElement) {
|
8241 | const eventName = `${swiper.params.eventsPrefix}init`;
|
8242 | const onThumbsSwiper = e => {
|
8243 | thumbs.swiper = e.detail[0];
|
8244 | thumbsElement.removeEventListener(eventName, onThumbsSwiper);
|
8245 | init();
|
8246 | update(true);
|
8247 | thumbs.swiper.update();
|
8248 | swiper.update();
|
8249 | };
|
8250 | thumbsElement.addEventListener(eventName, onThumbsSwiper);
|
8251 | }
|
8252 | return thumbsElement;
|
8253 | };
|
8254 | const watchForThumbsToAppear = () => {
|
8255 | if (swiper.destroyed) return;
|
8256 | const thumbsElement = getThumbsElementAndInit();
|
8257 | if (!thumbsElement) {
|
8258 | requestAnimationFrame(watchForThumbsToAppear);
|
8259 | }
|
8260 | };
|
8261 | requestAnimationFrame(watchForThumbsToAppear);
|
8262 | } else {
|
8263 | init();
|
8264 | update(true);
|
8265 | }
|
8266 | });
|
8267 | on('slideChange update resize observerUpdate', () => {
|
8268 | update();
|
8269 | });
|
8270 | on('setTransition', (_s, duration) => {
|
8271 | const thumbsSwiper = swiper.thumbs.swiper;
|
8272 | if (!thumbsSwiper || thumbsSwiper.destroyed) return;
|
8273 | thumbsSwiper.setTransition(duration);
|
8274 | });
|
8275 | on('beforeDestroy', () => {
|
8276 | const thumbsSwiper = swiper.thumbs.swiper;
|
8277 | if (!thumbsSwiper || thumbsSwiper.destroyed) return;
|
8278 | if (swiperCreated) {
|
8279 | thumbsSwiper.destroy();
|
8280 | }
|
8281 | });
|
8282 | Object.assign(swiper.thumbs, {
|
8283 | init,
|
8284 | update
|
8285 | });
|
8286 | }
|
8287 |
|
8288 | function freeMode(_ref) {
|
8289 | let {
|
8290 | swiper,
|
8291 | extendParams,
|
8292 | emit,
|
8293 | once
|
8294 | } = _ref;
|
8295 | extendParams({
|
8296 | freeMode: {
|
8297 | enabled: false,
|
8298 | momentum: true,
|
8299 | momentumRatio: 1,
|
8300 | momentumBounce: true,
|
8301 | momentumBounceRatio: 1,
|
8302 | momentumVelocityRatio: 1,
|
8303 | sticky: false,
|
8304 | minimumVelocity: 0.02
|
8305 | }
|
8306 | });
|
8307 | function onTouchStart() {
|
8308 | if (swiper.params.cssMode) return;
|
8309 | const translate = swiper.getTranslate();
|
8310 | swiper.setTranslate(translate);
|
8311 | swiper.setTransition(0);
|
8312 | swiper.touchEventsData.velocities.length = 0;
|
8313 | swiper.freeMode.onTouchEnd({
|
8314 | currentPos: swiper.rtl ? swiper.translate : -swiper.translate
|
8315 | });
|
8316 | }
|
8317 | function onTouchMove() {
|
8318 | if (swiper.params.cssMode) return;
|
8319 | const {
|
8320 | touchEventsData: data,
|
8321 | touches
|
8322 | } = swiper;
|
8323 |
|
8324 | if (data.velocities.length === 0) {
|
8325 | data.velocities.push({
|
8326 | position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
|
8327 | time: data.touchStartTime
|
8328 | });
|
8329 | }
|
8330 | data.velocities.push({
|
8331 | position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
|
8332 | time: now()
|
8333 | });
|
8334 | }
|
8335 | function onTouchEnd(_ref2) {
|
8336 | let {
|
8337 | currentPos
|
8338 | } = _ref2;
|
8339 | if (swiper.params.cssMode) return;
|
8340 | const {
|
8341 | params,
|
8342 | wrapperEl,
|
8343 | rtlTranslate: rtl,
|
8344 | snapGrid,
|
8345 | touchEventsData: data
|
8346 | } = swiper;
|
8347 |
|
8348 | const touchEndTime = now();
|
8349 | const timeDiff = touchEndTime - data.touchStartTime;
|
8350 | if (currentPos < -swiper.minTranslate()) {
|
8351 | swiper.slideTo(swiper.activeIndex);
|
8352 | return;
|
8353 | }
|
8354 | if (currentPos > -swiper.maxTranslate()) {
|
8355 | if (swiper.slides.length < snapGrid.length) {
|
8356 | swiper.slideTo(snapGrid.length - 1);
|
8357 | } else {
|
8358 | swiper.slideTo(swiper.slides.length - 1);
|
8359 | }
|
8360 | return;
|
8361 | }
|
8362 | if (params.freeMode.momentum) {
|
8363 | if (data.velocities.length > 1) {
|
8364 | const lastMoveEvent = data.velocities.pop();
|
8365 | const velocityEvent = data.velocities.pop();
|
8366 | const distance = lastMoveEvent.position - velocityEvent.position;
|
8367 | const time = lastMoveEvent.time - velocityEvent.time;
|
8368 | swiper.velocity = distance / time;
|
8369 | swiper.velocity /= 2;
|
8370 | if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
|
8371 | swiper.velocity = 0;
|
8372 | }
|
8373 |
|
8374 |
|
8375 | if (time > 150 || now() - lastMoveEvent.time > 300) {
|
8376 | swiper.velocity = 0;
|
8377 | }
|
8378 | } else {
|
8379 | swiper.velocity = 0;
|
8380 | }
|
8381 | swiper.velocity *= params.freeMode.momentumVelocityRatio;
|
8382 | data.velocities.length = 0;
|
8383 | let momentumDuration = 1000 * params.freeMode.momentumRatio;
|
8384 | const momentumDistance = swiper.velocity * momentumDuration;
|
8385 | let newPosition = swiper.translate + momentumDistance;
|
8386 | if (rtl) newPosition = -newPosition;
|
8387 | let doBounce = false;
|
8388 | let afterBouncePosition;
|
8389 | const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
|
8390 | let needsLoopFix;
|
8391 | if (newPosition < swiper.maxTranslate()) {
|
8392 | if (params.freeMode.momentumBounce) {
|
8393 | if (newPosition + swiper.maxTranslate() < -bounceAmount) {
|
8394 | newPosition = swiper.maxTranslate() - bounceAmount;
|
8395 | }
|
8396 | afterBouncePosition = swiper.maxTranslate();
|
8397 | doBounce = true;
|
8398 | data.allowMomentumBounce = true;
|
8399 | } else {
|
8400 | newPosition = swiper.maxTranslate();
|
8401 | }
|
8402 | if (params.loop && params.centeredSlides) needsLoopFix = true;
|
8403 | } else if (newPosition > swiper.minTranslate()) {
|
8404 | if (params.freeMode.momentumBounce) {
|
8405 | if (newPosition - swiper.minTranslate() > bounceAmount) {
|
8406 | newPosition = swiper.minTranslate() + bounceAmount;
|
8407 | }
|
8408 | afterBouncePosition = swiper.minTranslate();
|
8409 | doBounce = true;
|
8410 | data.allowMomentumBounce = true;
|
8411 | } else {
|
8412 | newPosition = swiper.minTranslate();
|
8413 | }
|
8414 | if (params.loop && params.centeredSlides) needsLoopFix = true;
|
8415 | } else if (params.freeMode.sticky) {
|
8416 | let nextSlide;
|
8417 | for (let j = 0; j < snapGrid.length; j += 1) {
|
8418 | if (snapGrid[j] > -newPosition) {
|
8419 | nextSlide = j;
|
8420 | break;
|
8421 | }
|
8422 | }
|
8423 | if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
|
8424 | newPosition = snapGrid[nextSlide];
|
8425 | } else {
|
8426 | newPosition = snapGrid[nextSlide - 1];
|
8427 | }
|
8428 | newPosition = -newPosition;
|
8429 | }
|
8430 | if (needsLoopFix) {
|
8431 | once('transitionEnd', () => {
|
8432 | swiper.loopFix();
|
8433 | });
|
8434 | }
|
8435 |
|
8436 | if (swiper.velocity !== 0) {
|
8437 | if (rtl) {
|
8438 | momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
|
8439 | } else {
|
8440 | momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
|
8441 | }
|
8442 | if (params.freeMode.sticky) {
|
8443 |
|
8444 |
|
8445 |
|
8446 |
|
8447 |
|
8448 |
|
8449 |
|
8450 | const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
|
8451 | const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
|
8452 | if (moveDistance < currentSlideSize) {
|
8453 | momentumDuration = params.speed;
|
8454 | } else if (moveDistance < 2 * currentSlideSize) {
|
8455 | momentumDuration = params.speed * 1.5;
|
8456 | } else {
|
8457 | momentumDuration = params.speed * 2.5;
|
8458 | }
|
8459 | }
|
8460 | } else if (params.freeMode.sticky) {
|
8461 | swiper.slideToClosest();
|
8462 | return;
|
8463 | }
|
8464 | if (params.freeMode.momentumBounce && doBounce) {
|
8465 | swiper.updateProgress(afterBouncePosition);
|
8466 | swiper.setTransition(momentumDuration);
|
8467 | swiper.setTranslate(newPosition);
|
8468 | swiper.transitionStart(true, swiper.swipeDirection);
|
8469 | swiper.animating = true;
|
8470 | elementTransitionEnd(wrapperEl, () => {
|
8471 | if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
|
8472 | emit('momentumBounce');
|
8473 | swiper.setTransition(params.speed);
|
8474 | setTimeout(() => {
|
8475 | swiper.setTranslate(afterBouncePosition);
|
8476 | elementTransitionEnd(wrapperEl, () => {
|
8477 | if (!swiper || swiper.destroyed) return;
|
8478 | swiper.transitionEnd();
|
8479 | });
|
8480 | }, 0);
|
8481 | });
|
8482 | } else if (swiper.velocity) {
|
8483 | emit('_freeModeNoMomentumRelease');
|
8484 | swiper.updateProgress(newPosition);
|
8485 | swiper.setTransition(momentumDuration);
|
8486 | swiper.setTranslate(newPosition);
|
8487 | swiper.transitionStart(true, swiper.swipeDirection);
|
8488 | if (!swiper.animating) {
|
8489 | swiper.animating = true;
|
8490 | elementTransitionEnd(wrapperEl, () => {
|
8491 | if (!swiper || swiper.destroyed) return;
|
8492 | swiper.transitionEnd();
|
8493 | });
|
8494 | }
|
8495 | } else {
|
8496 | swiper.updateProgress(newPosition);
|
8497 | }
|
8498 | swiper.updateActiveIndex();
|
8499 | swiper.updateSlidesClasses();
|
8500 | } else if (params.freeMode.sticky) {
|
8501 | swiper.slideToClosest();
|
8502 | return;
|
8503 | } else if (params.freeMode) {
|
8504 | emit('_freeModeNoMomentumRelease');
|
8505 | }
|
8506 | if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
|
8507 | emit('_freeModeStaticRelease');
|
8508 | swiper.updateProgress();
|
8509 | swiper.updateActiveIndex();
|
8510 | swiper.updateSlidesClasses();
|
8511 | }
|
8512 | }
|
8513 | Object.assign(swiper, {
|
8514 | freeMode: {
|
8515 | onTouchStart,
|
8516 | onTouchMove,
|
8517 | onTouchEnd
|
8518 | }
|
8519 | });
|
8520 | }
|
8521 |
|
8522 | function Grid(_ref) {
|
8523 | let {
|
8524 | swiper,
|
8525 | extendParams,
|
8526 | on
|
8527 | } = _ref;
|
8528 | extendParams({
|
8529 | grid: {
|
8530 | rows: 1,
|
8531 | fill: 'column'
|
8532 | }
|
8533 | });
|
8534 | let slidesNumberEvenToRows;
|
8535 | let slidesPerRow;
|
8536 | let numFullColumns;
|
8537 | let wasMultiRow;
|
8538 | const getSpaceBetween = () => {
|
8539 | let spaceBetween = swiper.params.spaceBetween;
|
8540 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
8541 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiper.size;
|
8542 | } else if (typeof spaceBetween === 'string') {
|
8543 | spaceBetween = parseFloat(spaceBetween);
|
8544 | }
|
8545 | return spaceBetween;
|
8546 | };
|
8547 | const initSlides = slides => {
|
8548 | const {
|
8549 | slidesPerView
|
8550 | } = swiper.params;
|
8551 | const {
|
8552 | rows,
|
8553 | fill
|
8554 | } = swiper.params.grid;
|
8555 | const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
|
8556 | numFullColumns = Math.floor(slidesLength / rows);
|
8557 | if (Math.floor(slidesLength / rows) === slidesLength / rows) {
|
8558 | slidesNumberEvenToRows = slidesLength;
|
8559 | } else {
|
8560 | slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
|
8561 | }
|
8562 | if (slidesPerView !== 'auto' && fill === 'row') {
|
8563 | slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
|
8564 | }
|
8565 | slidesPerRow = slidesNumberEvenToRows / rows;
|
8566 | };
|
8567 | const unsetSlides = () => {
|
8568 | if (swiper.slides) {
|
8569 | swiper.slides.forEach(slide => {
|
8570 | if (slide.swiperSlideGridSet) {
|
8571 | slide.style.height = '';
|
8572 | slide.style[swiper.getDirectionLabel('margin-top')] = '';
|
8573 | }
|
8574 | });
|
8575 | }
|
8576 | };
|
8577 | const updateSlide = (i, slide, slides) => {
|
8578 | const {
|
8579 | slidesPerGroup
|
8580 | } = swiper.params;
|
8581 | const spaceBetween = getSpaceBetween();
|
8582 | const {
|
8583 | rows,
|
8584 | fill
|
8585 | } = swiper.params.grid;
|
8586 | const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : slides.length;
|
8587 |
|
8588 | let newSlideOrderIndex;
|
8589 | let column;
|
8590 | let row;
|
8591 | if (fill === 'row' && slidesPerGroup > 1) {
|
8592 | const groupIndex = Math.floor(i / (slidesPerGroup * rows));
|
8593 | const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
|
8594 | const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
|
8595 | row = Math.floor(slideIndexInGroup / columnsInGroup);
|
8596 | column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
|
8597 | newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
|
8598 | slide.style.order = newSlideOrderIndex;
|
8599 | } else if (fill === 'column') {
|
8600 | column = Math.floor(i / rows);
|
8601 | row = i - column * rows;
|
8602 | if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
|
8603 | row += 1;
|
8604 | if (row >= rows) {
|
8605 | row = 0;
|
8606 | column += 1;
|
8607 | }
|
8608 | }
|
8609 | } else {
|
8610 | row = Math.floor(i / slidesPerRow);
|
8611 | column = i - row * slidesPerRow;
|
8612 | }
|
8613 | slide.row = row;
|
8614 | slide.column = column;
|
8615 | slide.style.height = `calc((100% - ${(rows - 1) * spaceBetween}px) / ${rows})`;
|
8616 | slide.style[swiper.getDirectionLabel('margin-top')] = row !== 0 ? spaceBetween && `${spaceBetween}px` : '';
|
8617 | slide.swiperSlideGridSet = true;
|
8618 | };
|
8619 | const updateWrapperSize = (slideSize, snapGrid) => {
|
8620 | const {
|
8621 | centeredSlides,
|
8622 | roundLengths
|
8623 | } = swiper.params;
|
8624 | const spaceBetween = getSpaceBetween();
|
8625 | const {
|
8626 | rows
|
8627 | } = swiper.params.grid;
|
8628 | swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
|
8629 | swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
|
8630 | if (!swiper.params.cssMode) {
|
8631 | swiper.wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
|
8632 | }
|
8633 | if (centeredSlides) {
|
8634 | const newSlidesGrid = [];
|
8635 | for (let i = 0; i < snapGrid.length; i += 1) {
|
8636 | let slidesGridItem = snapGrid[i];
|
8637 | if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
8638 | if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
|
8639 | }
|
8640 | snapGrid.splice(0, snapGrid.length);
|
8641 | snapGrid.push(...newSlidesGrid);
|
8642 | }
|
8643 | };
|
8644 | const onInit = () => {
|
8645 | wasMultiRow = swiper.params.grid && swiper.params.grid.rows > 1;
|
8646 | };
|
8647 | const onUpdate = () => {
|
8648 | const {
|
8649 | params,
|
8650 | el
|
8651 | } = swiper;
|
8652 | const isMultiRow = params.grid && params.grid.rows > 1;
|
8653 | if (wasMultiRow && !isMultiRow) {
|
8654 | el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
8655 | numFullColumns = 1;
|
8656 | swiper.emitContainerClasses();
|
8657 | } else if (!wasMultiRow && isMultiRow) {
|
8658 | el.classList.add(`${params.containerModifierClass}grid`);
|
8659 | if (params.grid.fill === 'column') {
|
8660 | el.classList.add(`${params.containerModifierClass}grid-column`);
|
8661 | }
|
8662 | swiper.emitContainerClasses();
|
8663 | }
|
8664 | wasMultiRow = isMultiRow;
|
8665 | };
|
8666 | on('init', onInit);
|
8667 | on('update', onUpdate);
|
8668 | swiper.grid = {
|
8669 | initSlides,
|
8670 | unsetSlides,
|
8671 | updateSlide,
|
8672 | updateWrapperSize
|
8673 | };
|
8674 | }
|
8675 |
|
8676 | function appendSlide(slides) {
|
8677 | const swiper = this;
|
8678 | const {
|
8679 | params,
|
8680 | slidesEl
|
8681 | } = swiper;
|
8682 | if (params.loop) {
|
8683 | swiper.loopDestroy();
|
8684 | }
|
8685 | const appendElement = slideEl => {
|
8686 | if (typeof slideEl === 'string') {
|
8687 | const tempDOM = document.createElement('div');
|
8688 | tempDOM.innerHTML = slideEl;
|
8689 | slidesEl.append(tempDOM.children[0]);
|
8690 | tempDOM.innerHTML = '';
|
8691 | } else {
|
8692 | slidesEl.append(slideEl);
|
8693 | }
|
8694 | };
|
8695 | if (typeof slides === 'object' && 'length' in slides) {
|
8696 | for (let i = 0; i < slides.length; i += 1) {
|
8697 | if (slides[i]) appendElement(slides[i]);
|
8698 | }
|
8699 | } else {
|
8700 | appendElement(slides);
|
8701 | }
|
8702 | swiper.recalcSlides();
|
8703 | if (params.loop) {
|
8704 | swiper.loopCreate();
|
8705 | }
|
8706 | if (!params.observer || swiper.isElement) {
|
8707 | swiper.update();
|
8708 | }
|
8709 | }
|
8710 |
|
8711 | function prependSlide(slides) {
|
8712 | const swiper = this;
|
8713 | const {
|
8714 | params,
|
8715 | activeIndex,
|
8716 | slidesEl
|
8717 | } = swiper;
|
8718 | if (params.loop) {
|
8719 | swiper.loopDestroy();
|
8720 | }
|
8721 | let newActiveIndex = activeIndex + 1;
|
8722 | const prependElement = slideEl => {
|
8723 | if (typeof slideEl === 'string') {
|
8724 | const tempDOM = document.createElement('div');
|
8725 | tempDOM.innerHTML = slideEl;
|
8726 | slidesEl.prepend(tempDOM.children[0]);
|
8727 | tempDOM.innerHTML = '';
|
8728 | } else {
|
8729 | slidesEl.prepend(slideEl);
|
8730 | }
|
8731 | };
|
8732 | if (typeof slides === 'object' && 'length' in slides) {
|
8733 | for (let i = 0; i < slides.length; i += 1) {
|
8734 | if (slides[i]) prependElement(slides[i]);
|
8735 | }
|
8736 | newActiveIndex = activeIndex + slides.length;
|
8737 | } else {
|
8738 | prependElement(slides);
|
8739 | }
|
8740 | swiper.recalcSlides();
|
8741 | if (params.loop) {
|
8742 | swiper.loopCreate();
|
8743 | }
|
8744 | if (!params.observer || swiper.isElement) {
|
8745 | swiper.update();
|
8746 | }
|
8747 | swiper.slideTo(newActiveIndex, 0, false);
|
8748 | }
|
8749 |
|
8750 | function addSlide(index, slides) {
|
8751 | const swiper = this;
|
8752 | const {
|
8753 | params,
|
8754 | activeIndex,
|
8755 | slidesEl
|
8756 | } = swiper;
|
8757 | let activeIndexBuffer = activeIndex;
|
8758 | if (params.loop) {
|
8759 | activeIndexBuffer -= swiper.loopedSlides;
|
8760 | swiper.loopDestroy();
|
8761 | swiper.recalcSlides();
|
8762 | }
|
8763 | const baseLength = swiper.slides.length;
|
8764 | if (index <= 0) {
|
8765 | swiper.prependSlide(slides);
|
8766 | return;
|
8767 | }
|
8768 | if (index >= baseLength) {
|
8769 | swiper.appendSlide(slides);
|
8770 | return;
|
8771 | }
|
8772 | let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
|
8773 | const slidesBuffer = [];
|
8774 | for (let i = baseLength - 1; i >= index; i -= 1) {
|
8775 | const currentSlide = swiper.slides[i];
|
8776 | currentSlide.remove();
|
8777 | slidesBuffer.unshift(currentSlide);
|
8778 | }
|
8779 | if (typeof slides === 'object' && 'length' in slides) {
|
8780 | for (let i = 0; i < slides.length; i += 1) {
|
8781 | if (slides[i]) slidesEl.append(slides[i]);
|
8782 | }
|
8783 | newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
|
8784 | } else {
|
8785 | slidesEl.append(slides);
|
8786 | }
|
8787 | for (let i = 0; i < slidesBuffer.length; i += 1) {
|
8788 | slidesEl.append(slidesBuffer[i]);
|
8789 | }
|
8790 | swiper.recalcSlides();
|
8791 | if (params.loop) {
|
8792 | swiper.loopCreate();
|
8793 | }
|
8794 | if (!params.observer || swiper.isElement) {
|
8795 | swiper.update();
|
8796 | }
|
8797 | if (params.loop) {
|
8798 | swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
|
8799 | } else {
|
8800 | swiper.slideTo(newActiveIndex, 0, false);
|
8801 | }
|
8802 | }
|
8803 |
|
8804 | function removeSlide(slidesIndexes) {
|
8805 | const swiper = this;
|
8806 | const {
|
8807 | params,
|
8808 | activeIndex
|
8809 | } = swiper;
|
8810 | let activeIndexBuffer = activeIndex;
|
8811 | if (params.loop) {
|
8812 | activeIndexBuffer -= swiper.loopedSlides;
|
8813 | swiper.loopDestroy();
|
8814 | }
|
8815 | let newActiveIndex = activeIndexBuffer;
|
8816 | let indexToRemove;
|
8817 | if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
|
8818 | for (let i = 0; i < slidesIndexes.length; i += 1) {
|
8819 | indexToRemove = slidesIndexes[i];
|
8820 | if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
|
8821 | if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
|
8822 | }
|
8823 | newActiveIndex = Math.max(newActiveIndex, 0);
|
8824 | } else {
|
8825 | indexToRemove = slidesIndexes;
|
8826 | if (swiper.slides[indexToRemove]) swiper.slides[indexToRemove].remove();
|
8827 | if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
|
8828 | newActiveIndex = Math.max(newActiveIndex, 0);
|
8829 | }
|
8830 | swiper.recalcSlides();
|
8831 | if (params.loop) {
|
8832 | swiper.loopCreate();
|
8833 | }
|
8834 | if (!params.observer || swiper.isElement) {
|
8835 | swiper.update();
|
8836 | }
|
8837 | if (params.loop) {
|
8838 | swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
|
8839 | } else {
|
8840 | swiper.slideTo(newActiveIndex, 0, false);
|
8841 | }
|
8842 | }
|
8843 |
|
8844 | function removeAllSlides() {
|
8845 | const swiper = this;
|
8846 | const slidesIndexes = [];
|
8847 | for (let i = 0; i < swiper.slides.length; i += 1) {
|
8848 | slidesIndexes.push(i);
|
8849 | }
|
8850 | swiper.removeSlide(slidesIndexes);
|
8851 | }
|
8852 |
|
8853 | function Manipulation(_ref) {
|
8854 | let {
|
8855 | swiper
|
8856 | } = _ref;
|
8857 | Object.assign(swiper, {
|
8858 | appendSlide: appendSlide.bind(swiper),
|
8859 | prependSlide: prependSlide.bind(swiper),
|
8860 | addSlide: addSlide.bind(swiper),
|
8861 | removeSlide: removeSlide.bind(swiper),
|
8862 | removeAllSlides: removeAllSlides.bind(swiper)
|
8863 | });
|
8864 | }
|
8865 |
|
8866 | function effectInit(params) {
|
8867 | const {
|
8868 | effect,
|
8869 | swiper,
|
8870 | on,
|
8871 | setTranslate,
|
8872 | setTransition,
|
8873 | overwriteParams,
|
8874 | perspective,
|
8875 | recreateShadows,
|
8876 | getEffectParams
|
8877 | } = params;
|
8878 | on('beforeInit', () => {
|
8879 | if (swiper.params.effect !== effect) return;
|
8880 | swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
|
8881 | if (perspective && perspective()) {
|
8882 | swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
|
8883 | }
|
8884 | const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
|
8885 | Object.assign(swiper.params, overwriteParamsResult);
|
8886 | Object.assign(swiper.originalParams, overwriteParamsResult);
|
8887 | });
|
8888 | on('setTranslate', () => {
|
8889 | if (swiper.params.effect !== effect) return;
|
8890 | setTranslate();
|
8891 | });
|
8892 | on('setTransition', (_s, duration) => {
|
8893 | if (swiper.params.effect !== effect) return;
|
8894 | setTransition(duration);
|
8895 | });
|
8896 | on('transitionEnd', () => {
|
8897 | if (swiper.params.effect !== effect) return;
|
8898 | if (recreateShadows) {
|
8899 | if (!getEffectParams || !getEffectParams().slideShadows) return;
|
8900 |
|
8901 | swiper.slides.forEach(slideEl => {
|
8902 | slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => shadowEl.remove());
|
8903 | });
|
8904 |
|
8905 | recreateShadows();
|
8906 | }
|
8907 | });
|
8908 | let requireUpdateOnVirtual;
|
8909 | on('virtualUpdate', () => {
|
8910 | if (swiper.params.effect !== effect) return;
|
8911 | if (!swiper.slides.length) {
|
8912 | requireUpdateOnVirtual = true;
|
8913 | }
|
8914 | requestAnimationFrame(() => {
|
8915 | if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
|
8916 | setTranslate();
|
8917 | requireUpdateOnVirtual = false;
|
8918 | }
|
8919 | });
|
8920 | });
|
8921 | }
|
8922 |
|
8923 | function effectTarget(effectParams, slideEl) {
|
8924 | const transformEl = getSlideTransformEl(slideEl);
|
8925 | if (transformEl !== slideEl) {
|
8926 | transformEl.style.backfaceVisibility = 'hidden';
|
8927 | transformEl.style['-webkit-backface-visibility'] = 'hidden';
|
8928 | }
|
8929 | return transformEl;
|
8930 | }
|
8931 |
|
8932 | function effectVirtualTransitionEnd(_ref) {
|
8933 | let {
|
8934 | swiper,
|
8935 | duration,
|
8936 | transformElements,
|
8937 | allSlides
|
8938 | } = _ref;
|
8939 | const {
|
8940 | activeIndex
|
8941 | } = swiper;
|
8942 | const getSlide = el => {
|
8943 | if (!el.parentElement) {
|
8944 |
|
8945 | const slide = swiper.slides.filter(slideEl => slideEl.shadowRoot && slideEl.shadowRoot === el.parentNode)[0];
|
8946 | return slide;
|
8947 | }
|
8948 | return el.parentElement;
|
8949 | };
|
8950 | if (swiper.params.virtualTranslate && duration !== 0) {
|
8951 | let eventTriggered = false;
|
8952 | let transitionEndTarget;
|
8953 | if (allSlides) {
|
8954 | transitionEndTarget = transformElements;
|
8955 | } else {
|
8956 | transitionEndTarget = transformElements.filter(transformEl => {
|
8957 | const el = transformEl.classList.contains('swiper-slide-transform') ? getSlide(transformEl) : transformEl;
|
8958 | return swiper.getSlideIndex(el) === activeIndex;
|
8959 | });
|
8960 | }
|
8961 | transitionEndTarget.forEach(el => {
|
8962 | elementTransitionEnd(el, () => {
|
8963 | if (eventTriggered) return;
|
8964 | if (!swiper || swiper.destroyed) return;
|
8965 | eventTriggered = true;
|
8966 | swiper.animating = false;
|
8967 | const evt = new window.CustomEvent('transitionend', {
|
8968 | bubbles: true,
|
8969 | cancelable: true
|
8970 | });
|
8971 | swiper.wrapperEl.dispatchEvent(evt);
|
8972 | });
|
8973 | });
|
8974 | }
|
8975 | }
|
8976 |
|
8977 | function EffectFade(_ref) {
|
8978 | let {
|
8979 | swiper,
|
8980 | extendParams,
|
8981 | on
|
8982 | } = _ref;
|
8983 | extendParams({
|
8984 | fadeEffect: {
|
8985 | crossFade: false
|
8986 | }
|
8987 | });
|
8988 | const setTranslate = () => {
|
8989 | const {
|
8990 | slides
|
8991 | } = swiper;
|
8992 | const params = swiper.params.fadeEffect;
|
8993 | for (let i = 0; i < slides.length; i += 1) {
|
8994 | const slideEl = swiper.slides[i];
|
8995 | const offset = slideEl.swiperSlideOffset;
|
8996 | let tx = -offset;
|
8997 | if (!swiper.params.virtualTranslate) tx -= swiper.translate;
|
8998 | let ty = 0;
|
8999 | if (!swiper.isHorizontal()) {
|
9000 | ty = tx;
|
9001 | tx = 0;
|
9002 | }
|
9003 | const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs(slideEl.progress), 0) : 1 + Math.min(Math.max(slideEl.progress, -1), 0);
|
9004 | const targetEl = effectTarget(params, slideEl);
|
9005 | targetEl.style.opacity = slideOpacity;
|
9006 | targetEl.style.transform = `translate3d(${tx}px, ${ty}px, 0px)`;
|
9007 | }
|
9008 | };
|
9009 | const setTransition = duration => {
|
9010 | const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
|
9011 | transformElements.forEach(el => {
|
9012 | el.style.transitionDuration = `${duration}ms`;
|
9013 | });
|
9014 | effectVirtualTransitionEnd({
|
9015 | swiper,
|
9016 | duration,
|
9017 | transformElements,
|
9018 | allSlides: true
|
9019 | });
|
9020 | };
|
9021 | effectInit({
|
9022 | effect: 'fade',
|
9023 | swiper,
|
9024 | on,
|
9025 | setTranslate,
|
9026 | setTransition,
|
9027 | overwriteParams: () => ({
|
9028 | slidesPerView: 1,
|
9029 | slidesPerGroup: 1,
|
9030 | watchSlidesProgress: true,
|
9031 | spaceBetween: 0,
|
9032 | virtualTranslate: !swiper.params.cssMode
|
9033 | })
|
9034 | });
|
9035 | }
|
9036 |
|
9037 | function EffectCube(_ref) {
|
9038 | let {
|
9039 | swiper,
|
9040 | extendParams,
|
9041 | on
|
9042 | } = _ref;
|
9043 | extendParams({
|
9044 | cubeEffect: {
|
9045 | slideShadows: true,
|
9046 | shadow: true,
|
9047 | shadowOffset: 20,
|
9048 | shadowScale: 0.94
|
9049 | }
|
9050 | });
|
9051 | const createSlideShadows = (slideEl, progress, isHorizontal) => {
|
9052 | let shadowBefore = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
|
9053 | let shadowAfter = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
|
9054 | if (!shadowBefore) {
|
9055 | shadowBefore = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}`.split(' '));
|
9056 | slideEl.append(shadowBefore);
|
9057 | }
|
9058 | if (!shadowAfter) {
|
9059 | shadowAfter = createElement('div', `swiper-slide-shadow-cube swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}`.split(' '));
|
9060 | slideEl.append(shadowAfter);
|
9061 | }
|
9062 | if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
|
9063 | if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
|
9064 | };
|
9065 | const recreateShadows = () => {
|
9066 |
|
9067 | const isHorizontal = swiper.isHorizontal();
|
9068 | swiper.slides.forEach(slideEl => {
|
9069 | const progress = Math.max(Math.min(slideEl.progress, 1), -1);
|
9070 | createSlideShadows(slideEl, progress, isHorizontal);
|
9071 | });
|
9072 | };
|
9073 | const setTranslate = () => {
|
9074 | const {
|
9075 | el,
|
9076 | wrapperEl,
|
9077 | slides,
|
9078 | width: swiperWidth,
|
9079 | height: swiperHeight,
|
9080 | rtlTranslate: rtl,
|
9081 | size: swiperSize,
|
9082 | browser
|
9083 | } = swiper;
|
9084 | const r = getRotateFix(swiper);
|
9085 | const params = swiper.params.cubeEffect;
|
9086 | const isHorizontal = swiper.isHorizontal();
|
9087 | const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
9088 | let wrapperRotate = 0;
|
9089 | let cubeShadowEl;
|
9090 | if (params.shadow) {
|
9091 | if (isHorizontal) {
|
9092 | cubeShadowEl = swiper.wrapperEl.querySelector('.swiper-cube-shadow');
|
9093 | if (!cubeShadowEl) {
|
9094 | cubeShadowEl = createElement('div', 'swiper-cube-shadow');
|
9095 | swiper.wrapperEl.append(cubeShadowEl);
|
9096 | }
|
9097 | cubeShadowEl.style.height = `${swiperWidth}px`;
|
9098 | } else {
|
9099 | cubeShadowEl = el.querySelector('.swiper-cube-shadow');
|
9100 | if (!cubeShadowEl) {
|
9101 | cubeShadowEl = createElement('div', 'swiper-cube-shadow');
|
9102 | el.append(cubeShadowEl);
|
9103 | }
|
9104 | }
|
9105 | }
|
9106 | for (let i = 0; i < slides.length; i += 1) {
|
9107 | const slideEl = slides[i];
|
9108 | let slideIndex = i;
|
9109 | if (isVirtual) {
|
9110 | slideIndex = parseInt(slideEl.getAttribute('data-swiper-slide-index'), 10);
|
9111 | }
|
9112 | let slideAngle = slideIndex * 90;
|
9113 | let round = Math.floor(slideAngle / 360);
|
9114 | if (rtl) {
|
9115 | slideAngle = -slideAngle;
|
9116 | round = Math.floor(-slideAngle / 360);
|
9117 | }
|
9118 | const progress = Math.max(Math.min(slideEl.progress, 1), -1);
|
9119 | let tx = 0;
|
9120 | let ty = 0;
|
9121 | let tz = 0;
|
9122 | if (slideIndex % 4 === 0) {
|
9123 | tx = -round * 4 * swiperSize;
|
9124 | tz = 0;
|
9125 | } else if ((slideIndex - 1) % 4 === 0) {
|
9126 | tx = 0;
|
9127 | tz = -round * 4 * swiperSize;
|
9128 | } else if ((slideIndex - 2) % 4 === 0) {
|
9129 | tx = swiperSize + round * 4 * swiperSize;
|
9130 | tz = swiperSize;
|
9131 | } else if ((slideIndex - 3) % 4 === 0) {
|
9132 | tx = -swiperSize;
|
9133 | tz = 3 * swiperSize + swiperSize * 4 * round;
|
9134 | }
|
9135 | if (rtl) {
|
9136 | tx = -tx;
|
9137 | }
|
9138 | if (!isHorizontal) {
|
9139 | ty = tx;
|
9140 | tx = 0;
|
9141 | }
|
9142 | const transform = `rotateX(${r(isHorizontal ? 0 : -slideAngle)}deg) rotateY(${r(isHorizontal ? slideAngle : 0)}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
|
9143 | if (progress <= 1 && progress > -1) {
|
9144 | wrapperRotate = slideIndex * 90 + progress * 90;
|
9145 | if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
|
9146 | }
|
9147 | slideEl.style.transform = transform;
|
9148 | if (params.slideShadows) {
|
9149 | createSlideShadows(slideEl, progress, isHorizontal);
|
9150 | }
|
9151 | }
|
9152 | wrapperEl.style.transformOrigin = `50% 50% -${swiperSize / 2}px`;
|
9153 | wrapperEl.style['-webkit-transform-origin'] = `50% 50% -${swiperSize / 2}px`;
|
9154 | if (params.shadow) {
|
9155 | if (isHorizontal) {
|
9156 | cubeShadowEl.style.transform = `translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(89.99deg) rotateZ(0deg) scale(${params.shadowScale})`;
|
9157 | } else {
|
9158 | const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
|
9159 | const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
|
9160 | const scale1 = params.shadowScale;
|
9161 | const scale2 = params.shadowScale / multiplier;
|
9162 | const offset = params.shadowOffset;
|
9163 | cubeShadowEl.style.transform = `scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-89.99deg)`;
|
9164 | }
|
9165 | }
|
9166 | const zFactor = (browser.isSafari || browser.isWebView) && browser.needPerspectiveFix ? -swiperSize / 2 : 0;
|
9167 | wrapperEl.style.transform = `translate3d(0px,0,${zFactor}px) rotateX(${r(swiper.isHorizontal() ? 0 : wrapperRotate)}deg) rotateY(${r(swiper.isHorizontal() ? -wrapperRotate : 0)}deg)`;
|
9168 | wrapperEl.style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
|
9169 | };
|
9170 | const setTransition = duration => {
|
9171 | const {
|
9172 | el,
|
9173 | slides
|
9174 | } = swiper;
|
9175 | slides.forEach(slideEl => {
|
9176 | slideEl.style.transitionDuration = `${duration}ms`;
|
9177 | slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(subEl => {
|
9178 | subEl.style.transitionDuration = `${duration}ms`;
|
9179 | });
|
9180 | });
|
9181 | if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
|
9182 | const shadowEl = el.querySelector('.swiper-cube-shadow');
|
9183 | if (shadowEl) shadowEl.style.transitionDuration = `${duration}ms`;
|
9184 | }
|
9185 | };
|
9186 | effectInit({
|
9187 | effect: 'cube',
|
9188 | swiper,
|
9189 | on,
|
9190 | setTranslate,
|
9191 | setTransition,
|
9192 | recreateShadows,
|
9193 | getEffectParams: () => swiper.params.cubeEffect,
|
9194 | perspective: () => true,
|
9195 | overwriteParams: () => ({
|
9196 | slidesPerView: 1,
|
9197 | slidesPerGroup: 1,
|
9198 | watchSlidesProgress: true,
|
9199 | resistanceRatio: 0,
|
9200 | spaceBetween: 0,
|
9201 | centeredSlides: false,
|
9202 | virtualTranslate: true
|
9203 | })
|
9204 | });
|
9205 | }
|
9206 |
|
9207 | function createShadow(suffix, slideEl, side) {
|
9208 | const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}${suffix ? ` swiper-slide-shadow-${suffix}` : ''}`;
|
9209 | const shadowContainer = getSlideTransformEl(slideEl);
|
9210 | let shadowEl = shadowContainer.querySelector(`.${shadowClass.split(' ').join('.')}`);
|
9211 | if (!shadowEl) {
|
9212 | shadowEl = createElement('div', shadowClass.split(' '));
|
9213 | shadowContainer.append(shadowEl);
|
9214 | }
|
9215 | return shadowEl;
|
9216 | }
|
9217 |
|
9218 | function EffectFlip(_ref) {
|
9219 | let {
|
9220 | swiper,
|
9221 | extendParams,
|
9222 | on
|
9223 | } = _ref;
|
9224 | extendParams({
|
9225 | flipEffect: {
|
9226 | slideShadows: true,
|
9227 | limitRotation: true
|
9228 | }
|
9229 | });
|
9230 | const createSlideShadows = (slideEl, progress) => {
|
9231 | let shadowBefore = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
|
9232 | let shadowAfter = swiper.isHorizontal() ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
|
9233 | if (!shadowBefore) {
|
9234 | shadowBefore = createShadow('flip', slideEl, swiper.isHorizontal() ? 'left' : 'top');
|
9235 | }
|
9236 | if (!shadowAfter) {
|
9237 | shadowAfter = createShadow('flip', slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
|
9238 | }
|
9239 | if (shadowBefore) shadowBefore.style.opacity = Math.max(-progress, 0);
|
9240 | if (shadowAfter) shadowAfter.style.opacity = Math.max(progress, 0);
|
9241 | };
|
9242 | const recreateShadows = () => {
|
9243 |
|
9244 | swiper.params.flipEffect;
|
9245 | swiper.slides.forEach(slideEl => {
|
9246 | let progress = slideEl.progress;
|
9247 | if (swiper.params.flipEffect.limitRotation) {
|
9248 | progress = Math.max(Math.min(slideEl.progress, 1), -1);
|
9249 | }
|
9250 | createSlideShadows(slideEl, progress);
|
9251 | });
|
9252 | };
|
9253 | const setTranslate = () => {
|
9254 | const {
|
9255 | slides,
|
9256 | rtlTranslate: rtl
|
9257 | } = swiper;
|
9258 | const params = swiper.params.flipEffect;
|
9259 | const rotateFix = getRotateFix(swiper);
|
9260 | for (let i = 0; i < slides.length; i += 1) {
|
9261 | const slideEl = slides[i];
|
9262 | let progress = slideEl.progress;
|
9263 | if (swiper.params.flipEffect.limitRotation) {
|
9264 | progress = Math.max(Math.min(slideEl.progress, 1), -1);
|
9265 | }
|
9266 | const offset = slideEl.swiperSlideOffset;
|
9267 | const rotate = -180 * progress;
|
9268 | let rotateY = rotate;
|
9269 | let rotateX = 0;
|
9270 | let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
|
9271 | let ty = 0;
|
9272 | if (!swiper.isHorizontal()) {
|
9273 | ty = tx;
|
9274 | tx = 0;
|
9275 | rotateX = -rotateY;
|
9276 | rotateY = 0;
|
9277 | } else if (rtl) {
|
9278 | rotateY = -rotateY;
|
9279 | }
|
9280 | slideEl.style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
|
9281 | if (params.slideShadows) {
|
9282 | createSlideShadows(slideEl, progress);
|
9283 | }
|
9284 | const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateFix(rotateX)}deg) rotateY(${rotateFix(rotateY)}deg)`;
|
9285 | const targetEl = effectTarget(params, slideEl);
|
9286 | targetEl.style.transform = transform;
|
9287 | }
|
9288 | };
|
9289 | const setTransition = duration => {
|
9290 | const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
|
9291 | transformElements.forEach(el => {
|
9292 | el.style.transitionDuration = `${duration}ms`;
|
9293 | el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
|
9294 | shadowEl.style.transitionDuration = `${duration}ms`;
|
9295 | });
|
9296 | });
|
9297 | effectVirtualTransitionEnd({
|
9298 | swiper,
|
9299 | duration,
|
9300 | transformElements
|
9301 | });
|
9302 | };
|
9303 | effectInit({
|
9304 | effect: 'flip',
|
9305 | swiper,
|
9306 | on,
|
9307 | setTranslate,
|
9308 | setTransition,
|
9309 | recreateShadows,
|
9310 | getEffectParams: () => swiper.params.flipEffect,
|
9311 | perspective: () => true,
|
9312 | overwriteParams: () => ({
|
9313 | slidesPerView: 1,
|
9314 | slidesPerGroup: 1,
|
9315 | watchSlidesProgress: true,
|
9316 | spaceBetween: 0,
|
9317 | virtualTranslate: !swiper.params.cssMode
|
9318 | })
|
9319 | });
|
9320 | }
|
9321 |
|
9322 | function EffectCoverflow(_ref) {
|
9323 | let {
|
9324 | swiper,
|
9325 | extendParams,
|
9326 | on
|
9327 | } = _ref;
|
9328 | extendParams({
|
9329 | coverflowEffect: {
|
9330 | rotate: 50,
|
9331 | stretch: 0,
|
9332 | depth: 100,
|
9333 | scale: 1,
|
9334 | modifier: 1,
|
9335 | slideShadows: true
|
9336 | }
|
9337 | });
|
9338 | const setTranslate = () => {
|
9339 | const {
|
9340 | width: swiperWidth,
|
9341 | height: swiperHeight,
|
9342 | slides,
|
9343 | slidesSizesGrid
|
9344 | } = swiper;
|
9345 | const params = swiper.params.coverflowEffect;
|
9346 | const isHorizontal = swiper.isHorizontal();
|
9347 | const transform = swiper.translate;
|
9348 | const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
|
9349 | const rotate = isHorizontal ? params.rotate : -params.rotate;
|
9350 | const translate = params.depth;
|
9351 | const r = getRotateFix(swiper);
|
9352 |
|
9353 | for (let i = 0, length = slides.length; i < length; i += 1) {
|
9354 | const slideEl = slides[i];
|
9355 | const slideSize = slidesSizesGrid[i];
|
9356 | const slideOffset = slideEl.swiperSlideOffset;
|
9357 | const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
|
9358 | const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
|
9359 | let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
|
9360 | let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier;
|
9361 |
|
9362 | let translateZ = -translate * Math.abs(offsetMultiplier);
|
9363 | let stretch = params.stretch;
|
9364 |
|
9365 | if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
|
9366 | stretch = parseFloat(params.stretch) / 100 * slideSize;
|
9367 | }
|
9368 | let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
|
9369 | let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
|
9370 | let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier);
|
9371 |
|
9372 |
|
9373 | if (Math.abs(translateX) < 0.001) translateX = 0;
|
9374 | if (Math.abs(translateY) < 0.001) translateY = 0;
|
9375 | if (Math.abs(translateZ) < 0.001) translateZ = 0;
|
9376 | if (Math.abs(rotateY) < 0.001) rotateY = 0;
|
9377 | if (Math.abs(rotateX) < 0.001) rotateX = 0;
|
9378 | if (Math.abs(scale) < 0.001) scale = 0;
|
9379 | const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${r(rotateX)}deg) rotateY(${r(rotateY)}deg) scale(${scale})`;
|
9380 | const targetEl = effectTarget(params, slideEl);
|
9381 | targetEl.style.transform = slideTransform;
|
9382 | slideEl.style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
|
9383 | if (params.slideShadows) {
|
9384 |
|
9385 | let shadowBeforeEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-left') : slideEl.querySelector('.swiper-slide-shadow-top');
|
9386 | let shadowAfterEl = isHorizontal ? slideEl.querySelector('.swiper-slide-shadow-right') : slideEl.querySelector('.swiper-slide-shadow-bottom');
|
9387 | if (!shadowBeforeEl) {
|
9388 | shadowBeforeEl = createShadow('coverflow', slideEl, isHorizontal ? 'left' : 'top');
|
9389 | }
|
9390 | if (!shadowAfterEl) {
|
9391 | shadowAfterEl = createShadow('coverflow', slideEl, isHorizontal ? 'right' : 'bottom');
|
9392 | }
|
9393 | if (shadowBeforeEl) shadowBeforeEl.style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
|
9394 | if (shadowAfterEl) shadowAfterEl.style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
|
9395 | }
|
9396 | }
|
9397 | };
|
9398 | const setTransition = duration => {
|
9399 | const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
|
9400 | transformElements.forEach(el => {
|
9401 | el.style.transitionDuration = `${duration}ms`;
|
9402 | el.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => {
|
9403 | shadowEl.style.transitionDuration = `${duration}ms`;
|
9404 | });
|
9405 | });
|
9406 | };
|
9407 | effectInit({
|
9408 | effect: 'coverflow',
|
9409 | swiper,
|
9410 | on,
|
9411 | setTranslate,
|
9412 | setTransition,
|
9413 | perspective: () => true,
|
9414 | overwriteParams: () => ({
|
9415 | watchSlidesProgress: true
|
9416 | })
|
9417 | });
|
9418 | }
|
9419 |
|
9420 | function EffectCreative(_ref) {
|
9421 | let {
|
9422 | swiper,
|
9423 | extendParams,
|
9424 | on
|
9425 | } = _ref;
|
9426 | extendParams({
|
9427 | creativeEffect: {
|
9428 | limitProgress: 1,
|
9429 | shadowPerProgress: false,
|
9430 | progressMultiplier: 1,
|
9431 | perspective: true,
|
9432 | prev: {
|
9433 | translate: [0, 0, 0],
|
9434 | rotate: [0, 0, 0],
|
9435 | opacity: 1,
|
9436 | scale: 1
|
9437 | },
|
9438 | next: {
|
9439 | translate: [0, 0, 0],
|
9440 | rotate: [0, 0, 0],
|
9441 | opacity: 1,
|
9442 | scale: 1
|
9443 | }
|
9444 | }
|
9445 | });
|
9446 | const getTranslateValue = value => {
|
9447 | if (typeof value === 'string') return value;
|
9448 | return `${value}px`;
|
9449 | };
|
9450 | const setTranslate = () => {
|
9451 | const {
|
9452 | slides,
|
9453 | wrapperEl,
|
9454 | slidesSizesGrid
|
9455 | } = swiper;
|
9456 | const params = swiper.params.creativeEffect;
|
9457 | const {
|
9458 | progressMultiplier: multiplier
|
9459 | } = params;
|
9460 | const isCenteredSlides = swiper.params.centeredSlides;
|
9461 | const rotateFix = getRotateFix(swiper);
|
9462 | if (isCenteredSlides) {
|
9463 | const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
|
9464 | wrapperEl.style.transform = `translateX(calc(50% - ${margin}px))`;
|
9465 | }
|
9466 | for (let i = 0; i < slides.length; i += 1) {
|
9467 | const slideEl = slides[i];
|
9468 | const slideProgress = slideEl.progress;
|
9469 | const progress = Math.min(Math.max(slideEl.progress, -params.limitProgress), params.limitProgress);
|
9470 | let originalProgress = progress;
|
9471 | if (!isCenteredSlides) {
|
9472 | originalProgress = Math.min(Math.max(slideEl.originalProgress, -params.limitProgress), params.limitProgress);
|
9473 | }
|
9474 | const offset = slideEl.swiperSlideOffset;
|
9475 | const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
|
9476 | const r = [0, 0, 0];
|
9477 | let custom = false;
|
9478 | if (!swiper.isHorizontal()) {
|
9479 | t[1] = t[0];
|
9480 | t[0] = 0;
|
9481 | }
|
9482 | let data = {
|
9483 | translate: [0, 0, 0],
|
9484 | rotate: [0, 0, 0],
|
9485 | scale: 1,
|
9486 | opacity: 1
|
9487 | };
|
9488 | if (progress < 0) {
|
9489 | data = params.next;
|
9490 | custom = true;
|
9491 | } else if (progress > 0) {
|
9492 | data = params.prev;
|
9493 | custom = true;
|
9494 | }
|
9495 |
|
9496 | t.forEach((value, index) => {
|
9497 | t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
|
9498 | });
|
9499 |
|
9500 | r.forEach((value, index) => {
|
9501 | let val = data.rotate[index] * Math.abs(progress * multiplier);
|
9502 | r[index] = val;
|
9503 | });
|
9504 | slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
|
9505 | const translateString = t.join(', ');
|
9506 | const rotateString = `rotateX(${rotateFix(r[0])}deg) rotateY(${rotateFix(r[1])}deg) rotateZ(${rotateFix(r[2])}deg)`;
|
9507 | const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
|
9508 | const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
|
9509 | const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`;
|
9510 |
|
9511 |
|
9512 | if (custom && data.shadow || !custom) {
|
9513 | let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
|
9514 | if (!shadowEl && data.shadow) {
|
9515 | shadowEl = createShadow('creative', slideEl);
|
9516 | }
|
9517 | if (shadowEl) {
|
9518 | const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
|
9519 | shadowEl.style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
|
9520 | }
|
9521 | }
|
9522 | const targetEl = effectTarget(params, slideEl);
|
9523 | targetEl.style.transform = transform;
|
9524 | targetEl.style.opacity = opacityString;
|
9525 | if (data.origin) {
|
9526 | targetEl.style.transformOrigin = data.origin;
|
9527 | }
|
9528 | }
|
9529 | };
|
9530 | const setTransition = duration => {
|
9531 | const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
|
9532 | transformElements.forEach(el => {
|
9533 | el.style.transitionDuration = `${duration}ms`;
|
9534 | el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
|
9535 | shadowEl.style.transitionDuration = `${duration}ms`;
|
9536 | });
|
9537 | });
|
9538 | effectVirtualTransitionEnd({
|
9539 | swiper,
|
9540 | duration,
|
9541 | transformElements,
|
9542 | allSlides: true
|
9543 | });
|
9544 | };
|
9545 | effectInit({
|
9546 | effect: 'creative',
|
9547 | swiper,
|
9548 | on,
|
9549 | setTranslate,
|
9550 | setTransition,
|
9551 | perspective: () => swiper.params.creativeEffect.perspective,
|
9552 | overwriteParams: () => ({
|
9553 | watchSlidesProgress: true,
|
9554 | virtualTranslate: !swiper.params.cssMode
|
9555 | })
|
9556 | });
|
9557 | }
|
9558 |
|
9559 | function EffectCards(_ref) {
|
9560 | let {
|
9561 | swiper,
|
9562 | extendParams,
|
9563 | on
|
9564 | } = _ref;
|
9565 | extendParams({
|
9566 | cardsEffect: {
|
9567 | slideShadows: true,
|
9568 | rotate: true,
|
9569 | perSlideRotate: 2,
|
9570 | perSlideOffset: 8
|
9571 | }
|
9572 | });
|
9573 | const setTranslate = () => {
|
9574 | const {
|
9575 | slides,
|
9576 | activeIndex,
|
9577 | rtlTranslate: rtl
|
9578 | } = swiper;
|
9579 | const params = swiper.params.cardsEffect;
|
9580 | const {
|
9581 | startTranslate,
|
9582 | isTouched
|
9583 | } = swiper.touchEventsData;
|
9584 | const currentTranslate = rtl ? -swiper.translate : swiper.translate;
|
9585 | for (let i = 0; i < slides.length; i += 1) {
|
9586 | const slideEl = slides[i];
|
9587 | const slideProgress = slideEl.progress;
|
9588 | const progress = Math.min(Math.max(slideProgress, -4), 4);
|
9589 | let offset = slideEl.swiperSlideOffset;
|
9590 | if (swiper.params.centeredSlides && !swiper.params.cssMode) {
|
9591 | swiper.wrapperEl.style.transform = `translateX(${swiper.minTranslate()}px)`;
|
9592 | }
|
9593 | if (swiper.params.centeredSlides && swiper.params.cssMode) {
|
9594 | offset -= slides[0].swiperSlideOffset;
|
9595 | }
|
9596 | let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
|
9597 | let tY = 0;
|
9598 | const tZ = -100 * Math.abs(progress);
|
9599 | let scale = 1;
|
9600 | let rotate = -params.perSlideRotate * progress;
|
9601 | let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
|
9602 | const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
|
9603 | const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
|
9604 | const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
|
9605 | if (isSwipeToNext || isSwipeToPrev) {
|
9606 | const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
|
9607 | rotate += -28 * progress * subProgress;
|
9608 | scale += -0.5 * subProgress;
|
9609 | tXAdd += 96 * subProgress;
|
9610 | tY = `${-25 * subProgress * Math.abs(progress)}%`;
|
9611 | }
|
9612 | if (progress < 0) {
|
9613 |
|
9614 | tX = `calc(${tX}px ${rtl ? '-' : '+'} (${tXAdd * Math.abs(progress)}%))`;
|
9615 | } else if (progress > 0) {
|
9616 |
|
9617 | tX = `calc(${tX}px ${rtl ? '-' : '+'} (-${tXAdd * Math.abs(progress)}%))`;
|
9618 | } else {
|
9619 | tX = `${tX}px`;
|
9620 | }
|
9621 | if (!swiper.isHorizontal()) {
|
9622 | const prevY = tY;
|
9623 | tY = tX;
|
9624 | tX = prevY;
|
9625 | }
|
9626 | const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
|
9627 |
|
9628 |
|
9629 | const transform = `
|
9630 | translate3d(${tX}, ${tY}, ${tZ}px)
|
9631 | rotateZ(${params.rotate ? rtl ? -rotate : rotate : 0}deg)
|
9632 | scale(${scaleString})
|
9633 | `;
|
9634 |
|
9635 |
|
9636 | if (params.slideShadows) {
|
9637 |
|
9638 | let shadowEl = slideEl.querySelector('.swiper-slide-shadow');
|
9639 | if (!shadowEl) {
|
9640 | shadowEl = createShadow('cards', slideEl);
|
9641 | }
|
9642 | if (shadowEl) shadowEl.style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
|
9643 | }
|
9644 | slideEl.style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
|
9645 | const targetEl = effectTarget(params, slideEl);
|
9646 | targetEl.style.transform = transform;
|
9647 | }
|
9648 | };
|
9649 | const setTransition = duration => {
|
9650 | const transformElements = swiper.slides.map(slideEl => getSlideTransformEl(slideEl));
|
9651 | transformElements.forEach(el => {
|
9652 | el.style.transitionDuration = `${duration}ms`;
|
9653 | el.querySelectorAll('.swiper-slide-shadow').forEach(shadowEl => {
|
9654 | shadowEl.style.transitionDuration = `${duration}ms`;
|
9655 | });
|
9656 | });
|
9657 | effectVirtualTransitionEnd({
|
9658 | swiper,
|
9659 | duration,
|
9660 | transformElements
|
9661 | });
|
9662 | };
|
9663 | effectInit({
|
9664 | effect: 'cards',
|
9665 | swiper,
|
9666 | on,
|
9667 | setTranslate,
|
9668 | setTransition,
|
9669 | perspective: () => true,
|
9670 | overwriteParams: () => ({
|
9671 | watchSlidesProgress: true,
|
9672 | virtualTranslate: !swiper.params.cssMode
|
9673 | })
|
9674 | });
|
9675 | }
|
9676 |
|
9677 | |
9678 |
|
9679 |
|
9680 |
|
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 |
|
9689 |
|
9690 |
|
9691 | const modules = [Virtual, Keyboard, Mousewheel, Navigation, Pagination, Scrollbar, Parallax, Zoom, Controller, A11y, History, HashNavigation, Autoplay, Thumb, freeMode, Grid, Manipulation, EffectFade, EffectCube, EffectFlip, EffectCoverflow, EffectCreative, EffectCards];
|
9692 | Swiper.use(modules);
|
9693 |
|
9694 |
|
9695 | const paramsList = ['eventsPrefix', 'injectStyles', 'injectStylesUrls', 'modules', 'init', '_direction', 'oneWayMovement', 'swiperElementNodeName', 'touchEventsTarget', 'initialSlide', '_speed', 'cssMode', 'updateOnWindowResize', 'resizeObserver', 'nested', 'focusableElements', '_enabled', '_width', '_height', 'preventInteractionOnTransition', 'userAgent', 'url', '_edgeSwipeDetection', '_edgeSwipeThreshold', '_freeMode', '_autoHeight', 'setWrapperSize', 'virtualTranslate', '_effect', 'breakpoints', 'breakpointsBase', '_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', 'loopAdditionalSlides', 'loopAddBlankSlides', 'loopPreventsSliding', '_rewind', '_allowSlidePrev', '_allowSlideNext', '_swipeHandler', '_noSwiping', 'noSwipingClass', 'noSwipingSelector', 'passiveListeners', 'containerModifierClass', 'slideClass', 'slideActiveClass', 'slideVisibleClass', 'slideFullyVisibleClass', 'slideNextClass', 'slidePrevClass', 'slideBlankClass', 'wrapperClass', 'lazyPreloaderClass', 'lazyPreloadPrevNext', 'runCallbacksOnInit', 'observer', 'observeParents', 'observeSlideChildren',
|
9696 |
|
9697 | 'a11y', '_autoplay', '_controller', 'coverflowEffect', 'cubeEffect', 'fadeEffect', 'flipEffect', 'creativeEffect', 'cardsEffect', 'hashNavigation', 'history', 'keyboard', 'mousewheel', '_navigation', '_pagination', 'parallax', '_scrollbar', '_thumbs', 'virtual', 'zoom', 'control'];
|
9698 |
|
9699 | function isObject(o) {
|
9700 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object' && !o.__swiper__;
|
9701 | }
|
9702 | function extend(target, src) {
|
9703 | const noExtend = ['__proto__', 'constructor', 'prototype'];
|
9704 | Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
|
9705 | if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
9706 | if (src[key].__swiper__) target[key] = src[key];else extend(target[key], src[key]);
|
9707 | } else {
|
9708 | target[key] = src[key];
|
9709 | }
|
9710 | });
|
9711 | }
|
9712 | function needsNavigation(params) {
|
9713 | if (params === void 0) {
|
9714 | params = {};
|
9715 | }
|
9716 | return params.navigation && typeof params.navigation.nextEl === 'undefined' && typeof params.navigation.prevEl === 'undefined';
|
9717 | }
|
9718 | function needsPagination(params) {
|
9719 | if (params === void 0) {
|
9720 | params = {};
|
9721 | }
|
9722 | return params.pagination && typeof params.pagination.el === 'undefined';
|
9723 | }
|
9724 | function needsScrollbar(params) {
|
9725 | if (params === void 0) {
|
9726 | params = {};
|
9727 | }
|
9728 | return params.scrollbar && typeof params.scrollbar.el === 'undefined';
|
9729 | }
|
9730 | function attrToProp(attrName) {
|
9731 | if (attrName === void 0) {
|
9732 | attrName = '';
|
9733 | }
|
9734 | return attrName.replace(/-[a-z]/g, l => l.toUpperCase().replace('-', ''));
|
9735 | }
|
9736 |
|
9737 | function updateSwiper(_ref) {
|
9738 | let {
|
9739 | swiper,
|
9740 | slides,
|
9741 | passedParams,
|
9742 | changedParams,
|
9743 | nextEl,
|
9744 | prevEl,
|
9745 | scrollbarEl,
|
9746 | paginationEl
|
9747 | } = _ref;
|
9748 | const updateParams = changedParams.filter(key => key !== 'children' && key !== 'direction' && key !== 'wrapperClass');
|
9749 | const {
|
9750 | params: currentParams,
|
9751 | pagination,
|
9752 | navigation,
|
9753 | scrollbar,
|
9754 | virtual,
|
9755 | thumbs
|
9756 | } = swiper;
|
9757 | let needThumbsInit;
|
9758 | let needControllerInit;
|
9759 | let needPaginationInit;
|
9760 | let needScrollbarInit;
|
9761 | let needNavigationInit;
|
9762 | let loopNeedDestroy;
|
9763 | let loopNeedEnable;
|
9764 | let loopNeedReloop;
|
9765 | if (changedParams.includes('thumbs') && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) {
|
9766 | needThumbsInit = true;
|
9767 | }
|
9768 | if (changedParams.includes('controller') && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) {
|
9769 | needControllerInit = true;
|
9770 | }
|
9771 | if (changedParams.includes('pagination') && passedParams.pagination && (passedParams.pagination.el || paginationEl) && (currentParams.pagination || currentParams.pagination === false) && pagination && !pagination.el) {
|
9772 | needPaginationInit = true;
|
9773 | }
|
9774 | if (changedParams.includes('scrollbar') && passedParams.scrollbar && (passedParams.scrollbar.el || scrollbarEl) && (currentParams.scrollbar || currentParams.scrollbar === false) && scrollbar && !scrollbar.el) {
|
9775 | needScrollbarInit = true;
|
9776 | }
|
9777 | if (changedParams.includes('navigation') && passedParams.navigation && (passedParams.navigation.prevEl || prevEl) && (passedParams.navigation.nextEl || nextEl) && (currentParams.navigation || currentParams.navigation === false) && navigation && !navigation.prevEl && !navigation.nextEl) {
|
9778 | needNavigationInit = true;
|
9779 | }
|
9780 | const destroyModule = mod => {
|
9781 | if (!swiper[mod]) return;
|
9782 | swiper[mod].destroy();
|
9783 | if (mod === 'navigation') {
|
9784 | if (swiper.isElement) {
|
9785 | swiper[mod].prevEl.remove();
|
9786 | swiper[mod].nextEl.remove();
|
9787 | }
|
9788 | currentParams[mod].prevEl = undefined;
|
9789 | currentParams[mod].nextEl = undefined;
|
9790 | swiper[mod].prevEl = undefined;
|
9791 | swiper[mod].nextEl = undefined;
|
9792 | } else {
|
9793 | if (swiper.isElement) {
|
9794 | swiper[mod].el.remove();
|
9795 | }
|
9796 | currentParams[mod].el = undefined;
|
9797 | swiper[mod].el = undefined;
|
9798 | }
|
9799 | };
|
9800 | if (changedParams.includes('loop') && swiper.isElement) {
|
9801 | if (currentParams.loop && !passedParams.loop) {
|
9802 | loopNeedDestroy = true;
|
9803 | } else if (!currentParams.loop && passedParams.loop) {
|
9804 | loopNeedEnable = true;
|
9805 | } else {
|
9806 | loopNeedReloop = true;
|
9807 | }
|
9808 | }
|
9809 | updateParams.forEach(key => {
|
9810 | if (isObject(currentParams[key]) && isObject(passedParams[key])) {
|
9811 | Object.assign(currentParams[key], passedParams[key]);
|
9812 | if ((key === 'navigation' || key === 'pagination' || key === 'scrollbar') && 'enabled' in passedParams[key] && !passedParams[key].enabled) {
|
9813 | destroyModule(key);
|
9814 | }
|
9815 | } else {
|
9816 | const newValue = passedParams[key];
|
9817 | if ((newValue === true || newValue === false) && (key === 'navigation' || key === 'pagination' || key === 'scrollbar')) {
|
9818 | if (newValue === false) {
|
9819 | destroyModule(key);
|
9820 | }
|
9821 | } else {
|
9822 | currentParams[key] = passedParams[key];
|
9823 | }
|
9824 | }
|
9825 | });
|
9826 | if (updateParams.includes('controller') && !needControllerInit && swiper.controller && swiper.controller.control && currentParams.controller && currentParams.controller.control) {
|
9827 | swiper.controller.control = currentParams.controller.control;
|
9828 | }
|
9829 | if (changedParams.includes('children') && slides && virtual && currentParams.virtual.enabled) {
|
9830 | virtual.slides = slides;
|
9831 | virtual.update(true);
|
9832 | } else if (changedParams.includes('virtual') && virtual && currentParams.virtual.enabled) {
|
9833 | if (slides) virtual.slides = slides;
|
9834 | virtual.update(true);
|
9835 | }
|
9836 | if (changedParams.includes('children') && slides && currentParams.loop) {
|
9837 | loopNeedReloop = true;
|
9838 | }
|
9839 | if (needThumbsInit) {
|
9840 | const initialized = thumbs.init();
|
9841 | if (initialized) thumbs.update(true);
|
9842 | }
|
9843 | if (needControllerInit) {
|
9844 | swiper.controller.control = currentParams.controller.control;
|
9845 | }
|
9846 | if (needPaginationInit) {
|
9847 | if (swiper.isElement && (!paginationEl || typeof paginationEl === 'string')) {
|
9848 | paginationEl = document.createElement('div');
|
9849 | paginationEl.classList.add('swiper-pagination');
|
9850 | paginationEl.part.add('pagination');
|
9851 | swiper.el.appendChild(paginationEl);
|
9852 | }
|
9853 | if (paginationEl) currentParams.pagination.el = paginationEl;
|
9854 | pagination.init();
|
9855 | pagination.render();
|
9856 | pagination.update();
|
9857 | }
|
9858 | if (needScrollbarInit) {
|
9859 | if (swiper.isElement && (!scrollbarEl || typeof scrollbarEl === 'string')) {
|
9860 | scrollbarEl = document.createElement('div');
|
9861 | scrollbarEl.classList.add('swiper-scrollbar');
|
9862 | scrollbarEl.part.add('scrollbar');
|
9863 | swiper.el.appendChild(scrollbarEl);
|
9864 | }
|
9865 | if (scrollbarEl) currentParams.scrollbar.el = scrollbarEl;
|
9866 | scrollbar.init();
|
9867 | scrollbar.updateSize();
|
9868 | scrollbar.setTranslate();
|
9869 | }
|
9870 | if (needNavigationInit) {
|
9871 | if (swiper.isElement) {
|
9872 | if (!nextEl || typeof nextEl === 'string') {
|
9873 | nextEl = document.createElement('div');
|
9874 | nextEl.classList.add('swiper-button-next');
|
9875 | nextEl.innerHTML = swiper.hostEl.constructor.nextButtonSvg;
|
9876 | nextEl.part.add('button-next');
|
9877 | swiper.el.appendChild(nextEl);
|
9878 | }
|
9879 | if (!prevEl || typeof prevEl === 'string') {
|
9880 | prevEl = document.createElement('div');
|
9881 | prevEl.classList.add('swiper-button-prev');
|
9882 | prevEl.innerHTML = swiper.hostEl.constructor.prevButtonSvg;
|
9883 | prevEl.part.add('button-prev');
|
9884 | swiper.el.appendChild(prevEl);
|
9885 | }
|
9886 | }
|
9887 | if (nextEl) currentParams.navigation.nextEl = nextEl;
|
9888 | if (prevEl) currentParams.navigation.prevEl = prevEl;
|
9889 | navigation.init();
|
9890 | navigation.update();
|
9891 | }
|
9892 | if (changedParams.includes('allowSlideNext')) {
|
9893 | swiper.allowSlideNext = passedParams.allowSlideNext;
|
9894 | }
|
9895 | if (changedParams.includes('allowSlidePrev')) {
|
9896 | swiper.allowSlidePrev = passedParams.allowSlidePrev;
|
9897 | }
|
9898 | if (changedParams.includes('direction')) {
|
9899 | swiper.changeDirection(passedParams.direction, false);
|
9900 | }
|
9901 | if (loopNeedDestroy || loopNeedReloop) {
|
9902 | swiper.loopDestroy();
|
9903 | }
|
9904 | if (loopNeedEnable || loopNeedReloop) {
|
9905 | swiper.loopCreate();
|
9906 | }
|
9907 | swiper.update();
|
9908 | }
|
9909 |
|
9910 | const formatValue = val => {
|
9911 | if (parseFloat(val) === Number(val)) return Number(val);
|
9912 | if (val === 'true') return true;
|
9913 | if (val === '') return true;
|
9914 | if (val === 'false') return false;
|
9915 | if (val === 'null') return null;
|
9916 | if (val === 'undefined') return undefined;
|
9917 | if (typeof val === 'string' && val.includes('{') && val.includes('}') && val.includes('"')) {
|
9918 | let v;
|
9919 | try {
|
9920 | v = JSON.parse(val);
|
9921 | } catch (err) {
|
9922 | v = val;
|
9923 | }
|
9924 | return v;
|
9925 | }
|
9926 | return val;
|
9927 | };
|
9928 | 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'];
|
9929 | function getParams(element, propName, propValue) {
|
9930 | const params = {};
|
9931 | const passedParams = {};
|
9932 | extend(params, defaults);
|
9933 | const localParamsList = [...paramsList, 'on'];
|
9934 | const allowedParams = localParamsList.map(key => key.replace(/_/, ''));
|
9935 |
|
9936 |
|
9937 | localParamsList.forEach(paramName => {
|
9938 | paramName = paramName.replace('_', '');
|
9939 | if (typeof element[paramName] !== 'undefined') {
|
9940 | passedParams[paramName] = element[paramName];
|
9941 | }
|
9942 | });
|
9943 |
|
9944 |
|
9945 | const attrsList = [...element.attributes];
|
9946 | if (typeof propName === 'string' && typeof propValue !== 'undefined') {
|
9947 | attrsList.push({
|
9948 | name: propName,
|
9949 | value: isObject(propValue) ? {
|
9950 | ...propValue
|
9951 | } : propValue
|
9952 | });
|
9953 | }
|
9954 | attrsList.forEach(attr => {
|
9955 | const moduleParam = modulesParamsList.filter(mParam => attr.name.indexOf(`${mParam}-`) === 0)[0];
|
9956 | if (moduleParam) {
|
9957 | const parentObjName = attrToProp(moduleParam);
|
9958 | const subObjName = attrToProp(attr.name.split(`${moduleParam}-`)[1]);
|
9959 | if (typeof passedParams[parentObjName] === 'undefined') passedParams[parentObjName] = {};
|
9960 | if (passedParams[parentObjName] === true) {
|
9961 | passedParams[parentObjName] = {
|
9962 | enabled: true
|
9963 | };
|
9964 | }
|
9965 | passedParams[parentObjName][subObjName] = formatValue(attr.value);
|
9966 | } else {
|
9967 | const name = attrToProp(attr.name);
|
9968 | if (!allowedParams.includes(name)) return;
|
9969 | const value = formatValue(attr.value);
|
9970 | if (passedParams[name] && modulesParamsList.includes(attr.name) && !isObject(value)) {
|
9971 | if (passedParams[name].constructor !== Object) {
|
9972 | passedParams[name] = {};
|
9973 | }
|
9974 | passedParams[name].enabled = !!value;
|
9975 | } else {
|
9976 | passedParams[name] = value;
|
9977 | }
|
9978 | }
|
9979 | });
|
9980 | extend(params, passedParams);
|
9981 | if (params.navigation) {
|
9982 | params.navigation = {
|
9983 | prevEl: '.swiper-button-prev',
|
9984 | nextEl: '.swiper-button-next',
|
9985 | ...(params.navigation !== true ? params.navigation : {})
|
9986 | };
|
9987 | } else if (params.navigation === false) {
|
9988 | delete params.navigation;
|
9989 | }
|
9990 | if (params.scrollbar) {
|
9991 | params.scrollbar = {
|
9992 | el: '.swiper-scrollbar',
|
9993 | ...(params.scrollbar !== true ? params.scrollbar : {})
|
9994 | };
|
9995 | } else if (params.scrollbar === false) {
|
9996 | delete params.scrollbar;
|
9997 | }
|
9998 | if (params.pagination) {
|
9999 | params.pagination = {
|
10000 | el: '.swiper-pagination',
|
10001 | ...(params.pagination !== true ? params.pagination : {})
|
10002 | };
|
10003 | } else if (params.pagination === false) {
|
10004 | delete params.pagination;
|
10005 | }
|
10006 | return {
|
10007 | params,
|
10008 | passedParams
|
10009 | };
|
10010 | }
|
10011 |
|
10012 | |
10013 |
|
10014 |
|
10015 |
|
10016 |
|
10017 |
|
10018 |
|
10019 |
|
10020 |
|
10021 |
|
10022 |
|
10023 |
|
10024 |
|
10025 |
|
10026 |
|
10027 | 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;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)}.swiper-virtual ::slotted(swiper-slide){-webkit-backface-visibility:hidden;transform:translateZ(0)}.swiper-virtual.swiper-css-mode .swiper-wrapper::after{content:'';position:absolute;left:0;top:0;pointer-events:none}.swiper-virtual.swiper-css-mode.swiper-horizontal .swiper-wrapper::after{height:1px;width:var(--swiper-virtual-size)}.swiper-virtual.swiper-css-mode.swiper-vertical .swiper-wrapper::after{width:1px;height:var(--swiper-virtual-size)}:host{--swiper-navigation-size:44px}.swiper-button-next,.swiper-button-prev{position:absolute;top:var(--swiper-navigation-top-offset,50%);width:calc(var(--swiper-navigation-size)/ 44 * 27);height:var(--swiper-navigation-size);margin-top:calc(0px - (var(--swiper-navigation-size)/ 2));z-index:10;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--swiper-navigation-color,var(--swiper-theme-color))}.swiper-button-next.swiper-button-disabled,.swiper-button-prev.swiper-button-disabled{opacity:.35;cursor:auto;pointer-events:none}.swiper-button-next.swiper-button-hidden,.swiper-button-prev.swiper-button-hidden{opacity:0;cursor:auto;pointer-events:none}.swiper-navigation-disabled .swiper-button-next,.swiper-navigation-disabled .swiper-button-prev{display:none!important}.swiper-button-next svg,.swiper-button-prev svg{width:100%;height:100%;object-fit:contain;transform-origin:center}.swiper-rtl .swiper-button-next svg,.swiper-rtl .swiper-button-prev svg{transform:rotate(180deg)}.swiper-button-prev,.swiper-rtl .swiper-button-next{left:var(--swiper-navigation-sides-offset,10px);right:auto}.swiper-button-next,.swiper-rtl .swiper-button-prev{right:var(--swiper-navigation-sides-offset,10px);left:auto}.swiper-button-lock{display:none}.swiper-pagination{position:absolute;text-align:center;transition:.3s opacity;transform:translate3d(0,0,0);z-index:10}.swiper-pagination.swiper-pagination-hidden{opacity:0}.swiper-pagination-disabled>.swiper-pagination,.swiper-pagination.swiper-pagination-disabled{display:none!important}.swiper-horizontal>.swiper-pagination-bullets,.swiper-pagination-bullets.swiper-pagination-horizontal,.swiper-pagination-custom,.swiper-pagination-fraction{bottom:var(--swiper-pagination-bottom,8px);top:var(--swiper-pagination-top,auto);left:0;width:100%}.swiper-pagination-bullets-dynamic{overflow:hidden;font-size:0}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet{transform:scale(.33);position:relative}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active{transform:scale(1)}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-main{transform:scale(1)}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev{transform:scale(.66)}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev-prev{transform:scale(.33)}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next{transform:scale(.66)}.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next-next{transform:scale(.33)}.swiper-pagination-bullet{width:var(--swiper-pagination-bullet-width,var(--swiper-pagination-bullet-size,8px));height:var(--swiper-pagination-bullet-height,var(--swiper-pagination-bullet-size,8px));display:inline-block;border-radius:var(--swiper-pagination-bullet-border-radius,50%);background:var(--swiper-pagination-bullet-inactive-color,#000);opacity:var(--swiper-pagination-bullet-inactive-opacity, .2)}button.swiper-pagination-bullet{border:none;margin:0;padding:0;box-shadow:none;-webkit-appearance:none;appearance:none}.swiper-pagination-clickable .swiper-pagination-bullet{cursor:pointer}.swiper-pagination-bullet:only-child{display:none!important}.swiper-pagination-bullet-active{opacity:var(--swiper-pagination-bullet-opacity, 1);background:var(--swiper-pagination-color,var(--swiper-theme-color))}.swiper-pagination-vertical.swiper-pagination-bullets,.swiper-vertical>.swiper-pagination-bullets{right:var(--swiper-pagination-right,8px);left:var(--swiper-pagination-left,auto);top:50%;transform:translate3d(0px,-50%,0)}.swiper-pagination-vertical.swiper-pagination-bullets .swiper-pagination-bullet,.swiper-vertical>.swiper-pagination-bullets .swiper-pagination-bullet{margin:var(--swiper-pagination-bullet-vertical-gap,6px) 0;display:block}.swiper-pagination-vertical.swiper-pagination-bullets.swiper-pagination-bullets-dynamic,.swiper-vertical>.swiper-pagination-bullets.swiper-pagination-bullets-dynamic{top:50%;transform:translateY(-50%);width:8px}.swiper-pagination-vertical.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet,.swiper-vertical>.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet{display:inline-block;transition:.2s transform,.2s top}.swiper-horizontal>.swiper-pagination-bullets .swiper-pagination-bullet,.swiper-pagination-horizontal.swiper-pagination-bullets .swiper-pagination-bullet{margin:0 var(--swiper-pagination-bullet-horizontal-gap,4px)}.swiper-horizontal>.swiper-pagination-bullets.swiper-pagination-bullets-dynamic,.swiper-pagination-horizontal.swiper-pagination-bullets.swiper-pagination-bullets-dynamic{left:50%;transform:translateX(-50%);white-space:nowrap}.swiper-horizontal>.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet,.swiper-pagination-horizontal.swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet{transition:.2s transform,.2s left}.swiper-horizontal.swiper-rtl>.swiper-pagination-bullets-dynamic .swiper-pagination-bullet{transition:.2s transform,.2s right}.swiper-pagination-fraction{color:var(--swiper-pagination-fraction-color,inherit)}.swiper-pagination-progressbar{background:var(--swiper-pagination-progressbar-bg-color,rgba(0,0,0,.25));position:absolute}.swiper-pagination-progressbar .swiper-pagination-progressbar-fill{background:var(--swiper-pagination-color,var(--swiper-theme-color));position:absolute;left:0;top:0;width:100%;height:100%;transform:scale(0);transform-origin:left top}.swiper-rtl .swiper-pagination-progressbar .swiper-pagination-progressbar-fill{transform-origin:right top}.swiper-horizontal>.swiper-pagination-progressbar,.swiper-pagination-progressbar.swiper-pagination-horizontal,.swiper-pagination-progressbar.swiper-pagination-vertical.swiper-pagination-progressbar-opposite,.swiper-vertical>.swiper-pagination-progressbar.swiper-pagination-progressbar-opposite{width:100%;height:var(--swiper-pagination-progressbar-size,4px);left:0;top:0}.swiper-horizontal>.swiper-pagination-progressbar.swiper-pagination-progressbar-opposite,.swiper-pagination-progressbar.swiper-pagination-horizontal.swiper-pagination-progressbar-opposite,.swiper-pagination-progressbar.swiper-pagination-vertical,.swiper-vertical>.swiper-pagination-progressbar{width:var(--swiper-pagination-progressbar-size,4px);height:100%;left:0;top:0}.swiper-pagination-lock{display:none}.swiper-scrollbar{border-radius:var(--swiper-scrollbar-border-radius,10px);position:relative;touch-action:none;background:var(--swiper-scrollbar-bg-color,rgba(0,0,0,.1))}.swiper-scrollbar-disabled>.swiper-scrollbar,.swiper-scrollbar.swiper-scrollbar-disabled{display:none!important}.swiper-horizontal>.swiper-scrollbar,.swiper-scrollbar.swiper-scrollbar-horizontal{position:absolute;left:var(--swiper-scrollbar-sides-offset,1%);bottom:var(--swiper-scrollbar-bottom,4px);top:var(--swiper-scrollbar-top,auto);z-index:50;height:var(--swiper-scrollbar-size,4px);width:calc(100% - 2 * var(--swiper-scrollbar-sides-offset,1%))}.swiper-scrollbar.swiper-scrollbar-vertical,.swiper-vertical>.swiper-scrollbar{position:absolute;left:var(--swiper-scrollbar-left,auto);right:var(--swiper-scrollbar-right,4px);top:var(--swiper-scrollbar-sides-offset,1%);z-index:50;width:var(--swiper-scrollbar-size,4px);height:calc(100% - 2 * var(--swiper-scrollbar-sides-offset,1%))}.swiper-scrollbar-drag{height:100%;width:100%;position:relative;background:var(--swiper-scrollbar-drag-bg-color,rgba(0,0,0,.5));border-radius:var(--swiper-scrollbar-border-radius,10px);left:0;top:0}.swiper-scrollbar-cursor-drag{cursor:move}.swiper-scrollbar-lock{display:none}::slotted(.swiper-slide-zoomed){cursor:move;touch-action:none}.swiper .swiper-notification{position:absolute;left:0;top:0;pointer-events:none;opacity:0;z-index:-1000}.swiper-free-mode>.swiper-wrapper{transition-timing-function:ease-out;margin:0 auto}.swiper-grid>.swiper-wrapper{flex-wrap:wrap}.swiper-grid-column>.swiper-wrapper{flex-wrap:wrap;flex-direction:column}.swiper-fade.swiper-free-mode ::slotted(swiper-slide){transition-timing-function:ease-out}.swiper-fade ::slotted(swiper-slide){pointer-events:none;transition-property:opacity}.swiper-fade ::slotted(swiper-slide) ::slotted(swiper-slide){pointer-events:none}.swiper-fade ::slotted(.swiper-slide-active){pointer-events:auto}.swiper-fade ::slotted(.swiper-slide-active) ::slotted(.swiper-slide-active){pointer-events:auto}.swiper.swiper-cube{overflow:visible}.swiper-cube ::slotted(swiper-slide){pointer-events:none;-webkit-backface-visibility:hidden;backface-visibility:hidden;z-index:1;visibility:hidden;transform-origin:0 0;width:100%;height:100%}.swiper-cube ::slotted(swiper-slide) ::slotted(swiper-slide){pointer-events:none}.swiper-cube.swiper-rtl ::slotted(swiper-slide){transform-origin:100% 0}.swiper-cube ::slotted(.swiper-slide-active),.swiper-cube ::slotted(.swiper-slide-active) ::slotted(.swiper-slide-active){pointer-events:auto}.swiper-cube ::slotted(.swiper-slide-active),.swiper-cube ::slotted(.swiper-slide-next),.swiper-cube ::slotted(.swiper-slide-prev){pointer-events:auto;visibility:visible}.swiper-cube .swiper-cube-shadow{position:absolute;left:0;bottom:0px;width:100%;height:100%;opacity:.6;z-index:0}.swiper-cube .swiper-cube-shadow:before{content:'';background:#000;position:absolute;left:0;top:0;bottom:0;right:0;filter:blur(50px)}.swiper-cube ::slotted(.swiper-slide-next)+::slotted(swiper-slide){pointer-events:auto;visibility:visible}.swiper.swiper-flip{overflow:visible}.swiper-flip ::slotted(swiper-slide){pointer-events:none;-webkit-backface-visibility:hidden;backface-visibility:hidden;z-index:1}.swiper-flip ::slotted(swiper-slide) ::slotted(swiper-slide){pointer-events:none}.swiper-flip ::slotted(.swiper-slide-active),.swiper-flip ::slotted(.swiper-slide-active) ::slotted(.swiper-slide-active){pointer-events:auto}.swiper-creative ::slotted(swiper-slide){-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden;transition-property:transform,opacity,height}.swiper.swiper-cards{overflow:visible}.swiper-cards ::slotted(swiper-slide){transform-origin:center bottom;-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden}`;
|
10028 | 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))}.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}::slotted(.swiper-zoom-container){width:100%;height:100%;display:flex;justify-content:center;align-items:center;text-align:center}::slotted(.swiper-zoom-container)>canvas,::slotted(.swiper-zoom-container)>img,::slotted(.swiper-zoom-container)>svg{max-width:100%;max-height:100%;object-fit:contain}`;
|
10029 |
|
10030 | class DummyHTMLElement {}
|
10031 | const ClassToExtend = typeof window === 'undefined' || typeof HTMLElement === 'undefined' ? DummyHTMLElement : HTMLElement;
|
10032 | 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>
|
10033 | `;
|
10034 | const addStyle = (shadowRoot, styles) => {
|
10035 | if (typeof CSSStyleSheet !== 'undefined' && shadowRoot.adoptedStyleSheets) {
|
10036 | const styleSheet = new CSSStyleSheet();
|
10037 | styleSheet.replaceSync(styles);
|
10038 | shadowRoot.adoptedStyleSheets = [styleSheet];
|
10039 | } else {
|
10040 | const style = document.createElement('style');
|
10041 | style.rel = 'stylesheet';
|
10042 | style.textContent = styles;
|
10043 | shadowRoot.appendChild(style);
|
10044 | }
|
10045 | };
|
10046 | class SwiperContainer extends ClassToExtend {
|
10047 | constructor() {
|
10048 | super();
|
10049 | this.attachShadow({
|
10050 | mode: 'open'
|
10051 | });
|
10052 | }
|
10053 | static get nextButtonSvg() {
|
10054 | return arrowSvg;
|
10055 | }
|
10056 | static get prevButtonSvg() {
|
10057 | return arrowSvg.replace('/></svg>', ' transform-origin="center" transform="rotate(180)"/></svg>');
|
10058 | }
|
10059 | cssStyles() {
|
10060 | return [SwiperCSS,
|
10061 |
|
10062 | ...(this.injectStyles && Array.isArray(this.injectStyles) ? this.injectStyles : [])].join('\n');
|
10063 | }
|
10064 | cssLinks() {
|
10065 | return this.injectStylesUrls || [];
|
10066 | }
|
10067 | calcSlideSlots() {
|
10068 | const currentSideSlots = this.slideSlots || 0;
|
10069 |
|
10070 | const slideSlotChildren = [...this.querySelectorAll(`[slot^=slide-]`)].map(child => {
|
10071 | return parseInt(child.getAttribute('slot').split('slide-')[1], 10);
|
10072 | });
|
10073 | this.slideSlots = slideSlotChildren.length ? Math.max(...slideSlotChildren) + 1 : 0;
|
10074 | if (!this.rendered) return;
|
10075 | if (this.slideSlots > currentSideSlots) {
|
10076 | for (let i = currentSideSlots; i < this.slideSlots; i += 1) {
|
10077 | const slideEl = document.createElement('swiper-slide');
|
10078 | slideEl.setAttribute('part', `slide slide-${i + 1}`);
|
10079 | const slotEl = document.createElement('slot');
|
10080 | slotEl.setAttribute('name', `slide-${i + 1}`);
|
10081 | slideEl.appendChild(slotEl);
|
10082 | this.shadowRoot.querySelector('.swiper-wrapper').appendChild(slideEl);
|
10083 | }
|
10084 | } else if (this.slideSlots < currentSideSlots) {
|
10085 | const slides = this.swiper.slides;
|
10086 | for (let i = slides.length - 1; i >= 0; i -= 1) {
|
10087 | if (i > this.slideSlots) {
|
10088 | slides[i].remove();
|
10089 | }
|
10090 | }
|
10091 | }
|
10092 | }
|
10093 | render() {
|
10094 | if (this.rendered) return;
|
10095 | this.calcSlideSlots();
|
10096 |
|
10097 |
|
10098 | let localStyles = this.cssStyles();
|
10099 | if (this.slideSlots > 0) {
|
10100 | localStyles = localStyles.replace(/::slotted\(([a-z-0-9.]*)\)/g, '$1');
|
10101 | }
|
10102 | if (localStyles.length) {
|
10103 | addStyle(this.shadowRoot, localStyles);
|
10104 | }
|
10105 | this.cssLinks().forEach(url => {
|
10106 | const linkExists = this.shadowRoot.querySelector(`link[href="${url}"]`);
|
10107 | if (linkExists) return;
|
10108 | const linkEl = document.createElement('link');
|
10109 | linkEl.rel = 'stylesheet';
|
10110 | linkEl.href = url;
|
10111 | this.shadowRoot.appendChild(linkEl);
|
10112 | });
|
10113 |
|
10114 | const el = document.createElement('div');
|
10115 | el.classList.add('swiper');
|
10116 | el.part = 'container';
|
10117 |
|
10118 |
|
10119 | el.innerHTML = `
|
10120 | <slot name="container-start"></slot>
|
10121 | <div class="swiper-wrapper" part="wrapper">
|
10122 | <slot></slot>
|
10123 | ${Array.from({
|
10124 | length: this.slideSlots
|
10125 | }).map((_, index) => `
|
10126 | <swiper-slide part="slide slide-${index}">
|
10127 | <slot name="slide-${index}"></slot>
|
10128 | </swiper-slide>
|
10129 | `).join('')}
|
10130 | </div>
|
10131 | <slot name="container-end"></slot>
|
10132 | ${needsNavigation(this.passedParams) ? `
|
10133 | <div part="button-prev" class="swiper-button-prev">${this.constructor.prevButtonSvg}</div>
|
10134 | <div part="button-next" class="swiper-button-next">${this.constructor.nextButtonSvg}</div>
|
10135 | ` : ''}
|
10136 | ${needsPagination(this.passedParams) ? `
|
10137 | <div part="pagination" class="swiper-pagination"></div>
|
10138 | ` : ''}
|
10139 | ${needsScrollbar(this.passedParams) ? `
|
10140 | <div part="scrollbar" class="swiper-scrollbar"></div>
|
10141 | ` : ''}
|
10142 | `;
|
10143 | this.shadowRoot.appendChild(el);
|
10144 | this.rendered = true;
|
10145 | }
|
10146 | initialize() {
|
10147 | var _this = this;
|
10148 | if (this.initialized) return;
|
10149 | this.initialized = true;
|
10150 | const {
|
10151 | params: swiperParams,
|
10152 | passedParams
|
10153 | } = getParams(this);
|
10154 | this.swiperParams = swiperParams;
|
10155 | this.passedParams = passedParams;
|
10156 | delete this.swiperParams.init;
|
10157 | this.render();
|
10158 |
|
10159 |
|
10160 | this.swiper = new Swiper(this.shadowRoot.querySelector('.swiper'), {
|
10161 | ...(swiperParams.virtual ? {} : {
|
10162 | observer: true
|
10163 | }),
|
10164 | ...swiperParams,
|
10165 | touchEventsTarget: 'container',
|
10166 | onAny: function (name) {
|
10167 | if (name === 'observerUpdate') {
|
10168 | _this.calcSlideSlots();
|
10169 | }
|
10170 | const eventName = swiperParams.eventsPrefix ? `${swiperParams.eventsPrefix}${name.toLowerCase()}` : name.toLowerCase();
|
10171 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
10172 | args[_key - 1] = arguments[_key];
|
10173 | }
|
10174 | const event = new CustomEvent(eventName, {
|
10175 | detail: args,
|
10176 | bubbles: name !== 'hashChange',
|
10177 | cancelable: true
|
10178 | });
|
10179 | _this.dispatchEvent(event);
|
10180 | }
|
10181 | });
|
10182 | }
|
10183 | connectedCallback() {
|
10184 | if (this.initialized && this.nested && this.closest('swiper-slide') && this.closest('swiper-slide').swiperLoopMoveDOM) {
|
10185 | return;
|
10186 | }
|
10187 | if (this.init === false || this.getAttribute('init') === 'false') {
|
10188 | return;
|
10189 | }
|
10190 | this.initialize();
|
10191 | }
|
10192 | disconnectedCallback() {
|
10193 | if (this.nested && this.closest('swiper-slide') && this.closest('swiper-slide').swiperLoopMoveDOM) {
|
10194 | return;
|
10195 | }
|
10196 | if (this.swiper && this.swiper.destroy) {
|
10197 | this.swiper.destroy();
|
10198 | }
|
10199 | this.initialized = false;
|
10200 | }
|
10201 | updateSwiperOnPropChange(propName, propValue) {
|
10202 | const {
|
10203 | params: swiperParams,
|
10204 | passedParams
|
10205 | } = getParams(this, propName, propValue);
|
10206 | this.passedParams = passedParams;
|
10207 | this.swiperParams = swiperParams;
|
10208 | if (this.swiper && this.swiper.params[propName] === propValue) {
|
10209 | return;
|
10210 | }
|
10211 | updateSwiper({
|
10212 | swiper: this.swiper,
|
10213 | passedParams: this.passedParams,
|
10214 | changedParams: [attrToProp(propName)],
|
10215 | ...(propName === 'navigation' && passedParams[propName] ? {
|
10216 | prevEl: '.swiper-button-prev',
|
10217 | nextEl: '.swiper-button-next'
|
10218 | } : {}),
|
10219 | ...(propName === 'pagination' && passedParams[propName] ? {
|
10220 | paginationEl: '.swiper-pagination'
|
10221 | } : {}),
|
10222 | ...(propName === 'scrollbar' && passedParams[propName] ? {
|
10223 | scrollbarEl: '.swiper-scrollbar'
|
10224 | } : {})
|
10225 | });
|
10226 | }
|
10227 | attributeChangedCallback(attr, prevValue, newValue) {
|
10228 | if (!this.initialized) return;
|
10229 | if (prevValue === 'true' && newValue === null) {
|
10230 | newValue = false;
|
10231 | }
|
10232 | this.updateSwiperOnPropChange(attr, newValue);
|
10233 | }
|
10234 | static get observedAttributes() {
|
10235 | const attrs = paramsList.filter(param => param.includes('_')).map(param => param.replace(/[A-Z]/g, v => `-${v}`).replace('_', '').toLowerCase());
|
10236 | return attrs;
|
10237 | }
|
10238 | }
|
10239 | paramsList.forEach(paramName => {
|
10240 | if (paramName === 'init') return;
|
10241 | paramName = paramName.replace('_', '');
|
10242 | Object.defineProperty(SwiperContainer.prototype, paramName, {
|
10243 | configurable: true,
|
10244 | get() {
|
10245 | return (this.passedParams || {})[paramName];
|
10246 | },
|
10247 | set(value) {
|
10248 | if (!this.passedParams) this.passedParams = {};
|
10249 | this.passedParams[paramName] = value;
|
10250 | if (!this.initialized) return;
|
10251 | this.updateSwiperOnPropChange(paramName, value);
|
10252 | }
|
10253 | });
|
10254 | });
|
10255 | class SwiperSlide extends ClassToExtend {
|
10256 | constructor() {
|
10257 | super();
|
10258 | this.attachShadow({
|
10259 | mode: 'open'
|
10260 | });
|
10261 | }
|
10262 | render() {
|
10263 | const lazy = this.lazy || this.getAttribute('lazy') === '' || this.getAttribute('lazy') === 'true';
|
10264 | addStyle(this.shadowRoot, SwiperSlideCSS);
|
10265 | this.shadowRoot.appendChild(document.createElement('slot'));
|
10266 | if (lazy) {
|
10267 | const lazyDiv = document.createElement('div');
|
10268 | lazyDiv.classList.add('swiper-lazy-preloader');
|
10269 | lazyDiv.part.add('preloader');
|
10270 | this.shadowRoot.appendChild(lazyDiv);
|
10271 | }
|
10272 | }
|
10273 | initialize() {
|
10274 | this.render();
|
10275 | }
|
10276 | connectedCallback() {
|
10277 | this.initialize();
|
10278 | }
|
10279 | }
|
10280 |
|
10281 |
|
10282 | const register = () => {
|
10283 | if (typeof window === 'undefined') return;
|
10284 | if (!window.customElements.get('swiper-container')) window.customElements.define('swiper-container', SwiperContainer);
|
10285 | if (!window.customElements.get('swiper-slide')) window.customElements.define('swiper-slide', SwiperSlide);
|
10286 | };
|
10287 | if (typeof window !== 'undefined') {
|
10288 | window.SwiperElementRegisterParams = params => {
|
10289 | paramsList.push(...params);
|
10290 | };
|
10291 | }
|
10292 |
|
10293 | register();
|
10294 |
|
10295 | })();
|