@gem-sdk/swiper 0.0.15 → 0.0.17-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 +1 -1
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +243 -579
- package/shared/utils.min.mjs +1 -1
- package/shared/utils.min.mjs.map +1 -1
- package/shared/utils.mjs +50 -1
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +297 -584
- 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 +299 -586
- 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 +297 -584
- 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 +295 -582
- 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/types/swiper-options.d.ts +2 -0
package/swiper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper 0.0.
|
|
2
|
+
* Swiper 0.0.17-dev.1
|
|
3
3
|
* Gem SDK - Swiper, Customized of swiper
|
|
4
4
|
* https://swiperjs.com
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Released under the MIT License
|
|
9
9
|
*
|
|
10
|
-
* Released on: March
|
|
10
|
+
* Released on: March 23, 2026
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
var Swiper = (function () {
|
|
@@ -189,7 +189,7 @@ var Swiper = (function () {
|
|
|
189
189
|
function now() {
|
|
190
190
|
return Date.now();
|
|
191
191
|
}
|
|
192
|
-
function getComputedStyle
|
|
192
|
+
function getComputedStyle(el) {
|
|
193
193
|
const window = getWindow();
|
|
194
194
|
let style;
|
|
195
195
|
if (window.getComputedStyle) {
|
|
@@ -211,7 +211,7 @@ var Swiper = (function () {
|
|
|
211
211
|
let matrix;
|
|
212
212
|
let curTransform;
|
|
213
213
|
let transformMatrix;
|
|
214
|
-
const curStyle = getComputedStyle
|
|
214
|
+
const curStyle = getComputedStyle(el);
|
|
215
215
|
if (window.WebKitCSSMatrix) {
|
|
216
216
|
curTransform = curStyle.transform || curStyle.webkitTransform;
|
|
217
217
|
if (curTransform.split(',').length > 6) {
|
|
@@ -447,6 +447,55 @@ var Swiper = (function () {
|
|
|
447
447
|
}
|
|
448
448
|
return el.offsetWidth;
|
|
449
449
|
}
|
|
450
|
+
function getComputedStyleValue(params) {
|
|
451
|
+
const {
|
|
452
|
+
styles,
|
|
453
|
+
swiper,
|
|
454
|
+
property
|
|
455
|
+
} = params ?? {};
|
|
456
|
+
return parseFloat(styles.getPropertyValue(swiper.getDirectionLabel(property))) || 0;
|
|
457
|
+
}
|
|
458
|
+
function computeAutoSlideSize(params) {
|
|
459
|
+
const {
|
|
460
|
+
el,
|
|
461
|
+
swiper
|
|
462
|
+
} = params ?? {};
|
|
463
|
+
const styles = getComputedStyle(el);
|
|
464
|
+
const width = getComputedStyleValue({
|
|
465
|
+
styles,
|
|
466
|
+
swiper,
|
|
467
|
+
property: 'width'
|
|
468
|
+
});
|
|
469
|
+
const paddingLeft = getComputedStyleValue({
|
|
470
|
+
styles,
|
|
471
|
+
swiper,
|
|
472
|
+
property: 'padding-left'
|
|
473
|
+
});
|
|
474
|
+
const paddingRight = getComputedStyleValue({
|
|
475
|
+
styles,
|
|
476
|
+
swiper,
|
|
477
|
+
property: 'padding-right'
|
|
478
|
+
});
|
|
479
|
+
const marginLeft = getComputedStyleValue({
|
|
480
|
+
styles,
|
|
481
|
+
swiper,
|
|
482
|
+
property: 'margin-left'
|
|
483
|
+
});
|
|
484
|
+
const marginRight = getComputedStyleValue({
|
|
485
|
+
styles,
|
|
486
|
+
swiper,
|
|
487
|
+
property: 'margin-right'
|
|
488
|
+
});
|
|
489
|
+
const boxSizing = styles.getPropertyValue('box-sizing');
|
|
490
|
+
if (boxSizing && boxSizing === 'border-box') {
|
|
491
|
+
return width + marginLeft + marginRight;
|
|
492
|
+
}
|
|
493
|
+
const {
|
|
494
|
+
clientWidth,
|
|
495
|
+
offsetWidth
|
|
496
|
+
} = slideEl;
|
|
497
|
+
return width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
498
|
+
}
|
|
450
499
|
|
|
451
500
|
let support;
|
|
452
501
|
function calcSupport() {
|
|
@@ -829,9 +878,6 @@ var Swiper = (function () {
|
|
|
829
878
|
|
|
830
879
|
function updateSlides() {
|
|
831
880
|
const swiper = this;
|
|
832
|
-
function getDirectionPropertyValue(node, label) {
|
|
833
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
834
|
-
}
|
|
835
881
|
const params = swiper.params;
|
|
836
882
|
const {
|
|
837
883
|
wrapperEl,
|
|
@@ -840,10 +886,8 @@ var Swiper = (function () {
|
|
|
840
886
|
rtlTranslate: rtl,
|
|
841
887
|
wrongRTL
|
|
842
888
|
} = swiper;
|
|
843
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
844
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
845
889
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
846
|
-
const slidesLength =
|
|
890
|
+
const slidesLength = slides.length;
|
|
847
891
|
let snapGrid = [];
|
|
848
892
|
const slidesGrid = [];
|
|
849
893
|
const slidesSizesGrid = [];
|
|
@@ -861,15 +905,15 @@ var Swiper = (function () {
|
|
|
861
905
|
let slidePosition = -offsetBefore;
|
|
862
906
|
let prevSlideSize = 0;
|
|
863
907
|
let index = 0;
|
|
864
|
-
if (typeof swiperSize === 'undefined')
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
908
|
+
if (typeof swiperSize === 'undefined') return;
|
|
867
909
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
868
910
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
869
911
|
} else if (typeof spaceBetween === 'string') {
|
|
870
912
|
spaceBetween = parseFloat(spaceBetween);
|
|
871
913
|
}
|
|
872
|
-
|
|
914
|
+
|
|
915
|
+
// core-lite: compute total slides size without optional modules
|
|
916
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
873
917
|
|
|
874
918
|
// reset margins
|
|
875
919
|
slides.forEach(slideEl => {
|
|
@@ -887,67 +931,90 @@ var Swiper = (function () {
|
|
|
887
931
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
888
932
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
889
933
|
}
|
|
890
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
891
|
-
if (gridEnabled) {
|
|
892
|
-
swiper.grid.initSlides(slides);
|
|
893
|
-
} else if (swiper.grid) {
|
|
894
|
-
swiper.grid.unsetSlides();
|
|
895
|
-
}
|
|
896
934
|
|
|
897
935
|
// Calc slides
|
|
898
936
|
let slideSize;
|
|
899
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
900
|
-
|
|
901
|
-
}).length > 0;
|
|
902
|
-
for (let i = 0; i < slidesLength; i += 1) {
|
|
903
|
-
slideSize = 0;
|
|
904
|
-
let slide;
|
|
905
|
-
if (slides[i]) slide = slides[i];
|
|
906
|
-
if (gridEnabled) {
|
|
907
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
908
|
-
}
|
|
909
|
-
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
937
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
938
|
+
const isAutoSlidesPerView = params.slidesPerView === 'auto';
|
|
910
939
|
|
|
911
|
-
|
|
940
|
+
// --- Phase 1: Batch DOM writes (grid updates, width/transform resets) ---
|
|
941
|
+
// Moving all style writes before any reads prevents per-slide forced reflows
|
|
942
|
+
|
|
943
|
+
const savedTransforms = [];
|
|
944
|
+
if (isAutoSlidesPerView) {
|
|
945
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
946
|
+
if (!slides[i]) continue;
|
|
912
947
|
if (shouldResetSlideSize) {
|
|
913
948
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
914
949
|
}
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
-
|
|
950
|
+
const currentTransform = slides[i].style.transform;
|
|
951
|
+
const currentWebKitTransform = slides[i].style.webkitTransform;
|
|
952
|
+
savedTransforms[i] = {
|
|
953
|
+
transform: currentTransform,
|
|
954
|
+
webkitTransform: currentWebKitTransform
|
|
955
|
+
};
|
|
918
956
|
if (currentTransform) {
|
|
919
|
-
|
|
957
|
+
slides[i].style.transform = 'none';
|
|
920
958
|
}
|
|
921
959
|
if (currentWebKitTransform) {
|
|
922
|
-
|
|
960
|
+
slides[i].style.webkitTransform = 'none';
|
|
923
961
|
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// --- Phase 2: Batch DOM reads (single forced reflow for all slides) ---
|
|
966
|
+
// Read wrapper offset here (before Phase 3 writes) so it's batched with slide reads, not after
|
|
967
|
+
const wrapperOffset = swiper.isElement ? swiper.wrapperEl[`offset${swiper.isHorizontal() ? 'Left' : 'Top'}`] : 0;
|
|
968
|
+
const slideVisible = [];
|
|
969
|
+
const slideSizes = [];
|
|
970
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
971
|
+
if (!slides[i]) {
|
|
972
|
+
slideVisible[i] = false;
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
if (elementStyle(slides[i], 'display') === 'none') {
|
|
976
|
+
slideVisible[i] = false;
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
slideVisible[i] = true;
|
|
980
|
+
|
|
981
|
+
// Cache offsetHeight for autoHeight (batched here to avoid a separate forced reflow in updateAutoHeight)
|
|
982
|
+
if (params.autoHeight) {
|
|
983
|
+
slides[i].swiperSlideHeight = slides[i]['offsetHeight'];
|
|
984
|
+
}
|
|
985
|
+
if (isAutoSlidesPerView) {
|
|
924
986
|
if (params.roundLengths) {
|
|
925
|
-
|
|
987
|
+
slideSizes[i] = swiper.isHorizontal() ? elementOuterSize(slides[i], 'width', true) : elementOuterSize(slides[i], 'height', true);
|
|
926
988
|
} else {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
|
932
|
-
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
|
933
|
-
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
934
|
-
if (boxSizing && boxSizing === 'border-box') {
|
|
935
|
-
slideSize = width + marginLeft + marginRight;
|
|
936
|
-
} else {
|
|
937
|
-
const {
|
|
938
|
-
clientWidth,
|
|
939
|
-
offsetWidth
|
|
940
|
-
} = slide;
|
|
941
|
-
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
942
|
-
}
|
|
989
|
+
slideSizes[i] = computeAutoSlideSize({
|
|
990
|
+
el: slides[i],
|
|
991
|
+
swiper
|
|
992
|
+
});
|
|
943
993
|
}
|
|
944
|
-
if (
|
|
945
|
-
|
|
994
|
+
if (params.roundLengths) slideSizes[i] = Math.floor(slideSizes[i]);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// --- Phase 3: Restore transforms (batch write) ---
|
|
999
|
+
if (isAutoSlidesPerView) {
|
|
1000
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1001
|
+
if (!savedTransforms[i]) continue;
|
|
1002
|
+
if (savedTransforms[i].transform) {
|
|
1003
|
+
slides[i].style.transform = savedTransforms[i].transform;
|
|
946
1004
|
}
|
|
947
|
-
if (
|
|
948
|
-
|
|
1005
|
+
if (savedTransforms[i].webkitTransform) {
|
|
1006
|
+
slides[i].style.webkitTransform = savedTransforms[i].webkitTransform;
|
|
949
1007
|
}
|
|
950
|
-
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// --- Phase 4: Calculate positions + set sizes (math + deferred writes) ---
|
|
1012
|
+
const cssOverflowAdj = swiper.cssOverflowAdjustment();
|
|
1013
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1014
|
+
slideSize = 0;
|
|
1015
|
+
if (!slideVisible[i]) continue;
|
|
1016
|
+
if (isAutoSlidesPerView) {
|
|
1017
|
+
slideSize = slideSizes[i] || 0;
|
|
951
1018
|
} else {
|
|
952
1019
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
953
1020
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
@@ -955,13 +1022,13 @@ var Swiper = (function () {
|
|
|
955
1022
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
956
1023
|
}
|
|
957
1024
|
}
|
|
958
|
-
if (slides[i])
|
|
959
|
-
slides[i].swiperSlideSize = slideSize;
|
|
960
|
-
}
|
|
1025
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
961
1026
|
slidesSizesGrid.push(slideSize);
|
|
962
1027
|
if (params.centeredSlides) {
|
|
963
1028
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
964
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
1029
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
1030
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1031
|
+
}
|
|
965
1032
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
966
1033
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
967
1034
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -969,55 +1036,42 @@ var Swiper = (function () {
|
|
|
969
1036
|
slidesGrid.push(slidePosition);
|
|
970
1037
|
} else {
|
|
971
1038
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
972
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
1039
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
1040
|
+
snapGrid.push(slidePosition);
|
|
1041
|
+
}
|
|
973
1042
|
slidesGrid.push(slidePosition);
|
|
974
1043
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
975
1044
|
}
|
|
976
|
-
|
|
1045
|
+
|
|
1046
|
+
// Set swiperSlideOffset from computed grid position (avoids DOM reads in updateSlidesOffset)
|
|
1047
|
+
if (slides[i]) {
|
|
1048
|
+
slides[i].swiperSlideOffset = slidesGrid[slidesGrid.length - 1] - cssOverflowAdj - wrapperOffset;
|
|
1049
|
+
}
|
|
1050
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
977
1051
|
prevSlideSize = slideSize;
|
|
978
1052
|
index += 1;
|
|
979
1053
|
}
|
|
980
|
-
swiper.
|
|
981
|
-
if (rtl && wrongRTL &&
|
|
982
|
-
wrapperEl.style.width = `${swiper.
|
|
1054
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
1055
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
1056
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
983
1057
|
}
|
|
984
1058
|
if (params.setWrapperSize) {
|
|
985
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
986
|
-
}
|
|
987
|
-
if (gridEnabled) {
|
|
988
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
1059
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
989
1060
|
}
|
|
990
1061
|
|
|
991
|
-
// Remove last
|
|
1062
|
+
// Remove last snap points depending on width (non-centered)
|
|
992
1063
|
if (!params.centeredSlides) {
|
|
993
1064
|
const newSlidesGrid = [];
|
|
994
1065
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
995
1066
|
let slidesGridItem = snapGrid[i];
|
|
996
1067
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
997
|
-
if (snapGrid[i] <= swiper.
|
|
1068
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
998
1069
|
newSlidesGrid.push(slidesGridItem);
|
|
999
1070
|
}
|
|
1000
1071
|
}
|
|
1001
1072
|
snapGrid = newSlidesGrid;
|
|
1002
|
-
if (Math.floor(swiper.
|
|
1003
|
-
snapGrid.push(swiper.
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
if (isVirtual && params.loop) {
|
|
1007
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
1008
|
-
if (params.slidesPerGroup > 1) {
|
|
1009
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
1010
|
-
const groupSize = size * params.slidesPerGroup;
|
|
1011
|
-
for (let i = 0; i < groups; i += 1) {
|
|
1012
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
1016
|
-
if (params.slidesPerGroup === 1) {
|
|
1017
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
1018
|
-
}
|
|
1019
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
1020
|
-
swiper.virtualSize += size;
|
|
1073
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
1074
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1021
1075
|
}
|
|
1022
1076
|
}
|
|
1023
1077
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1025,9 +1079,7 @@ var Swiper = (function () {
|
|
|
1025
1079
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1026
1080
|
slides.filter((_, slideIndex) => {
|
|
1027
1081
|
if (!params.cssMode || params.loop) return true;
|
|
1028
|
-
if (slideIndex === slides.length - 1)
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1082
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1031
1083
|
return true;
|
|
1032
1084
|
}).forEach(slideEl => {
|
|
1033
1085
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1077,7 +1129,9 @@ var Swiper = (function () {
|
|
|
1077
1129
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1078
1130
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1079
1131
|
}
|
|
1080
|
-
|
|
1132
|
+
|
|
1133
|
+
// Emit changes
|
|
1134
|
+
if (slidesLength !== slides.length) {
|
|
1081
1135
|
swiper.emit('slidesLengthChange');
|
|
1082
1136
|
}
|
|
1083
1137
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1088,10 +1142,12 @@ var Swiper = (function () {
|
|
|
1088
1142
|
swiper.emit('slidesGridLengthChange');
|
|
1089
1143
|
}
|
|
1090
1144
|
if (params.watchSlidesProgress) {
|
|
1091
|
-
swiper.updateSlidesOffset(
|
|
1145
|
+
swiper.updateSlidesOffset({
|
|
1146
|
+
isCalculatedFromUpdateSlides: true
|
|
1147
|
+
});
|
|
1092
1148
|
}
|
|
1093
1149
|
swiper.emit('slidesUpdated');
|
|
1094
|
-
if (!
|
|
1150
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1095
1151
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1096
1152
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1097
1153
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1105,20 +1161,13 @@ var Swiper = (function () {
|
|
|
1105
1161
|
function updateAutoHeight(speed) {
|
|
1106
1162
|
const swiper = this;
|
|
1107
1163
|
const activeSlides = [];
|
|
1108
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1109
|
-
let newHeight = 0;
|
|
1110
|
-
let i;
|
|
1111
1164
|
if (typeof speed === 'number') {
|
|
1112
1165
|
swiper.setTransition(speed);
|
|
1113
1166
|
} else if (speed === true) {
|
|
1114
1167
|
swiper.setTransition(swiper.params.speed);
|
|
1115
1168
|
}
|
|
1116
|
-
const getSlideByIndex = index =>
|
|
1117
|
-
|
|
1118
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1119
|
-
}
|
|
1120
|
-
return swiper.slides[index];
|
|
1121
|
-
};
|
|
1169
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1170
|
+
|
|
1122
1171
|
// Find slides currently in view
|
|
1123
1172
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1124
1173
|
if (swiper.params.centeredSlides) {
|
|
@@ -1126,9 +1175,9 @@ var Swiper = (function () {
|
|
|
1126
1175
|
activeSlides.push(slide);
|
|
1127
1176
|
});
|
|
1128
1177
|
} else {
|
|
1129
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1178
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1130
1179
|
const index = swiper.activeIndex + i;
|
|
1131
|
-
if (index > swiper.slides.length
|
|
1180
|
+
if (index > swiper.slides.length) break;
|
|
1132
1181
|
activeSlides.push(getSlideByIndex(index));
|
|
1133
1182
|
}
|
|
1134
1183
|
}
|
|
@@ -1137,18 +1186,23 @@ var Swiper = (function () {
|
|
|
1137
1186
|
}
|
|
1138
1187
|
|
|
1139
1188
|
// Find new height from highest slide in view
|
|
1140
|
-
|
|
1189
|
+
let newHeight = 0;
|
|
1190
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1141
1191
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1142
|
-
const height = activeSlides[i].offsetHeight;
|
|
1192
|
+
const height = activeSlides[i].swiperSlideHeight ?? activeSlides[i]['offsetHeight'];
|
|
1143
1193
|
newHeight = height > newHeight ? height : newHeight;
|
|
1144
1194
|
}
|
|
1145
1195
|
}
|
|
1146
|
-
|
|
1147
|
-
// Update Height
|
|
1148
1196
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1149
1197
|
}
|
|
1150
1198
|
|
|
1151
|
-
function updateSlidesOffset() {
|
|
1199
|
+
function updateSlidesOffset(params) {
|
|
1200
|
+
const {
|
|
1201
|
+
isCalculatedFromUpdateSlides = false
|
|
1202
|
+
} = params ?? {};
|
|
1203
|
+
if (isCalculatedFromUpdateSlides) {
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1152
1206
|
const swiper = this;
|
|
1153
1207
|
const slides = swiper.slides;
|
|
1154
1208
|
// eslint-disable-next-line
|
|
@@ -1289,46 +1343,16 @@ var Swiper = (function () {
|
|
|
1289
1343
|
slidesEl,
|
|
1290
1344
|
activeIndex
|
|
1291
1345
|
} = swiper;
|
|
1292
|
-
const
|
|
1293
|
-
const
|
|
1294
|
-
const
|
|
1295
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1296
|
-
};
|
|
1297
|
-
let activeSlide;
|
|
1298
|
-
let prevSlide;
|
|
1346
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1347
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1348
|
+
const activeSlide = slides[activeIndex];
|
|
1299
1349
|
let nextSlide;
|
|
1300
|
-
|
|
1301
|
-
if (params.loop) {
|
|
1302
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
1303
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
1304
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
1305
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
1306
|
-
} else {
|
|
1307
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1308
|
-
}
|
|
1309
|
-
} else {
|
|
1310
|
-
if (gridEnabled) {
|
|
1311
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
1312
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
1313
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
1314
|
-
} else {
|
|
1315
|
-
activeSlide = slides[activeIndex];
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1350
|
+
let prevSlide;
|
|
1318
1351
|
if (activeSlide) {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
nextSlide = slides[0];
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
// Prev Slide
|
|
1327
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1328
|
-
if (params.loop && !prevSlide === 0) {
|
|
1329
|
-
prevSlide = slides[slides.length - 1];
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1352
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1353
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1354
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1355
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1332
1356
|
}
|
|
1333
1357
|
slides.forEach(slideEl => {
|
|
1334
1358
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1419,7 +1443,6 @@ var Swiper = (function () {
|
|
|
1419
1443
|
activeIndex = i;
|
|
1420
1444
|
}
|
|
1421
1445
|
}
|
|
1422
|
-
// Normalize slideIndex
|
|
1423
1446
|
if (params.normalizeSlideIndex) {
|
|
1424
1447
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1425
1448
|
}
|
|
@@ -1437,16 +1460,6 @@ var Swiper = (function () {
|
|
|
1437
1460
|
} = swiper;
|
|
1438
1461
|
let activeIndex = newActiveIndex;
|
|
1439
1462
|
let snapIndex;
|
|
1440
|
-
const getVirtualRealIndex = aIndex => {
|
|
1441
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
1442
|
-
if (realIndex < 0) {
|
|
1443
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
1444
|
-
}
|
|
1445
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
1446
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1447
|
-
}
|
|
1448
|
-
return realIndex;
|
|
1449
|
-
};
|
|
1450
1463
|
if (typeof activeIndex === 'undefined') {
|
|
1451
1464
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1452
1465
|
}
|
|
@@ -1464,32 +1477,12 @@ var Swiper = (function () {
|
|
|
1464
1477
|
}
|
|
1465
1478
|
return;
|
|
1466
1479
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
return;
|
|
1470
|
-
}
|
|
1471
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1472
|
-
|
|
1473
|
-
// Get real index
|
|
1474
|
-
let realIndex;
|
|
1475
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1476
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1477
|
-
} else if (gridEnabled) {
|
|
1478
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1479
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1480
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1481
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1482
|
-
}
|
|
1483
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1484
|
-
} else if (swiper.slides[activeIndex]) {
|
|
1480
|
+
let realIndex = activeIndex;
|
|
1481
|
+
if (swiper.slides[activeIndex]) {
|
|
1485
1482
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1486
1483
|
if (slideIndex) {
|
|
1487
1484
|
realIndex = parseInt(slideIndex, 10);
|
|
1488
|
-
} else {
|
|
1489
|
-
realIndex = activeIndex;
|
|
1490
1485
|
}
|
|
1491
|
-
} else {
|
|
1492
|
-
realIndex = activeIndex;
|
|
1493
1486
|
}
|
|
1494
1487
|
Object.assign(swiper, {
|
|
1495
1488
|
previousSnapIndex,
|
|
@@ -1536,11 +1529,7 @@ var Swiper = (function () {
|
|
|
1536
1529
|
}
|
|
1537
1530
|
if (slide && slideFound) {
|
|
1538
1531
|
swiper.clickedSlide = slide;
|
|
1539
|
-
|
|
1540
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1541
|
-
} else {
|
|
1542
|
-
swiper.clickedIndex = slideIndex;
|
|
1543
|
-
}
|
|
1532
|
+
swiper.clickedIndex = slideIndex;
|
|
1544
1533
|
} else {
|
|
1545
1534
|
swiper.clickedSlide = undefined;
|
|
1546
1535
|
swiper.clickedIndex = undefined;
|
|
@@ -1574,9 +1563,6 @@ var Swiper = (function () {
|
|
|
1574
1563
|
translate,
|
|
1575
1564
|
wrapperEl
|
|
1576
1565
|
} = swiper;
|
|
1577
|
-
if (params.virtualTranslate) {
|
|
1578
|
-
return rtl ? -translate : translate;
|
|
1579
|
-
}
|
|
1580
1566
|
if (params.cssMode) {
|
|
1581
1567
|
return translate;
|
|
1582
1568
|
}
|
|
@@ -1610,7 +1596,7 @@ var Swiper = (function () {
|
|
|
1610
1596
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1611
1597
|
if (params.cssMode) {
|
|
1612
1598
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1613
|
-
} else
|
|
1599
|
+
} else {
|
|
1614
1600
|
if (swiper.isHorizontal()) {
|
|
1615
1601
|
x -= swiper.cssOverflowAdjustment();
|
|
1616
1602
|
} else {
|
|
@@ -1847,7 +1833,6 @@ var Swiper = (function () {
|
|
|
1847
1833
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1848
1834
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1849
1835
|
const translate = -snapGrid[snapIndex];
|
|
1850
|
-
// Normalize slideIndex
|
|
1851
1836
|
if (params.normalizeSlideIndex) {
|
|
1852
1837
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1853
1838
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1864,33 +1849,24 @@ var Swiper = (function () {
|
|
|
1864
1849
|
}
|
|
1865
1850
|
}
|
|
1866
1851
|
}
|
|
1852
|
+
|
|
1867
1853
|
// Directions locks
|
|
1868
1854
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1869
1855
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1870
1856
|
return false;
|
|
1871
1857
|
}
|
|
1872
1858
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1873
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1874
|
-
return false;
|
|
1875
|
-
}
|
|
1859
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1876
1860
|
}
|
|
1877
1861
|
}
|
|
1878
1862
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1879
1863
|
swiper.emit('beforeSlideChangeStart');
|
|
1880
1864
|
}
|
|
1881
|
-
|
|
1882
|
-
// Update progress
|
|
1883
1865
|
swiper.updateProgress(translate);
|
|
1884
1866
|
let direction;
|
|
1885
1867
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1886
|
-
|
|
1887
|
-
// initial virtual
|
|
1888
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1889
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1890
|
-
// Update Index
|
|
1891
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1868
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1892
1869
|
swiper.updateActiveIndex(slideIndex);
|
|
1893
|
-
// Update Height
|
|
1894
1870
|
if (params.autoHeight) {
|
|
1895
1871
|
swiper.updateAutoHeight();
|
|
1896
1872
|
}
|
|
@@ -1908,24 +1884,7 @@ var Swiper = (function () {
|
|
|
1908
1884
|
const isH = swiper.isHorizontal();
|
|
1909
1885
|
const t = rtl ? translate : -translate;
|
|
1910
1886
|
if (speed === 0) {
|
|
1911
|
-
|
|
1912
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1913
|
-
swiper._immediateVirtual = true;
|
|
1914
|
-
}
|
|
1915
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1916
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1917
|
-
requestAnimationFrame(() => {
|
|
1918
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1919
|
-
});
|
|
1920
|
-
} else {
|
|
1921
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1922
|
-
}
|
|
1923
|
-
if (isVirtual) {
|
|
1924
|
-
requestAnimationFrame(() => {
|
|
1925
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1926
|
-
swiper._immediateVirtual = false;
|
|
1927
|
-
});
|
|
1928
|
-
}
|
|
1887
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1929
1888
|
} else {
|
|
1930
1889
|
if (!swiper.support.smoothScroll) {
|
|
1931
1890
|
animateCSSModeScroll({
|
|
@@ -1943,10 +1902,7 @@ var Swiper = (function () {
|
|
|
1943
1902
|
return true;
|
|
1944
1903
|
}
|
|
1945
1904
|
const browser = getBrowser();
|
|
1946
|
-
|
|
1947
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1948
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1949
|
-
}
|
|
1905
|
+
browser.isSafari;
|
|
1950
1906
|
swiper.setTransition(speed);
|
|
1951
1907
|
swiper.setTranslate(translate);
|
|
1952
1908
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2117,8 +2073,6 @@ var Swiper = (function () {
|
|
|
2117
2073
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2118
2074
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2119
2075
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2120
|
-
|
|
2121
|
-
// Move last item to first position only if active slide is the first slide
|
|
2122
2076
|
const lastSlide = slides[slides.length - 1];
|
|
2123
2077
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2124
2078
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2153,11 +2107,8 @@ var Swiper = (function () {
|
|
|
2153
2107
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2154
2108
|
}
|
|
2155
2109
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2156
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2157
2110
|
if (params.loop) {
|
|
2158
|
-
if (animating &&
|
|
2159
|
-
|
|
2160
|
-
// Kiểm tra xem loop có bị disable không
|
|
2111
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2161
2112
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2162
2113
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2163
2114
|
swiper.loopFix({
|
|
@@ -2184,7 +2135,6 @@ var Swiper = (function () {
|
|
|
2184
2135
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2185
2136
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2186
2137
|
if (!swiper.params.loop) return;
|
|
2187
|
-
// Move first item to last position only if active slide is the last slide
|
|
2188
2138
|
const firstSlide = slides[0];
|
|
2189
2139
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2190
2140
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2209,17 +2159,14 @@ var Swiper = (function () {
|
|
|
2209
2159
|
params,
|
|
2210
2160
|
snapGrid,
|
|
2211
2161
|
slidesGrid,
|
|
2212
|
-
rtlTranslate,
|
|
2213
|
-
enabled
|
|
2214
|
-
animating
|
|
2162
|
+
rtlTranslate: rtlTranslate,
|
|
2163
|
+
enabled
|
|
2215
2164
|
} = swiper;
|
|
2216
2165
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2217
2166
|
if (typeof speed === 'undefined') {
|
|
2218
2167
|
speed = swiper.params.speed;
|
|
2219
2168
|
}
|
|
2220
|
-
swiper.virtual && params.virtual.enabled;
|
|
2221
2169
|
if (params.loop) {
|
|
2222
|
-
// Kiểm tra xem loop có bị disable không
|
|
2223
2170
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2224
2171
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2225
2172
|
swiper.loopFix({
|
|
@@ -2236,18 +2183,16 @@ var Swiper = (function () {
|
|
|
2236
2183
|
}
|
|
2237
2184
|
const normalizedTranslate = normalize(translate);
|
|
2238
2185
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2239
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2240
2186
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2241
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2187
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2242
2188
|
let prevSnapIndex;
|
|
2243
2189
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2244
2190
|
if (normalizedTranslate >= snap) {
|
|
2245
|
-
// prevSnap = snap;
|
|
2246
2191
|
prevSnapIndex = snapIndex;
|
|
2247
2192
|
}
|
|
2248
2193
|
});
|
|
2249
2194
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2250
|
-
prevSnap =
|
|
2195
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2251
2196
|
}
|
|
2252
2197
|
}
|
|
2253
2198
|
let prevIndex = 0;
|
|
@@ -2260,7 +2205,7 @@ var Swiper = (function () {
|
|
|
2260
2205
|
}
|
|
2261
2206
|
}
|
|
2262
2207
|
if (params.rewind && swiper.isBeginning) {
|
|
2263
|
-
const lastIndex = swiper.
|
|
2208
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2264
2209
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2265
2210
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2266
2211
|
requestAnimationFrame(() => {
|
|
@@ -2274,8 +2219,6 @@ var Swiper = (function () {
|
|
|
2274
2219
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2275
2220
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2276
2221
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2277
|
-
|
|
2278
|
-
// Move last item to first position only if active slide is the first slide
|
|
2279
2222
|
if (!swiper.params.loop) return;
|
|
2280
2223
|
const lastSlide = slides[slides.length - 1];
|
|
2281
2224
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2352,20 +2295,19 @@ var Swiper = (function () {
|
|
|
2352
2295
|
slidesEl
|
|
2353
2296
|
} = swiper;
|
|
2354
2297
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2355
|
-
|
|
2298
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2356
2299
|
let realIndex;
|
|
2357
2300
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2358
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2359
2301
|
if (params.loop) {
|
|
2360
2302
|
if (swiper.animating) return;
|
|
2361
2303
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2362
2304
|
if (params.centeredSlides) {
|
|
2363
2305
|
swiper.slideToLoop(realIndex);
|
|
2364
|
-
} else if (slideToIndex >
|
|
2306
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2365
2307
|
swiper.loopFix();
|
|
2366
|
-
|
|
2308
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2367
2309
|
nextTick(() => {
|
|
2368
|
-
swiper.slideTo(
|
|
2310
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2369
2311
|
});
|
|
2370
2312
|
} else {
|
|
2371
2313
|
swiper.slideTo(slideToIndex);
|
|
@@ -2392,7 +2334,7 @@ var Swiper = (function () {
|
|
|
2392
2334
|
params,
|
|
2393
2335
|
slidesEl
|
|
2394
2336
|
} = swiper;
|
|
2395
|
-
if (!params.loop
|
|
2337
|
+
if (!params.loop) return;
|
|
2396
2338
|
const initSlides = () => {
|
|
2397
2339
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2398
2340
|
slides.forEach((el, index) => {
|
|
@@ -2401,21 +2343,17 @@ var Swiper = (function () {
|
|
|
2401
2343
|
};
|
|
2402
2344
|
const clearBlankSlides = () => {
|
|
2403
2345
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2404
|
-
slides.forEach(el =>
|
|
2405
|
-
el.remove();
|
|
2406
|
-
});
|
|
2346
|
+
slides.forEach(el => el.remove());
|
|
2407
2347
|
if (slides.length > 0) {
|
|
2408
2348
|
swiper.recalcSlides();
|
|
2409
2349
|
swiper.updateSlides();
|
|
2410
2350
|
}
|
|
2411
2351
|
};
|
|
2412
|
-
|
|
2413
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2352
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2414
2353
|
clearBlankSlides();
|
|
2415
2354
|
}
|
|
2416
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2355
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2417
2356
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2418
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2419
2357
|
const addBlankSlides = amountOfSlides => {
|
|
2420
2358
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2421
2359
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2432,16 +2370,6 @@ var Swiper = (function () {
|
|
|
2432
2370
|
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)');
|
|
2433
2371
|
}
|
|
2434
2372
|
initSlides();
|
|
2435
|
-
} else if (shouldFillGrid) {
|
|
2436
|
-
if (params.loopAddBlankSlides) {
|
|
2437
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2438
|
-
addBlankSlides(slidesToAdd);
|
|
2439
|
-
swiper.recalcSlides();
|
|
2440
|
-
swiper.updateSlides();
|
|
2441
|
-
} else {
|
|
2442
|
-
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)');
|
|
2443
|
-
}
|
|
2444
|
-
initSlides();
|
|
2445
2373
|
} else {
|
|
2446
2374
|
initSlides();
|
|
2447
2375
|
}
|
|
@@ -2460,13 +2388,12 @@ var Swiper = (function () {
|
|
|
2460
2388
|
setTranslate,
|
|
2461
2389
|
activeSlideIndex,
|
|
2462
2390
|
initial,
|
|
2463
|
-
byController,
|
|
2464
2391
|
byMousewheel
|
|
2465
2392
|
} = _temp === void 0 ? {} : _temp;
|
|
2466
2393
|
const swiper = this;
|
|
2467
2394
|
if (!swiper.params.loop) return;
|
|
2468
2395
|
|
|
2469
|
-
// Disable loop mode
|
|
2396
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2470
2397
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2471
2398
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2472
2399
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2486,21 +2413,6 @@ var Swiper = (function () {
|
|
|
2486
2413
|
} = params;
|
|
2487
2414
|
swiper.allowSlidePrev = true;
|
|
2488
2415
|
swiper.allowSlideNext = true;
|
|
2489
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2490
|
-
if (slideTo) {
|
|
2491
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2492
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2493
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2494
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2495
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2496
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2500
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2501
|
-
swiper.emit('loopFix');
|
|
2502
|
-
return;
|
|
2503
|
-
}
|
|
2504
2416
|
let slidesPerView = params.slidesPerView;
|
|
2505
2417
|
if (slidesPerView === 'auto') {
|
|
2506
2418
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2510,22 +2422,19 @@ var Swiper = (function () {
|
|
|
2510
2422
|
slidesPerView = slidesPerView + 1;
|
|
2511
2423
|
}
|
|
2512
2424
|
}
|
|
2513
|
-
const slidesPerGroup = params.
|
|
2425
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2514
2426
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2515
2427
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2516
2428
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2517
2429
|
}
|
|
2518
2430
|
loopedSlides += params.loopAdditionalSlides;
|
|
2519
2431
|
swiper.loopedSlides = loopedSlides;
|
|
2520
|
-
|
|
2521
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2432
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2522
2433
|
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');
|
|
2523
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2524
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2525
2434
|
}
|
|
2526
2435
|
const prependSlidesIndexes = [];
|
|
2527
2436
|
const appendSlidesIndexes = [];
|
|
2528
|
-
const cols =
|
|
2437
|
+
const cols = slides.length;
|
|
2529
2438
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2530
2439
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2531
2440
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2537,24 +2446,15 @@ var Swiper = (function () {
|
|
|
2537
2446
|
const isPrev = direction === 'prev' || !direction;
|
|
2538
2447
|
let slidesPrepended = 0;
|
|
2539
2448
|
let slidesAppended = 0;
|
|
2540
|
-
const activeColIndex =
|
|
2449
|
+
const activeColIndex = activeSlideIndex;
|
|
2541
2450
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2451
|
+
|
|
2542
2452
|
// prepend last slides before start
|
|
2543
2453
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2544
2454
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2545
2455
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2546
2456
|
const index = i - Math.floor(i / cols) * cols;
|
|
2547
|
-
|
|
2548
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2549
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2550
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2551
|
-
}
|
|
2552
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2553
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2554
|
-
// });
|
|
2555
|
-
} else {
|
|
2556
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2557
|
-
}
|
|
2457
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2558
2458
|
}
|
|
2559
2459
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2560
2460
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2563,27 +2463,13 @@ var Swiper = (function () {
|
|
|
2563
2463
|
}
|
|
2564
2464
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2565
2465
|
const index = i - Math.floor(i / cols) * cols;
|
|
2566
|
-
|
|
2567
|
-
slides.forEach((slide, slideIndex) => {
|
|
2568
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2569
|
-
});
|
|
2570
|
-
} else {
|
|
2571
|
-
appendSlidesIndexes.push(index);
|
|
2572
|
-
}
|
|
2466
|
+
appendSlidesIndexes.push(index);
|
|
2573
2467
|
}
|
|
2574
2468
|
}
|
|
2575
2469
|
swiper.__preventObserver__ = true;
|
|
2576
2470
|
requestAnimationFrame(() => {
|
|
2577
2471
|
swiper.__preventObserver__ = false;
|
|
2578
2472
|
});
|
|
2579
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2580
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2581
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2582
|
-
}
|
|
2583
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2584
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
2473
|
if (isPrev) {
|
|
2588
2474
|
prependSlidesIndexes.forEach(index => {
|
|
2589
2475
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2601,13 +2487,11 @@ var Swiper = (function () {
|
|
|
2601
2487
|
swiper.recalcSlides();
|
|
2602
2488
|
if (params.slidesPerView === 'auto') {
|
|
2603
2489
|
swiper.updateSlides();
|
|
2604
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2605
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2606
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2607
|
-
});
|
|
2608
2490
|
}
|
|
2609
2491
|
if (params.watchSlidesProgress) {
|
|
2610
|
-
swiper.updateSlidesOffset(
|
|
2492
|
+
swiper.updateSlidesOffset({
|
|
2493
|
+
isCalculatedFromUpdateSlides: params.slidesPerView === 'auto'
|
|
2494
|
+
});
|
|
2611
2495
|
}
|
|
2612
2496
|
if (slideTo) {
|
|
2613
2497
|
if (prependSlidesIndexes.length > 0 && isPrev) {
|
|
@@ -2624,12 +2508,10 @@ var Swiper = (function () {
|
|
|
2624
2508
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2625
2509
|
}
|
|
2626
2510
|
}
|
|
2627
|
-
} else {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2632
|
-
}
|
|
2511
|
+
} else if (setTranslate) {
|
|
2512
|
+
const shift = prependSlidesIndexes.length;
|
|
2513
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2514
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2633
2515
|
}
|
|
2634
2516
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2635
2517
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2645,36 +2527,14 @@ var Swiper = (function () {
|
|
|
2645
2527
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2646
2528
|
}
|
|
2647
2529
|
}
|
|
2648
|
-
} else {
|
|
2649
|
-
const shift =
|
|
2530
|
+
} else if (setTranslate) {
|
|
2531
|
+
const shift = appendSlidesIndexes.length;
|
|
2650
2532
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2651
2533
|
}
|
|
2652
2534
|
}
|
|
2653
2535
|
}
|
|
2654
2536
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2655
2537
|
swiper.allowSlideNext = allowSlideNext;
|
|
2656
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2657
|
-
const loopParams = {
|
|
2658
|
-
slideRealIndex,
|
|
2659
|
-
direction,
|
|
2660
|
-
setTranslate,
|
|
2661
|
-
activeSlideIndex,
|
|
2662
|
-
byController: true
|
|
2663
|
-
};
|
|
2664
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2665
|
-
swiper.controller.control.forEach(c => {
|
|
2666
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2667
|
-
...loopParams,
|
|
2668
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2669
|
-
});
|
|
2670
|
-
});
|
|
2671
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2672
|
-
swiper.controller.control.loopFix({
|
|
2673
|
-
...loopParams,
|
|
2674
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
2538
|
swiper.emit('loopFix');
|
|
2679
2539
|
}
|
|
2680
2540
|
|
|
@@ -2691,7 +2551,7 @@ var Swiper = (function () {
|
|
|
2691
2551
|
const swiper = this;
|
|
2692
2552
|
if (!swiper.params.loop) return;
|
|
2693
2553
|
|
|
2694
|
-
// Disable loop mode
|
|
2554
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2695
2555
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2696
2556
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2697
2557
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2730,7 +2590,7 @@ var Swiper = (function () {
|
|
|
2730
2590
|
}
|
|
2731
2591
|
loopedSlides += params.loopAdditionalSlides;
|
|
2732
2592
|
swiper.loopedSlides = loopedSlides;
|
|
2733
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2593
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2734
2594
|
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');
|
|
2735
2595
|
}
|
|
2736
2596
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2756,20 +2616,16 @@ var Swiper = (function () {
|
|
|
2756
2616
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2757
2617
|
}
|
|
2758
2618
|
|
|
2759
|
-
//
|
|
2619
|
+
// DocumentFragment to hold slide clones
|
|
2760
2620
|
const cloneFragment = document.createDocumentFragment();
|
|
2761
2621
|
|
|
2762
|
-
// Clone
|
|
2622
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2763
2623
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2764
2624
|
if (slides[index]) {
|
|
2765
2625
|
const originalSlide = slides[index];
|
|
2766
2626
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2767
|
-
|
|
2768
|
-
// Đánh dấu slide clone
|
|
2769
2627
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2770
2628
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2771
|
-
|
|
2772
|
-
// Thêm clone vào fragment
|
|
2773
2629
|
cloneFragment.appendChild(clonedSlide);
|
|
2774
2630
|
}
|
|
2775
2631
|
});
|
|
@@ -2790,32 +2646,28 @@ var Swiper = (function () {
|
|
|
2790
2646
|
});
|
|
2791
2647
|
}
|
|
2792
2648
|
|
|
2793
|
-
//
|
|
2649
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2794
2650
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2795
2651
|
clonedSlides.sort((a, b) => {
|
|
2796
2652
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2797
2653
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2798
2654
|
return indexA - indexB;
|
|
2799
2655
|
});
|
|
2800
|
-
|
|
2801
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2802
2656
|
cloneFragment.innerHTML = '';
|
|
2803
2657
|
clonedSlides.forEach(slide => {
|
|
2804
2658
|
cloneFragment.appendChild(slide);
|
|
2805
2659
|
});
|
|
2806
2660
|
|
|
2807
|
-
//
|
|
2661
|
+
// Place fragment into the right position
|
|
2808
2662
|
if (isPrev) {
|
|
2809
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2810
2663
|
slidesEl.appendChild(cloneFragment);
|
|
2811
2664
|
} else if (isNext) {
|
|
2812
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2813
2665
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2814
2666
|
}
|
|
2815
2667
|
swiper.recalcSlides();
|
|
2816
2668
|
swiper.updateSlides();
|
|
2817
2669
|
|
|
2818
|
-
//
|
|
2670
|
+
// Find old active slide index after recalculation
|
|
2819
2671
|
let oldActiveIndex = null;
|
|
2820
2672
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2821
2673
|
const child = slidesEl.children[i];
|
|
@@ -2828,7 +2680,7 @@ var Swiper = (function () {
|
|
|
2828
2680
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2829
2681
|
}
|
|
2830
2682
|
|
|
2831
|
-
//
|
|
2683
|
+
// Update translate after removing clones for animation
|
|
2832
2684
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2833
2685
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2834
2686
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2854,7 +2706,8 @@ var Swiper = (function () {
|
|
|
2854
2706
|
}
|
|
2855
2707
|
swiper.setTranslate(updateTranslate);
|
|
2856
2708
|
}
|
|
2857
|
-
|
|
2709
|
+
|
|
2710
|
+
// Remove clones
|
|
2858
2711
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2859
2712
|
cloneSlides.forEach(cloneSlide => {
|
|
2860
2713
|
if (cloneSlide.parentNode) {
|
|
@@ -2884,7 +2737,7 @@ var Swiper = (function () {
|
|
|
2884
2737
|
params,
|
|
2885
2738
|
slidesEl
|
|
2886
2739
|
} = swiper;
|
|
2887
|
-
if (!params.loop || !slidesEl
|
|
2740
|
+
if (!params.loop || !slidesEl) return;
|
|
2888
2741
|
swiper.recalcSlides();
|
|
2889
2742
|
const newSlidesOrder = [];
|
|
2890
2743
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2945,7 +2798,6 @@ var Swiper = (function () {
|
|
|
2945
2798
|
unsetGrabCursor
|
|
2946
2799
|
};
|
|
2947
2800
|
|
|
2948
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2949
2801
|
function closestElement(selector, base) {
|
|
2950
2802
|
if (base === void 0) {
|
|
2951
2803
|
base = this;
|
|
@@ -2954,9 +2806,7 @@ var Swiper = (function () {
|
|
|
2954
2806
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2955
2807
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2956
2808
|
const found = el.closest(selector);
|
|
2957
|
-
if (!found && !el.getRootNode)
|
|
2958
|
-
return null;
|
|
2959
|
-
}
|
|
2809
|
+
if (!found && !el.getRootNode) return null;
|
|
2960
2810
|
return found || __closestFrom(el.getRootNode().host);
|
|
2961
2811
|
}
|
|
2962
2812
|
return __closestFrom(base);
|
|
@@ -2984,9 +2834,7 @@ var Swiper = (function () {
|
|
|
2984
2834
|
if (e.originalEvent) e = e.originalEvent;
|
|
2985
2835
|
const data = swiper.touchEventsData;
|
|
2986
2836
|
if (e.type === 'pointerdown') {
|
|
2987
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
2988
|
-
return;
|
|
2989
|
-
}
|
|
2837
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
2990
2838
|
data.pointerId = e.pointerId;
|
|
2991
2839
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2992
2840
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3003,9 +2851,7 @@ var Swiper = (function () {
|
|
|
3003
2851
|
} = swiper;
|
|
3004
2852
|
if (!enabled) return;
|
|
3005
2853
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3006
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3007
|
-
return;
|
|
3008
|
-
}
|
|
2854
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3009
2855
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3010
2856
|
swiper.loopFix();
|
|
3011
2857
|
}
|
|
@@ -3016,8 +2862,6 @@ var Swiper = (function () {
|
|
|
3016
2862
|
if ('which' in e && e.which === 3) return;
|
|
3017
2863
|
if ('button' in e && e.button > 0) return;
|
|
3018
2864
|
if (data.isTouched && data.isMoved) return;
|
|
3019
|
-
|
|
3020
|
-
// change target el for shadow root component
|
|
3021
2865
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3022
2866
|
// eslint-disable-next-line
|
|
3023
2867
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3026,8 +2870,6 @@ var Swiper = (function () {
|
|
|
3026
2870
|
}
|
|
3027
2871
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3028
2872
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3029
|
-
|
|
3030
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3031
2873
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3032
2874
|
swiper.allowClick = true;
|
|
3033
2875
|
return;
|
|
@@ -3039,12 +2881,7 @@ var Swiper = (function () {
|
|
|
3039
2881
|
touches.currentY = e.pageY;
|
|
3040
2882
|
const startX = touches.currentX;
|
|
3041
2883
|
const startY = touches.currentY;
|
|
3042
|
-
|
|
3043
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3044
|
-
|
|
3045
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
2884
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3048
2885
|
Object.assign(data, {
|
|
3049
2886
|
isTouched: true,
|
|
3050
2887
|
isMoved: false,
|
|
@@ -3073,9 +2910,6 @@ var Swiper = (function () {
|
|
|
3073
2910
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3074
2911
|
e.preventDefault();
|
|
3075
2912
|
}
|
|
3076
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3077
|
-
swiper.freeMode.onTouchStart();
|
|
3078
|
-
}
|
|
3079
2913
|
swiper.emit('touchStart', e);
|
|
3080
2914
|
}
|
|
3081
2915
|
|
|
@@ -3094,7 +2928,7 @@ var Swiper = (function () {
|
|
|
3094
2928
|
let e = event;
|
|
3095
2929
|
if (e.originalEvent) e = e.originalEvent;
|
|
3096
2930
|
if (e.type === 'pointermove') {
|
|
3097
|
-
if (data.touchId !== null) return;
|
|
2931
|
+
if (data.touchId !== null) return;
|
|
3098
2932
|
const id = e.pointerId;
|
|
3099
2933
|
if (id !== data.pointerId) return;
|
|
3100
2934
|
}
|
|
@@ -3135,7 +2969,6 @@ var Swiper = (function () {
|
|
|
3135
2969
|
}
|
|
3136
2970
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3137
2971
|
if (swiper.isVertical()) {
|
|
3138
|
-
// Vertical
|
|
3139
2972
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3140
2973
|
data.isTouched = false;
|
|
3141
2974
|
data.isMoved = false;
|
|
@@ -3237,7 +3070,6 @@ var Swiper = (function () {
|
|
|
3237
3070
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3238
3071
|
}
|
|
3239
3072
|
data.allowMomentumBounce = false;
|
|
3240
|
-
// Grab Cursor
|
|
3241
3073
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3242
3074
|
swiper.setGrabCursor(true);
|
|
3243
3075
|
}
|
|
@@ -3308,8 +3140,6 @@ var Swiper = (function () {
|
|
|
3308
3140
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3309
3141
|
data.currentTranslate = data.startTranslate;
|
|
3310
3142
|
}
|
|
3311
|
-
|
|
3312
|
-
// Threshold
|
|
3313
3143
|
if (params.threshold > 0) {
|
|
3314
3144
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3315
3145
|
if (!data.allowThresholdMove) {
|
|
@@ -3327,17 +3157,12 @@ var Swiper = (function () {
|
|
|
3327
3157
|
}
|
|
3328
3158
|
if (!params.followFinger || params.cssMode) return;
|
|
3329
3159
|
|
|
3330
|
-
//
|
|
3331
|
-
if (params.
|
|
3160
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3161
|
+
if (params.watchSlidesProgress) {
|
|
3332
3162
|
swiper.updateActiveIndex();
|
|
3333
3163
|
swiper.updateSlidesClasses();
|
|
3334
3164
|
}
|
|
3335
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3336
|
-
swiper.freeMode.onTouchMove();
|
|
3337
|
-
}
|
|
3338
|
-
// Update progress
|
|
3339
3165
|
swiper.updateProgress(data.currentTranslate);
|
|
3340
|
-
// Update translate
|
|
3341
3166
|
swiper.setTranslate(data.currentTranslate);
|
|
3342
3167
|
}
|
|
3343
3168
|
|
|
@@ -3349,7 +3174,7 @@ var Swiper = (function () {
|
|
|
3349
3174
|
let targetTouch;
|
|
3350
3175
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3351
3176
|
if (!isTouchEvent) {
|
|
3352
|
-
if (data.touchId !== null) return;
|
|
3177
|
+
if (data.touchId !== null) return;
|
|
3353
3178
|
if (e.pointerId !== data.pointerId) return;
|
|
3354
3179
|
targetTouch = e;
|
|
3355
3180
|
} else {
|
|
@@ -3358,9 +3183,7 @@ var Swiper = (function () {
|
|
|
3358
3183
|
}
|
|
3359
3184
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3360
3185
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3361
|
-
if (!proceed)
|
|
3362
|
-
return;
|
|
3363
|
-
}
|
|
3186
|
+
if (!proceed) return;
|
|
3364
3187
|
}
|
|
3365
3188
|
data.pointerId = null;
|
|
3366
3189
|
data.touchId = null;
|
|
@@ -3378,9 +3201,7 @@ var Swiper = (function () {
|
|
|
3378
3201
|
}
|
|
3379
3202
|
data.allowTouchCallbacks = false;
|
|
3380
3203
|
if (!data.isTouched) {
|
|
3381
|
-
if (data.isMoved && params.grabCursor)
|
|
3382
|
-
swiper.setGrabCursor(false);
|
|
3383
|
-
}
|
|
3204
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3384
3205
|
data.isMoved = false;
|
|
3385
3206
|
data.startMoving = false;
|
|
3386
3207
|
return;
|
|
@@ -3390,8 +3211,6 @@ var Swiper = (function () {
|
|
|
3390
3211
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3391
3212
|
swiper.setGrabCursor(false);
|
|
3392
3213
|
}
|
|
3393
|
-
|
|
3394
|
-
// Time diff
|
|
3395
3214
|
const touchEndTime = now();
|
|
3396
3215
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3397
3216
|
|
|
@@ -3418,20 +3237,8 @@ var Swiper = (function () {
|
|
|
3418
3237
|
data.isMoved = false;
|
|
3419
3238
|
data.startMoving = false;
|
|
3420
3239
|
let currentPos;
|
|
3421
|
-
if (params.followFinger)
|
|
3422
|
-
|
|
3423
|
-
} else {
|
|
3424
|
-
currentPos = -data.currentTranslate;
|
|
3425
|
-
}
|
|
3426
|
-
if (params.cssMode) {
|
|
3427
|
-
return;
|
|
3428
|
-
}
|
|
3429
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3430
|
-
swiper.freeMode.onTouchEnd({
|
|
3431
|
-
currentPos
|
|
3432
|
-
});
|
|
3433
|
-
return;
|
|
3434
|
-
}
|
|
3240
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3241
|
+
if (params.cssMode) return;
|
|
3435
3242
|
|
|
3436
3243
|
// Find current slide
|
|
3437
3244
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3453,22 +3260,22 @@ var Swiper = (function () {
|
|
|
3453
3260
|
let rewindLastIndex = null;
|
|
3454
3261
|
if (params.rewind) {
|
|
3455
3262
|
if (swiper.isBeginning) {
|
|
3456
|
-
rewindLastIndex =
|
|
3263
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3457
3264
|
} else if (swiper.isEnd) {
|
|
3458
3265
|
rewindFirstIndex = 0;
|
|
3459
3266
|
}
|
|
3460
3267
|
}
|
|
3461
|
-
// Find current slide size
|
|
3462
3268
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3463
3269
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3464
3270
|
if (timeDiff > params.longSwipesMs) {
|
|
3465
|
-
// Long touches
|
|
3466
3271
|
if (!params.longSwipes) {
|
|
3467
3272
|
swiper.slideTo(swiper.activeIndex);
|
|
3468
3273
|
return;
|
|
3469
3274
|
}
|
|
3470
3275
|
if (swiper.swipeDirection === 'next') {
|
|
3471
|
-
if (ratio >= params.longSwipesRatio)
|
|
3276
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3277
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3278
|
+
} else swiper.slideTo(stopIndex);
|
|
3472
3279
|
}
|
|
3473
3280
|
if (swiper.swipeDirection === 'prev') {
|
|
3474
3281
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3520,7 +3327,6 @@ var Swiper = (function () {
|
|
|
3520
3327
|
allowSlidePrev,
|
|
3521
3328
|
snapGrid
|
|
3522
3329
|
} = swiper;
|
|
3523
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3524
3330
|
|
|
3525
3331
|
// Disable locks on resize
|
|
3526
3332
|
swiper.allowSlideNext = true;
|
|
@@ -3528,15 +3334,12 @@ var Swiper = (function () {
|
|
|
3528
3334
|
swiper.updateSize();
|
|
3529
3335
|
swiper.updateSlides();
|
|
3530
3336
|
swiper.updateSlidesClasses();
|
|
3531
|
-
|
|
3532
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3337
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3533
3338
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3339
|
+
} else if (swiper.params.loop) {
|
|
3340
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3534
3341
|
} else {
|
|
3535
|
-
|
|
3536
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3537
|
-
} else {
|
|
3538
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3539
|
-
}
|
|
3342
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3540
3343
|
}
|
|
3541
3344
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3542
3345
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3546,10 +3349,11 @@ var Swiper = (function () {
|
|
|
3546
3349
|
}
|
|
3547
3350
|
}, 500);
|
|
3548
3351
|
}
|
|
3352
|
+
|
|
3549
3353
|
// Return locks after resize
|
|
3550
3354
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3551
3355
|
swiper.allowSlideNext = allowSlideNext;
|
|
3552
|
-
if (
|
|
3356
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3553
3357
|
swiper.checkOverflow();
|
|
3554
3358
|
}
|
|
3555
3359
|
}
|
|
@@ -3603,6 +3407,10 @@ var Swiper = (function () {
|
|
|
3603
3407
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3604
3408
|
return;
|
|
3605
3409
|
}
|
|
3410
|
+
const el = e?.target;
|
|
3411
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3412
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3413
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3606
3414
|
swiper.update();
|
|
3607
3415
|
}
|
|
3608
3416
|
|
|
@@ -3714,8 +3522,15 @@ var Swiper = (function () {
|
|
|
3714
3522
|
detachEvents
|
|
3715
3523
|
};
|
|
3716
3524
|
|
|
3717
|
-
const
|
|
3718
|
-
|
|
3525
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3526
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3527
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3528
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3529
|
+
swiper[prop].disable();
|
|
3530
|
+
}
|
|
3531
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3532
|
+
swiper[prop].enable();
|
|
3533
|
+
}
|
|
3719
3534
|
};
|
|
3720
3535
|
function setBreakpoint() {
|
|
3721
3536
|
const swiper = this;
|
|
@@ -3736,38 +3551,20 @@ var Swiper = (function () {
|
|
|
3736
3551
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3737
3552
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3738
3553
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3739
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3740
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3741
3554
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3742
3555
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3743
3556
|
const wasEnabled = params.enabled;
|
|
3744
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3745
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3746
|
-
swiper.emitContainerClasses();
|
|
3747
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3748
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3749
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3750
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3751
|
-
}
|
|
3752
|
-
swiper.emitContainerClasses();
|
|
3753
|
-
}
|
|
3754
3557
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3755
3558
|
swiper.unsetGrabCursor();
|
|
3756
3559
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3757
3560
|
swiper.setGrabCursor();
|
|
3758
3561
|
}
|
|
3759
3562
|
|
|
3760
|
-
//
|
|
3761
|
-
['navigation', 'pagination'
|
|
3563
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3564
|
+
const modules = ['navigation', 'pagination'];
|
|
3565
|
+
modules.forEach(prop => {
|
|
3762
3566
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3763
|
-
|
|
3764
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3765
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3766
|
-
swiper[prop].disable();
|
|
3767
|
-
}
|
|
3768
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3769
|
-
swiper[prop].enable();
|
|
3770
|
-
}
|
|
3567
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3771
3568
|
});
|
|
3772
3569
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3773
3570
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3849,7 +3646,7 @@ var Swiper = (function () {
|
|
|
3849
3646
|
getBreakpoint
|
|
3850
3647
|
};
|
|
3851
3648
|
|
|
3852
|
-
|
|
3649
|
+
const prepareClasses = (entries, prefix) => {
|
|
3853
3650
|
const resultClasses = [];
|
|
3854
3651
|
entries.forEach(item => {
|
|
3855
3652
|
if (typeof item === 'object') {
|
|
@@ -3863,7 +3660,7 @@ var Swiper = (function () {
|
|
|
3863
3660
|
}
|
|
3864
3661
|
});
|
|
3865
3662
|
return resultClasses;
|
|
3866
|
-
}
|
|
3663
|
+
};
|
|
3867
3664
|
function addClasses() {
|
|
3868
3665
|
const swiper = this;
|
|
3869
3666
|
const {
|
|
@@ -3873,17 +3670,12 @@ var Swiper = (function () {
|
|
|
3873
3670
|
el,
|
|
3874
3671
|
device
|
|
3875
3672
|
} = swiper;
|
|
3673
|
+
// core-lite: removed module-specific classes
|
|
3876
3674
|
// prettier-ignore
|
|
3877
3675
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3878
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3879
|
-
}, {
|
|
3880
3676
|
'autoheight': params.autoHeight
|
|
3881
3677
|
}, {
|
|
3882
3678
|
'rtl': rtl
|
|
3883
|
-
}, {
|
|
3884
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3885
|
-
}, {
|
|
3886
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3887
3679
|
}, {
|
|
3888
3680
|
'android': device.android
|
|
3889
3681
|
}, {
|
|
@@ -3980,16 +3772,12 @@ var Swiper = (function () {
|
|
|
3980
3772
|
autoHeight: false,
|
|
3981
3773
|
// Set wrapper width
|
|
3982
3774
|
setWrapperSize: false,
|
|
3983
|
-
//
|
|
3984
|
-
virtualTranslate: false,
|
|
3985
|
-
// Effects
|
|
3775
|
+
// Effects (core-lite only supports `slide`)
|
|
3986
3776
|
effect: 'slide',
|
|
3987
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
3988
|
-
|
|
3989
3777
|
// Breakpoints
|
|
3990
3778
|
breakpoints: undefined,
|
|
3991
3779
|
breakpointsBase: 'window',
|
|
3992
|
-
// Slides
|
|
3780
|
+
// Slides
|
|
3993
3781
|
spaceBetween: 0,
|
|
3994
3782
|
slidesPerView: 1,
|
|
3995
3783
|
slidesPerGroup: 1,
|
|
@@ -4092,7 +3880,9 @@ var Swiper = (function () {
|
|
|
4092
3880
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4093
3881
|
params[moduleParamName].auto = true;
|
|
4094
3882
|
}
|
|
4095
|
-
|
|
3883
|
+
|
|
3884
|
+
// Core-lite: keep only pagination auto-init.
|
|
3885
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4096
3886
|
params[moduleParamName].auto = true;
|
|
4097
3887
|
}
|
|
4098
3888
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4218,7 +4008,6 @@ var Swiper = (function () {
|
|
|
4218
4008
|
// Indexes
|
|
4219
4009
|
activeIndex: 0,
|
|
4220
4010
|
realIndex: 0,
|
|
4221
|
-
//
|
|
4222
4011
|
isBeginning: true,
|
|
4223
4012
|
isEnd: false,
|
|
4224
4013
|
// Props
|
|
@@ -4245,12 +4034,9 @@ var Swiper = (function () {
|
|
|
4245
4034
|
currentTranslate: undefined,
|
|
4246
4035
|
startTranslate: undefined,
|
|
4247
4036
|
allowThresholdMove: undefined,
|
|
4248
|
-
// Form elements to match
|
|
4249
4037
|
focusableElements: swiper.params.focusableElements,
|
|
4250
|
-
// Last click time
|
|
4251
4038
|
lastClickTime: 0,
|
|
4252
4039
|
clickTimeout: undefined,
|
|
4253
|
-
// Velocities
|
|
4254
4040
|
velocities: [],
|
|
4255
4041
|
allowMomentumBounce: undefined,
|
|
4256
4042
|
startMoving: undefined,
|
|
@@ -4270,7 +4056,8 @@ var Swiper = (function () {
|
|
|
4270
4056
|
},
|
|
4271
4057
|
// Images
|
|
4272
4058
|
imagesToLoad: [],
|
|
4273
|
-
imagesLoaded: 0
|
|
4059
|
+
imagesLoaded: 0,
|
|
4060
|
+
rtl: params?.rtl
|
|
4274
4061
|
});
|
|
4275
4062
|
swiper.emit('_swiper');
|
|
4276
4063
|
|
|
@@ -4279,7 +4066,6 @@ var Swiper = (function () {
|
|
|
4279
4066
|
swiper.init();
|
|
4280
4067
|
}
|
|
4281
4068
|
|
|
4282
|
-
// Return app instance
|
|
4283
4069
|
// eslint-disable-next-line no-constructor-return
|
|
4284
4070
|
return swiper;
|
|
4285
4071
|
}
|
|
@@ -4311,16 +4097,6 @@ var Swiper = (function () {
|
|
|
4311
4097
|
getSlideIndexByData(index) {
|
|
4312
4098
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4313
4099
|
}
|
|
4314
|
-
getSlideIndexWhenGrid(index) {
|
|
4315
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4316
|
-
if (this.params.grid.fill === 'column') {
|
|
4317
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4318
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4319
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4320
|
-
}
|
|
4321
|
-
}
|
|
4322
|
-
return index;
|
|
4323
|
-
}
|
|
4324
4100
|
recalcSlides() {
|
|
4325
4101
|
const swiper = this;
|
|
4326
4102
|
const {
|
|
@@ -4422,21 +4198,15 @@ var Swiper = (function () {
|
|
|
4422
4198
|
}
|
|
4423
4199
|
}
|
|
4424
4200
|
} else {
|
|
4425
|
-
// eslint-disable-next-line
|
|
4426
4201
|
if (view === 'current') {
|
|
4427
4202
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4428
4203
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4429
|
-
if (slideInView)
|
|
4430
|
-
spv += 1;
|
|
4431
|
-
}
|
|
4204
|
+
if (slideInView) spv += 1;
|
|
4432
4205
|
}
|
|
4433
4206
|
} else {
|
|
4434
|
-
// previous
|
|
4435
4207
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4436
4208
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4437
|
-
if (slideInView)
|
|
4438
|
-
spv += 1;
|
|
4439
|
-
}
|
|
4209
|
+
if (slideInView) spv += 1;
|
|
4440
4210
|
}
|
|
4441
4211
|
}
|
|
4442
4212
|
}
|
|
@@ -4449,14 +4219,11 @@ var Swiper = (function () {
|
|
|
4449
4219
|
snapGrid,
|
|
4450
4220
|
params
|
|
4451
4221
|
} = swiper;
|
|
4452
|
-
// Breakpoints
|
|
4453
4222
|
if (params.breakpoints) {
|
|
4454
4223
|
swiper.setBreakpoint();
|
|
4455
4224
|
}
|
|
4456
4225
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4457
|
-
if (imageEl.complete)
|
|
4458
|
-
processLazyPreloader(swiper, imageEl);
|
|
4459
|
-
}
|
|
4226
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4460
4227
|
});
|
|
4461
4228
|
swiper.updateSize();
|
|
4462
4229
|
swiper.updateSlides();
|
|
@@ -4470,22 +4237,12 @@ var Swiper = (function () {
|
|
|
4470
4237
|
swiper.updateSlidesClasses();
|
|
4471
4238
|
}
|
|
4472
4239
|
let translated;
|
|
4473
|
-
if (params.
|
|
4474
|
-
|
|
4475
|
-
if (params.autoHeight) {
|
|
4476
|
-
swiper.updateAutoHeight();
|
|
4477
|
-
}
|
|
4240
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4241
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4478
4242
|
} else {
|
|
4479
|
-
|
|
4480
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4481
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4482
|
-
} else {
|
|
4483
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4484
|
-
}
|
|
4485
|
-
if (!translated) {
|
|
4486
|
-
setTranslate();
|
|
4487
|
-
}
|
|
4243
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4488
4244
|
}
|
|
4245
|
+
if (!translated) setTranslate();
|
|
4489
4246
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4490
4247
|
swiper.checkOverflow();
|
|
4491
4248
|
}
|
|
@@ -4498,7 +4255,6 @@ var Swiper = (function () {
|
|
|
4498
4255
|
const swiper = this;
|
|
4499
4256
|
const currentDirection = swiper.params.direction;
|
|
4500
4257
|
if (!newDirection) {
|
|
4501
|
-
// eslint-disable-next-line
|
|
4502
4258
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4503
4259
|
}
|
|
4504
4260
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4536,15 +4292,11 @@ var Swiper = (function () {
|
|
|
4536
4292
|
mount(element) {
|
|
4537
4293
|
const swiper = this;
|
|
4538
4294
|
if (swiper.mounted) return true;
|
|
4539
|
-
|
|
4540
|
-
// Find el
|
|
4541
4295
|
let el = element || swiper.params.el;
|
|
4542
4296
|
if (typeof el === 'string') {
|
|
4543
4297
|
el = document.querySelector(el);
|
|
4544
4298
|
}
|
|
4545
|
-
if (!el)
|
|
4546
|
-
return false;
|
|
4547
|
-
}
|
|
4299
|
+
if (!el) return false;
|
|
4548
4300
|
el.swiper = swiper;
|
|
4549
4301
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4550
4302
|
swiper.isElement = true;
|
|
@@ -4555,12 +4307,10 @@ var Swiper = (function () {
|
|
|
4555
4307
|
const getWrapper = () => {
|
|
4556
4308
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4557
4309
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4558
|
-
// Children needs to return slot items
|
|
4559
4310
|
return res;
|
|
4560
4311
|
}
|
|
4561
4312
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4562
4313
|
};
|
|
4563
|
-
// Find Wrapper
|
|
4564
4314
|
let wrapperEl = getWrapper();
|
|
4565
4315
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4566
4316
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4569,6 +4319,8 @@ var Swiper = (function () {
|
|
|
4569
4319
|
wrapperEl.append(slideEl);
|
|
4570
4320
|
});
|
|
4571
4321
|
}
|
|
4322
|
+
const rtl = swiper.params.rtl ?? (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl');
|
|
4323
|
+
const wrongRTL = false;
|
|
4572
4324
|
Object.assign(swiper, {
|
|
4573
4325
|
el,
|
|
4574
4326
|
wrapperEl,
|
|
@@ -4576,9 +4328,9 @@ var Swiper = (function () {
|
|
|
4576
4328
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4577
4329
|
mounted: true,
|
|
4578
4330
|
// RTL
|
|
4579
|
-
rtl
|
|
4580
|
-
rtlTranslate: swiper.params.direction === 'horizontal' &&
|
|
4581
|
-
wrongRTL
|
|
4331
|
+
rtl,
|
|
4332
|
+
rtlTranslate: swiper.params.direction === 'horizontal' && rtl,
|
|
4333
|
+
wrongRTL
|
|
4582
4334
|
});
|
|
4583
4335
|
return true;
|
|
4584
4336
|
}
|
|
@@ -4595,7 +4347,6 @@ var Swiper = (function () {
|
|
|
4595
4347
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4596
4348
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4597
4349
|
if (isFirstSlide) {
|
|
4598
|
-
// Move last item to first position when at first slide
|
|
4599
4350
|
const lastSlide = slides.at(-1);
|
|
4600
4351
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4601
4352
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4607,7 +4358,6 @@ var Swiper = (function () {
|
|
|
4607
4358
|
swiper.setTransition(speed);
|
|
4608
4359
|
swiper.setTranslate(-swiperTranslate);
|
|
4609
4360
|
} else if (isLastSlide) {
|
|
4610
|
-
// Move first item to last position when at last slide
|
|
4611
4361
|
const firstSlide = slides[0];
|
|
4612
4362
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4613
4363
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4628,42 +4378,24 @@ var Swiper = (function () {
|
|
|
4628
4378
|
const mounted = swiper.mount(el);
|
|
4629
4379
|
if (mounted === false) return swiper;
|
|
4630
4380
|
swiper.emit('beforeInit');
|
|
4631
|
-
|
|
4632
|
-
// Set breakpoint
|
|
4633
4381
|
if (swiper.params.breakpoints) {
|
|
4634
4382
|
swiper.setBreakpoint();
|
|
4635
4383
|
}
|
|
4636
|
-
|
|
4637
|
-
// Add Classes
|
|
4638
4384
|
swiper.addClasses();
|
|
4639
|
-
|
|
4640
|
-
// Update size
|
|
4641
4385
|
swiper.updateSize();
|
|
4642
|
-
|
|
4643
|
-
// Update slides
|
|
4644
4386
|
swiper.updateSlides();
|
|
4645
4387
|
if (swiper.params.watchOverflow) {
|
|
4646
4388
|
swiper.checkOverflow();
|
|
4647
4389
|
}
|
|
4648
|
-
|
|
4649
|
-
// Set Grab Cursor
|
|
4650
4390
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4651
4391
|
swiper.setGrabCursor();
|
|
4652
4392
|
}
|
|
4653
4393
|
|
|
4654
|
-
// Slide
|
|
4655
|
-
|
|
4656
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4657
|
-
} else {
|
|
4658
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
|
-
// Create loop
|
|
4394
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4395
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4662
4396
|
if (swiper.params.loop) {
|
|
4663
4397
|
swiper.loopCreate(undefined, true);
|
|
4664
4398
|
}
|
|
4665
|
-
|
|
4666
|
-
// Attach events
|
|
4667
4399
|
swiper.attachEvents();
|
|
4668
4400
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4669
4401
|
if (swiper.isElement) {
|
|
@@ -4673,16 +4405,11 @@ var Swiper = (function () {
|
|
|
4673
4405
|
if (imageEl.complete) {
|
|
4674
4406
|
processLazyPreloader(swiper, imageEl);
|
|
4675
4407
|
} else {
|
|
4676
|
-
imageEl.addEventListener('load', e =>
|
|
4677
|
-
processLazyPreloader(swiper, e.target);
|
|
4678
|
-
});
|
|
4408
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4679
4409
|
}
|
|
4680
4410
|
});
|
|
4681
4411
|
preload(swiper);
|
|
4682
|
-
|
|
4683
|
-
// Init Flag
|
|
4684
4412
|
swiper.initialized = true;
|
|
4685
|
-
preload(swiper);
|
|
4686
4413
|
|
|
4687
4414
|
// Emit
|
|
4688
4415
|
swiper.emit('init');
|
|
@@ -4707,27 +4434,15 @@ var Swiper = (function () {
|
|
|
4707
4434
|
return null;
|
|
4708
4435
|
}
|
|
4709
4436
|
swiper.emit('beforeDestroy');
|
|
4710
|
-
|
|
4711
|
-
// Init Flag
|
|
4712
4437
|
swiper.initialized = false;
|
|
4713
|
-
|
|
4714
|
-
// Detach events
|
|
4715
4438
|
swiper.detachEvents();
|
|
4716
|
-
|
|
4717
|
-
// Destroy loop
|
|
4718
4439
|
if (params.loop) {
|
|
4719
4440
|
swiper.loopDestroy();
|
|
4720
4441
|
}
|
|
4721
|
-
|
|
4722
|
-
// Cleanup styles
|
|
4723
4442
|
if (cleanStyles) {
|
|
4724
4443
|
swiper.removeClasses();
|
|
4725
|
-
if (el && typeof el !== 'string')
|
|
4726
|
-
|
|
4727
|
-
}
|
|
4728
|
-
if (wrapperEl) {
|
|
4729
|
-
wrapperEl.removeAttribute('style');
|
|
4730
|
-
}
|
|
4444
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4445
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4731
4446
|
if (slides && slides.length) {
|
|
4732
4447
|
slides.forEach(slideEl => {
|
|
4733
4448
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4737,8 +4452,6 @@ var Swiper = (function () {
|
|
|
4737
4452
|
}
|
|
4738
4453
|
}
|
|
4739
4454
|
swiper.emit('destroy');
|
|
4740
|
-
|
|
4741
|
-
// Detach emitter events
|
|
4742
4455
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4743
4456
|
swiper.off(eventName);
|
|
4744
4457
|
});
|