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