@gem-sdk/swiper 0.0.14-staging.2 → 0.0.15-dev.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/core-bk/core.less +225 -0
- package/core-bk/core.scss +227 -0
- package/package.json +2 -2
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +155 -557
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +159 -561
- package/swiper-bundle.min.css +2 -2
- package/swiper-bundle.min.js +3 -3
- package/swiper-bundle.min.js.map +1 -1
- package/swiper-bundle.min.mjs +2 -2
- package/swiper-bundle.mjs +2 -2
- package/swiper-effect-utils.min.mjs +2 -2
- package/swiper-effect-utils.mjs +2 -2
- package/swiper-element-bundle.js +161 -563
- package/swiper-element-bundle.min.js +3 -3
- package/swiper-element-bundle.min.js.map +1 -1
- package/swiper-element-bundle.min.mjs +2 -2
- package/swiper-element-bundle.mjs +2 -2
- package/swiper-element.js +159 -561
- package/swiper-element.min.js +3 -3
- package/swiper-element.min.js.map +1 -1
- package/swiper-element.min.mjs +2 -2
- package/swiper-element.mjs +2 -2
- package/swiper-react.mjs +2 -2
- package/swiper-vue.mjs +2 -2
- package/swiper.css +2 -2
- package/swiper.js +157 -559
- package/swiper.less +2 -2
- package/swiper.min.css +2 -2
- package/swiper.min.js +3 -3
- package/swiper.min.js.map +1 -1
- package/swiper.min.mjs +2 -2
- package/swiper.mjs +2 -2
- package/swiper.scss +2 -2
package/shared/swiper-core.mjs
CHANGED
|
@@ -382,9 +382,6 @@ function updateSize() {
|
|
|
382
382
|
|
|
383
383
|
function updateSlides() {
|
|
384
384
|
const swiper = this;
|
|
385
|
-
function getDirectionPropertyValue(node, label) {
|
|
386
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
387
|
-
}
|
|
388
385
|
const params = swiper.params;
|
|
389
386
|
const {
|
|
390
387
|
wrapperEl,
|
|
@@ -393,10 +390,8 @@ function updateSlides() {
|
|
|
393
390
|
rtlTranslate: rtl,
|
|
394
391
|
wrongRTL
|
|
395
392
|
} = swiper;
|
|
396
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
397
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
398
393
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
399
|
-
const slidesLength =
|
|
394
|
+
const slidesLength = slides.length;
|
|
400
395
|
let snapGrid = [];
|
|
401
396
|
const slidesGrid = [];
|
|
402
397
|
const slidesSizesGrid = [];
|
|
@@ -414,15 +409,15 @@ function updateSlides() {
|
|
|
414
409
|
let slidePosition = -offsetBefore;
|
|
415
410
|
let prevSlideSize = 0;
|
|
416
411
|
let index = 0;
|
|
417
|
-
if (typeof swiperSize === 'undefined')
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
412
|
+
if (typeof swiperSize === 'undefined') return;
|
|
420
413
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
421
414
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
422
415
|
} else if (typeof spaceBetween === 'string') {
|
|
423
416
|
spaceBetween = parseFloat(spaceBetween);
|
|
424
417
|
}
|
|
425
|
-
|
|
418
|
+
|
|
419
|
+
// core-lite: compute total slides size without optional modules
|
|
420
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
426
421
|
|
|
427
422
|
// reset margins
|
|
428
423
|
slides.forEach(slideEl => {
|
|
@@ -440,49 +435,34 @@ function updateSlides() {
|
|
|
440
435
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
441
436
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
442
437
|
}
|
|
443
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
444
|
-
if (gridEnabled) {
|
|
445
|
-
swiper.grid.initSlides(slides);
|
|
446
|
-
} else if (swiper.grid) {
|
|
447
|
-
swiper.grid.unsetSlides();
|
|
448
|
-
}
|
|
449
438
|
|
|
450
439
|
// Calc slides
|
|
451
440
|
let slideSize;
|
|
452
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
453
|
-
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
|
454
|
-
}).length > 0;
|
|
441
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
455
442
|
for (let i = 0; i < slidesLength; i += 1) {
|
|
456
443
|
slideSize = 0;
|
|
457
444
|
let slide;
|
|
458
445
|
if (slides[i]) slide = slides[i];
|
|
459
|
-
if (gridEnabled) {
|
|
460
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
461
|
-
}
|
|
462
446
|
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
463
447
|
|
|
464
448
|
if (params.slidesPerView === 'auto') {
|
|
465
|
-
if (shouldResetSlideSize) {
|
|
449
|
+
if (shouldResetSlideSize && slides[i]) {
|
|
466
450
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
467
451
|
}
|
|
468
452
|
const slideStyles = getComputedStyle(slide);
|
|
469
453
|
const currentTransform = slide.style.transform;
|
|
470
454
|
const currentWebKitTransform = slide.style.webkitTransform;
|
|
471
|
-
if (currentTransform)
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
if (currentWebKitTransform) {
|
|
475
|
-
slide.style.webkitTransform = 'none';
|
|
476
|
-
}
|
|
455
|
+
if (currentTransform) slide.style.transform = 'none';
|
|
456
|
+
if (currentWebKitTransform) slide.style.webkitTransform = 'none';
|
|
477
457
|
if (params.roundLengths) {
|
|
478
458
|
slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
|
479
459
|
} else {
|
|
480
460
|
// eslint-disable-next-line
|
|
481
|
-
const width =
|
|
482
|
-
const paddingLeft =
|
|
483
|
-
const paddingRight =
|
|
484
|
-
const marginLeft =
|
|
485
|
-
const marginRight =
|
|
461
|
+
const width = parseFloat(slideStyles.getPropertyValue('width')) || slide.offsetWidth;
|
|
462
|
+
const paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left')) || 0;
|
|
463
|
+
const paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right')) || 0;
|
|
464
|
+
const marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left')) || 0;
|
|
465
|
+
const marginRight = parseFloat(slideStyles.getPropertyValue('margin-right')) || 0;
|
|
486
466
|
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
487
467
|
if (boxSizing && boxSizing === 'border-box') {
|
|
488
468
|
slideSize = width + marginLeft + marginRight;
|
|
@@ -494,12 +474,8 @@ function updateSlides() {
|
|
|
494
474
|
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
495
475
|
}
|
|
496
476
|
}
|
|
497
|
-
if (currentTransform)
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
if (currentWebKitTransform) {
|
|
501
|
-
slide.style.webkitTransform = currentWebKitTransform;
|
|
502
|
-
}
|
|
477
|
+
if (currentTransform) slide.style.transform = currentTransform;
|
|
478
|
+
if (currentWebKitTransform) slide.style.webkitTransform = currentWebKitTransform;
|
|
503
479
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
504
480
|
} else {
|
|
505
481
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
@@ -508,13 +484,13 @@ function updateSlides() {
|
|
|
508
484
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
509
485
|
}
|
|
510
486
|
}
|
|
511
|
-
if (slides[i])
|
|
512
|
-
slides[i].swiperSlideSize = slideSize;
|
|
513
|
-
}
|
|
487
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
514
488
|
slidesSizesGrid.push(slideSize);
|
|
515
489
|
if (params.centeredSlides) {
|
|
516
490
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
517
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
491
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
492
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
493
|
+
}
|
|
518
494
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
519
495
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
520
496
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -522,55 +498,37 @@ function updateSlides() {
|
|
|
522
498
|
slidesGrid.push(slidePosition);
|
|
523
499
|
} else {
|
|
524
500
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
525
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
501
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
502
|
+
snapGrid.push(slidePosition);
|
|
503
|
+
}
|
|
526
504
|
slidesGrid.push(slidePosition);
|
|
527
505
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
528
506
|
}
|
|
529
|
-
swiper.
|
|
507
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
530
508
|
prevSlideSize = slideSize;
|
|
531
509
|
index += 1;
|
|
532
510
|
}
|
|
533
|
-
swiper.
|
|
534
|
-
if (rtl && wrongRTL &&
|
|
535
|
-
wrapperEl.style.width = `${swiper.
|
|
511
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
512
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
513
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
536
514
|
}
|
|
537
515
|
if (params.setWrapperSize) {
|
|
538
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
539
|
-
}
|
|
540
|
-
if (gridEnabled) {
|
|
541
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
516
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
542
517
|
}
|
|
543
518
|
|
|
544
|
-
// Remove last
|
|
519
|
+
// Remove last snap points depending on width (non-centered)
|
|
545
520
|
if (!params.centeredSlides) {
|
|
546
521
|
const newSlidesGrid = [];
|
|
547
522
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
548
523
|
let slidesGridItem = snapGrid[i];
|
|
549
524
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
550
|
-
if (snapGrid[i] <= swiper.
|
|
525
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
551
526
|
newSlidesGrid.push(slidesGridItem);
|
|
552
527
|
}
|
|
553
528
|
}
|
|
554
529
|
snapGrid = newSlidesGrid;
|
|
555
|
-
if (Math.floor(swiper.
|
|
556
|
-
snapGrid.push(swiper.
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
if (isVirtual && params.loop) {
|
|
560
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
561
|
-
if (params.slidesPerGroup > 1) {
|
|
562
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
563
|
-
const groupSize = size * params.slidesPerGroup;
|
|
564
|
-
for (let i = 0; i < groups; i += 1) {
|
|
565
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
569
|
-
if (params.slidesPerGroup === 1) {
|
|
570
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
571
|
-
}
|
|
572
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
573
|
-
swiper.virtualSize += size;
|
|
530
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
531
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
574
532
|
}
|
|
575
533
|
}
|
|
576
534
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -578,9 +536,7 @@ function updateSlides() {
|
|
|
578
536
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
579
537
|
slides.filter((_, slideIndex) => {
|
|
580
538
|
if (!params.cssMode || params.loop) return true;
|
|
581
|
-
if (slideIndex === slides.length - 1)
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
539
|
+
if (slideIndex === slides.length - 1) return false;
|
|
584
540
|
return true;
|
|
585
541
|
}).forEach(slideEl => {
|
|
586
542
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -630,7 +586,9 @@ function updateSlides() {
|
|
|
630
586
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
631
587
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
632
588
|
}
|
|
633
|
-
|
|
589
|
+
|
|
590
|
+
// Emit changes
|
|
591
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
634
592
|
swiper.emit('slidesLengthChange');
|
|
635
593
|
}
|
|
636
594
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -644,7 +602,7 @@ function updateSlides() {
|
|
|
644
602
|
swiper.updateSlidesOffset();
|
|
645
603
|
}
|
|
646
604
|
swiper.emit('slidesUpdated');
|
|
647
|
-
if (!
|
|
605
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
648
606
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
649
607
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
650
608
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -658,20 +616,13 @@ function updateSlides() {
|
|
|
658
616
|
function updateAutoHeight(speed) {
|
|
659
617
|
const swiper = this;
|
|
660
618
|
const activeSlides = [];
|
|
661
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
662
|
-
let newHeight = 0;
|
|
663
|
-
let i;
|
|
664
619
|
if (typeof speed === 'number') {
|
|
665
620
|
swiper.setTransition(speed);
|
|
666
621
|
} else if (speed === true) {
|
|
667
622
|
swiper.setTransition(swiper.params.speed);
|
|
668
623
|
}
|
|
669
|
-
const getSlideByIndex = index =>
|
|
670
|
-
|
|
671
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
672
|
-
}
|
|
673
|
-
return swiper.slides[index];
|
|
674
|
-
};
|
|
624
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
625
|
+
|
|
675
626
|
// Find slides currently in view
|
|
676
627
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
677
628
|
if (swiper.params.centeredSlides) {
|
|
@@ -679,9 +630,9 @@ function updateAutoHeight(speed) {
|
|
|
679
630
|
activeSlides.push(slide);
|
|
680
631
|
});
|
|
681
632
|
} else {
|
|
682
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
633
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
683
634
|
const index = swiper.activeIndex + i;
|
|
684
|
-
if (index > swiper.slides.length
|
|
635
|
+
if (index > swiper.slides.length) break;
|
|
685
636
|
activeSlides.push(getSlideByIndex(index));
|
|
686
637
|
}
|
|
687
638
|
}
|
|
@@ -690,14 +641,13 @@ function updateAutoHeight(speed) {
|
|
|
690
641
|
}
|
|
691
642
|
|
|
692
643
|
// Find new height from highest slide in view
|
|
693
|
-
|
|
644
|
+
let newHeight = 0;
|
|
645
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
694
646
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
695
647
|
const height = activeSlides[i].offsetHeight;
|
|
696
648
|
newHeight = height > newHeight ? height : newHeight;
|
|
697
649
|
}
|
|
698
650
|
}
|
|
699
|
-
|
|
700
|
-
// Update Height
|
|
701
651
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
702
652
|
}
|
|
703
653
|
|
|
@@ -842,46 +792,16 @@ function updateSlidesClasses() {
|
|
|
842
792
|
slidesEl,
|
|
843
793
|
activeIndex
|
|
844
794
|
} = swiper;
|
|
845
|
-
const
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
849
|
-
};
|
|
850
|
-
let activeSlide;
|
|
851
|
-
let prevSlide;
|
|
795
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
796
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
797
|
+
const activeSlide = slides[activeIndex];
|
|
852
798
|
let nextSlide;
|
|
853
|
-
|
|
854
|
-
if (params.loop) {
|
|
855
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
856
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
857
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
858
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
859
|
-
} else {
|
|
860
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
861
|
-
}
|
|
862
|
-
} else {
|
|
863
|
-
if (gridEnabled) {
|
|
864
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
865
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
866
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
867
|
-
} else {
|
|
868
|
-
activeSlide = slides[activeIndex];
|
|
869
|
-
}
|
|
870
|
-
}
|
|
799
|
+
let prevSlide;
|
|
871
800
|
if (activeSlide) {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
nextSlide = slides[0];
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
// Prev Slide
|
|
880
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
881
|
-
if (params.loop && !prevSlide === 0) {
|
|
882
|
-
prevSlide = slides[slides.length - 1];
|
|
883
|
-
}
|
|
884
|
-
}
|
|
801
|
+
nextSlide = getNextSlide(activeSlide);
|
|
802
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
803
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
804
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
885
805
|
}
|
|
886
806
|
slides.forEach(slideEl => {
|
|
887
807
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -972,7 +892,6 @@ function getActiveIndexByTranslate(swiper) {
|
|
|
972
892
|
activeIndex = i;
|
|
973
893
|
}
|
|
974
894
|
}
|
|
975
|
-
// Normalize slideIndex
|
|
976
895
|
if (params.normalizeSlideIndex) {
|
|
977
896
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
978
897
|
}
|
|
@@ -990,16 +909,6 @@ function updateActiveIndex(newActiveIndex) {
|
|
|
990
909
|
} = swiper;
|
|
991
910
|
let activeIndex = newActiveIndex;
|
|
992
911
|
let snapIndex;
|
|
993
|
-
const getVirtualRealIndex = aIndex => {
|
|
994
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
995
|
-
if (realIndex < 0) {
|
|
996
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
997
|
-
}
|
|
998
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
999
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1000
|
-
}
|
|
1001
|
-
return realIndex;
|
|
1002
|
-
};
|
|
1003
912
|
if (typeof activeIndex === 'undefined') {
|
|
1004
913
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1005
914
|
}
|
|
@@ -1017,32 +926,12 @@ function updateActiveIndex(newActiveIndex) {
|
|
|
1017
926
|
}
|
|
1018
927
|
return;
|
|
1019
928
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1025
|
-
|
|
1026
|
-
// Get real index
|
|
1027
|
-
let realIndex;
|
|
1028
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1029
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1030
|
-
} else if (gridEnabled) {
|
|
1031
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1032
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1033
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1034
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1035
|
-
}
|
|
1036
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1037
|
-
} else if (swiper.slides[activeIndex]) {
|
|
929
|
+
let realIndex = activeIndex;
|
|
930
|
+
if (swiper.slides[activeIndex]) {
|
|
1038
931
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1039
932
|
if (slideIndex) {
|
|
1040
933
|
realIndex = parseInt(slideIndex, 10);
|
|
1041
|
-
} else {
|
|
1042
|
-
realIndex = activeIndex;
|
|
1043
934
|
}
|
|
1044
|
-
} else {
|
|
1045
|
-
realIndex = activeIndex;
|
|
1046
935
|
}
|
|
1047
936
|
Object.assign(swiper, {
|
|
1048
937
|
previousSnapIndex,
|
|
@@ -1089,11 +978,7 @@ function updateClickedSlide(el, path) {
|
|
|
1089
978
|
}
|
|
1090
979
|
if (slide && slideFound) {
|
|
1091
980
|
swiper.clickedSlide = slide;
|
|
1092
|
-
|
|
1093
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1094
|
-
} else {
|
|
1095
|
-
swiper.clickedIndex = slideIndex;
|
|
1096
|
-
}
|
|
981
|
+
swiper.clickedIndex = slideIndex;
|
|
1097
982
|
} else {
|
|
1098
983
|
swiper.clickedSlide = undefined;
|
|
1099
984
|
swiper.clickedIndex = undefined;
|
|
@@ -1127,9 +1012,6 @@ function getSwiperTranslate(axis) {
|
|
|
1127
1012
|
translate,
|
|
1128
1013
|
wrapperEl
|
|
1129
1014
|
} = swiper;
|
|
1130
|
-
if (params.virtualTranslate) {
|
|
1131
|
-
return rtl ? -translate : translate;
|
|
1132
|
-
}
|
|
1133
1015
|
if (params.cssMode) {
|
|
1134
1016
|
return translate;
|
|
1135
1017
|
}
|
|
@@ -1163,7 +1045,7 @@ function setTranslate(translate, byController) {
|
|
|
1163
1045
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1164
1046
|
if (params.cssMode) {
|
|
1165
1047
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1166
|
-
} else
|
|
1048
|
+
} else {
|
|
1167
1049
|
if (swiper.isHorizontal()) {
|
|
1168
1050
|
x -= swiper.cssOverflowAdjustment();
|
|
1169
1051
|
} else {
|
|
@@ -1400,7 +1282,6 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1400
1282
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1401
1283
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1402
1284
|
const translate = -snapGrid[snapIndex];
|
|
1403
|
-
// Normalize slideIndex
|
|
1404
1285
|
if (params.normalizeSlideIndex) {
|
|
1405
1286
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1406
1287
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1417,33 +1298,24 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1417
1298
|
}
|
|
1418
1299
|
}
|
|
1419
1300
|
}
|
|
1301
|
+
|
|
1420
1302
|
// Directions locks
|
|
1421
1303
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1422
1304
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1423
1305
|
return false;
|
|
1424
1306
|
}
|
|
1425
1307
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1426
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1427
|
-
return false;
|
|
1428
|
-
}
|
|
1308
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1429
1309
|
}
|
|
1430
1310
|
}
|
|
1431
1311
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1432
1312
|
swiper.emit('beforeSlideChangeStart');
|
|
1433
1313
|
}
|
|
1434
|
-
|
|
1435
|
-
// Update progress
|
|
1436
1314
|
swiper.updateProgress(translate);
|
|
1437
1315
|
let direction;
|
|
1438
1316
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1439
|
-
|
|
1440
|
-
// initial virtual
|
|
1441
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1442
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1443
|
-
// Update Index
|
|
1444
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1317
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1445
1318
|
swiper.updateActiveIndex(slideIndex);
|
|
1446
|
-
// Update Height
|
|
1447
1319
|
if (params.autoHeight) {
|
|
1448
1320
|
swiper.updateAutoHeight();
|
|
1449
1321
|
}
|
|
@@ -1461,24 +1333,7 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1461
1333
|
const isH = swiper.isHorizontal();
|
|
1462
1334
|
const t = rtl ? translate : -translate;
|
|
1463
1335
|
if (speed === 0) {
|
|
1464
|
-
|
|
1465
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1466
|
-
swiper._immediateVirtual = true;
|
|
1467
|
-
}
|
|
1468
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1469
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1470
|
-
requestAnimationFrame(() => {
|
|
1471
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1472
|
-
});
|
|
1473
|
-
} else {
|
|
1474
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1475
|
-
}
|
|
1476
|
-
if (isVirtual) {
|
|
1477
|
-
requestAnimationFrame(() => {
|
|
1478
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1479
|
-
swiper._immediateVirtual = false;
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1336
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1482
1337
|
} else {
|
|
1483
1338
|
if (!swiper.support.smoothScroll) {
|
|
1484
1339
|
animateCSSModeScroll({
|
|
@@ -1496,10 +1351,7 @@ function slideTo(index, speed, runCallbacks, internal, initial) {
|
|
|
1496
1351
|
return true;
|
|
1497
1352
|
}
|
|
1498
1353
|
const browser = getBrowser();
|
|
1499
|
-
|
|
1500
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1501
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1502
|
-
}
|
|
1354
|
+
browser.isSafari;
|
|
1503
1355
|
swiper.setTransition(speed);
|
|
1504
1356
|
swiper.setTranslate(translate);
|
|
1505
1357
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -1670,8 +1522,6 @@ function slideToLoopCenterSneakPeek(index, speed, runCallbacks, internal) {
|
|
|
1670
1522
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
1671
1523
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
1672
1524
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
1673
|
-
|
|
1674
|
-
// Move last item to first position only if active slide is the first slide
|
|
1675
1525
|
const lastSlide = slides[slides.length - 1];
|
|
1676
1526
|
lastSlide.swiperLoopMoveDOM = true;
|
|
1677
1527
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -1706,11 +1556,8 @@ function slideNext(speed, runCallbacks, internal) {
|
|
|
1706
1556
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
1707
1557
|
}
|
|
1708
1558
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
1709
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
1710
1559
|
if (params.loop) {
|
|
1711
|
-
if (animating &&
|
|
1712
|
-
|
|
1713
|
-
// Kiểm tra xem loop có bị disable không
|
|
1560
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
1714
1561
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
1715
1562
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
1716
1563
|
swiper.loopFix({
|
|
@@ -1737,7 +1584,6 @@ function slideNext(speed, runCallbacks, internal) {
|
|
|
1737
1584
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
1738
1585
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
1739
1586
|
if (!swiper.params.loop) return;
|
|
1740
|
-
// Move first item to last position only if active slide is the last slide
|
|
1741
1587
|
const firstSlide = slides[0];
|
|
1742
1588
|
firstSlide.swiperLoopMoveDOM = true;
|
|
1743
1589
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -1762,17 +1608,14 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1762
1608
|
params,
|
|
1763
1609
|
snapGrid,
|
|
1764
1610
|
slidesGrid,
|
|
1765
|
-
rtlTranslate,
|
|
1766
|
-
enabled
|
|
1767
|
-
animating
|
|
1611
|
+
rtlTranslate: rtlTranslate,
|
|
1612
|
+
enabled
|
|
1768
1613
|
} = swiper;
|
|
1769
1614
|
if (!enabled || swiper.destroyed) return swiper;
|
|
1770
1615
|
if (typeof speed === 'undefined') {
|
|
1771
1616
|
speed = swiper.params.speed;
|
|
1772
1617
|
}
|
|
1773
|
-
swiper.virtual && params.virtual.enabled;
|
|
1774
1618
|
if (params.loop) {
|
|
1775
|
-
// Kiểm tra xem loop có bị disable không
|
|
1776
1619
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
1777
1620
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
1778
1621
|
swiper.loopFix({
|
|
@@ -1789,18 +1632,16 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1789
1632
|
}
|
|
1790
1633
|
const normalizedTranslate = normalize(translate);
|
|
1791
1634
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
1792
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
1793
1635
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
1794
|
-
if (typeof prevSnap === 'undefined' &&
|
|
1636
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
1795
1637
|
let prevSnapIndex;
|
|
1796
1638
|
snapGrid.forEach((snap, snapIndex) => {
|
|
1797
1639
|
if (normalizedTranslate >= snap) {
|
|
1798
|
-
// prevSnap = snap;
|
|
1799
1640
|
prevSnapIndex = snapIndex;
|
|
1800
1641
|
}
|
|
1801
1642
|
});
|
|
1802
1643
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
1803
|
-
prevSnap =
|
|
1644
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
1804
1645
|
}
|
|
1805
1646
|
}
|
|
1806
1647
|
let prevIndex = 0;
|
|
@@ -1813,7 +1654,7 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1813
1654
|
}
|
|
1814
1655
|
}
|
|
1815
1656
|
if (params.rewind && swiper.isBeginning) {
|
|
1816
|
-
const lastIndex = swiper.
|
|
1657
|
+
const lastIndex = swiper.slides.length - 1;
|
|
1817
1658
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
1818
1659
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
1819
1660
|
requestAnimationFrame(() => {
|
|
@@ -1827,8 +1668,6 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1827
1668
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
1828
1669
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
1829
1670
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
1830
|
-
|
|
1831
|
-
// Move last item to first position only if active slide is the first slide
|
|
1832
1671
|
if (!swiper.params.loop) return;
|
|
1833
1672
|
const lastSlide = slides[slides.length - 1];
|
|
1834
1673
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -1905,20 +1744,19 @@ function slideToClickedSlide() {
|
|
|
1905
1744
|
slidesEl
|
|
1906
1745
|
} = swiper;
|
|
1907
1746
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
1908
|
-
|
|
1747
|
+
const slideToIndex = swiper.clickedIndex;
|
|
1909
1748
|
let realIndex;
|
|
1910
1749
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
1911
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
1912
1750
|
if (params.loop) {
|
|
1913
1751
|
if (swiper.animating) return;
|
|
1914
1752
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
1915
1753
|
if (params.centeredSlides) {
|
|
1916
1754
|
swiper.slideToLoop(realIndex);
|
|
1917
|
-
} else if (slideToIndex >
|
|
1755
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
1918
1756
|
swiper.loopFix();
|
|
1919
|
-
|
|
1757
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
1920
1758
|
nextTick(() => {
|
|
1921
|
-
swiper.slideTo(
|
|
1759
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
1922
1760
|
});
|
|
1923
1761
|
} else {
|
|
1924
1762
|
swiper.slideTo(slideToIndex);
|
|
@@ -1945,7 +1783,7 @@ function loopCreate(slideRealIndex, initial) {
|
|
|
1945
1783
|
params,
|
|
1946
1784
|
slidesEl
|
|
1947
1785
|
} = swiper;
|
|
1948
|
-
if (!params.loop
|
|
1786
|
+
if (!params.loop) return;
|
|
1949
1787
|
const initSlides = () => {
|
|
1950
1788
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
1951
1789
|
slides.forEach((el, index) => {
|
|
@@ -1954,21 +1792,17 @@ function loopCreate(slideRealIndex, initial) {
|
|
|
1954
1792
|
};
|
|
1955
1793
|
const clearBlankSlides = () => {
|
|
1956
1794
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
1957
|
-
slides.forEach(el =>
|
|
1958
|
-
el.remove();
|
|
1959
|
-
});
|
|
1795
|
+
slides.forEach(el => el.remove());
|
|
1960
1796
|
if (slides.length > 0) {
|
|
1961
1797
|
swiper.recalcSlides();
|
|
1962
1798
|
swiper.updateSlides();
|
|
1963
1799
|
}
|
|
1964
1800
|
};
|
|
1965
|
-
|
|
1966
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
1801
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
1967
1802
|
clearBlankSlides();
|
|
1968
1803
|
}
|
|
1969
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
1804
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
1970
1805
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
1971
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
1972
1806
|
const addBlankSlides = amountOfSlides => {
|
|
1973
1807
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
1974
1808
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -1985,16 +1819,6 @@ function loopCreate(slideRealIndex, initial) {
|
|
|
1985
1819
|
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)');
|
|
1986
1820
|
}
|
|
1987
1821
|
initSlides();
|
|
1988
|
-
} else if (shouldFillGrid) {
|
|
1989
|
-
if (params.loopAddBlankSlides) {
|
|
1990
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
1991
|
-
addBlankSlides(slidesToAdd);
|
|
1992
|
-
swiper.recalcSlides();
|
|
1993
|
-
swiper.updateSlides();
|
|
1994
|
-
} else {
|
|
1995
|
-
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)');
|
|
1996
|
-
}
|
|
1997
|
-
initSlides();
|
|
1998
1822
|
} else {
|
|
1999
1823
|
initSlides();
|
|
2000
1824
|
}
|
|
@@ -2013,13 +1837,12 @@ function loopFix(_temp) {
|
|
|
2013
1837
|
setTranslate,
|
|
2014
1838
|
activeSlideIndex,
|
|
2015
1839
|
initial,
|
|
2016
|
-
byController,
|
|
2017
1840
|
byMousewheel
|
|
2018
1841
|
} = _temp === void 0 ? {} : _temp;
|
|
2019
1842
|
const swiper = this;
|
|
2020
1843
|
if (!swiper.params.loop) return;
|
|
2021
1844
|
|
|
2022
|
-
// Disable loop mode
|
|
1845
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2023
1846
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2024
1847
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2025
1848
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2039,21 +1862,6 @@ function loopFix(_temp) {
|
|
|
2039
1862
|
} = params;
|
|
2040
1863
|
swiper.allowSlidePrev = true;
|
|
2041
1864
|
swiper.allowSlideNext = true;
|
|
2042
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2043
|
-
if (slideTo) {
|
|
2044
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2045
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2046
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2047
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2048
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2049
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2053
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2054
|
-
swiper.emit('loopFix');
|
|
2055
|
-
return;
|
|
2056
|
-
}
|
|
2057
1865
|
let slidesPerView = params.slidesPerView;
|
|
2058
1866
|
if (slidesPerView === 'auto') {
|
|
2059
1867
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2063,22 +1871,19 @@ function loopFix(_temp) {
|
|
|
2063
1871
|
slidesPerView = slidesPerView + 1;
|
|
2064
1872
|
}
|
|
2065
1873
|
}
|
|
2066
|
-
const slidesPerGroup = params.
|
|
1874
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2067
1875
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2068
1876
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2069
1877
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2070
1878
|
}
|
|
2071
1879
|
loopedSlides += params.loopAdditionalSlides;
|
|
2072
1880
|
swiper.loopedSlides = loopedSlides;
|
|
2073
|
-
|
|
2074
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
1881
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2075
1882
|
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');
|
|
2076
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2077
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2078
1883
|
}
|
|
2079
1884
|
const prependSlidesIndexes = [];
|
|
2080
1885
|
const appendSlidesIndexes = [];
|
|
2081
|
-
const cols =
|
|
1886
|
+
const cols = slides.length;
|
|
2082
1887
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2083
1888
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2084
1889
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2090,24 +1895,15 @@ function loopFix(_temp) {
|
|
|
2090
1895
|
const isPrev = direction === 'prev' || !direction;
|
|
2091
1896
|
let slidesPrepended = 0;
|
|
2092
1897
|
let slidesAppended = 0;
|
|
2093
|
-
const activeColIndex =
|
|
1898
|
+
const activeColIndex = activeSlideIndex;
|
|
2094
1899
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
1900
|
+
|
|
2095
1901
|
// prepend last slides before start
|
|
2096
1902
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2097
1903
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2098
1904
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2099
1905
|
const index = i - Math.floor(i / cols) * cols;
|
|
2100
|
-
|
|
2101
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2102
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2103
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2104
|
-
}
|
|
2105
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2106
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2107
|
-
// });
|
|
2108
|
-
} else {
|
|
2109
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2110
|
-
}
|
|
1906
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2111
1907
|
}
|
|
2112
1908
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2113
1909
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2116,27 +1912,13 @@ function loopFix(_temp) {
|
|
|
2116
1912
|
}
|
|
2117
1913
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2118
1914
|
const index = i - Math.floor(i / cols) * cols;
|
|
2119
|
-
|
|
2120
|
-
slides.forEach((slide, slideIndex) => {
|
|
2121
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2122
|
-
});
|
|
2123
|
-
} else {
|
|
2124
|
-
appendSlidesIndexes.push(index);
|
|
2125
|
-
}
|
|
1915
|
+
appendSlidesIndexes.push(index);
|
|
2126
1916
|
}
|
|
2127
1917
|
}
|
|
2128
1918
|
swiper.__preventObserver__ = true;
|
|
2129
1919
|
requestAnimationFrame(() => {
|
|
2130
1920
|
swiper.__preventObserver__ = false;
|
|
2131
1921
|
});
|
|
2132
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2133
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2134
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2135
|
-
}
|
|
2136
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2137
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
1922
|
if (isPrev) {
|
|
2141
1923
|
prependSlidesIndexes.forEach(index => {
|
|
2142
1924
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2154,10 +1936,6 @@ function loopFix(_temp) {
|
|
|
2154
1936
|
swiper.recalcSlides();
|
|
2155
1937
|
if (params.slidesPerView === 'auto') {
|
|
2156
1938
|
swiper.updateSlides();
|
|
2157
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2158
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2159
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2160
|
-
});
|
|
2161
1939
|
}
|
|
2162
1940
|
if (params.watchSlidesProgress) {
|
|
2163
1941
|
swiper.updateSlidesOffset();
|
|
@@ -2177,12 +1955,10 @@ function loopFix(_temp) {
|
|
|
2177
1955
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2178
1956
|
}
|
|
2179
1957
|
}
|
|
2180
|
-
} else {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2185
|
-
}
|
|
1958
|
+
} else if (setTranslate) {
|
|
1959
|
+
const shift = prependSlidesIndexes.length;
|
|
1960
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
1961
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2186
1962
|
}
|
|
2187
1963
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2188
1964
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2198,36 +1974,14 @@ function loopFix(_temp) {
|
|
|
2198
1974
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2199
1975
|
}
|
|
2200
1976
|
}
|
|
2201
|
-
} else {
|
|
2202
|
-
const shift =
|
|
1977
|
+
} else if (setTranslate) {
|
|
1978
|
+
const shift = appendSlidesIndexes.length;
|
|
2203
1979
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2204
1980
|
}
|
|
2205
1981
|
}
|
|
2206
1982
|
}
|
|
2207
1983
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2208
1984
|
swiper.allowSlideNext = allowSlideNext;
|
|
2209
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2210
|
-
const loopParams = {
|
|
2211
|
-
slideRealIndex,
|
|
2212
|
-
direction,
|
|
2213
|
-
setTranslate,
|
|
2214
|
-
activeSlideIndex,
|
|
2215
|
-
byController: true
|
|
2216
|
-
};
|
|
2217
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2218
|
-
swiper.controller.control.forEach(c => {
|
|
2219
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2220
|
-
...loopParams,
|
|
2221
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2222
|
-
});
|
|
2223
|
-
});
|
|
2224
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2225
|
-
swiper.controller.control.loopFix({
|
|
2226
|
-
...loopParams,
|
|
2227
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2228
|
-
});
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
1985
|
swiper.emit('loopFix');
|
|
2232
1986
|
}
|
|
2233
1987
|
|
|
@@ -2244,7 +1998,7 @@ function loopFixDot(_temp) {
|
|
|
2244
1998
|
const swiper = this;
|
|
2245
1999
|
if (!swiper.params.loop) return;
|
|
2246
2000
|
|
|
2247
|
-
// Disable loop mode
|
|
2001
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2248
2002
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2249
2003
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2250
2004
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2283,7 +2037,7 @@ function loopFixDot(_temp) {
|
|
|
2283
2037
|
}
|
|
2284
2038
|
loopedSlides += params.loopAdditionalSlides;
|
|
2285
2039
|
swiper.loopedSlides = loopedSlides;
|
|
2286
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2040
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2287
2041
|
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');
|
|
2288
2042
|
}
|
|
2289
2043
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2309,20 +2063,16 @@ function loopFixDot(_temp) {
|
|
|
2309
2063
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2310
2064
|
}
|
|
2311
2065
|
|
|
2312
|
-
//
|
|
2066
|
+
// DocumentFragment to hold slide clones
|
|
2313
2067
|
const cloneFragment = document.createDocumentFragment();
|
|
2314
2068
|
|
|
2315
|
-
// Clone
|
|
2069
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2316
2070
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2317
2071
|
if (slides[index]) {
|
|
2318
2072
|
const originalSlide = slides[index];
|
|
2319
2073
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2320
|
-
|
|
2321
|
-
// Đánh dấu slide clone
|
|
2322
2074
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2323
2075
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2324
|
-
|
|
2325
|
-
// Thêm clone vào fragment
|
|
2326
2076
|
cloneFragment.appendChild(clonedSlide);
|
|
2327
2077
|
}
|
|
2328
2078
|
});
|
|
@@ -2343,32 +2093,28 @@ function loopFixDot(_temp) {
|
|
|
2343
2093
|
});
|
|
2344
2094
|
}
|
|
2345
2095
|
|
|
2346
|
-
//
|
|
2096
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2347
2097
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2348
2098
|
clonedSlides.sort((a, b) => {
|
|
2349
2099
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2350
2100
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2351
2101
|
return indexA - indexB;
|
|
2352
2102
|
});
|
|
2353
|
-
|
|
2354
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2355
2103
|
cloneFragment.innerHTML = '';
|
|
2356
2104
|
clonedSlides.forEach(slide => {
|
|
2357
2105
|
cloneFragment.appendChild(slide);
|
|
2358
2106
|
});
|
|
2359
2107
|
|
|
2360
|
-
//
|
|
2108
|
+
// Place fragment into the right position
|
|
2361
2109
|
if (isPrev) {
|
|
2362
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2363
2110
|
slidesEl.appendChild(cloneFragment);
|
|
2364
2111
|
} else if (isNext) {
|
|
2365
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2366
2112
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2367
2113
|
}
|
|
2368
2114
|
swiper.recalcSlides();
|
|
2369
2115
|
swiper.updateSlides();
|
|
2370
2116
|
|
|
2371
|
-
//
|
|
2117
|
+
// Find old active slide index after recalculation
|
|
2372
2118
|
let oldActiveIndex = null;
|
|
2373
2119
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2374
2120
|
const child = slidesEl.children[i];
|
|
@@ -2381,7 +2127,7 @@ function loopFixDot(_temp) {
|
|
|
2381
2127
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2382
2128
|
}
|
|
2383
2129
|
|
|
2384
|
-
//
|
|
2130
|
+
// Update translate after removing clones for animation
|
|
2385
2131
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2386
2132
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2387
2133
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2407,7 +2153,8 @@ function loopFixDot(_temp) {
|
|
|
2407
2153
|
}
|
|
2408
2154
|
swiper.setTranslate(updateTranslate);
|
|
2409
2155
|
}
|
|
2410
|
-
|
|
2156
|
+
|
|
2157
|
+
// Remove clones
|
|
2411
2158
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2412
2159
|
cloneSlides.forEach(cloneSlide => {
|
|
2413
2160
|
if (cloneSlide.parentNode) {
|
|
@@ -2437,7 +2184,7 @@ function loopDestroy() {
|
|
|
2437
2184
|
params,
|
|
2438
2185
|
slidesEl
|
|
2439
2186
|
} = swiper;
|
|
2440
|
-
if (!params.loop || !slidesEl
|
|
2187
|
+
if (!params.loop || !slidesEl) return;
|
|
2441
2188
|
swiper.recalcSlides();
|
|
2442
2189
|
const newSlidesOrder = [];
|
|
2443
2190
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2498,7 +2245,6 @@ var grabCursor = {
|
|
|
2498
2245
|
unsetGrabCursor
|
|
2499
2246
|
};
|
|
2500
2247
|
|
|
2501
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2502
2248
|
function closestElement(selector, base) {
|
|
2503
2249
|
if (base === void 0) {
|
|
2504
2250
|
base = this;
|
|
@@ -2507,9 +2253,7 @@ function closestElement(selector, base) {
|
|
|
2507
2253
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2508
2254
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2509
2255
|
const found = el.closest(selector);
|
|
2510
|
-
if (!found && !el.getRootNode)
|
|
2511
|
-
return null;
|
|
2512
|
-
}
|
|
2256
|
+
if (!found && !el.getRootNode) return null;
|
|
2513
2257
|
return found || __closestFrom(el.getRootNode().host);
|
|
2514
2258
|
}
|
|
2515
2259
|
return __closestFrom(base);
|
|
@@ -2537,9 +2281,7 @@ function onTouchStart(event) {
|
|
|
2537
2281
|
if (e.originalEvent) e = e.originalEvent;
|
|
2538
2282
|
const data = swiper.touchEventsData;
|
|
2539
2283
|
if (e.type === 'pointerdown') {
|
|
2540
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
2541
|
-
return;
|
|
2542
|
-
}
|
|
2284
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
2543
2285
|
data.pointerId = e.pointerId;
|
|
2544
2286
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2545
2287
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -2556,9 +2298,7 @@ function onTouchStart(event) {
|
|
|
2556
2298
|
} = swiper;
|
|
2557
2299
|
if (!enabled) return;
|
|
2558
2300
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
2559
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
2560
|
-
return;
|
|
2561
|
-
}
|
|
2301
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
2562
2302
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
2563
2303
|
swiper.loopFix();
|
|
2564
2304
|
}
|
|
@@ -2569,8 +2309,6 @@ function onTouchStart(event) {
|
|
|
2569
2309
|
if ('which' in e && e.which === 3) return;
|
|
2570
2310
|
if ('button' in e && e.button > 0) return;
|
|
2571
2311
|
if (data.isTouched && data.isMoved) return;
|
|
2572
|
-
|
|
2573
|
-
// change target el for shadow root component
|
|
2574
2312
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
2575
2313
|
// eslint-disable-next-line
|
|
2576
2314
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -2579,8 +2317,6 @@ function onTouchStart(event) {
|
|
|
2579
2317
|
}
|
|
2580
2318
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
2581
2319
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
2582
|
-
|
|
2583
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
2584
2320
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
2585
2321
|
swiper.allowClick = true;
|
|
2586
2322
|
return;
|
|
@@ -2592,12 +2328,7 @@ function onTouchStart(event) {
|
|
|
2592
2328
|
touches.currentY = e.pageY;
|
|
2593
2329
|
const startX = touches.currentX;
|
|
2594
2330
|
const startY = touches.currentY;
|
|
2595
|
-
|
|
2596
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
2597
|
-
|
|
2598
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
2599
|
-
return;
|
|
2600
|
-
}
|
|
2331
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
2601
2332
|
Object.assign(data, {
|
|
2602
2333
|
isTouched: true,
|
|
2603
2334
|
isMoved: false,
|
|
@@ -2626,9 +2357,6 @@ function onTouchStart(event) {
|
|
|
2626
2357
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
2627
2358
|
e.preventDefault();
|
|
2628
2359
|
}
|
|
2629
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
2630
|
-
swiper.freeMode.onTouchStart();
|
|
2631
|
-
}
|
|
2632
2360
|
swiper.emit('touchStart', e);
|
|
2633
2361
|
}
|
|
2634
2362
|
|
|
@@ -2647,7 +2375,7 @@ function onTouchMove(event) {
|
|
|
2647
2375
|
let e = event;
|
|
2648
2376
|
if (e.originalEvent) e = e.originalEvent;
|
|
2649
2377
|
if (e.type === 'pointermove') {
|
|
2650
|
-
if (data.touchId !== null) return;
|
|
2378
|
+
if (data.touchId !== null) return;
|
|
2651
2379
|
const id = e.pointerId;
|
|
2652
2380
|
if (id !== data.pointerId) return;
|
|
2653
2381
|
}
|
|
@@ -2688,7 +2416,6 @@ function onTouchMove(event) {
|
|
|
2688
2416
|
}
|
|
2689
2417
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
2690
2418
|
if (swiper.isVertical()) {
|
|
2691
|
-
// Vertical
|
|
2692
2419
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
2693
2420
|
data.isTouched = false;
|
|
2694
2421
|
data.isMoved = false;
|
|
@@ -2790,7 +2517,6 @@ function onTouchMove(event) {
|
|
|
2790
2517
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
2791
2518
|
}
|
|
2792
2519
|
data.allowMomentumBounce = false;
|
|
2793
|
-
// Grab Cursor
|
|
2794
2520
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
2795
2521
|
swiper.setGrabCursor(true);
|
|
2796
2522
|
}
|
|
@@ -2861,8 +2587,6 @@ function onTouchMove(event) {
|
|
|
2861
2587
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
2862
2588
|
data.currentTranslate = data.startTranslate;
|
|
2863
2589
|
}
|
|
2864
|
-
|
|
2865
|
-
// Threshold
|
|
2866
2590
|
if (params.threshold > 0) {
|
|
2867
2591
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
2868
2592
|
if (!data.allowThresholdMove) {
|
|
@@ -2880,17 +2604,12 @@ function onTouchMove(event) {
|
|
|
2880
2604
|
}
|
|
2881
2605
|
if (!params.followFinger || params.cssMode) return;
|
|
2882
2606
|
|
|
2883
|
-
//
|
|
2884
|
-
if (params.
|
|
2607
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
2608
|
+
if (params.watchSlidesProgress) {
|
|
2885
2609
|
swiper.updateActiveIndex();
|
|
2886
2610
|
swiper.updateSlidesClasses();
|
|
2887
2611
|
}
|
|
2888
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
2889
|
-
swiper.freeMode.onTouchMove();
|
|
2890
|
-
}
|
|
2891
|
-
// Update progress
|
|
2892
2612
|
swiper.updateProgress(data.currentTranslate);
|
|
2893
|
-
// Update translate
|
|
2894
2613
|
swiper.setTranslate(data.currentTranslate);
|
|
2895
2614
|
}
|
|
2896
2615
|
|
|
@@ -2902,7 +2621,7 @@ function onTouchEnd(event) {
|
|
|
2902
2621
|
let targetTouch;
|
|
2903
2622
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
2904
2623
|
if (!isTouchEvent) {
|
|
2905
|
-
if (data.touchId !== null) return;
|
|
2624
|
+
if (data.touchId !== null) return;
|
|
2906
2625
|
if (e.pointerId !== data.pointerId) return;
|
|
2907
2626
|
targetTouch = e;
|
|
2908
2627
|
} else {
|
|
@@ -2911,9 +2630,7 @@ function onTouchEnd(event) {
|
|
|
2911
2630
|
}
|
|
2912
2631
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
2913
2632
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
2914
|
-
if (!proceed)
|
|
2915
|
-
return;
|
|
2916
|
-
}
|
|
2633
|
+
if (!proceed) return;
|
|
2917
2634
|
}
|
|
2918
2635
|
data.pointerId = null;
|
|
2919
2636
|
data.touchId = null;
|
|
@@ -2931,9 +2648,7 @@ function onTouchEnd(event) {
|
|
|
2931
2648
|
}
|
|
2932
2649
|
data.allowTouchCallbacks = false;
|
|
2933
2650
|
if (!data.isTouched) {
|
|
2934
|
-
if (data.isMoved && params.grabCursor)
|
|
2935
|
-
swiper.setGrabCursor(false);
|
|
2936
|
-
}
|
|
2651
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
2937
2652
|
data.isMoved = false;
|
|
2938
2653
|
data.startMoving = false;
|
|
2939
2654
|
return;
|
|
@@ -2943,8 +2658,6 @@ function onTouchEnd(event) {
|
|
|
2943
2658
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
2944
2659
|
swiper.setGrabCursor(false);
|
|
2945
2660
|
}
|
|
2946
|
-
|
|
2947
|
-
// Time diff
|
|
2948
2661
|
const touchEndTime = now();
|
|
2949
2662
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
2950
2663
|
|
|
@@ -2971,20 +2684,8 @@ function onTouchEnd(event) {
|
|
|
2971
2684
|
data.isMoved = false;
|
|
2972
2685
|
data.startMoving = false;
|
|
2973
2686
|
let currentPos;
|
|
2974
|
-
if (params.followFinger)
|
|
2975
|
-
|
|
2976
|
-
} else {
|
|
2977
|
-
currentPos = -data.currentTranslate;
|
|
2978
|
-
}
|
|
2979
|
-
if (params.cssMode) {
|
|
2980
|
-
return;
|
|
2981
|
-
}
|
|
2982
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
2983
|
-
swiper.freeMode.onTouchEnd({
|
|
2984
|
-
currentPos
|
|
2985
|
-
});
|
|
2986
|
-
return;
|
|
2987
|
-
}
|
|
2687
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
2688
|
+
if (params.cssMode) return;
|
|
2988
2689
|
|
|
2989
2690
|
// Find current slide
|
|
2990
2691
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3006,22 +2707,22 @@ function onTouchEnd(event) {
|
|
|
3006
2707
|
let rewindLastIndex = null;
|
|
3007
2708
|
if (params.rewind) {
|
|
3008
2709
|
if (swiper.isBeginning) {
|
|
3009
|
-
rewindLastIndex =
|
|
2710
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3010
2711
|
} else if (swiper.isEnd) {
|
|
3011
2712
|
rewindFirstIndex = 0;
|
|
3012
2713
|
}
|
|
3013
2714
|
}
|
|
3014
|
-
// Find current slide size
|
|
3015
2715
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3016
2716
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3017
2717
|
if (timeDiff > params.longSwipesMs) {
|
|
3018
|
-
// Long touches
|
|
3019
2718
|
if (!params.longSwipes) {
|
|
3020
2719
|
swiper.slideTo(swiper.activeIndex);
|
|
3021
2720
|
return;
|
|
3022
2721
|
}
|
|
3023
2722
|
if (swiper.swipeDirection === 'next') {
|
|
3024
|
-
if (ratio >= params.longSwipesRatio)
|
|
2723
|
+
if (ratio >= params.longSwipesRatio) {
|
|
2724
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
2725
|
+
} else swiper.slideTo(stopIndex);
|
|
3025
2726
|
}
|
|
3026
2727
|
if (swiper.swipeDirection === 'prev') {
|
|
3027
2728
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3073,7 +2774,6 @@ function onResize() {
|
|
|
3073
2774
|
allowSlidePrev,
|
|
3074
2775
|
snapGrid
|
|
3075
2776
|
} = swiper;
|
|
3076
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3077
2777
|
|
|
3078
2778
|
// Disable locks on resize
|
|
3079
2779
|
swiper.allowSlideNext = true;
|
|
@@ -3081,15 +2781,12 @@ function onResize() {
|
|
|
3081
2781
|
swiper.updateSize();
|
|
3082
2782
|
swiper.updateSlides();
|
|
3083
2783
|
swiper.updateSlidesClasses();
|
|
3084
|
-
|
|
3085
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
2784
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3086
2785
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
2786
|
+
} else if (swiper.params.loop) {
|
|
2787
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3087
2788
|
} else {
|
|
3088
|
-
|
|
3089
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3090
|
-
} else {
|
|
3091
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3092
|
-
}
|
|
2789
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3093
2790
|
}
|
|
3094
2791
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3095
2792
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3099,10 +2796,11 @@ function onResize() {
|
|
|
3099
2796
|
}
|
|
3100
2797
|
}, 500);
|
|
3101
2798
|
}
|
|
2799
|
+
|
|
3102
2800
|
// Return locks after resize
|
|
3103
2801
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3104
2802
|
swiper.allowSlideNext = allowSlideNext;
|
|
3105
|
-
if (
|
|
2803
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3106
2804
|
swiper.checkOverflow();
|
|
3107
2805
|
}
|
|
3108
2806
|
}
|
|
@@ -3271,8 +2969,15 @@ var events$1 = {
|
|
|
3271
2969
|
detachEvents
|
|
3272
2970
|
};
|
|
3273
2971
|
|
|
3274
|
-
const
|
|
3275
|
-
|
|
2972
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
2973
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
2974
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
2975
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
2976
|
+
swiper[prop].disable();
|
|
2977
|
+
}
|
|
2978
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
2979
|
+
swiper[prop].enable();
|
|
2980
|
+
}
|
|
3276
2981
|
};
|
|
3277
2982
|
function setBreakpoint() {
|
|
3278
2983
|
const swiper = this;
|
|
@@ -3293,38 +2998,20 @@ function setBreakpoint() {
|
|
|
3293
2998
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3294
2999
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3295
3000
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3296
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3297
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3298
3001
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3299
3002
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3300
3003
|
const wasEnabled = params.enabled;
|
|
3301
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3302
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3303
|
-
swiper.emitContainerClasses();
|
|
3304
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3305
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3306
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3307
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3308
|
-
}
|
|
3309
|
-
swiper.emitContainerClasses();
|
|
3310
|
-
}
|
|
3311
3004
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3312
3005
|
swiper.unsetGrabCursor();
|
|
3313
3006
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3314
3007
|
swiper.setGrabCursor();
|
|
3315
3008
|
}
|
|
3316
3009
|
|
|
3317
|
-
//
|
|
3318
|
-
['navigation', 'pagination'
|
|
3010
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3011
|
+
const modules = ['navigation', 'pagination'];
|
|
3012
|
+
modules.forEach(prop => {
|
|
3319
3013
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3320
|
-
|
|
3321
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3322
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3323
|
-
swiper[prop].disable();
|
|
3324
|
-
}
|
|
3325
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3326
|
-
swiper[prop].enable();
|
|
3327
|
-
}
|
|
3014
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3328
3015
|
});
|
|
3329
3016
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3330
3017
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3406,7 +3093,7 @@ var breakpoints = {
|
|
|
3406
3093
|
getBreakpoint
|
|
3407
3094
|
};
|
|
3408
3095
|
|
|
3409
|
-
|
|
3096
|
+
const prepareClasses = (entries, prefix) => {
|
|
3410
3097
|
const resultClasses = [];
|
|
3411
3098
|
entries.forEach(item => {
|
|
3412
3099
|
if (typeof item === 'object') {
|
|
@@ -3420,7 +3107,7 @@ function prepareClasses(entries, prefix) {
|
|
|
3420
3107
|
}
|
|
3421
3108
|
});
|
|
3422
3109
|
return resultClasses;
|
|
3423
|
-
}
|
|
3110
|
+
};
|
|
3424
3111
|
function addClasses() {
|
|
3425
3112
|
const swiper = this;
|
|
3426
3113
|
const {
|
|
@@ -3430,17 +3117,12 @@ function addClasses() {
|
|
|
3430
3117
|
el,
|
|
3431
3118
|
device
|
|
3432
3119
|
} = swiper;
|
|
3120
|
+
// core-lite: removed module-specific classes
|
|
3433
3121
|
// prettier-ignore
|
|
3434
3122
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3435
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3436
|
-
}, {
|
|
3437
3123
|
'autoheight': params.autoHeight
|
|
3438
3124
|
}, {
|
|
3439
3125
|
'rtl': rtl
|
|
3440
|
-
}, {
|
|
3441
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3442
|
-
}, {
|
|
3443
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3444
3126
|
}, {
|
|
3445
3127
|
'android': device.android
|
|
3446
3128
|
}, {
|
|
@@ -3537,16 +3219,12 @@ var defaults = {
|
|
|
3537
3219
|
autoHeight: false,
|
|
3538
3220
|
// Set wrapper width
|
|
3539
3221
|
setWrapperSize: false,
|
|
3540
|
-
//
|
|
3541
|
-
virtualTranslate: false,
|
|
3542
|
-
// Effects
|
|
3222
|
+
// Effects (core-lite only supports `slide`)
|
|
3543
3223
|
effect: 'slide',
|
|
3544
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
3545
|
-
|
|
3546
3224
|
// Breakpoints
|
|
3547
3225
|
breakpoints: undefined,
|
|
3548
3226
|
breakpointsBase: 'window',
|
|
3549
|
-
// Slides
|
|
3227
|
+
// Slides
|
|
3550
3228
|
spaceBetween: 0,
|
|
3551
3229
|
slidesPerView: 1,
|
|
3552
3230
|
slidesPerGroup: 1,
|
|
@@ -3649,7 +3327,9 @@ function moduleExtendParams(params, allModulesParams) {
|
|
|
3649
3327
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
3650
3328
|
params[moduleParamName].auto = true;
|
|
3651
3329
|
}
|
|
3652
|
-
|
|
3330
|
+
|
|
3331
|
+
// Core-lite: keep only pagination auto-init.
|
|
3332
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
3653
3333
|
params[moduleParamName].auto = true;
|
|
3654
3334
|
}
|
|
3655
3335
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -3775,7 +3455,6 @@ class Swiper {
|
|
|
3775
3455
|
// Indexes
|
|
3776
3456
|
activeIndex: 0,
|
|
3777
3457
|
realIndex: 0,
|
|
3778
|
-
//
|
|
3779
3458
|
isBeginning: true,
|
|
3780
3459
|
isEnd: false,
|
|
3781
3460
|
// Props
|
|
@@ -3802,12 +3481,9 @@ class Swiper {
|
|
|
3802
3481
|
currentTranslate: undefined,
|
|
3803
3482
|
startTranslate: undefined,
|
|
3804
3483
|
allowThresholdMove: undefined,
|
|
3805
|
-
// Form elements to match
|
|
3806
3484
|
focusableElements: swiper.params.focusableElements,
|
|
3807
|
-
// Last click time
|
|
3808
3485
|
lastClickTime: 0,
|
|
3809
3486
|
clickTimeout: undefined,
|
|
3810
|
-
// Velocities
|
|
3811
3487
|
velocities: [],
|
|
3812
3488
|
allowMomentumBounce: undefined,
|
|
3813
3489
|
startMoving: undefined,
|
|
@@ -3836,7 +3512,6 @@ class Swiper {
|
|
|
3836
3512
|
swiper.init();
|
|
3837
3513
|
}
|
|
3838
3514
|
|
|
3839
|
-
// Return app instance
|
|
3840
3515
|
// eslint-disable-next-line no-constructor-return
|
|
3841
3516
|
return swiper;
|
|
3842
3517
|
}
|
|
@@ -3868,16 +3543,6 @@ class Swiper {
|
|
|
3868
3543
|
getSlideIndexByData(index) {
|
|
3869
3544
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
3870
3545
|
}
|
|
3871
|
-
getSlideIndexWhenGrid(index) {
|
|
3872
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
3873
|
-
if (this.params.grid.fill === 'column') {
|
|
3874
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
3875
|
-
} else if (this.params.grid.fill === 'row') {
|
|
3876
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
return index;
|
|
3880
|
-
}
|
|
3881
3546
|
recalcSlides() {
|
|
3882
3547
|
const swiper = this;
|
|
3883
3548
|
const {
|
|
@@ -3979,21 +3644,15 @@ class Swiper {
|
|
|
3979
3644
|
}
|
|
3980
3645
|
}
|
|
3981
3646
|
} else {
|
|
3982
|
-
// eslint-disable-next-line
|
|
3983
3647
|
if (view === 'current') {
|
|
3984
3648
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
3985
3649
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
3986
|
-
if (slideInView)
|
|
3987
|
-
spv += 1;
|
|
3988
|
-
}
|
|
3650
|
+
if (slideInView) spv += 1;
|
|
3989
3651
|
}
|
|
3990
3652
|
} else {
|
|
3991
|
-
// previous
|
|
3992
3653
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
3993
3654
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
3994
|
-
if (slideInView)
|
|
3995
|
-
spv += 1;
|
|
3996
|
-
}
|
|
3655
|
+
if (slideInView) spv += 1;
|
|
3997
3656
|
}
|
|
3998
3657
|
}
|
|
3999
3658
|
}
|
|
@@ -4006,14 +3665,11 @@ class Swiper {
|
|
|
4006
3665
|
snapGrid,
|
|
4007
3666
|
params
|
|
4008
3667
|
} = swiper;
|
|
4009
|
-
// Breakpoints
|
|
4010
3668
|
if (params.breakpoints) {
|
|
4011
3669
|
swiper.setBreakpoint();
|
|
4012
3670
|
}
|
|
4013
3671
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4014
|
-
if (imageEl.complete)
|
|
4015
|
-
processLazyPreloader(swiper, imageEl);
|
|
4016
|
-
}
|
|
3672
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4017
3673
|
});
|
|
4018
3674
|
swiper.updateSize();
|
|
4019
3675
|
swiper.updateSlides();
|
|
@@ -4027,22 +3683,12 @@ class Swiper {
|
|
|
4027
3683
|
swiper.updateSlidesClasses();
|
|
4028
3684
|
}
|
|
4029
3685
|
let translated;
|
|
4030
|
-
if (params.
|
|
4031
|
-
|
|
4032
|
-
if (params.autoHeight) {
|
|
4033
|
-
swiper.updateAutoHeight();
|
|
4034
|
-
}
|
|
3686
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
3687
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4035
3688
|
} else {
|
|
4036
|
-
|
|
4037
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4038
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4039
|
-
} else {
|
|
4040
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4041
|
-
}
|
|
4042
|
-
if (!translated) {
|
|
4043
|
-
setTranslate();
|
|
4044
|
-
}
|
|
3689
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4045
3690
|
}
|
|
3691
|
+
if (!translated) setTranslate();
|
|
4046
3692
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4047
3693
|
swiper.checkOverflow();
|
|
4048
3694
|
}
|
|
@@ -4055,7 +3701,6 @@ class Swiper {
|
|
|
4055
3701
|
const swiper = this;
|
|
4056
3702
|
const currentDirection = swiper.params.direction;
|
|
4057
3703
|
if (!newDirection) {
|
|
4058
|
-
// eslint-disable-next-line
|
|
4059
3704
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4060
3705
|
}
|
|
4061
3706
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4093,15 +3738,11 @@ class Swiper {
|
|
|
4093
3738
|
mount(element) {
|
|
4094
3739
|
const swiper = this;
|
|
4095
3740
|
if (swiper.mounted) return true;
|
|
4096
|
-
|
|
4097
|
-
// Find el
|
|
4098
3741
|
let el = element || swiper.params.el;
|
|
4099
3742
|
if (typeof el === 'string') {
|
|
4100
3743
|
el = document.querySelector(el);
|
|
4101
3744
|
}
|
|
4102
|
-
if (!el)
|
|
4103
|
-
return false;
|
|
4104
|
-
}
|
|
3745
|
+
if (!el) return false;
|
|
4105
3746
|
el.swiper = swiper;
|
|
4106
3747
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4107
3748
|
swiper.isElement = true;
|
|
@@ -4112,12 +3753,10 @@ class Swiper {
|
|
|
4112
3753
|
const getWrapper = () => {
|
|
4113
3754
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4114
3755
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4115
|
-
// Children needs to return slot items
|
|
4116
3756
|
return res;
|
|
4117
3757
|
}
|
|
4118
3758
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4119
3759
|
};
|
|
4120
|
-
// Find Wrapper
|
|
4121
3760
|
let wrapperEl = getWrapper();
|
|
4122
3761
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4123
3762
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4132,7 +3771,6 @@ class Swiper {
|
|
|
4132
3771
|
slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
|
4133
3772
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4134
3773
|
mounted: true,
|
|
4135
|
-
// RTL
|
|
4136
3774
|
rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
|
4137
3775
|
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
|
4138
3776
|
wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
|
@@ -4152,7 +3790,6 @@ class Swiper {
|
|
|
4152
3790
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4153
3791
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4154
3792
|
if (isFirstSlide) {
|
|
4155
|
-
// Move last item to first position when at first slide
|
|
4156
3793
|
const lastSlide = slides.at(-1);
|
|
4157
3794
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4158
3795
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4164,7 +3801,6 @@ class Swiper {
|
|
|
4164
3801
|
swiper.setTransition(speed);
|
|
4165
3802
|
swiper.setTranslate(-swiperTranslate);
|
|
4166
3803
|
} else if (isLastSlide) {
|
|
4167
|
-
// Move first item to last position when at last slide
|
|
4168
3804
|
const firstSlide = slides[0];
|
|
4169
3805
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4170
3806
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4185,42 +3821,24 @@ class Swiper {
|
|
|
4185
3821
|
const mounted = swiper.mount(el);
|
|
4186
3822
|
if (mounted === false) return swiper;
|
|
4187
3823
|
swiper.emit('beforeInit');
|
|
4188
|
-
|
|
4189
|
-
// Set breakpoint
|
|
4190
3824
|
if (swiper.params.breakpoints) {
|
|
4191
3825
|
swiper.setBreakpoint();
|
|
4192
3826
|
}
|
|
4193
|
-
|
|
4194
|
-
// Add Classes
|
|
4195
3827
|
swiper.addClasses();
|
|
4196
|
-
|
|
4197
|
-
// Update size
|
|
4198
3828
|
swiper.updateSize();
|
|
4199
|
-
|
|
4200
|
-
// Update slides
|
|
4201
3829
|
swiper.updateSlides();
|
|
4202
3830
|
if (swiper.params.watchOverflow) {
|
|
4203
3831
|
swiper.checkOverflow();
|
|
4204
3832
|
}
|
|
4205
|
-
|
|
4206
|
-
// Set Grab Cursor
|
|
4207
3833
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4208
3834
|
swiper.setGrabCursor();
|
|
4209
3835
|
}
|
|
4210
3836
|
|
|
4211
|
-
// Slide
|
|
4212
|
-
|
|
4213
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4214
|
-
} else {
|
|
4215
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4216
|
-
}
|
|
4217
|
-
|
|
4218
|
-
// Create loop
|
|
3837
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
3838
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4219
3839
|
if (swiper.params.loop) {
|
|
4220
3840
|
swiper.loopCreate(undefined, true);
|
|
4221
3841
|
}
|
|
4222
|
-
|
|
4223
|
-
// Attach events
|
|
4224
3842
|
swiper.attachEvents();
|
|
4225
3843
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4226
3844
|
if (swiper.isElement) {
|
|
@@ -4230,18 +3848,12 @@ class Swiper {
|
|
|
4230
3848
|
if (imageEl.complete) {
|
|
4231
3849
|
processLazyPreloader(swiper, imageEl);
|
|
4232
3850
|
} else {
|
|
4233
|
-
imageEl.addEventListener('load', e =>
|
|
4234
|
-
processLazyPreloader(swiper, e.target);
|
|
4235
|
-
});
|
|
3851
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4236
3852
|
}
|
|
4237
3853
|
});
|
|
4238
3854
|
preload(swiper);
|
|
4239
|
-
|
|
4240
|
-
// Init Flag
|
|
4241
3855
|
swiper.initialized = true;
|
|
4242
3856
|
preload(swiper);
|
|
4243
|
-
|
|
4244
|
-
// Emit
|
|
4245
3857
|
swiper.emit('init');
|
|
4246
3858
|
swiper.emit('afterInit');
|
|
4247
3859
|
return swiper;
|
|
@@ -4264,27 +3876,15 @@ class Swiper {
|
|
|
4264
3876
|
return null;
|
|
4265
3877
|
}
|
|
4266
3878
|
swiper.emit('beforeDestroy');
|
|
4267
|
-
|
|
4268
|
-
// Init Flag
|
|
4269
3879
|
swiper.initialized = false;
|
|
4270
|
-
|
|
4271
|
-
// Detach events
|
|
4272
3880
|
swiper.detachEvents();
|
|
4273
|
-
|
|
4274
|
-
// Destroy loop
|
|
4275
3881
|
if (params.loop) {
|
|
4276
3882
|
swiper.loopDestroy();
|
|
4277
3883
|
}
|
|
4278
|
-
|
|
4279
|
-
// Cleanup styles
|
|
4280
3884
|
if (cleanStyles) {
|
|
4281
3885
|
swiper.removeClasses();
|
|
4282
|
-
if (el && typeof el !== 'string')
|
|
4283
|
-
|
|
4284
|
-
}
|
|
4285
|
-
if (wrapperEl) {
|
|
4286
|
-
wrapperEl.removeAttribute('style');
|
|
4287
|
-
}
|
|
3886
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
3887
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4288
3888
|
if (slides && slides.length) {
|
|
4289
3889
|
slides.forEach(slideEl => {
|
|
4290
3890
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4294,8 +3894,6 @@ class Swiper {
|
|
|
4294
3894
|
}
|
|
4295
3895
|
}
|
|
4296
3896
|
swiper.emit('destroy');
|
|
4297
|
-
|
|
4298
|
-
// Detach emitter events
|
|
4299
3897
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4300
3898
|
swiper.off(eventName);
|
|
4301
3899
|
});
|