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