@gravity-ui/page-constructor 8.12.0 → 8.13.0-beta.1
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/build/cjs/_vendor/swiper-modules.js +187 -136
- package/build/cjs/_vendor/swiper-modules.js.map +3 -3
- package/build/cjs/_vendor/swiper-react.js +770 -481
- package/build/cjs/_vendor/swiper-react.js.map +3 -3
- package/build/cjs/_vendor/swiper.js +693 -404
- package/build/cjs/_vendor/swiper.js.map +3 -3
- package/build/cjs/node_modules/swiper/modules/index.js +187 -136
- package/build/cjs/node_modules/swiper/modules/pagination.css +108 -104
- package/build/cjs/node_modules/swiper/package.json +1 -1
- package/build/cjs/node_modules/swiper/swiper-react.d.ts +5 -0
- package/build/cjs/node_modules/swiper/swiper-react.js +770 -481
- package/build/cjs/node_modules/swiper/swiper.css +124 -102
- package/build/cjs/node_modules/swiper/swiper.js +693 -404
- package/build/cjs/node_modules/swiper/types/modules/index.d.ts +0 -2
- package/build/cjs/sub-blocks/Content/Content.css +4 -4
- package/build/esm/sub-blocks/Content/Content.css +4 -4
- package/package.json +3 -2
- package/widget/index.js +1 -1
|
@@ -28,14 +28,9 @@ module.exports = __toCommonJS(swiper_exports);
|
|
|
28
28
|
function isObject(obj) {
|
|
29
29
|
return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object;
|
|
30
30
|
}
|
|
31
|
-
function extend(target, src) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
if (src === void 0) {
|
|
36
|
-
src = {};
|
|
37
|
-
}
|
|
38
|
-
Object.keys(src).forEach((key) => {
|
|
31
|
+
function extend(target = {}, src = {}) {
|
|
32
|
+
const noExtend = ["__proto__", "constructor", "prototype"];
|
|
33
|
+
Object.keys(src).filter((key) => noExtend.indexOf(key) < 0).forEach((key) => {
|
|
39
34
|
if (typeof target[key] === "undefined") target[key] = src[key];
|
|
40
35
|
else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
|
41
36
|
extend(target[key], src[key]);
|
|
@@ -174,6 +169,9 @@ function getWindow() {
|
|
|
174
169
|
}
|
|
175
170
|
|
|
176
171
|
// node_modules/swiper/shared/utils.mjs
|
|
172
|
+
function classesToTokens(classes2 = "") {
|
|
173
|
+
return classes2.trim().split(" ").filter((c) => !!c.trim());
|
|
174
|
+
}
|
|
177
175
|
function deleteProps(obj) {
|
|
178
176
|
const object = obj;
|
|
179
177
|
Object.keys(object).forEach((key) => {
|
|
@@ -187,10 +185,7 @@ function deleteProps(obj) {
|
|
|
187
185
|
}
|
|
188
186
|
});
|
|
189
187
|
}
|
|
190
|
-
function nextTick(callback, delay) {
|
|
191
|
-
if (delay === void 0) {
|
|
192
|
-
delay = 0;
|
|
193
|
-
}
|
|
188
|
+
function nextTick(callback, delay = 0) {
|
|
194
189
|
return setTimeout(callback, delay);
|
|
195
190
|
}
|
|
196
191
|
function now() {
|
|
@@ -210,10 +205,7 @@ function getComputedStyle2(el) {
|
|
|
210
205
|
}
|
|
211
206
|
return style;
|
|
212
207
|
}
|
|
213
|
-
function getTranslate(el, axis) {
|
|
214
|
-
if (axis === void 0) {
|
|
215
|
-
axis = "x";
|
|
216
|
-
}
|
|
208
|
+
function getTranslate(el, axis = "x") {
|
|
217
209
|
const window2 = getWindow();
|
|
218
210
|
let matrix;
|
|
219
211
|
let curTransform;
|
|
@@ -250,13 +242,12 @@ function isNode(node) {
|
|
|
250
242
|
}
|
|
251
243
|
return node && (node.nodeType === 1 || node.nodeType === 11);
|
|
252
244
|
}
|
|
253
|
-
function extend2() {
|
|
254
|
-
const to = Object(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const nextSource = i < 0 || arguments.length <= i ? void 0 : arguments[i];
|
|
245
|
+
function extend2(...args) {
|
|
246
|
+
const to = Object(args[0]);
|
|
247
|
+
for (let i = 1; i < args.length; i += 1) {
|
|
248
|
+
const nextSource = args[i];
|
|
258
249
|
if (nextSource !== void 0 && nextSource !== null && !isNode(nextSource)) {
|
|
259
|
-
const keysArray = Object.keys(Object(nextSource)).filter((key) =>
|
|
250
|
+
const keysArray = Object.keys(Object(nextSource)).filter((key) => key !== "__proto__" && key !== "constructor" && key !== "prototype");
|
|
260
251
|
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
|
|
261
252
|
const nextKey = keysArray[nextIndex];
|
|
262
253
|
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
@@ -286,12 +277,11 @@ function extend2() {
|
|
|
286
277
|
function setCSSProperty(el, varName, varValue) {
|
|
287
278
|
el.style.setProperty(varName, varValue);
|
|
288
279
|
}
|
|
289
|
-
function animateCSSModeScroll(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} = _ref;
|
|
280
|
+
function animateCSSModeScroll({
|
|
281
|
+
swiper,
|
|
282
|
+
targetPosition,
|
|
283
|
+
side
|
|
284
|
+
}) {
|
|
295
285
|
const window2 = getWindow();
|
|
296
286
|
const startPosition = -swiper.translate;
|
|
297
287
|
let startTime = null;
|
|
@@ -333,18 +323,49 @@ function animateCSSModeScroll(_ref) {
|
|
|
333
323
|
};
|
|
334
324
|
animate();
|
|
335
325
|
}
|
|
336
|
-
function elementChildren(element, selector) {
|
|
337
|
-
|
|
338
|
-
|
|
326
|
+
function elementChildren(element, selector = "") {
|
|
327
|
+
const window2 = getWindow();
|
|
328
|
+
const children = [...element.children];
|
|
329
|
+
if (window2.HTMLSlotElement && element instanceof HTMLSlotElement) {
|
|
330
|
+
children.push(...element.assignedElements());
|
|
331
|
+
}
|
|
332
|
+
if (!selector) {
|
|
333
|
+
return children;
|
|
334
|
+
}
|
|
335
|
+
return children.filter((el) => el.matches(selector));
|
|
336
|
+
}
|
|
337
|
+
function elementIsChildOfSlot(el, slot) {
|
|
338
|
+
const elementsQueue = [slot];
|
|
339
|
+
while (elementsQueue.length > 0) {
|
|
340
|
+
const elementToCheck = elementsQueue.shift();
|
|
341
|
+
if (el === elementToCheck) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
elementsQueue.push(...elementToCheck.children, ...elementToCheck.shadowRoot ? elementToCheck.shadowRoot.children : [], ...elementToCheck.assignedElements ? elementToCheck.assignedElements() : []);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function elementIsChildOf(el, parent) {
|
|
348
|
+
const window2 = getWindow();
|
|
349
|
+
let isChild = parent.contains(el);
|
|
350
|
+
if (!isChild && window2.HTMLSlotElement && parent instanceof HTMLSlotElement) {
|
|
351
|
+
const children = [...parent.assignedElements()];
|
|
352
|
+
isChild = children.includes(el);
|
|
353
|
+
if (!isChild) {
|
|
354
|
+
isChild = elementIsChildOfSlot(el, parent);
|
|
355
|
+
}
|
|
339
356
|
}
|
|
340
|
-
return
|
|
357
|
+
return isChild;
|
|
341
358
|
}
|
|
342
|
-
function
|
|
343
|
-
|
|
344
|
-
|
|
359
|
+
function showWarning(text) {
|
|
360
|
+
try {
|
|
361
|
+
console.warn(text);
|
|
362
|
+
return;
|
|
363
|
+
} catch (err) {
|
|
345
364
|
}
|
|
365
|
+
}
|
|
366
|
+
function createElement(tag, classes2 = []) {
|
|
346
367
|
const el = document.createElement(tag);
|
|
347
|
-
el.classList.add(...Array.isArray(classes2) ? classes2 :
|
|
368
|
+
el.classList.add(...Array.isArray(classes2) ? classes2 : classesToTokens(classes2));
|
|
348
369
|
return el;
|
|
349
370
|
}
|
|
350
371
|
function elementPrevAll(el, selector) {
|
|
@@ -423,10 +444,9 @@ function getSupport() {
|
|
|
423
444
|
return support;
|
|
424
445
|
}
|
|
425
446
|
var deviceCached;
|
|
426
|
-
function calcDevice(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
} = _temp === void 0 ? {} : _temp;
|
|
447
|
+
function calcDevice({
|
|
448
|
+
userAgent
|
|
449
|
+
} = {}) {
|
|
430
450
|
const support2 = getSupport();
|
|
431
451
|
const window2 = getWindow();
|
|
432
452
|
const platform = window2.navigator.platform;
|
|
@@ -438,7 +458,7 @@ function calcDevice(_temp) {
|
|
|
438
458
|
const screenWidth = window2.screen.width;
|
|
439
459
|
const screenHeight = window2.screen.height;
|
|
440
460
|
const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
|
|
441
|
-
let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
|
461
|
+
let ipad = ua.match(/(iPad)(?!\1).*OS\s([\d_]+)/);
|
|
442
462
|
const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
|
443
463
|
const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
|
444
464
|
const windows = platform === "Win32";
|
|
@@ -459,10 +479,7 @@ function calcDevice(_temp) {
|
|
|
459
479
|
}
|
|
460
480
|
return device;
|
|
461
481
|
}
|
|
462
|
-
function getDevice(overrides) {
|
|
463
|
-
if (overrides === void 0) {
|
|
464
|
-
overrides = {};
|
|
465
|
-
}
|
|
482
|
+
function getDevice(overrides = {}) {
|
|
466
483
|
if (!deviceCached) {
|
|
467
484
|
deviceCached = calcDevice(overrides);
|
|
468
485
|
}
|
|
@@ -471,6 +488,7 @@ function getDevice(overrides) {
|
|
|
471
488
|
var browser;
|
|
472
489
|
function calcBrowser() {
|
|
473
490
|
const window2 = getWindow();
|
|
491
|
+
const device = getDevice();
|
|
474
492
|
let needPerspectiveFix = false;
|
|
475
493
|
function isSafari() {
|
|
476
494
|
const ua = window2.navigator.userAgent.toLowerCase();
|
|
@@ -483,10 +501,14 @@ function calcBrowser() {
|
|
|
483
501
|
needPerspectiveFix = major < 16 || major === 16 && minor < 2;
|
|
484
502
|
}
|
|
485
503
|
}
|
|
504
|
+
const isWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window2.navigator.userAgent);
|
|
505
|
+
const isSafariBrowser = isSafari();
|
|
506
|
+
const need3dFix = isSafariBrowser || isWebView && device.ios;
|
|
486
507
|
return {
|
|
487
|
-
isSafari: needPerspectiveFix ||
|
|
508
|
+
isSafari: needPerspectiveFix || isSafariBrowser,
|
|
488
509
|
needPerspectiveFix,
|
|
489
|
-
|
|
510
|
+
need3dFix,
|
|
511
|
+
isWebView
|
|
490
512
|
};
|
|
491
513
|
}
|
|
492
514
|
function getBrowser() {
|
|
@@ -495,12 +517,11 @@ function getBrowser() {
|
|
|
495
517
|
}
|
|
496
518
|
return browser;
|
|
497
519
|
}
|
|
498
|
-
function Resize(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
} = _ref;
|
|
520
|
+
function Resize({
|
|
521
|
+
swiper,
|
|
522
|
+
on,
|
|
523
|
+
emit
|
|
524
|
+
}) {
|
|
504
525
|
const window2 = getWindow();
|
|
505
526
|
let observer = null;
|
|
506
527
|
let animationFrame = null;
|
|
@@ -519,12 +540,11 @@ function Resize(_ref) {
|
|
|
519
540
|
} = swiper;
|
|
520
541
|
let newWidth = width;
|
|
521
542
|
let newHeight = height;
|
|
522
|
-
entries.forEach((
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
} = _ref2;
|
|
543
|
+
entries.forEach(({
|
|
544
|
+
contentBoxSize,
|
|
545
|
+
contentRect,
|
|
546
|
+
target
|
|
547
|
+
}) => {
|
|
528
548
|
if (target && target !== swiper.el) return;
|
|
529
549
|
newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
|
|
530
550
|
newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
|
|
@@ -563,19 +583,15 @@ function Resize(_ref) {
|
|
|
563
583
|
window2.removeEventListener("orientationchange", orientationChangeHandler);
|
|
564
584
|
});
|
|
565
585
|
}
|
|
566
|
-
function Observer(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
} = _ref;
|
|
586
|
+
function Observer({
|
|
587
|
+
swiper,
|
|
588
|
+
extendParams,
|
|
589
|
+
on,
|
|
590
|
+
emit
|
|
591
|
+
}) {
|
|
573
592
|
const observers = [];
|
|
574
593
|
const window2 = getWindow();
|
|
575
|
-
const attach =
|
|
576
|
-
if (options === void 0) {
|
|
577
|
-
options = {};
|
|
578
|
-
}
|
|
594
|
+
const attach = (target, options = {}) => {
|
|
579
595
|
const ObserverFunc = window2.MutationObserver || window2.WebkitMutationObserver;
|
|
580
596
|
const observer = new ObserverFunc((mutations) => {
|
|
581
597
|
if (swiper.__preventObserver__) return;
|
|
@@ -594,7 +610,7 @@ function Observer(_ref) {
|
|
|
594
610
|
});
|
|
595
611
|
observer.observe(target, {
|
|
596
612
|
attributes: typeof options.attributes === "undefined" ? true : options.attributes,
|
|
597
|
-
childList: typeof options.childList === "undefined" ? true : options.childList,
|
|
613
|
+
childList: swiper.isElement || (typeof options.childList === "undefined" ? true : options).childList,
|
|
598
614
|
characterData: typeof options.characterData === "undefined" ? true : options.characterData
|
|
599
615
|
});
|
|
600
616
|
observers.push(observer);
|
|
@@ -644,14 +660,11 @@ var eventsEmitter = {
|
|
|
644
660
|
const self = this;
|
|
645
661
|
if (!self.eventsListeners || self.destroyed) return self;
|
|
646
662
|
if (typeof handler !== "function") return self;
|
|
647
|
-
function onceHandler() {
|
|
663
|
+
function onceHandler(...args) {
|
|
648
664
|
self.off(events2, onceHandler);
|
|
649
665
|
if (onceHandler.__emitterProxy) {
|
|
650
666
|
delete onceHandler.__emitterProxy;
|
|
651
667
|
}
|
|
652
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
653
|
-
args[_key] = arguments[_key];
|
|
654
|
-
}
|
|
655
668
|
handler.apply(self, args);
|
|
656
669
|
}
|
|
657
670
|
onceHandler.__emitterProxy = handler;
|
|
@@ -694,16 +707,13 @@ var eventsEmitter = {
|
|
|
694
707
|
});
|
|
695
708
|
return self;
|
|
696
709
|
},
|
|
697
|
-
emit() {
|
|
710
|
+
emit(...args) {
|
|
698
711
|
const self = this;
|
|
699
712
|
if (!self.eventsListeners || self.destroyed) return self;
|
|
700
713
|
if (!self.eventsListeners) return self;
|
|
701
714
|
let events2;
|
|
702
715
|
let data;
|
|
703
716
|
let context;
|
|
704
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
705
|
-
args[_key2] = arguments[_key2];
|
|
706
|
-
}
|
|
707
717
|
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
708
718
|
events2 = args[0];
|
|
709
719
|
data = args.slice(1, args.length);
|
|
@@ -760,29 +770,13 @@ function updateSize() {
|
|
|
760
770
|
}
|
|
761
771
|
function updateSlides() {
|
|
762
772
|
const swiper = this;
|
|
763
|
-
function getDirectionLabel(property) {
|
|
764
|
-
if (swiper.isHorizontal()) {
|
|
765
|
-
return property;
|
|
766
|
-
}
|
|
767
|
-
return {
|
|
768
|
-
"width": "height",
|
|
769
|
-
"margin-top": "margin-left",
|
|
770
|
-
"margin-bottom ": "margin-right",
|
|
771
|
-
"margin-left": "margin-top",
|
|
772
|
-
"margin-right": "margin-bottom",
|
|
773
|
-
"padding-left": "padding-top",
|
|
774
|
-
"padding-right": "padding-bottom",
|
|
775
|
-
"marginRight": "marginBottom"
|
|
776
|
-
}[property];
|
|
777
|
-
}
|
|
778
773
|
function getDirectionPropertyValue(node, label) {
|
|
779
|
-
return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
|
|
774
|
+
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
780
775
|
}
|
|
781
776
|
const params = swiper.params;
|
|
782
777
|
const {
|
|
783
778
|
wrapperEl,
|
|
784
779
|
slidesEl,
|
|
785
|
-
size: swiperSize,
|
|
786
780
|
rtlTranslate: rtl,
|
|
787
781
|
wrongRTL
|
|
788
782
|
} = swiper;
|
|
@@ -803,6 +797,7 @@ function updateSlides() {
|
|
|
803
797
|
}
|
|
804
798
|
const previousSnapGridLength = swiper.snapGrid.length;
|
|
805
799
|
const previousSlidesGridLength = swiper.slidesGrid.length;
|
|
800
|
+
const swiperSize = swiper.size - offsetBefore - offsetAfter;
|
|
806
801
|
let spaceBetween = params.spaceBetween;
|
|
807
802
|
let slidePosition = -offsetBefore;
|
|
808
803
|
let prevSlideSize = 0;
|
|
@@ -815,7 +810,7 @@ function updateSlides() {
|
|
|
815
810
|
} else if (typeof spaceBetween === "string") {
|
|
816
811
|
spaceBetween = parseFloat(spaceBetween);
|
|
817
812
|
}
|
|
818
|
-
swiper.virtualSize = -spaceBetween;
|
|
813
|
+
swiper.virtualSize = -spaceBetween - offsetBefore - offsetAfter;
|
|
819
814
|
slides.forEach((slideEl) => {
|
|
820
815
|
if (rtl) {
|
|
821
816
|
slideEl.style.marginLeft = "";
|
|
@@ -829,9 +824,15 @@ function updateSlides() {
|
|
|
829
824
|
setCSSProperty(wrapperEl, "--swiper-centered-offset-before", "");
|
|
830
825
|
setCSSProperty(wrapperEl, "--swiper-centered-offset-after", "");
|
|
831
826
|
}
|
|
827
|
+
if (params.cssMode) {
|
|
828
|
+
setCSSProperty(wrapperEl, "--swiper-slides-offset-before", `${offsetBefore}px`);
|
|
829
|
+
setCSSProperty(wrapperEl, "--swiper-slides-offset-after", `${offsetAfter}px`);
|
|
830
|
+
}
|
|
832
831
|
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
833
832
|
if (gridEnabled) {
|
|
834
|
-
swiper.grid.initSlides(
|
|
833
|
+
swiper.grid.initSlides(slides);
|
|
834
|
+
} else if (swiper.grid) {
|
|
835
|
+
swiper.grid.unsetSlides();
|
|
835
836
|
}
|
|
836
837
|
let slideSize;
|
|
837
838
|
const shouldResetSlideSize = params.slidesPerView === "auto" && params.breakpoints && Object.keys(params.breakpoints).filter((key) => {
|
|
@@ -839,15 +840,24 @@ function updateSlides() {
|
|
|
839
840
|
}).length > 0;
|
|
840
841
|
for (let i = 0; i < slidesLength; i += 1) {
|
|
841
842
|
slideSize = 0;
|
|
842
|
-
|
|
843
|
-
if (
|
|
844
|
-
|
|
845
|
-
|
|
843
|
+
const slide2 = slides[i];
|
|
844
|
+
if (slide2) {
|
|
845
|
+
if (gridEnabled) {
|
|
846
|
+
swiper.grid.updateSlide(i, slide2, slides);
|
|
847
|
+
}
|
|
848
|
+
if (elementStyle(slide2, "display") === "none") continue;
|
|
846
849
|
}
|
|
847
|
-
if (
|
|
848
|
-
|
|
850
|
+
if (isVirtual && params.slidesPerView === "auto") {
|
|
851
|
+
if (params.virtual.slidesPerViewAutoSlideSize) {
|
|
852
|
+
slideSize = params.virtual.slidesPerViewAutoSlideSize;
|
|
853
|
+
}
|
|
854
|
+
if (slideSize && slide2) {
|
|
855
|
+
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
856
|
+
slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`;
|
|
857
|
+
}
|
|
858
|
+
} else if (params.slidesPerView === "auto") {
|
|
849
859
|
if (shouldResetSlideSize) {
|
|
850
|
-
|
|
860
|
+
slide2.style[swiper.getDirectionLabel("width")] = ``;
|
|
851
861
|
}
|
|
852
862
|
const slideStyles = getComputedStyle(slide2);
|
|
853
863
|
const currentTransform = slide2.style.transform;
|
|
@@ -887,12 +897,12 @@ function updateSlides() {
|
|
|
887
897
|
} else {
|
|
888
898
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
889
899
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
890
|
-
if (
|
|
891
|
-
|
|
900
|
+
if (slide2) {
|
|
901
|
+
slide2.style[swiper.getDirectionLabel("width")] = `${slideSize}px`;
|
|
892
902
|
}
|
|
893
903
|
}
|
|
894
|
-
if (
|
|
895
|
-
|
|
904
|
+
if (slide2) {
|
|
905
|
+
slide2.swiperSlideSize = slideSize;
|
|
896
906
|
}
|
|
897
907
|
slidesSizesGrid.push(slideSize);
|
|
898
908
|
if (params.centeredSlides) {
|
|
@@ -918,23 +928,50 @@ function updateSlides() {
|
|
|
918
928
|
wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
|
|
919
929
|
}
|
|
920
930
|
if (params.setWrapperSize) {
|
|
921
|
-
wrapperEl.style[getDirectionLabel("width")] = `${swiper.virtualSize + spaceBetween}px`;
|
|
931
|
+
wrapperEl.style[swiper.getDirectionLabel("width")] = `${swiper.virtualSize + spaceBetween}px`;
|
|
922
932
|
}
|
|
923
933
|
if (gridEnabled) {
|
|
924
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid
|
|
934
|
+
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
925
935
|
}
|
|
926
936
|
if (!params.centeredSlides) {
|
|
937
|
+
const isFractionalSlidesPerView = params.slidesPerView !== "auto" && params.slidesPerView % 1 !== 0;
|
|
938
|
+
const shouldSnapToSlideEdge = params.snapToSlideEdge && !params.loop && (params.slidesPerView === "auto" || isFractionalSlidesPerView);
|
|
939
|
+
let lastAllowedSnapIndex = snapGrid.length;
|
|
940
|
+
if (shouldSnapToSlideEdge) {
|
|
941
|
+
let minVisibleSlides;
|
|
942
|
+
if (params.slidesPerView === "auto") {
|
|
943
|
+
minVisibleSlides = 1;
|
|
944
|
+
let accumulatedSize = 0;
|
|
945
|
+
for (let i = slidesSizesGrid.length - 1; i >= 0; i -= 1) {
|
|
946
|
+
accumulatedSize += slidesSizesGrid[i] + (i < slidesSizesGrid.length - 1 ? spaceBetween : 0);
|
|
947
|
+
if (accumulatedSize <= swiperSize) {
|
|
948
|
+
minVisibleSlides = slidesSizesGrid.length - i;
|
|
949
|
+
} else {
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
} else {
|
|
954
|
+
minVisibleSlides = Math.floor(params.slidesPerView);
|
|
955
|
+
}
|
|
956
|
+
lastAllowedSnapIndex = Math.max(slidesLength - minVisibleSlides, 0);
|
|
957
|
+
}
|
|
927
958
|
const newSlidesGrid = [];
|
|
928
959
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
929
960
|
let slidesGridItem = snapGrid[i];
|
|
930
961
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
931
|
-
if (
|
|
962
|
+
if (shouldSnapToSlideEdge) {
|
|
963
|
+
if (i <= lastAllowedSnapIndex) {
|
|
964
|
+
newSlidesGrid.push(slidesGridItem);
|
|
965
|
+
}
|
|
966
|
+
} else if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
|
|
932
967
|
newSlidesGrid.push(slidesGridItem);
|
|
933
968
|
}
|
|
934
969
|
}
|
|
935
970
|
snapGrid = newSlidesGrid;
|
|
936
971
|
if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
937
|
-
|
|
972
|
+
if (!shouldSnapToSlideEdge) {
|
|
973
|
+
snapGrid.push(swiper.virtualSize - swiperSize);
|
|
974
|
+
}
|
|
938
975
|
}
|
|
939
976
|
}
|
|
940
977
|
if (isVirtual && params.loop) {
|
|
@@ -956,7 +993,7 @@ function updateSlides() {
|
|
|
956
993
|
}
|
|
957
994
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
958
995
|
if (spaceBetween !== 0) {
|
|
959
|
-
const key = swiper.isHorizontal() && rtl ? "marginLeft" : getDirectionLabel("marginRight");
|
|
996
|
+
const key = swiper.isHorizontal() && rtl ? "marginLeft" : swiper.getDirectionLabel("marginRight");
|
|
960
997
|
slides.filter((_, slideIndex) => {
|
|
961
998
|
if (!params.cssMode || params.loop) return true;
|
|
962
999
|
if (slideIndex === slides.length - 1) {
|
|
@@ -973,7 +1010,7 @@ function updateSlides() {
|
|
|
973
1010
|
allSlidesSize += slideSizeValue + (spaceBetween || 0);
|
|
974
1011
|
});
|
|
975
1012
|
allSlidesSize -= spaceBetween;
|
|
976
|
-
const maxSnap = allSlidesSize - swiperSize;
|
|
1013
|
+
const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0;
|
|
977
1014
|
snapGrid = snapGrid.map((snap) => {
|
|
978
1015
|
if (snap <= 0) return -offsetBefore;
|
|
979
1016
|
if (snap > maxSnap) return maxSnap + offsetAfter;
|
|
@@ -1023,6 +1060,7 @@ function updateSlides() {
|
|
|
1023
1060
|
if (params.watchSlidesProgress) {
|
|
1024
1061
|
swiper.updateSlidesOffset();
|
|
1025
1062
|
}
|
|
1063
|
+
swiper.emit("slidesUpdated");
|
|
1026
1064
|
if (!isVirtual && !params.cssMode && (params.effect === "slide" || params.effect === "fade")) {
|
|
1027
1065
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1028
1066
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
@@ -1081,10 +1119,14 @@ function updateSlidesOffset() {
|
|
|
1081
1119
|
slides[i].swiperSlideOffset = (swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop) - minusOffset - swiper.cssOverflowAdjustment();
|
|
1082
1120
|
}
|
|
1083
1121
|
}
|
|
1084
|
-
|
|
1085
|
-
if (
|
|
1086
|
-
|
|
1122
|
+
var toggleSlideClasses$1 = (slideEl, condition, className) => {
|
|
1123
|
+
if (condition && !slideEl.classList.contains(className)) {
|
|
1124
|
+
slideEl.classList.add(className);
|
|
1125
|
+
} else if (!condition && slideEl.classList.contains(className)) {
|
|
1126
|
+
slideEl.classList.remove(className);
|
|
1087
1127
|
}
|
|
1128
|
+
};
|
|
1129
|
+
function updateSlidesProgress(translate2 = this && this.translate || 0) {
|
|
1088
1130
|
const swiper = this;
|
|
1089
1131
|
const params = swiper.params;
|
|
1090
1132
|
const {
|
|
@@ -1096,9 +1138,6 @@ function updateSlidesProgress(translate2) {
|
|
|
1096
1138
|
if (typeof slides[0].swiperSlideOffset === "undefined") swiper.updateSlidesOffset();
|
|
1097
1139
|
let offsetCenter = -translate2;
|
|
1098
1140
|
if (rtl) offsetCenter = translate2;
|
|
1099
|
-
slides.forEach((slideEl) => {
|
|
1100
|
-
slideEl.classList.remove(params.slideVisibleClass);
|
|
1101
|
-
});
|
|
1102
1141
|
swiper.visibleSlidesIndexes = [];
|
|
1103
1142
|
swiper.visibleSlides = [];
|
|
1104
1143
|
let spaceBetween = params.spaceBetween;
|
|
@@ -1117,12 +1156,14 @@ function updateSlidesProgress(translate2) {
|
|
|
1117
1156
|
const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide2.swiperSlideSize + spaceBetween);
|
|
1118
1157
|
const slideBefore = -(offsetCenter - slideOffset);
|
|
1119
1158
|
const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
|
1159
|
+
const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
|
|
1120
1160
|
const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
|
1121
1161
|
if (isVisible) {
|
|
1122
1162
|
swiper.visibleSlides.push(slide2);
|
|
1123
1163
|
swiper.visibleSlidesIndexes.push(i);
|
|
1124
|
-
slides[i].classList.add(params.slideVisibleClass);
|
|
1125
1164
|
}
|
|
1165
|
+
toggleSlideClasses$1(slide2, isVisible, params.slideVisibleClass);
|
|
1166
|
+
toggleSlideClasses$1(slide2, isFullyVisible, params.slideFullyVisibleClass);
|
|
1126
1167
|
slide2.progress = rtl ? -slideProgress : slideProgress;
|
|
1127
1168
|
slide2.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
|
1128
1169
|
}
|
|
@@ -1188,6 +1229,13 @@ function updateProgress(translate2) {
|
|
|
1188
1229
|
}
|
|
1189
1230
|
swiper.emit("progress", progress);
|
|
1190
1231
|
}
|
|
1232
|
+
var toggleSlideClasses = (slideEl, condition, className) => {
|
|
1233
|
+
if (condition && !slideEl.classList.contains(className)) {
|
|
1234
|
+
slideEl.classList.add(className);
|
|
1235
|
+
} else if (!condition && slideEl.classList.contains(className)) {
|
|
1236
|
+
slideEl.classList.remove(className);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1191
1239
|
function updateSlidesClasses() {
|
|
1192
1240
|
const swiper = this;
|
|
1193
1241
|
const {
|
|
@@ -1197,13 +1245,13 @@ function updateSlidesClasses() {
|
|
|
1197
1245
|
activeIndex
|
|
1198
1246
|
} = swiper;
|
|
1199
1247
|
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
1248
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1200
1249
|
const getFilteredSlide = (selector) => {
|
|
1201
1250
|
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1202
1251
|
};
|
|
1203
|
-
slides.forEach((slideEl) => {
|
|
1204
|
-
slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
1205
|
-
});
|
|
1206
1252
|
let activeSlide;
|
|
1253
|
+
let prevSlide;
|
|
1254
|
+
let nextSlide;
|
|
1207
1255
|
if (isVirtual) {
|
|
1208
1256
|
if (params.loop) {
|
|
1209
1257
|
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
@@ -1214,25 +1262,31 @@ function updateSlidesClasses() {
|
|
|
1214
1262
|
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1215
1263
|
}
|
|
1216
1264
|
} else {
|
|
1217
|
-
|
|
1265
|
+
if (gridEnabled) {
|
|
1266
|
+
activeSlide = slides.find((slideEl) => slideEl.column === activeIndex);
|
|
1267
|
+
nextSlide = slides.find((slideEl) => slideEl.column === activeIndex + 1);
|
|
1268
|
+
prevSlide = slides.find((slideEl) => slideEl.column === activeIndex - 1);
|
|
1269
|
+
} else {
|
|
1270
|
+
activeSlide = slides[activeIndex];
|
|
1271
|
+
}
|
|
1218
1272
|
}
|
|
1219
1273
|
if (activeSlide) {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
if (params.loop && !prevSlide === 0) {
|
|
1230
|
-
prevSlide = slides[slides.length - 1];
|
|
1231
|
-
}
|
|
1232
|
-
if (prevSlide) {
|
|
1233
|
-
prevSlide.classList.add(params.slidePrevClass);
|
|
1274
|
+
if (!gridEnabled) {
|
|
1275
|
+
nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1276
|
+
if (params.loop && !nextSlide) {
|
|
1277
|
+
nextSlide = slides[0];
|
|
1278
|
+
}
|
|
1279
|
+
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1280
|
+
if (params.loop && !prevSlide === 0) {
|
|
1281
|
+
prevSlide = slides[slides.length - 1];
|
|
1282
|
+
}
|
|
1234
1283
|
}
|
|
1235
1284
|
}
|
|
1285
|
+
slides.forEach((slideEl) => {
|
|
1286
|
+
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
1287
|
+
toggleSlideClasses(slideEl, slideEl === nextSlide, params.slideNextClass);
|
|
1288
|
+
toggleSlideClasses(slideEl, slideEl === prevSlide, params.slidePrevClass);
|
|
1289
|
+
});
|
|
1236
1290
|
swiper.emitSlidesClasses();
|
|
1237
1291
|
}
|
|
1238
1292
|
var processLazyPreloader = (swiper, imageEl) => {
|
|
@@ -1248,12 +1302,12 @@ var processLazyPreloader = (swiper, imageEl) => {
|
|
|
1248
1302
|
requestAnimationFrame(() => {
|
|
1249
1303
|
if (slideEl.shadowRoot) {
|
|
1250
1304
|
lazyEl = slideEl.shadowRoot.querySelector(`.${swiper.params.lazyPreloaderClass}`);
|
|
1251
|
-
if (lazyEl) lazyEl.remove();
|
|
1305
|
+
if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
|
|
1252
1306
|
}
|
|
1253
1307
|
});
|
|
1254
1308
|
}
|
|
1255
1309
|
}
|
|
1256
|
-
if (lazyEl) lazyEl.remove();
|
|
1310
|
+
if (lazyEl && !lazyEl.lazyPreloaderManaged) lazyEl.remove();
|
|
1257
1311
|
}
|
|
1258
1312
|
};
|
|
1259
1313
|
var unlazy = (swiper, index) => {
|
|
@@ -1351,21 +1405,39 @@ function updateActiveIndex(newActiveIndex) {
|
|
|
1351
1405
|
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
|
1352
1406
|
}
|
|
1353
1407
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1354
|
-
if (activeIndex === previousIndex) {
|
|
1408
|
+
if (activeIndex === previousIndex && !swiper.params.loop) {
|
|
1355
1409
|
if (snapIndex !== previousSnapIndex) {
|
|
1356
1410
|
swiper.snapIndex = snapIndex;
|
|
1357
1411
|
swiper.emit("snapIndexChange");
|
|
1358
1412
|
}
|
|
1359
|
-
if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
|
1360
|
-
swiper.realIndex = getVirtualRealIndex(activeIndex);
|
|
1361
|
-
}
|
|
1362
1413
|
return;
|
|
1363
1414
|
}
|
|
1415
|
+
if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
|
1416
|
+
swiper.realIndex = getVirtualRealIndex(activeIndex);
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1364
1420
|
let realIndex;
|
|
1365
|
-
if (swiper.virtual && params.virtual.enabled
|
|
1366
|
-
|
|
1421
|
+
if (swiper.virtual && params.virtual.enabled) {
|
|
1422
|
+
if (params.loop) {
|
|
1423
|
+
realIndex = getVirtualRealIndex(activeIndex);
|
|
1424
|
+
} else {
|
|
1425
|
+
realIndex = activeIndex;
|
|
1426
|
+
}
|
|
1427
|
+
} else if (gridEnabled) {
|
|
1428
|
+
const firstSlideInColumn = swiper.slides.find((slideEl) => slideEl.column === activeIndex);
|
|
1429
|
+
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute("data-swiper-slide-index"), 10);
|
|
1430
|
+
if (Number.isNaN(activeSlideIndex)) {
|
|
1431
|
+
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1432
|
+
}
|
|
1433
|
+
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1367
1434
|
} else if (swiper.slides[activeIndex]) {
|
|
1368
|
-
|
|
1435
|
+
const slideIndex = swiper.slides[activeIndex].getAttribute("data-swiper-slide-index");
|
|
1436
|
+
if (slideIndex) {
|
|
1437
|
+
realIndex = parseInt(slideIndex, 10);
|
|
1438
|
+
} else {
|
|
1439
|
+
realIndex = activeIndex;
|
|
1440
|
+
}
|
|
1369
1441
|
} else {
|
|
1370
1442
|
realIndex = activeIndex;
|
|
1371
1443
|
}
|
|
@@ -1438,10 +1510,7 @@ var update = {
|
|
|
1438
1510
|
updateActiveIndex,
|
|
1439
1511
|
updateClickedSlide
|
|
1440
1512
|
};
|
|
1441
|
-
function getSwiperTranslate(axis) {
|
|
1442
|
-
if (axis === void 0) {
|
|
1443
|
-
axis = this.isHorizontal() ? "x" : "y";
|
|
1444
|
-
}
|
|
1513
|
+
function getSwiperTranslate(axis = this.isHorizontal() ? "x" : "y") {
|
|
1445
1514
|
const swiper = this;
|
|
1446
1515
|
const {
|
|
1447
1516
|
params,
|
|
@@ -1510,19 +1579,7 @@ function minTranslate() {
|
|
|
1510
1579
|
function maxTranslate() {
|
|
1511
1580
|
return -this.snapGrid[this.snapGrid.length - 1];
|
|
1512
1581
|
}
|
|
1513
|
-
function translateTo(translate2, speed, runCallbacks, translateBounds, internal) {
|
|
1514
|
-
if (translate2 === void 0) {
|
|
1515
|
-
translate2 = 0;
|
|
1516
|
-
}
|
|
1517
|
-
if (speed === void 0) {
|
|
1518
|
-
speed = this.params.speed;
|
|
1519
|
-
}
|
|
1520
|
-
if (runCallbacks === void 0) {
|
|
1521
|
-
runCallbacks = true;
|
|
1522
|
-
}
|
|
1523
|
-
if (translateBounds === void 0) {
|
|
1524
|
-
translateBounds = true;
|
|
1525
|
-
}
|
|
1582
|
+
function translateTo(translate2 = 0, speed = this.params.speed, runCallbacks = true, translateBounds = true, internal) {
|
|
1526
1583
|
const swiper = this;
|
|
1527
1584
|
const {
|
|
1528
1585
|
params,
|
|
@@ -1581,6 +1638,7 @@ function translateTo(translate2, speed, runCallbacks, translateBounds, internal)
|
|
|
1581
1638
|
swiper.wrapperEl.removeEventListener("transitionend", swiper.onTranslateToWrapperTransitionEnd);
|
|
1582
1639
|
swiper.onTranslateToWrapperTransitionEnd = null;
|
|
1583
1640
|
delete swiper.onTranslateToWrapperTransitionEnd;
|
|
1641
|
+
swiper.animating = false;
|
|
1584
1642
|
if (runCallbacks) {
|
|
1585
1643
|
swiper.emit("transitionEnd");
|
|
1586
1644
|
}
|
|
@@ -1606,13 +1664,12 @@ function setTransition(duration, byController) {
|
|
|
1606
1664
|
}
|
|
1607
1665
|
swiper.emit("setTransition", duration, byController);
|
|
1608
1666
|
}
|
|
1609
|
-
function transitionEmit(
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
} = _ref;
|
|
1667
|
+
function transitionEmit({
|
|
1668
|
+
swiper,
|
|
1669
|
+
runCallbacks,
|
|
1670
|
+
direction,
|
|
1671
|
+
step
|
|
1672
|
+
}) {
|
|
1616
1673
|
const {
|
|
1617
1674
|
activeIndex,
|
|
1618
1675
|
previousIndex
|
|
@@ -1624,11 +1681,9 @@ function transitionEmit(_ref) {
|
|
|
1624
1681
|
else dir = "reset";
|
|
1625
1682
|
}
|
|
1626
1683
|
swiper.emit(`transition${step}`);
|
|
1627
|
-
if (runCallbacks &&
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
return;
|
|
1631
|
-
}
|
|
1684
|
+
if (runCallbacks && dir === "reset") {
|
|
1685
|
+
swiper.emit(`slideResetTransition${step}`);
|
|
1686
|
+
} else if (runCallbacks && activeIndex !== previousIndex) {
|
|
1632
1687
|
swiper.emit(`slideChangeTransition${step}`);
|
|
1633
1688
|
if (dir === "next") {
|
|
1634
1689
|
swiper.emit(`slideNextTransition${step}`);
|
|
@@ -1637,10 +1692,7 @@ function transitionEmit(_ref) {
|
|
|
1637
1692
|
}
|
|
1638
1693
|
}
|
|
1639
1694
|
}
|
|
1640
|
-
function transitionStart(runCallbacks, direction) {
|
|
1641
|
-
if (runCallbacks === void 0) {
|
|
1642
|
-
runCallbacks = true;
|
|
1643
|
-
}
|
|
1695
|
+
function transitionStart(runCallbacks = true, direction) {
|
|
1644
1696
|
const swiper = this;
|
|
1645
1697
|
const {
|
|
1646
1698
|
params
|
|
@@ -1656,10 +1708,7 @@ function transitionStart(runCallbacks, direction) {
|
|
|
1656
1708
|
step: "Start"
|
|
1657
1709
|
});
|
|
1658
1710
|
}
|
|
1659
|
-
function transitionEnd(runCallbacks, direction) {
|
|
1660
|
-
if (runCallbacks === void 0) {
|
|
1661
|
-
runCallbacks = true;
|
|
1662
|
-
}
|
|
1711
|
+
function transitionEnd(runCallbacks = true, direction) {
|
|
1663
1712
|
const swiper = this;
|
|
1664
1713
|
const {
|
|
1665
1714
|
params
|
|
@@ -1679,16 +1728,7 @@ var transition = {
|
|
|
1679
1728
|
transitionStart,
|
|
1680
1729
|
transitionEnd
|
|
1681
1730
|
};
|
|
1682
|
-
function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
1683
|
-
if (index === void 0) {
|
|
1684
|
-
index = 0;
|
|
1685
|
-
}
|
|
1686
|
-
if (speed === void 0) {
|
|
1687
|
-
speed = this.params.speed;
|
|
1688
|
-
}
|
|
1689
|
-
if (runCallbacks === void 0) {
|
|
1690
|
-
runCallbacks = true;
|
|
1691
|
-
}
|
|
1731
|
+
function slideTo(index = 0, speed, runCallbacks = true, internal, initial) {
|
|
1692
1732
|
if (typeof index === "string") {
|
|
1693
1733
|
index = parseInt(index, 10);
|
|
1694
1734
|
}
|
|
@@ -1705,9 +1745,12 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1705
1745
|
wrapperEl,
|
|
1706
1746
|
enabled
|
|
1707
1747
|
} = swiper;
|
|
1708
|
-
if (
|
|
1748
|
+
if (!enabled && !internal && !initial || swiper.destroyed || swiper.animating && params.preventInteractionOnTransition) {
|
|
1709
1749
|
return false;
|
|
1710
1750
|
}
|
|
1751
|
+
if (typeof speed === "undefined") {
|
|
1752
|
+
speed = swiper.params.speed;
|
|
1753
|
+
}
|
|
1711
1754
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
|
1712
1755
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1713
1756
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
@@ -1746,7 +1789,9 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1746
1789
|
if (slideIndex > activeIndex) direction = "next";
|
|
1747
1790
|
else if (slideIndex < activeIndex) direction = "prev";
|
|
1748
1791
|
else direction = "reset";
|
|
1749
|
-
|
|
1792
|
+
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1793
|
+
const isInitialVirtual = isVirtual && initial;
|
|
1794
|
+
if (!isInitialVirtual && (rtl && -translate2 === swiper.translate || !rtl && translate2 === swiper.translate)) {
|
|
1750
1795
|
swiper.updateActiveIndex(slideIndex);
|
|
1751
1796
|
if (params.autoHeight) {
|
|
1752
1797
|
swiper.updateAutoHeight();
|
|
@@ -1765,7 +1810,6 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1765
1810
|
const isH = swiper.isHorizontal();
|
|
1766
1811
|
const t = rtl ? translate2 : -translate2;
|
|
1767
1812
|
if (speed === 0) {
|
|
1768
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1769
1813
|
if (isVirtual) {
|
|
1770
1814
|
swiper.wrapperEl.style.scrollSnapType = "none";
|
|
1771
1815
|
swiper._immediateVirtual = true;
|
|
@@ -1800,6 +1844,11 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1800
1844
|
}
|
|
1801
1845
|
return true;
|
|
1802
1846
|
}
|
|
1847
|
+
const browser2 = getBrowser();
|
|
1848
|
+
const isSafari = browser2.isSafari;
|
|
1849
|
+
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1850
|
+
swiper.virtual.update(false, false, slideIndex);
|
|
1851
|
+
}
|
|
1803
1852
|
swiper.setTransition(speed);
|
|
1804
1853
|
swiper.setTranslate(translate2);
|
|
1805
1854
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -1824,45 +1873,85 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1824
1873
|
}
|
|
1825
1874
|
return true;
|
|
1826
1875
|
}
|
|
1827
|
-
function slideToLoop(index, speed, runCallbacks, internal) {
|
|
1828
|
-
if (index === void 0) {
|
|
1829
|
-
index = 0;
|
|
1830
|
-
}
|
|
1831
|
-
if (speed === void 0) {
|
|
1832
|
-
speed = this.params.speed;
|
|
1833
|
-
}
|
|
1834
|
-
if (runCallbacks === void 0) {
|
|
1835
|
-
runCallbacks = true;
|
|
1836
|
-
}
|
|
1876
|
+
function slideToLoop(index = 0, speed, runCallbacks = true, internal) {
|
|
1837
1877
|
if (typeof index === "string") {
|
|
1838
1878
|
const indexAsNumber = parseInt(index, 10);
|
|
1839
1879
|
index = indexAsNumber;
|
|
1840
1880
|
}
|
|
1841
1881
|
const swiper = this;
|
|
1882
|
+
if (swiper.destroyed) return;
|
|
1883
|
+
if (typeof speed === "undefined") {
|
|
1884
|
+
speed = swiper.params.speed;
|
|
1885
|
+
}
|
|
1886
|
+
const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
1842
1887
|
let newIndex = index;
|
|
1843
1888
|
if (swiper.params.loop) {
|
|
1844
1889
|
if (swiper.virtual && swiper.params.virtual.enabled) {
|
|
1845
1890
|
newIndex = newIndex + swiper.virtual.slidesBefore;
|
|
1846
1891
|
} else {
|
|
1847
|
-
|
|
1892
|
+
let targetSlideIndex;
|
|
1893
|
+
if (gridEnabled) {
|
|
1894
|
+
const slideIndex = newIndex * swiper.params.grid.rows;
|
|
1895
|
+
targetSlideIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column;
|
|
1896
|
+
} else {
|
|
1897
|
+
targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
|
1898
|
+
}
|
|
1899
|
+
const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
|
|
1900
|
+
const {
|
|
1901
|
+
centeredSlides,
|
|
1902
|
+
slidesOffsetBefore,
|
|
1903
|
+
slidesOffsetAfter
|
|
1904
|
+
} = swiper.params;
|
|
1905
|
+
const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
|
|
1906
|
+
let slidesPerView = swiper.params.slidesPerView;
|
|
1907
|
+
if (slidesPerView === "auto") {
|
|
1908
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
1909
|
+
} else {
|
|
1910
|
+
slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1911
|
+
if (bothDirections && slidesPerView % 2 === 0) {
|
|
1912
|
+
slidesPerView = slidesPerView + 1;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
let needLoopFix = cols - targetSlideIndex < slidesPerView;
|
|
1916
|
+
if (bothDirections) {
|
|
1917
|
+
needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
|
|
1918
|
+
}
|
|
1919
|
+
if (internal && bothDirections && swiper.params.slidesPerView !== "auto" && !gridEnabled) {
|
|
1920
|
+
needLoopFix = false;
|
|
1921
|
+
}
|
|
1922
|
+
if (needLoopFix) {
|
|
1923
|
+
const direction = bothDirections ? targetSlideIndex < swiper.activeIndex ? "prev" : "next" : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? "next" : "prev";
|
|
1924
|
+
swiper.loopFix({
|
|
1925
|
+
direction,
|
|
1926
|
+
slideTo: true,
|
|
1927
|
+
activeSlideIndex: direction === "next" ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
1928
|
+
slideRealIndex: direction === "next" ? swiper.realIndex : void 0
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
if (gridEnabled) {
|
|
1932
|
+
const slideIndex = newIndex * swiper.params.grid.rows;
|
|
1933
|
+
newIndex = swiper.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === slideIndex).column;
|
|
1934
|
+
} else {
|
|
1935
|
+
newIndex = swiper.getSlideIndexByData(newIndex);
|
|
1936
|
+
}
|
|
1848
1937
|
}
|
|
1849
1938
|
}
|
|
1850
|
-
|
|
1939
|
+
requestAnimationFrame(() => {
|
|
1940
|
+
swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
|
1941
|
+
});
|
|
1942
|
+
return swiper;
|
|
1851
1943
|
}
|
|
1852
|
-
function slideNext(speed, runCallbacks, internal) {
|
|
1853
|
-
if (speed === void 0) {
|
|
1854
|
-
speed = this.params.speed;
|
|
1855
|
-
}
|
|
1856
|
-
if (runCallbacks === void 0) {
|
|
1857
|
-
runCallbacks = true;
|
|
1858
|
-
}
|
|
1944
|
+
function slideNext(speed, runCallbacks = true, internal) {
|
|
1859
1945
|
const swiper = this;
|
|
1860
1946
|
const {
|
|
1861
1947
|
enabled,
|
|
1862
1948
|
params,
|
|
1863
1949
|
animating
|
|
1864
1950
|
} = swiper;
|
|
1865
|
-
if (!enabled) return swiper;
|
|
1951
|
+
if (!enabled || swiper.destroyed) return swiper;
|
|
1952
|
+
if (typeof speed === "undefined") {
|
|
1953
|
+
speed = swiper.params.speed;
|
|
1954
|
+
}
|
|
1866
1955
|
let perGroup = params.slidesPerGroup;
|
|
1867
1956
|
if (params.slidesPerView === "auto" && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
|
1868
1957
|
perGroup = Math.max(swiper.slidesPerViewDynamic("current", true), 1);
|
|
@@ -1887,13 +1976,7 @@ function slideNext(speed, runCallbacks, internal) {
|
|
|
1887
1976
|
}
|
|
1888
1977
|
return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
|
1889
1978
|
}
|
|
1890
|
-
function slidePrev(speed, runCallbacks, internal) {
|
|
1891
|
-
if (speed === void 0) {
|
|
1892
|
-
speed = this.params.speed;
|
|
1893
|
-
}
|
|
1894
|
-
if (runCallbacks === void 0) {
|
|
1895
|
-
runCallbacks = true;
|
|
1896
|
-
}
|
|
1979
|
+
function slidePrev(speed, runCallbacks = true, internal) {
|
|
1897
1980
|
const swiper = this;
|
|
1898
1981
|
const {
|
|
1899
1982
|
params,
|
|
@@ -1903,7 +1986,10 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1903
1986
|
enabled,
|
|
1904
1987
|
animating
|
|
1905
1988
|
} = swiper;
|
|
1906
|
-
if (!enabled) return swiper;
|
|
1989
|
+
if (!enabled || swiper.destroyed) return swiper;
|
|
1990
|
+
if (typeof speed === "undefined") {
|
|
1991
|
+
speed = swiper.params.speed;
|
|
1992
|
+
}
|
|
1907
1993
|
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
1908
1994
|
if (params.loop) {
|
|
1909
1995
|
if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
|
@@ -1919,8 +2005,9 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1919
2005
|
}
|
|
1920
2006
|
const normalizedTranslate = normalize(translate2);
|
|
1921
2007
|
const normalizedSnapGrid = snapGrid.map((val) => normalize(val));
|
|
2008
|
+
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
1922
2009
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
1923
|
-
if (typeof prevSnap === "undefined" && params.cssMode) {
|
|
2010
|
+
if (typeof prevSnap === "undefined" && (params.cssMode || isFreeMode)) {
|
|
1924
2011
|
let prevSnapIndex;
|
|
1925
2012
|
snapGrid.forEach((snap, snapIndex) => {
|
|
1926
2013
|
if (normalizedTranslate >= snap) {
|
|
@@ -1928,7 +2015,7 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1928
2015
|
}
|
|
1929
2016
|
});
|
|
1930
2017
|
if (typeof prevSnapIndex !== "undefined") {
|
|
1931
|
-
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2018
|
+
prevSnap = isFreeMode ? snapGrid[prevSnapIndex] : snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
1932
2019
|
}
|
|
1933
2020
|
}
|
|
1934
2021
|
let prevIndex = 0;
|
|
@@ -1951,27 +2038,20 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1951
2038
|
}
|
|
1952
2039
|
return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
|
1953
2040
|
}
|
|
1954
|
-
function slideReset(speed, runCallbacks, internal) {
|
|
1955
|
-
if (speed === void 0) {
|
|
1956
|
-
speed = this.params.speed;
|
|
1957
|
-
}
|
|
1958
|
-
if (runCallbacks === void 0) {
|
|
1959
|
-
runCallbacks = true;
|
|
1960
|
-
}
|
|
2041
|
+
function slideReset(speed, runCallbacks = true, internal) {
|
|
1961
2042
|
const swiper = this;
|
|
2043
|
+
if (swiper.destroyed) return;
|
|
2044
|
+
if (typeof speed === "undefined") {
|
|
2045
|
+
speed = swiper.params.speed;
|
|
2046
|
+
}
|
|
1962
2047
|
return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
|
1963
2048
|
}
|
|
1964
|
-
function slideToClosest(speed, runCallbacks, internal, threshold) {
|
|
1965
|
-
if (speed === void 0) {
|
|
1966
|
-
speed = this.params.speed;
|
|
1967
|
-
}
|
|
1968
|
-
if (runCallbacks === void 0) {
|
|
1969
|
-
runCallbacks = true;
|
|
1970
|
-
}
|
|
1971
|
-
if (threshold === void 0) {
|
|
1972
|
-
threshold = 0.5;
|
|
1973
|
-
}
|
|
2049
|
+
function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) {
|
|
1974
2050
|
const swiper = this;
|
|
2051
|
+
if (swiper.destroyed) return;
|
|
2052
|
+
if (typeof speed === "undefined") {
|
|
2053
|
+
speed = swiper.params.speed;
|
|
2054
|
+
}
|
|
1975
2055
|
let index = swiper.activeIndex;
|
|
1976
2056
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
|
1977
2057
|
const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
|
@@ -1995,28 +2075,22 @@ function slideToClosest(speed, runCallbacks, internal, threshold) {
|
|
|
1995
2075
|
}
|
|
1996
2076
|
function slideToClickedSlide() {
|
|
1997
2077
|
const swiper = this;
|
|
2078
|
+
if (swiper.destroyed) return;
|
|
1998
2079
|
const {
|
|
1999
2080
|
params,
|
|
2000
2081
|
slidesEl
|
|
2001
2082
|
} = swiper;
|
|
2002
2083
|
const slidesPerView = params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2003
|
-
let slideToIndex = swiper.clickedIndex;
|
|
2084
|
+
let slideToIndex = swiper.getSlideIndexWhenGrid(swiper.clickedIndex);
|
|
2004
2085
|
let realIndex;
|
|
2005
2086
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2087
|
+
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2006
2088
|
if (params.loop) {
|
|
2007
2089
|
if (swiper.animating) return;
|
|
2008
2090
|
realIndex = parseInt(swiper.clickedSlide.getAttribute("data-swiper-slide-index"), 10);
|
|
2009
2091
|
if (params.centeredSlides) {
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
|
2013
|
-
nextTick(() => {
|
|
2014
|
-
swiper.slideTo(slideToIndex);
|
|
2015
|
-
});
|
|
2016
|
-
} else {
|
|
2017
|
-
swiper.slideTo(slideToIndex);
|
|
2018
|
-
}
|
|
2019
|
-
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2092
|
+
swiper.slideToLoop(realIndex);
|
|
2093
|
+
} else if (slideToIndex > (isGrid ? (swiper.slides.length - slidesPerView) / 2 - (swiper.params.grid.rows - 1) : swiper.slides.length - slidesPerView)) {
|
|
2020
2094
|
swiper.loopFix();
|
|
2021
2095
|
slideToIndex = swiper.getSlideIndex(elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0]);
|
|
2022
2096
|
nextTick(() => {
|
|
@@ -2038,32 +2112,82 @@ var slide = {
|
|
|
2038
2112
|
slideToClosest,
|
|
2039
2113
|
slideToClickedSlide
|
|
2040
2114
|
};
|
|
2041
|
-
function loopCreate(slideRealIndex) {
|
|
2115
|
+
function loopCreate(slideRealIndex, initial) {
|
|
2042
2116
|
const swiper = this;
|
|
2043
2117
|
const {
|
|
2044
2118
|
params,
|
|
2045
2119
|
slidesEl
|
|
2046
2120
|
} = swiper;
|
|
2047
2121
|
if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
|
2048
|
-
const
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2122
|
+
const initSlides = () => {
|
|
2123
|
+
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2124
|
+
slides.forEach((el, index) => {
|
|
2125
|
+
el.setAttribute("data-swiper-slide-index", index);
|
|
2126
|
+
});
|
|
2127
|
+
};
|
|
2128
|
+
const clearBlankSlides = () => {
|
|
2129
|
+
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2130
|
+
slides.forEach((el) => {
|
|
2131
|
+
el.remove();
|
|
2132
|
+
});
|
|
2133
|
+
if (slides.length > 0) {
|
|
2134
|
+
swiper.recalcSlides();
|
|
2135
|
+
swiper.updateSlides();
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
2139
|
+
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2140
|
+
clearBlankSlides();
|
|
2141
|
+
}
|
|
2142
|
+
const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
|
|
2143
|
+
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2144
|
+
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2145
|
+
const addBlankSlides = (amountOfSlides) => {
|
|
2146
|
+
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2147
|
+
const slideEl = swiper.isElement ? createElement("swiper-slide", [params.slideBlankClass]) : createElement("div", [params.slideClass, params.slideBlankClass]);
|
|
2148
|
+
swiper.slidesEl.append(slideEl);
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
if (shouldFillGroup) {
|
|
2152
|
+
if (params.loopAddBlankSlides) {
|
|
2153
|
+
const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
|
|
2154
|
+
addBlankSlides(slidesToAdd);
|
|
2155
|
+
swiper.recalcSlides();
|
|
2156
|
+
swiper.updateSlides();
|
|
2157
|
+
} else {
|
|
2158
|
+
showWarning("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");
|
|
2159
|
+
}
|
|
2160
|
+
initSlides();
|
|
2161
|
+
} else if (shouldFillGrid) {
|
|
2162
|
+
if (params.loopAddBlankSlides) {
|
|
2163
|
+
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2164
|
+
addBlankSlides(slidesToAdd);
|
|
2165
|
+
swiper.recalcSlides();
|
|
2166
|
+
swiper.updateSlides();
|
|
2167
|
+
} else {
|
|
2168
|
+
showWarning("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");
|
|
2169
|
+
}
|
|
2170
|
+
initSlides();
|
|
2171
|
+
} else {
|
|
2172
|
+
initSlides();
|
|
2173
|
+
}
|
|
2174
|
+
const bothDirections = params.centeredSlides || !!params.slidesOffsetBefore || !!params.slidesOffsetAfter;
|
|
2052
2175
|
swiper.loopFix({
|
|
2053
2176
|
slideRealIndex,
|
|
2054
|
-
direction:
|
|
2177
|
+
direction: bothDirections ? void 0 : "next",
|
|
2178
|
+
initial
|
|
2055
2179
|
});
|
|
2056
2180
|
}
|
|
2057
|
-
function loopFix(
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2181
|
+
function loopFix({
|
|
2182
|
+
slideRealIndex,
|
|
2183
|
+
slideTo: slideTo2 = true,
|
|
2184
|
+
direction,
|
|
2185
|
+
setTranslate: setTranslate2,
|
|
2186
|
+
activeSlideIndex,
|
|
2187
|
+
initial,
|
|
2188
|
+
byController,
|
|
2189
|
+
byMousewheel
|
|
2190
|
+
} = {}) {
|
|
2067
2191
|
const swiper = this;
|
|
2068
2192
|
if (!swiper.params.loop) return;
|
|
2069
2193
|
swiper.emit("beforeLoopFix");
|
|
@@ -2074,13 +2198,20 @@ function loopFix(_temp) {
|
|
|
2074
2198
|
slidesEl,
|
|
2075
2199
|
params
|
|
2076
2200
|
} = swiper;
|
|
2201
|
+
const {
|
|
2202
|
+
centeredSlides,
|
|
2203
|
+
slidesOffsetBefore,
|
|
2204
|
+
slidesOffsetAfter,
|
|
2205
|
+
initialSlide
|
|
2206
|
+
} = params;
|
|
2207
|
+
const bothDirections = centeredSlides || !!slidesOffsetBefore || !!slidesOffsetAfter;
|
|
2077
2208
|
swiper.allowSlidePrev = true;
|
|
2078
2209
|
swiper.allowSlideNext = true;
|
|
2079
2210
|
if (swiper.virtual && params.virtual.enabled) {
|
|
2080
2211
|
if (slideTo2) {
|
|
2081
|
-
if (!
|
|
2212
|
+
if (!bothDirections && swiper.snapIndex === 0) {
|
|
2082
2213
|
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2083
|
-
} else if (
|
|
2214
|
+
} else if (bothDirections && swiper.snapIndex < params.slidesPerView) {
|
|
2084
2215
|
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2085
2216
|
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2086
2217
|
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
@@ -2091,17 +2222,35 @@ function loopFix(_temp) {
|
|
|
2091
2222
|
swiper.emit("loopFix");
|
|
2092
2223
|
return;
|
|
2093
2224
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2225
|
+
let slidesPerView = params.slidesPerView;
|
|
2226
|
+
if (slidesPerView === "auto") {
|
|
2227
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
2228
|
+
} else {
|
|
2229
|
+
slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2230
|
+
if (bothDirections && slidesPerView % 2 === 0) {
|
|
2231
|
+
slidesPerView = slidesPerView + 1;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
|
|
2235
|
+
let loopedSlides = bothDirections ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2236
|
+
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2237
|
+
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2098
2238
|
}
|
|
2239
|
+
loopedSlides += params.loopAdditionalSlides;
|
|
2099
2240
|
swiper.loopedSlides = loopedSlides;
|
|
2241
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
2242
|
+
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2243
|
+
showWarning("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters");
|
|
2244
|
+
} else if (gridEnabled && params.grid.fill === "row") {
|
|
2245
|
+
showWarning("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");
|
|
2246
|
+
}
|
|
2100
2247
|
const prependSlidesIndexes = [];
|
|
2101
2248
|
const appendSlidesIndexes = [];
|
|
2102
|
-
|
|
2249
|
+
const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
|
|
2250
|
+
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !bothDirections;
|
|
2251
|
+
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2103
2252
|
if (typeof activeSlideIndex === "undefined") {
|
|
2104
|
-
activeSlideIndex = swiper.getSlideIndex(
|
|
2253
|
+
activeSlideIndex = swiper.getSlideIndex(slides.find((el) => el.classList.contains(params.slideActiveClass)));
|
|
2105
2254
|
} else {
|
|
2106
2255
|
activeIndex = activeSlideIndex;
|
|
2107
2256
|
}
|
|
@@ -2109,36 +2258,70 @@ function loopFix(_temp) {
|
|
|
2109
2258
|
const isPrev = direction === "prev" || !direction;
|
|
2110
2259
|
let slidesPrepended = 0;
|
|
2111
2260
|
let slidesAppended = 0;
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2261
|
+
const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
|
|
2262
|
+
const activeColIndexWithShift = activeColIndex + (bothDirections && typeof setTranslate2 === "undefined" ? -slidesPerView / 2 + 0.5 : 0);
|
|
2263
|
+
if (activeColIndexWithShift < loopedSlides) {
|
|
2264
|
+
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2265
|
+
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2266
|
+
const index = i - Math.floor(i / cols) * cols;
|
|
2267
|
+
if (gridEnabled) {
|
|
2268
|
+
const colIndexToPrepend = cols - index - 1;
|
|
2269
|
+
for (let i2 = slides.length - 1; i2 >= 0; i2 -= 1) {
|
|
2270
|
+
if (slides[i2].column === colIndexToPrepend) prependSlidesIndexes.push(i2);
|
|
2271
|
+
}
|
|
2272
|
+
} else {
|
|
2273
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2277
|
+
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
2278
|
+
if (isInitialOverflow) {
|
|
2279
|
+
slidesAppended = Math.max(slidesAppended, slidesPerView - cols + initialSlide + 1);
|
|
2280
|
+
}
|
|
2120
2281
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2121
|
-
const index = i - Math.floor(i /
|
|
2122
|
-
|
|
2282
|
+
const index = i - Math.floor(i / cols) * cols;
|
|
2283
|
+
if (gridEnabled) {
|
|
2284
|
+
slides.forEach((slide2, slideIndex) => {
|
|
2285
|
+
if (slide2.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2286
|
+
});
|
|
2287
|
+
} else {
|
|
2288
|
+
appendSlidesIndexes.push(index);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
swiper.__preventObserver__ = true;
|
|
2293
|
+
requestAnimationFrame(() => {
|
|
2294
|
+
swiper.__preventObserver__ = false;
|
|
2295
|
+
});
|
|
2296
|
+
if (swiper.params.effect === "cards" && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2297
|
+
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2298
|
+
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2299
|
+
}
|
|
2300
|
+
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2301
|
+
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2123
2302
|
}
|
|
2124
2303
|
}
|
|
2125
2304
|
if (isPrev) {
|
|
2126
2305
|
prependSlidesIndexes.forEach((index) => {
|
|
2127
|
-
|
|
2128
|
-
slidesEl.prepend(
|
|
2129
|
-
|
|
2306
|
+
slides[index].swiperLoopMoveDOM = true;
|
|
2307
|
+
slidesEl.prepend(slides[index]);
|
|
2308
|
+
slides[index].swiperLoopMoveDOM = false;
|
|
2130
2309
|
});
|
|
2131
2310
|
}
|
|
2132
2311
|
if (isNext) {
|
|
2133
2312
|
appendSlidesIndexes.forEach((index) => {
|
|
2134
|
-
|
|
2135
|
-
slidesEl.append(
|
|
2136
|
-
|
|
2313
|
+
slides[index].swiperLoopMoveDOM = true;
|
|
2314
|
+
slidesEl.append(slides[index]);
|
|
2315
|
+
slides[index].swiperLoopMoveDOM = false;
|
|
2137
2316
|
});
|
|
2138
2317
|
}
|
|
2139
2318
|
swiper.recalcSlides();
|
|
2140
2319
|
if (params.slidesPerView === "auto") {
|
|
2141
2320
|
swiper.updateSlides();
|
|
2321
|
+
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2322
|
+
swiper.slides.forEach((slide2, slideIndex) => {
|
|
2323
|
+
swiper.grid.updateSlide(slideIndex, slide2, swiper.slides);
|
|
2324
|
+
});
|
|
2142
2325
|
}
|
|
2143
2326
|
if (params.watchSlidesProgress) {
|
|
2144
2327
|
swiper.updateSlidesOffset();
|
|
@@ -2152,15 +2335,16 @@ function loopFix(_temp) {
|
|
|
2152
2335
|
if (byMousewheel) {
|
|
2153
2336
|
swiper.setTranslate(swiper.translate - diff);
|
|
2154
2337
|
} else {
|
|
2155
|
-
swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
|
|
2338
|
+
swiper.slideTo(activeIndex + Math.ceil(slidesPrepended), 0, false, true);
|
|
2156
2339
|
if (setTranslate2) {
|
|
2157
|
-
swiper.
|
|
2158
|
-
swiper.touchEventsData.currentTranslate = swiper.
|
|
2340
|
+
swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
|
2341
|
+
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2159
2342
|
}
|
|
2160
2343
|
}
|
|
2161
2344
|
} else {
|
|
2162
2345
|
if (setTranslate2) {
|
|
2163
|
-
|
|
2346
|
+
const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
|
|
2347
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2164
2348
|
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2165
2349
|
}
|
|
2166
2350
|
}
|
|
@@ -2174,12 +2358,13 @@ function loopFix(_temp) {
|
|
|
2174
2358
|
} else {
|
|
2175
2359
|
swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
|
|
2176
2360
|
if (setTranslate2) {
|
|
2177
|
-
swiper.
|
|
2178
|
-
swiper.touchEventsData.currentTranslate = swiper.
|
|
2361
|
+
swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
|
2362
|
+
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2179
2363
|
}
|
|
2180
2364
|
}
|
|
2181
2365
|
} else {
|
|
2182
|
-
|
|
2366
|
+
const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
|
|
2367
|
+
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2183
2368
|
}
|
|
2184
2369
|
}
|
|
2185
2370
|
}
|
|
@@ -2215,7 +2400,7 @@ function loopDestroy() {
|
|
|
2215
2400
|
params,
|
|
2216
2401
|
slidesEl
|
|
2217
2402
|
} = swiper;
|
|
2218
|
-
if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
|
2403
|
+
if (!params.loop || !slidesEl || swiper.virtual && swiper.params.virtual.enabled) return;
|
|
2219
2404
|
swiper.recalcSlides();
|
|
2220
2405
|
const newSlidesOrder = [];
|
|
2221
2406
|
swiper.slides.forEach((slideEl) => {
|
|
@@ -2270,10 +2455,7 @@ var grabCursor = {
|
|
|
2270
2455
|
setGrabCursor,
|
|
2271
2456
|
unsetGrabCursor
|
|
2272
2457
|
};
|
|
2273
|
-
function closestElement(selector, base) {
|
|
2274
|
-
if (base === void 0) {
|
|
2275
|
-
base = this;
|
|
2276
|
-
}
|
|
2458
|
+
function closestElement(selector, base = this) {
|
|
2277
2459
|
function __closestFrom(el) {
|
|
2278
2460
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2279
2461
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
@@ -2285,36 +2467,63 @@ function closestElement(selector, base) {
|
|
|
2285
2467
|
}
|
|
2286
2468
|
return __closestFrom(base);
|
|
2287
2469
|
}
|
|
2470
|
+
function preventEdgeSwipe(swiper, event, startX) {
|
|
2471
|
+
const window2 = getWindow();
|
|
2472
|
+
const {
|
|
2473
|
+
params
|
|
2474
|
+
} = swiper;
|
|
2475
|
+
const edgeSwipeDetection = params.edgeSwipeDetection;
|
|
2476
|
+
const edgeSwipeThreshold = params.edgeSwipeThreshold;
|
|
2477
|
+
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) {
|
|
2478
|
+
if (edgeSwipeDetection === "prevent") {
|
|
2479
|
+
event.preventDefault();
|
|
2480
|
+
return true;
|
|
2481
|
+
}
|
|
2482
|
+
return false;
|
|
2483
|
+
}
|
|
2484
|
+
return true;
|
|
2485
|
+
}
|
|
2288
2486
|
function onTouchStart(event) {
|
|
2289
2487
|
const swiper = this;
|
|
2488
|
+
if (swiper.destroyed) return;
|
|
2290
2489
|
const document2 = getDocument();
|
|
2291
|
-
|
|
2490
|
+
let e = event;
|
|
2491
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
2292
2492
|
const data = swiper.touchEventsData;
|
|
2293
|
-
|
|
2493
|
+
if (e.type === "pointerdown") {
|
|
2494
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) {
|
|
2495
|
+
return;
|
|
2496
|
+
}
|
|
2497
|
+
data.pointerId = e.pointerId;
|
|
2498
|
+
} else if (e.type === "touchstart" && e.targetTouches.length === 1) {
|
|
2499
|
+
data.touchId = e.targetTouches[0].identifier;
|
|
2500
|
+
}
|
|
2501
|
+
if (e.type === "touchstart") {
|
|
2502
|
+
preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2294
2505
|
const {
|
|
2295
2506
|
params,
|
|
2296
2507
|
touches,
|
|
2297
2508
|
enabled
|
|
2298
2509
|
} = swiper;
|
|
2299
2510
|
if (!enabled) return;
|
|
2300
|
-
if (!params.simulateTouch &&
|
|
2511
|
+
if (!params.simulateTouch && e.pointerType === "mouse") return;
|
|
2301
2512
|
if (swiper.animating && params.preventInteractionOnTransition) {
|
|
2302
2513
|
return;
|
|
2303
2514
|
}
|
|
2304
2515
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
2305
2516
|
swiper.loopFix();
|
|
2306
2517
|
}
|
|
2307
|
-
let e = event;
|
|
2308
|
-
if (e.originalEvent) e = e.originalEvent;
|
|
2309
2518
|
let targetEl = e.target;
|
|
2310
2519
|
if (params.touchEventsTarget === "wrapper") {
|
|
2311
|
-
if (!swiper.wrapperEl
|
|
2520
|
+
if (!elementIsChildOf(targetEl, swiper.wrapperEl)) return;
|
|
2312
2521
|
}
|
|
2313
2522
|
if ("which" in e && e.which === 3) return;
|
|
2314
2523
|
if ("button" in e && e.button > 0) return;
|
|
2315
2524
|
if (data.isTouched && data.isMoved) return;
|
|
2316
2525
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== "";
|
|
2317
|
-
const eventPath =
|
|
2526
|
+
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
2318
2527
|
if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
|
|
2319
2528
|
targetEl = eventPath[0];
|
|
2320
2529
|
}
|
|
@@ -2331,14 +2540,8 @@ function onTouchStart(event) {
|
|
|
2331
2540
|
touches.currentY = e.pageY;
|
|
2332
2541
|
const startX = touches.currentX;
|
|
2333
2542
|
const startY = touches.currentY;
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window2.innerWidth - edgeSwipeThreshold)) {
|
|
2337
|
-
if (edgeSwipeDetection === "prevent") {
|
|
2338
|
-
event.preventDefault();
|
|
2339
|
-
} else {
|
|
2340
|
-
return;
|
|
2341
|
-
}
|
|
2543
|
+
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
2544
|
+
return;
|
|
2342
2545
|
}
|
|
2343
2546
|
Object.assign(data, {
|
|
2344
2547
|
isTouched: true,
|
|
@@ -2361,7 +2564,7 @@ function onTouchStart(event) {
|
|
|
2361
2564
|
data.isTouched = false;
|
|
2362
2565
|
}
|
|
2363
2566
|
}
|
|
2364
|
-
if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl) {
|
|
2567
|
+
if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== targetEl && (e.pointerType === "mouse" || e.pointerType !== "mouse" && !targetEl.matches(data.focusableElements))) {
|
|
2365
2568
|
document2.activeElement.blur();
|
|
2366
2569
|
}
|
|
2367
2570
|
const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
|
@@ -2376,6 +2579,7 @@ function onTouchStart(event) {
|
|
|
2376
2579
|
function onTouchMove(event) {
|
|
2377
2580
|
const document2 = getDocument();
|
|
2378
2581
|
const swiper = this;
|
|
2582
|
+
if (swiper.destroyed) return;
|
|
2379
2583
|
const data = swiper.touchEventsData;
|
|
2380
2584
|
const {
|
|
2381
2585
|
params,
|
|
@@ -2387,15 +2591,24 @@ function onTouchMove(event) {
|
|
|
2387
2591
|
if (!params.simulateTouch && event.pointerType === "mouse") return;
|
|
2388
2592
|
let e = event;
|
|
2389
2593
|
if (e.originalEvent) e = e.originalEvent;
|
|
2594
|
+
if (e.type === "pointermove") {
|
|
2595
|
+
if (data.touchId !== null) return;
|
|
2596
|
+
const id = e.pointerId;
|
|
2597
|
+
if (id !== data.pointerId) return;
|
|
2598
|
+
}
|
|
2599
|
+
let targetTouch;
|
|
2600
|
+
if (e.type === "touchmove") {
|
|
2601
|
+
targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId);
|
|
2602
|
+
if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
|
2603
|
+
} else {
|
|
2604
|
+
targetTouch = e;
|
|
2605
|
+
}
|
|
2390
2606
|
if (!data.isTouched) {
|
|
2391
2607
|
if (data.startMoving && data.isScrolling) {
|
|
2392
2608
|
swiper.emit("touchMoveOpposite", e);
|
|
2393
2609
|
}
|
|
2394
2610
|
return;
|
|
2395
2611
|
}
|
|
2396
|
-
const pointerIndex = data.evCache.findIndex((cachedEv) => cachedEv.pointerId === e.pointerId);
|
|
2397
|
-
if (pointerIndex >= 0) data.evCache[pointerIndex] = e;
|
|
2398
|
-
const targetTouch = data.evCache.length > 1 ? data.evCache[0] : e;
|
|
2399
2612
|
const pageX = targetTouch.pageX;
|
|
2400
2613
|
const pageY = targetTouch.pageY;
|
|
2401
2614
|
if (e.preventedByNestedSwiper) {
|
|
@@ -2411,8 +2624,6 @@ function onTouchMove(event) {
|
|
|
2411
2624
|
Object.assign(touches, {
|
|
2412
2625
|
startX: pageX,
|
|
2413
2626
|
startY: pageY,
|
|
2414
|
-
prevX: swiper.touches.currentX,
|
|
2415
|
-
prevY: swiper.touches.currentY,
|
|
2416
2627
|
currentX: pageX,
|
|
2417
2628
|
currentY: pageY
|
|
2418
2629
|
});
|
|
@@ -2427,10 +2638,15 @@ function onTouchMove(event) {
|
|
|
2427
2638
|
data.isMoved = false;
|
|
2428
2639
|
return;
|
|
2429
2640
|
}
|
|
2430
|
-
} else if (pageX
|
|
2641
|
+
} else if (rtl && (pageX > touches.startX && -swiper.translate <= swiper.maxTranslate() || pageX < touches.startX && -swiper.translate >= swiper.minTranslate())) {
|
|
2642
|
+
return;
|
|
2643
|
+
} else if (!rtl && (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate())) {
|
|
2431
2644
|
return;
|
|
2432
2645
|
}
|
|
2433
2646
|
}
|
|
2647
|
+
if (document2.activeElement && document2.activeElement.matches(data.focusableElements) && document2.activeElement !== e.target && e.pointerType !== "mouse") {
|
|
2648
|
+
document2.activeElement.blur();
|
|
2649
|
+
}
|
|
2434
2650
|
if (document2.activeElement) {
|
|
2435
2651
|
if (e.target === document2.activeElement && e.target.matches(data.focusableElements)) {
|
|
2436
2652
|
data.isMoved = true;
|
|
@@ -2441,7 +2657,8 @@ function onTouchMove(event) {
|
|
|
2441
2657
|
if (data.allowTouchCallbacks) {
|
|
2442
2658
|
swiper.emit("touchMove", e);
|
|
2443
2659
|
}
|
|
2444
|
-
|
|
2660
|
+
touches.previousX = touches.currentX;
|
|
2661
|
+
touches.previousY = touches.currentY;
|
|
2445
2662
|
touches.currentX = pageX;
|
|
2446
2663
|
touches.currentY = pageY;
|
|
2447
2664
|
const diffX = touches.currentX - touches.startX;
|
|
@@ -2466,7 +2683,7 @@ function onTouchMove(event) {
|
|
|
2466
2683
|
data.startMoving = true;
|
|
2467
2684
|
}
|
|
2468
2685
|
}
|
|
2469
|
-
if (data.isScrolling ||
|
|
2686
|
+
if (data.isScrolling || e.type === "touchmove" && data.preventTouchMoveFromPointerMove) {
|
|
2470
2687
|
data.isTouched = false;
|
|
2471
2688
|
return;
|
|
2472
2689
|
}
|
|
@@ -2496,7 +2713,7 @@ function onTouchMove(event) {
|
|
|
2496
2713
|
swiper.swipeDirection = diff > 0 ? "prev" : "next";
|
|
2497
2714
|
swiper.touchesDirection = touchesDiff > 0 ? "prev" : "next";
|
|
2498
2715
|
const isLoop = swiper.params.loop && !params.cssMode;
|
|
2499
|
-
const allowLoopFix = swiper.
|
|
2716
|
+
const allowLoopFix = swiper.touchesDirection === "next" && swiper.allowSlideNext || swiper.touchesDirection === "prev" && swiper.allowSlidePrev;
|
|
2500
2717
|
if (!data.isMoved) {
|
|
2501
2718
|
if (isLoop && allowLoopFix) {
|
|
2502
2719
|
swiper.loopFix({
|
|
@@ -2508,7 +2725,10 @@ function onTouchMove(event) {
|
|
|
2508
2725
|
if (swiper.animating) {
|
|
2509
2726
|
const evt = new window.CustomEvent("transitionend", {
|
|
2510
2727
|
bubbles: true,
|
|
2511
|
-
cancelable: true
|
|
2728
|
+
cancelable: true,
|
|
2729
|
+
detail: {
|
|
2730
|
+
bySwiperTouchMove: true
|
|
2731
|
+
}
|
|
2512
2732
|
});
|
|
2513
2733
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
2514
2734
|
}
|
|
@@ -2519,12 +2739,18 @@ function onTouchMove(event) {
|
|
|
2519
2739
|
swiper.emit("sliderFirstMove", e);
|
|
2520
2740
|
}
|
|
2521
2741
|
let loopFixed;
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2742
|
+
(/* @__PURE__ */ new Date()).getTime();
|
|
2743
|
+
if (params._loopSwapReset !== false && data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
|
|
2744
|
+
Object.assign(touches, {
|
|
2745
|
+
startX: pageX,
|
|
2746
|
+
startY: pageY,
|
|
2747
|
+
currentX: pageX,
|
|
2748
|
+
currentY: pageY,
|
|
2749
|
+
startTranslate: data.currentTranslate
|
|
2526
2750
|
});
|
|
2527
|
-
|
|
2751
|
+
data.loopSwapReset = true;
|
|
2752
|
+
data.startTranslate = data.currentTranslate;
|
|
2753
|
+
return;
|
|
2528
2754
|
}
|
|
2529
2755
|
swiper.emit("sliderMove", e);
|
|
2530
2756
|
data.isMoved = true;
|
|
@@ -2535,7 +2761,7 @@ function onTouchMove(event) {
|
|
|
2535
2761
|
resistanceRatio = 0;
|
|
2536
2762
|
}
|
|
2537
2763
|
if (diff > 0) {
|
|
2538
|
-
if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.
|
|
2764
|
+
if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] - (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.activeIndex + 1] + swiper.params.spaceBetween : 0) - swiper.params.spaceBetween : swiper.minTranslate())) {
|
|
2539
2765
|
swiper.loopFix({
|
|
2540
2766
|
direction: "prev",
|
|
2541
2767
|
setTranslate: true,
|
|
@@ -2549,7 +2775,7 @@ function onTouchMove(event) {
|
|
|
2549
2775
|
}
|
|
2550
2776
|
}
|
|
2551
2777
|
} else if (diff < 0) {
|
|
2552
|
-
if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.
|
|
2778
|
+
if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween + (params.slidesPerView !== "auto" && swiper.slides.length - params.slidesPerView >= 2 ? swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] + swiper.params.spaceBetween : 0) : swiper.maxTranslate())) {
|
|
2553
2779
|
swiper.loopFix({
|
|
2554
2780
|
direction: "next",
|
|
2555
2781
|
setTranslate: true,
|
|
@@ -2603,17 +2829,28 @@ function onTouchMove(event) {
|
|
|
2603
2829
|
}
|
|
2604
2830
|
function onTouchEnd(event) {
|
|
2605
2831
|
const swiper = this;
|
|
2832
|
+
if (swiper.destroyed) return;
|
|
2606
2833
|
const data = swiper.touchEventsData;
|
|
2607
|
-
|
|
2608
|
-
if (
|
|
2609
|
-
|
|
2834
|
+
let e = event;
|
|
2835
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
2836
|
+
let targetTouch;
|
|
2837
|
+
const isTouchEvent = e.type === "touchend" || e.type === "touchcancel";
|
|
2838
|
+
if (!isTouchEvent) {
|
|
2839
|
+
if (data.touchId !== null) return;
|
|
2840
|
+
if (e.pointerId !== data.pointerId) return;
|
|
2841
|
+
targetTouch = e;
|
|
2842
|
+
} else {
|
|
2843
|
+
targetTouch = [...e.changedTouches].find((t) => t.identifier === data.touchId);
|
|
2844
|
+
if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
|
2610
2845
|
}
|
|
2611
|
-
if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(
|
|
2612
|
-
const proceed = ["pointercancel", "contextmenu"].includes(
|
|
2846
|
+
if (["pointercancel", "pointerout", "pointerleave", "contextmenu"].includes(e.type)) {
|
|
2847
|
+
const proceed = ["pointercancel", "contextmenu"].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
2613
2848
|
if (!proceed) {
|
|
2614
2849
|
return;
|
|
2615
2850
|
}
|
|
2616
2851
|
}
|
|
2852
|
+
data.pointerId = null;
|
|
2853
|
+
data.touchId = null;
|
|
2617
2854
|
const {
|
|
2618
2855
|
params,
|
|
2619
2856
|
touches,
|
|
@@ -2622,9 +2859,7 @@ function onTouchEnd(event) {
|
|
|
2622
2859
|
enabled
|
|
2623
2860
|
} = swiper;
|
|
2624
2861
|
if (!enabled) return;
|
|
2625
|
-
if (!params.simulateTouch &&
|
|
2626
|
-
let e = event;
|
|
2627
|
-
if (e.originalEvent) e = e.originalEvent;
|
|
2862
|
+
if (!params.simulateTouch && e.pointerType === "mouse") return;
|
|
2628
2863
|
if (data.allowTouchCallbacks) {
|
|
2629
2864
|
swiper.emit("touchEnd", e);
|
|
2630
2865
|
}
|
|
@@ -2654,7 +2889,7 @@ function onTouchEnd(event) {
|
|
|
2654
2889
|
nextTick(() => {
|
|
2655
2890
|
if (!swiper.destroyed) swiper.allowClick = true;
|
|
2656
2891
|
});
|
|
2657
|
-
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
|
|
2892
|
+
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
|
|
2658
2893
|
data.isTouched = false;
|
|
2659
2894
|
data.isMoved = false;
|
|
2660
2895
|
data.startMoving = false;
|
|
@@ -2678,16 +2913,17 @@ function onTouchEnd(event) {
|
|
|
2678
2913
|
});
|
|
2679
2914
|
return;
|
|
2680
2915
|
}
|
|
2916
|
+
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
2681
2917
|
let stopIndex = 0;
|
|
2682
2918
|
let groupSize = swiper.slidesSizesGrid[0];
|
|
2683
2919
|
for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
|
2684
2920
|
const increment2 = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
2685
2921
|
if (typeof slidesGrid[i + increment2] !== "undefined") {
|
|
2686
|
-
if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) {
|
|
2922
|
+
if (swipeToLast || currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment2]) {
|
|
2687
2923
|
stopIndex = i;
|
|
2688
2924
|
groupSize = slidesGrid[i + increment2] - slidesGrid[i];
|
|
2689
2925
|
}
|
|
2690
|
-
} else if (currentPos >= slidesGrid[i]) {
|
|
2926
|
+
} else if (swipeToLast || currentPos >= slidesGrid[i]) {
|
|
2691
2927
|
stopIndex = i;
|
|
2692
2928
|
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
|
2693
2929
|
}
|
|
@@ -2764,7 +3000,8 @@ function onResize() {
|
|
|
2764
3000
|
swiper.updateSlidesClasses();
|
|
2765
3001
|
const isVirtualLoop = isVirtual && params.loop;
|
|
2766
3002
|
if ((params.slidesPerView === "auto" || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
2767
|
-
swiper.
|
|
3003
|
+
const slides = isVirtual ? swiper.virtual.slides : swiper.slides;
|
|
3004
|
+
swiper.slideTo(slides.length - 1, 0, false, true);
|
|
2768
3005
|
} else {
|
|
2769
3006
|
if (swiper.params.loop && !isVirtual) {
|
|
2770
3007
|
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
@@ -2788,6 +3025,7 @@ function onResize() {
|
|
|
2788
3025
|
}
|
|
2789
3026
|
function onClick(e) {
|
|
2790
3027
|
const swiper = this;
|
|
3028
|
+
if (swiper.destroyed) return;
|
|
2791
3029
|
if (!swiper.enabled) return;
|
|
2792
3030
|
if (!swiper.allowClick) {
|
|
2793
3031
|
if (swiper.params.preventClicks) e.preventDefault();
|
|
@@ -2799,6 +3037,7 @@ function onClick(e) {
|
|
|
2799
3037
|
}
|
|
2800
3038
|
function onScroll() {
|
|
2801
3039
|
const swiper = this;
|
|
3040
|
+
if (swiper.destroyed) return;
|
|
2802
3041
|
const {
|
|
2803
3042
|
wrapperEl,
|
|
2804
3043
|
rtlTranslate,
|
|
@@ -2828,14 +3067,21 @@ function onScroll() {
|
|
|
2828
3067
|
}
|
|
2829
3068
|
function onLoad(e) {
|
|
2830
3069
|
const swiper = this;
|
|
3070
|
+
if (swiper.destroyed) return;
|
|
2831
3071
|
processLazyPreloader(swiper, e.target);
|
|
2832
3072
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== "auto" && !swiper.params.autoHeight) {
|
|
2833
3073
|
return;
|
|
2834
3074
|
}
|
|
2835
3075
|
swiper.update();
|
|
2836
3076
|
}
|
|
2837
|
-
|
|
2838
|
-
|
|
3077
|
+
function onDocumentTouchStart() {
|
|
3078
|
+
const swiper = this;
|
|
3079
|
+
if (swiper.destroyed) return;
|
|
3080
|
+
if (swiper.documentTouchHandlerProceeded) return;
|
|
3081
|
+
swiper.documentTouchHandlerProceeded = true;
|
|
3082
|
+
if (swiper.params.touchReleaseOnEdges) {
|
|
3083
|
+
swiper.el.style.touchAction = "auto";
|
|
3084
|
+
}
|
|
2839
3085
|
}
|
|
2840
3086
|
var events = (swiper, method) => {
|
|
2841
3087
|
const document2 = getDocument();
|
|
@@ -2848,19 +3094,37 @@ var events = (swiper, method) => {
|
|
|
2848
3094
|
const capture = !!params.nested;
|
|
2849
3095
|
const domMethod = method === "on" ? "addEventListener" : "removeEventListener";
|
|
2850
3096
|
const swiperMethod = method;
|
|
3097
|
+
if (!el || typeof el === "string") return;
|
|
3098
|
+
document2[domMethod]("touchstart", swiper.onDocumentTouchStart, {
|
|
3099
|
+
passive: false,
|
|
3100
|
+
capture
|
|
3101
|
+
});
|
|
3102
|
+
el[domMethod]("touchstart", swiper.onTouchStart, {
|
|
3103
|
+
passive: false
|
|
3104
|
+
});
|
|
2851
3105
|
el[domMethod]("pointerdown", swiper.onTouchStart, {
|
|
2852
3106
|
passive: false
|
|
2853
3107
|
});
|
|
3108
|
+
document2[domMethod]("touchmove", swiper.onTouchMove, {
|
|
3109
|
+
passive: false,
|
|
3110
|
+
capture
|
|
3111
|
+
});
|
|
2854
3112
|
document2[domMethod]("pointermove", swiper.onTouchMove, {
|
|
2855
3113
|
passive: false,
|
|
2856
3114
|
capture
|
|
2857
3115
|
});
|
|
3116
|
+
document2[domMethod]("touchend", swiper.onTouchEnd, {
|
|
3117
|
+
passive: true
|
|
3118
|
+
});
|
|
2858
3119
|
document2[domMethod]("pointerup", swiper.onTouchEnd, {
|
|
2859
3120
|
passive: true
|
|
2860
3121
|
});
|
|
2861
3122
|
document2[domMethod]("pointercancel", swiper.onTouchEnd, {
|
|
2862
3123
|
passive: true
|
|
2863
3124
|
});
|
|
3125
|
+
document2[domMethod]("touchcancel", swiper.onTouchEnd, {
|
|
3126
|
+
passive: true
|
|
3127
|
+
});
|
|
2864
3128
|
document2[domMethod]("pointerout", swiper.onTouchEnd, {
|
|
2865
3129
|
passive: true
|
|
2866
3130
|
});
|
|
@@ -2887,22 +3151,18 @@ var events = (swiper, method) => {
|
|
|
2887
3151
|
};
|
|
2888
3152
|
function attachEvents() {
|
|
2889
3153
|
const swiper = this;
|
|
2890
|
-
const document2 = getDocument();
|
|
2891
3154
|
const {
|
|
2892
3155
|
params
|
|
2893
3156
|
} = swiper;
|
|
2894
3157
|
swiper.onTouchStart = onTouchStart.bind(swiper);
|
|
2895
3158
|
swiper.onTouchMove = onTouchMove.bind(swiper);
|
|
2896
3159
|
swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
|
3160
|
+
swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
|
|
2897
3161
|
if (params.cssMode) {
|
|
2898
3162
|
swiper.onScroll = onScroll.bind(swiper);
|
|
2899
3163
|
}
|
|
2900
3164
|
swiper.onClick = onClick.bind(swiper);
|
|
2901
3165
|
swiper.onLoad = onLoad.bind(swiper);
|
|
2902
|
-
if (!dummyEventAttached) {
|
|
2903
|
-
document2.addEventListener("touchstart", dummyEventListener);
|
|
2904
|
-
dummyEventAttached = true;
|
|
2905
|
-
}
|
|
2906
3166
|
events(swiper, "on");
|
|
2907
3167
|
}
|
|
2908
3168
|
function detachEvents() {
|
|
@@ -2926,12 +3186,17 @@ function setBreakpoint() {
|
|
|
2926
3186
|
} = swiper;
|
|
2927
3187
|
const breakpoints2 = params.breakpoints;
|
|
2928
3188
|
if (!breakpoints2 || breakpoints2 && Object.keys(breakpoints2).length === 0) return;
|
|
2929
|
-
const
|
|
3189
|
+
const document2 = getDocument();
|
|
3190
|
+
const breakpointsBase = params.breakpointsBase === "window" || !params.breakpointsBase ? params.breakpointsBase : "container";
|
|
3191
|
+
const breakpointContainer = ["window", "container"].includes(params.breakpointsBase) || !params.breakpointsBase ? swiper.el : document2.querySelector(params.breakpointsBase);
|
|
3192
|
+
const breakpoint = swiper.getBreakpoint(breakpoints2, breakpointsBase, breakpointContainer);
|
|
2930
3193
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
2931
3194
|
const breakpointOnlyParams = breakpoint in breakpoints2 ? breakpoints2[breakpoint] : void 0;
|
|
2932
3195
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
2933
3196
|
const wasMultiRow = isGridEnabled(swiper, params);
|
|
2934
3197
|
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3198
|
+
const wasGrabCursor = swiper.params.grabCursor;
|
|
3199
|
+
const isGrabCursor = breakpointParams.grabCursor;
|
|
2935
3200
|
const wasEnabled = params.enabled;
|
|
2936
3201
|
if (wasMultiRow && !isMultiRow) {
|
|
2937
3202
|
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
@@ -2943,6 +3208,11 @@ function setBreakpoint() {
|
|
|
2943
3208
|
}
|
|
2944
3209
|
swiper.emitContainerClasses();
|
|
2945
3210
|
}
|
|
3211
|
+
if (wasGrabCursor && !isGrabCursor) {
|
|
3212
|
+
swiper.unsetGrabCursor();
|
|
3213
|
+
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3214
|
+
swiper.setGrabCursor();
|
|
3215
|
+
}
|
|
2946
3216
|
["navigation", "pagination", "scrollbar"].forEach((prop) => {
|
|
2947
3217
|
if (typeof breakpointParams[prop] === "undefined") return;
|
|
2948
3218
|
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
@@ -2989,10 +3259,7 @@ function setBreakpoint() {
|
|
|
2989
3259
|
}
|
|
2990
3260
|
swiper.emit("breakpoint", breakpointParams);
|
|
2991
3261
|
}
|
|
2992
|
-
function getBreakpoint(breakpoints2, base, containerEl) {
|
|
2993
|
-
if (base === void 0) {
|
|
2994
|
-
base = "window";
|
|
2995
|
-
}
|
|
3262
|
+
function getBreakpoint(breakpoints2, base = "window", containerEl) {
|
|
2996
3263
|
if (!breakpoints2 || base === "container" && !containerEl) return void 0;
|
|
2997
3264
|
let breakpoint = false;
|
|
2998
3265
|
const window2 = getWindow();
|
|
@@ -3086,6 +3353,7 @@ function removeClasses() {
|
|
|
3086
3353
|
el,
|
|
3087
3354
|
classNames
|
|
3088
3355
|
} = swiper;
|
|
3356
|
+
if (!el || typeof el === "string") return;
|
|
3089
3357
|
el.classList.remove(...classNames);
|
|
3090
3358
|
swiper.emitContainerClasses();
|
|
3091
3359
|
}
|
|
@@ -3129,6 +3397,7 @@ var defaults = {
|
|
|
3129
3397
|
init: true,
|
|
3130
3398
|
direction: "horizontal",
|
|
3131
3399
|
oneWayMovement: false,
|
|
3400
|
+
swiperElementNodeName: "SWIPER-CONTAINER",
|
|
3132
3401
|
touchEventsTarget: "wrapper",
|
|
3133
3402
|
initialSlide: 0,
|
|
3134
3403
|
speed: 300,
|
|
@@ -3137,6 +3406,7 @@ var defaults = {
|
|
|
3137
3406
|
resizeObserver: true,
|
|
3138
3407
|
nested: false,
|
|
3139
3408
|
createElements: false,
|
|
3409
|
+
eventsPrefix: "swiper",
|
|
3140
3410
|
enabled: true,
|
|
3141
3411
|
focusableElements: "input, select, option, textarea, button, video, label",
|
|
3142
3412
|
// Overrides
|
|
@@ -3176,6 +3446,7 @@ var defaults = {
|
|
|
3176
3446
|
// in px
|
|
3177
3447
|
normalizeSlideIndex: true,
|
|
3178
3448
|
centerInsufficientSlides: false,
|
|
3449
|
+
snapToSlideEdge: false,
|
|
3179
3450
|
// Disable swiper and hide navigation when container not overflow
|
|
3180
3451
|
watchOverflow: true,
|
|
3181
3452
|
// Round length
|
|
@@ -3210,7 +3481,8 @@ var defaults = {
|
|
|
3210
3481
|
slideToClickedSlide: false,
|
|
3211
3482
|
// loop
|
|
3212
3483
|
loop: false,
|
|
3213
|
-
|
|
3484
|
+
loopAddBlankSlides: true,
|
|
3485
|
+
loopAdditionalSlides: 0,
|
|
3214
3486
|
loopPreventsSliding: true,
|
|
3215
3487
|
// rewind
|
|
3216
3488
|
rewind: false,
|
|
@@ -3229,8 +3501,10 @@ var defaults = {
|
|
|
3229
3501
|
containerModifierClass: "swiper-",
|
|
3230
3502
|
// NEW
|
|
3231
3503
|
slideClass: "swiper-slide",
|
|
3504
|
+
slideBlankClass: "swiper-slide-blank",
|
|
3232
3505
|
slideActiveClass: "swiper-slide-active",
|
|
3233
3506
|
slideVisibleClass: "swiper-slide-visible",
|
|
3507
|
+
slideFullyVisibleClass: "swiper-slide-fully-visible",
|
|
3234
3508
|
slideNextClass: "swiper-slide-next",
|
|
3235
3509
|
slidePrevClass: "swiper-slide-prev",
|
|
3236
3510
|
wrapperClass: "swiper-wrapper",
|
|
@@ -3242,10 +3516,7 @@ var defaults = {
|
|
|
3242
3516
|
_emitClasses: false
|
|
3243
3517
|
};
|
|
3244
3518
|
function moduleExtendParams(params, allModulesParams) {
|
|
3245
|
-
return function extendParams(obj) {
|
|
3246
|
-
if (obj === void 0) {
|
|
3247
|
-
obj = {};
|
|
3248
|
-
}
|
|
3519
|
+
return function extendParams(obj = {}) {
|
|
3249
3520
|
const moduleParamName = Object.keys(obj)[0];
|
|
3250
3521
|
const moduleParams = obj[moduleParamName];
|
|
3251
3522
|
if (typeof moduleParams !== "object" || moduleParams === null) {
|
|
@@ -3291,12 +3562,9 @@ var prototypes = {
|
|
|
3291
3562
|
};
|
|
3292
3563
|
var extendedDefaults = {};
|
|
3293
3564
|
var Swiper = class _Swiper {
|
|
3294
|
-
constructor() {
|
|
3565
|
+
constructor(...args) {
|
|
3295
3566
|
let el;
|
|
3296
3567
|
let params;
|
|
3297
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3298
|
-
args[_key] = arguments[_key];
|
|
3299
|
-
}
|
|
3300
3568
|
if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === "Object") {
|
|
3301
3569
|
params = args[0];
|
|
3302
3570
|
} else {
|
|
@@ -3327,7 +3595,11 @@ var Swiper = class _Swiper {
|
|
|
3327
3595
|
swiper.eventsAnyListeners = [];
|
|
3328
3596
|
swiper.modules = [...swiper.__modules__];
|
|
3329
3597
|
if (params.modules && Array.isArray(params.modules)) {
|
|
3330
|
-
|
|
3598
|
+
params.modules.forEach((mod) => {
|
|
3599
|
+
if (typeof mod === "function" && swiper.modules.indexOf(mod) < 0) {
|
|
3600
|
+
swiper.modules.push(mod);
|
|
3601
|
+
}
|
|
3602
|
+
});
|
|
3331
3603
|
}
|
|
3332
3604
|
const allModulesParams = {};
|
|
3333
3605
|
swiper.modules.forEach((mod) => {
|
|
@@ -3407,7 +3679,8 @@ var Swiper = class _Swiper {
|
|
|
3407
3679
|
velocities: [],
|
|
3408
3680
|
allowMomentumBounce: void 0,
|
|
3409
3681
|
startMoving: void 0,
|
|
3410
|
-
|
|
3682
|
+
pointerId: null,
|
|
3683
|
+
touchId: null
|
|
3411
3684
|
},
|
|
3412
3685
|
// Clicks
|
|
3413
3686
|
allowClick: true,
|
|
@@ -3430,6 +3703,21 @@ var Swiper = class _Swiper {
|
|
|
3430
3703
|
}
|
|
3431
3704
|
return swiper;
|
|
3432
3705
|
}
|
|
3706
|
+
getDirectionLabel(property) {
|
|
3707
|
+
if (this.isHorizontal()) {
|
|
3708
|
+
return property;
|
|
3709
|
+
}
|
|
3710
|
+
return {
|
|
3711
|
+
"width": "height",
|
|
3712
|
+
"margin-top": "margin-left",
|
|
3713
|
+
"margin-bottom ": "margin-right",
|
|
3714
|
+
"margin-left": "margin-top",
|
|
3715
|
+
"margin-right": "margin-bottom",
|
|
3716
|
+
"padding-left": "padding-top",
|
|
3717
|
+
"padding-right": "padding-bottom",
|
|
3718
|
+
"marginRight": "marginBottom"
|
|
3719
|
+
}[property];
|
|
3720
|
+
}
|
|
3433
3721
|
getSlideIndex(slideEl) {
|
|
3434
3722
|
const {
|
|
3435
3723
|
slidesEl,
|
|
@@ -3440,7 +3728,17 @@ var Swiper = class _Swiper {
|
|
|
3440
3728
|
return elementIndex(slideEl) - firstSlideIndex;
|
|
3441
3729
|
}
|
|
3442
3730
|
getSlideIndexByData(index) {
|
|
3443
|
-
return this.getSlideIndex(this.slides.
|
|
3731
|
+
return this.getSlideIndex(this.slides.find((slideEl) => slideEl.getAttribute("data-swiper-slide-index") * 1 === index));
|
|
3732
|
+
}
|
|
3733
|
+
getSlideIndexWhenGrid(index) {
|
|
3734
|
+
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
3735
|
+
if (this.params.grid.fill === "column") {
|
|
3736
|
+
index = Math.floor(index / this.params.grid.rows);
|
|
3737
|
+
} else if (this.params.grid.fill === "row") {
|
|
3738
|
+
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
return index;
|
|
3444
3742
|
}
|
|
3445
3743
|
recalcSlides() {
|
|
3446
3744
|
const swiper = this;
|
|
@@ -3507,13 +3805,7 @@ var Swiper = class _Swiper {
|
|
|
3507
3805
|
});
|
|
3508
3806
|
swiper.emit("_slideClasses", updates);
|
|
3509
3807
|
}
|
|
3510
|
-
slidesPerViewDynamic(view, exact) {
|
|
3511
|
-
if (view === void 0) {
|
|
3512
|
-
view = "current";
|
|
3513
|
-
}
|
|
3514
|
-
if (exact === void 0) {
|
|
3515
|
-
exact = false;
|
|
3516
|
-
}
|
|
3808
|
+
slidesPerViewDynamic(view = "current", exact = false) {
|
|
3517
3809
|
const swiper = this;
|
|
3518
3810
|
const {
|
|
3519
3811
|
params,
|
|
@@ -3526,11 +3818,11 @@ var Swiper = class _Swiper {
|
|
|
3526
3818
|
let spv = 1;
|
|
3527
3819
|
if (typeof params.slidesPerView === "number") return params.slidesPerView;
|
|
3528
3820
|
if (params.centeredSlides) {
|
|
3529
|
-
let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0;
|
|
3821
|
+
let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0;
|
|
3530
3822
|
let breakLoop;
|
|
3531
3823
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
3532
3824
|
if (slides[i] && !breakLoop) {
|
|
3533
|
-
slideSize += slides[i].swiperSlideSize;
|
|
3825
|
+
slideSize += Math.ceil(slides[i].swiperSlideSize);
|
|
3534
3826
|
spv += 1;
|
|
3535
3827
|
if (slideSize > swiperSize) breakLoop = true;
|
|
3536
3828
|
}
|
|
@@ -3609,10 +3901,7 @@ var Swiper = class _Swiper {
|
|
|
3609
3901
|
}
|
|
3610
3902
|
swiper.emit("update");
|
|
3611
3903
|
}
|
|
3612
|
-
changeDirection(newDirection, needUpdate) {
|
|
3613
|
-
if (needUpdate === void 0) {
|
|
3614
|
-
needUpdate = true;
|
|
3615
|
-
}
|
|
3904
|
+
changeDirection(newDirection, needUpdate = true) {
|
|
3616
3905
|
const swiper = this;
|
|
3617
3906
|
const currentDirection = swiper.params.direction;
|
|
3618
3907
|
if (!newDirection) {
|
|
@@ -3661,7 +3950,7 @@ var Swiper = class _Swiper {
|
|
|
3661
3950
|
return false;
|
|
3662
3951
|
}
|
|
3663
3952
|
el.swiper = swiper;
|
|
3664
|
-
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName ===
|
|
3953
|
+
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
3665
3954
|
swiper.isElement = true;
|
|
3666
3955
|
}
|
|
3667
3956
|
const getWrapperSelector = () => {
|
|
@@ -3719,7 +4008,7 @@ var Swiper = class _Swiper {
|
|
|
3719
4008
|
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
3720
4009
|
}
|
|
3721
4010
|
if (swiper.params.loop) {
|
|
3722
|
-
swiper.loopCreate();
|
|
4011
|
+
swiper.loopCreate(void 0, true);
|
|
3723
4012
|
}
|
|
3724
4013
|
swiper.attachEvents();
|
|
3725
4014
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
@@ -3742,13 +4031,7 @@ var Swiper = class _Swiper {
|
|
|
3742
4031
|
swiper.emit("afterInit");
|
|
3743
4032
|
return swiper;
|
|
3744
4033
|
}
|
|
3745
|
-
destroy(deleteInstance, cleanStyles) {
|
|
3746
|
-
if (deleteInstance === void 0) {
|
|
3747
|
-
deleteInstance = true;
|
|
3748
|
-
}
|
|
3749
|
-
if (cleanStyles === void 0) {
|
|
3750
|
-
cleanStyles = true;
|
|
3751
|
-
}
|
|
4034
|
+
destroy(deleteInstance = true, cleanStyles = true) {
|
|
3752
4035
|
const swiper = this;
|
|
3753
4036
|
const {
|
|
3754
4037
|
params,
|
|
@@ -3767,11 +4050,15 @@ var Swiper = class _Swiper {
|
|
|
3767
4050
|
}
|
|
3768
4051
|
if (cleanStyles) {
|
|
3769
4052
|
swiper.removeClasses();
|
|
3770
|
-
el
|
|
3771
|
-
|
|
4053
|
+
if (el && typeof el !== "string") {
|
|
4054
|
+
el.removeAttribute("style");
|
|
4055
|
+
}
|
|
4056
|
+
if (wrapperEl) {
|
|
4057
|
+
wrapperEl.removeAttribute("style");
|
|
4058
|
+
}
|
|
3772
4059
|
if (slides && slides.length) {
|
|
3773
4060
|
slides.forEach((slideEl) => {
|
|
3774
|
-
slideEl.classList.remove(params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
4061
|
+
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
3775
4062
|
slideEl.removeAttribute("style");
|
|
3776
4063
|
slideEl.removeAttribute("data-swiper-slide-index");
|
|
3777
4064
|
});
|
|
@@ -3782,7 +4069,9 @@ var Swiper = class _Swiper {
|
|
|
3782
4069
|
swiper.off(eventName);
|
|
3783
4070
|
});
|
|
3784
4071
|
if (deleteInstance !== false) {
|
|
3785
|
-
swiper.el.
|
|
4072
|
+
if (swiper.el && typeof swiper.el !== "string") {
|
|
4073
|
+
swiper.el.swiper = null;
|
|
4074
|
+
}
|
|
3786
4075
|
deleteProps(swiper);
|
|
3787
4076
|
}
|
|
3788
4077
|
swiper.destroyed = true;
|