@gem-sdk/swiper 0.0.15 → 0.0.16-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 -578
- package/shared/utils.min.mjs +1 -1
- package/shared/utils.min.mjs.map +1 -1
- package/shared/utils.mjs +18 -1
- package/swiper-bundle.css +1 -1
- package/swiper-bundle.js +263 -581
- package/swiper-bundle.min.css +1 -1
- package/swiper-bundle.min.js +2 -2
- package/swiper-bundle.min.js.map +1 -1
- package/swiper-bundle.min.mjs +1 -1
- package/swiper-bundle.mjs +1 -1
- package/swiper-effect-utils.min.mjs +1 -1
- package/swiper-effect-utils.mjs +1 -1
- package/swiper-element-bundle.js +264 -582
- package/swiper-element-bundle.min.js +2 -2
- package/swiper-element-bundle.min.js.map +1 -1
- package/swiper-element-bundle.min.mjs +1 -1
- package/swiper-element-bundle.mjs +1 -1
- package/swiper-element.js +263 -581
- package/swiper-element.min.js +2 -2
- package/swiper-element.min.js.map +1 -1
- package/swiper-element.min.mjs +1 -1
- package/swiper-element.mjs +1 -1
- package/swiper-react.mjs +1 -1
- package/swiper-vue.mjs +1 -1
- package/swiper.css +1 -1
- package/swiper.js +262 -580
- package/swiper.less +1 -1
- package/swiper.min.css +1 -1
- package/swiper.min.js +2 -2
- package/swiper.min.js.map +1 -1
- package/swiper.min.mjs +1 -1
- package/swiper.mjs +1 -1
- package/swiper.scss +1 -1
- package/types/swiper-options.d.ts +2 -0
package/swiper-element-bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper Custom Element 0.0.
|
|
2
|
+
* Swiper Custom Element 0.0.16-dev.1
|
|
3
3
|
* Gem SDK - Swiper, Customized of swiper
|
|
4
4
|
* https://swiperjs.com
|
|
5
5
|
*
|
|
@@ -189,7 +189,7 @@
|
|
|
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 @@
|
|
|
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) {
|
|
@@ -497,6 +497,23 @@
|
|
|
497
497
|
el.innerHTML = html;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
+
function computeAutoSlideSize(slideEl, getDirectionPropValue) {
|
|
501
|
+
const styles = getComputedStyle(slideEl);
|
|
502
|
+
const width = getDirectionPropValue(styles, 'width');
|
|
503
|
+
const paddingLeft = getDirectionPropValue(styles, 'padding-left');
|
|
504
|
+
const paddingRight = getDirectionPropValue(styles, 'padding-right');
|
|
505
|
+
const marginLeft = getDirectionPropValue(styles, 'margin-left');
|
|
506
|
+
const marginRight = getDirectionPropValue(styles, 'margin-right');
|
|
507
|
+
const boxSizing = styles.getPropertyValue('box-sizing');
|
|
508
|
+
if (boxSizing && boxSizing === 'border-box') {
|
|
509
|
+
return width + marginLeft + marginRight;
|
|
510
|
+
}
|
|
511
|
+
const {
|
|
512
|
+
clientWidth,
|
|
513
|
+
offsetWidth
|
|
514
|
+
} = slideEl;
|
|
515
|
+
return width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
516
|
+
}
|
|
500
517
|
|
|
501
518
|
let support;
|
|
502
519
|
function calcSupport() {
|
|
@@ -879,9 +896,6 @@
|
|
|
879
896
|
|
|
880
897
|
function updateSlides() {
|
|
881
898
|
const swiper = this;
|
|
882
|
-
function getDirectionPropertyValue(node, label) {
|
|
883
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
884
|
-
}
|
|
885
899
|
const params = swiper.params;
|
|
886
900
|
const {
|
|
887
901
|
wrapperEl,
|
|
@@ -890,10 +904,8 @@
|
|
|
890
904
|
rtlTranslate: rtl,
|
|
891
905
|
wrongRTL
|
|
892
906
|
} = swiper;
|
|
893
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
894
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
895
907
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
896
|
-
const slidesLength =
|
|
908
|
+
const slidesLength = slides.length;
|
|
897
909
|
let snapGrid = [];
|
|
898
910
|
const slidesGrid = [];
|
|
899
911
|
const slidesSizesGrid = [];
|
|
@@ -911,15 +923,15 @@
|
|
|
911
923
|
let slidePosition = -offsetBefore;
|
|
912
924
|
let prevSlideSize = 0;
|
|
913
925
|
let index = 0;
|
|
914
|
-
if (typeof swiperSize === 'undefined')
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
926
|
+
if (typeof swiperSize === 'undefined') return;
|
|
917
927
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
918
928
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
919
929
|
} else if (typeof spaceBetween === 'string') {
|
|
920
930
|
spaceBetween = parseFloat(spaceBetween);
|
|
921
931
|
}
|
|
922
|
-
|
|
932
|
+
|
|
933
|
+
// core-lite: compute total slides size without optional modules
|
|
934
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
923
935
|
|
|
924
936
|
// reset margins
|
|
925
937
|
slides.forEach(slideEl => {
|
|
@@ -937,67 +949,91 @@
|
|
|
937
949
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
938
950
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
939
951
|
}
|
|
940
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
941
|
-
if (gridEnabled) {
|
|
942
|
-
swiper.grid.initSlides(slides);
|
|
943
|
-
} else if (swiper.grid) {
|
|
944
|
-
swiper.grid.unsetSlides();
|
|
945
|
-
}
|
|
946
952
|
|
|
947
953
|
// Calc slides
|
|
948
954
|
let slideSize;
|
|
949
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
950
|
-
|
|
951
|
-
}).length > 0;
|
|
952
|
-
for (let i = 0; i < slidesLength; i += 1) {
|
|
953
|
-
slideSize = 0;
|
|
954
|
-
let slide;
|
|
955
|
-
if (slides[i]) slide = slides[i];
|
|
956
|
-
if (gridEnabled) {
|
|
957
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
958
|
-
}
|
|
959
|
-
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
955
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
956
|
+
const isAutoSlides = params.slidesPerView === 'auto';
|
|
960
957
|
|
|
961
|
-
|
|
958
|
+
// --- Phase 1: Batch DOM writes (grid updates, width/transform resets) ---
|
|
959
|
+
// Moving all style writes before any reads prevents per-slide forced reflows
|
|
960
|
+
if (gridEnabled) {
|
|
961
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
962
|
+
if (slides[i]) swiper.grid.updateSlide(i, slides[i], slides);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const savedTransforms = [];
|
|
966
|
+
if (isAutoSlides) {
|
|
967
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
968
|
+
if (!slides[i]) continue;
|
|
962
969
|
if (shouldResetSlideSize) {
|
|
963
970
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
964
971
|
}
|
|
965
|
-
const
|
|
966
|
-
const
|
|
967
|
-
|
|
972
|
+
const currentTransform = slides[i].style.transform;
|
|
973
|
+
const currentWebKitTransform = slides[i].style.webkitTransform;
|
|
974
|
+
savedTransforms[i] = {
|
|
975
|
+
transform: currentTransform,
|
|
976
|
+
webkitTransform: currentWebKitTransform
|
|
977
|
+
};
|
|
968
978
|
if (currentTransform) {
|
|
969
|
-
|
|
979
|
+
slides[i].style.transform = 'none';
|
|
970
980
|
}
|
|
971
981
|
if (currentWebKitTransform) {
|
|
972
|
-
|
|
982
|
+
slides[i].style.webkitTransform = 'none';
|
|
973
983
|
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// --- Phase 2: Batch DOM reads (single forced reflow for all slides) ---
|
|
988
|
+
// Read wrapper offset here (before Phase 3 writes) so it's batched with slide reads, not after
|
|
989
|
+
const wrapperOffset = swiper.isElement ? swiper.wrapperEl[`offset${swiper.isHorizontal() ? 'Left' : 'Top'}`] : 0;
|
|
990
|
+
const slideVisible = [];
|
|
991
|
+
const slideSizes = [];
|
|
992
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
993
|
+
if (!slides[i]) {
|
|
994
|
+
slideVisible[i] = false;
|
|
995
|
+
continue;
|
|
996
|
+
}
|
|
997
|
+
if (elementStyle(slides[i], 'display') === 'none') {
|
|
998
|
+
slideVisible[i] = false;
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
slideVisible[i] = true;
|
|
1002
|
+
|
|
1003
|
+
// Cache offsetHeight for autoHeight (batched here to avoid a separate forced reflow in updateAutoHeight)
|
|
1004
|
+
if (params.autoHeight) {
|
|
1005
|
+
slides[i].swiperSlideHeight = slides[i]['offsetHeight'];
|
|
1006
|
+
}
|
|
1007
|
+
if (isAutoSlides) {
|
|
974
1008
|
if (params.roundLengths) {
|
|
975
|
-
|
|
1009
|
+
slideSizes[i] = swiper.isHorizontal() ? elementOuterSize(slides[i], 'width', true) : elementOuterSize(slides[i], 'height', true);
|
|
976
1010
|
} else {
|
|
977
|
-
|
|
978
|
-
const width = getDirectionPropertyValue(slideStyles, 'width');
|
|
979
|
-
const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
|
980
|
-
const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
|
981
|
-
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
|
982
|
-
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
|
983
|
-
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
984
|
-
if (boxSizing && boxSizing === 'border-box') {
|
|
985
|
-
slideSize = width + marginLeft + marginRight;
|
|
986
|
-
} else {
|
|
987
|
-
const {
|
|
988
|
-
clientWidth,
|
|
989
|
-
offsetWidth
|
|
990
|
-
} = slide;
|
|
991
|
-
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
992
|
-
}
|
|
1011
|
+
slideSizes[i] = computeAutoSlideSize(slides[i], getDirectionPropertyValue);
|
|
993
1012
|
}
|
|
994
|
-
if (
|
|
995
|
-
|
|
1013
|
+
if (params.roundLengths) slideSizes[i] = Math.floor(slideSizes[i]);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// --- Phase 3: Restore transforms (batch write) ---
|
|
1018
|
+
if (isAutoSlides) {
|
|
1019
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1020
|
+
if (!savedTransforms[i]) continue;
|
|
1021
|
+
if (savedTransforms[i].transform) {
|
|
1022
|
+
slides[i].style.transform = savedTransforms[i].transform;
|
|
996
1023
|
}
|
|
997
|
-
if (
|
|
998
|
-
|
|
1024
|
+
if (savedTransforms[i].webkitTransform) {
|
|
1025
|
+
slides[i].style.webkitTransform = savedTransforms[i].webkitTransform;
|
|
999
1026
|
}
|
|
1000
|
-
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// --- Phase 4: Calculate positions + set sizes (math + deferred writes) ---
|
|
1031
|
+
const cssOverflowAdj = swiper.cssOverflowAdjustment();
|
|
1032
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1033
|
+
slideSize = 0;
|
|
1034
|
+
if (!slideVisible[i]) continue;
|
|
1035
|
+
if (isAutoSlides) {
|
|
1036
|
+
slideSize = slideSizes[i] || 0;
|
|
1001
1037
|
} else {
|
|
1002
1038
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
1003
1039
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
@@ -1005,13 +1041,13 @@
|
|
|
1005
1041
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
1006
1042
|
}
|
|
1007
1043
|
}
|
|
1008
|
-
if (slides[i])
|
|
1009
|
-
slides[i].swiperSlideSize = slideSize;
|
|
1010
|
-
}
|
|
1044
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
1011
1045
|
slidesSizesGrid.push(slideSize);
|
|
1012
1046
|
if (params.centeredSlides) {
|
|
1013
1047
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
1014
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
1048
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
1049
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1050
|
+
}
|
|
1015
1051
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1016
1052
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
1017
1053
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -1019,55 +1055,42 @@
|
|
|
1019
1055
|
slidesGrid.push(slidePosition);
|
|
1020
1056
|
} else {
|
|
1021
1057
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
1022
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
1058
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
1059
|
+
snapGrid.push(slidePosition);
|
|
1060
|
+
}
|
|
1023
1061
|
slidesGrid.push(slidePosition);
|
|
1024
1062
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
1025
1063
|
}
|
|
1064
|
+
|
|
1065
|
+
// Set swiperSlideOffset from computed grid position (avoids DOM reads in updateSlidesOffset)
|
|
1066
|
+
if (slides[i]) {
|
|
1067
|
+
slides[i].swiperSlideOffset = slidesGrid[slidesGrid.length - 1] - cssOverflowAdj - wrapperOffset;
|
|
1068
|
+
}
|
|
1026
1069
|
swiper.virtualSize += slideSize + spaceBetween;
|
|
1027
1070
|
prevSlideSize = slideSize;
|
|
1028
1071
|
index += 1;
|
|
1029
1072
|
}
|
|
1030
|
-
swiper.
|
|
1031
|
-
if (rtl && wrongRTL &&
|
|
1032
|
-
wrapperEl.style.width = `${swiper.
|
|
1073
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
1074
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
1075
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1033
1076
|
}
|
|
1034
1077
|
if (params.setWrapperSize) {
|
|
1035
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
1036
|
-
}
|
|
1037
|
-
if (gridEnabled) {
|
|
1038
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
1078
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1039
1079
|
}
|
|
1040
1080
|
|
|
1041
|
-
// Remove last
|
|
1081
|
+
// Remove last snap points depending on width (non-centered)
|
|
1042
1082
|
if (!params.centeredSlides) {
|
|
1043
1083
|
const newSlidesGrid = [];
|
|
1044
1084
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
1045
1085
|
let slidesGridItem = snapGrid[i];
|
|
1046
1086
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
1047
|
-
if (snapGrid[i] <= swiper.
|
|
1087
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
1048
1088
|
newSlidesGrid.push(slidesGridItem);
|
|
1049
1089
|
}
|
|
1050
1090
|
}
|
|
1051
1091
|
snapGrid = newSlidesGrid;
|
|
1052
|
-
if (Math.floor(swiper.
|
|
1053
|
-
snapGrid.push(swiper.
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
if (isVirtual && params.loop) {
|
|
1057
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
1058
|
-
if (params.slidesPerGroup > 1) {
|
|
1059
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
1060
|
-
const groupSize = size * params.slidesPerGroup;
|
|
1061
|
-
for (let i = 0; i < groups; i += 1) {
|
|
1062
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
1066
|
-
if (params.slidesPerGroup === 1) {
|
|
1067
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
1068
|
-
}
|
|
1069
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
1070
|
-
swiper.virtualSize += size;
|
|
1092
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
1093
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1071
1094
|
}
|
|
1072
1095
|
}
|
|
1073
1096
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1075,9 +1098,7 @@
|
|
|
1075
1098
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1076
1099
|
slides.filter((_, slideIndex) => {
|
|
1077
1100
|
if (!params.cssMode || params.loop) return true;
|
|
1078
|
-
if (slideIndex === slides.length - 1)
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1101
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1081
1102
|
return true;
|
|
1082
1103
|
}).forEach(slideEl => {
|
|
1083
1104
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1127,7 +1148,9 @@
|
|
|
1127
1148
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1128
1149
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1129
1150
|
}
|
|
1130
|
-
|
|
1151
|
+
|
|
1152
|
+
// Emit changes
|
|
1153
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
1131
1154
|
swiper.emit('slidesLengthChange');
|
|
1132
1155
|
}
|
|
1133
1156
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1138,10 +1161,12 @@
|
|
|
1138
1161
|
swiper.emit('slidesGridLengthChange');
|
|
1139
1162
|
}
|
|
1140
1163
|
if (params.watchSlidesProgress) {
|
|
1141
|
-
swiper.updateSlidesOffset(
|
|
1164
|
+
swiper.updateSlidesOffset({
|
|
1165
|
+
isCalculatedFromUpdateSlides: false
|
|
1166
|
+
});
|
|
1142
1167
|
}
|
|
1143
1168
|
swiper.emit('slidesUpdated');
|
|
1144
|
-
if (!
|
|
1169
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1145
1170
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1146
1171
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1147
1172
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1155,20 +1180,13 @@
|
|
|
1155
1180
|
function updateAutoHeight(speed) {
|
|
1156
1181
|
const swiper = this;
|
|
1157
1182
|
const activeSlides = [];
|
|
1158
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1159
|
-
let newHeight = 0;
|
|
1160
|
-
let i;
|
|
1161
1183
|
if (typeof speed === 'number') {
|
|
1162
1184
|
swiper.setTransition(speed);
|
|
1163
1185
|
} else if (speed === true) {
|
|
1164
1186
|
swiper.setTransition(swiper.params.speed);
|
|
1165
1187
|
}
|
|
1166
|
-
const getSlideByIndex = index =>
|
|
1167
|
-
|
|
1168
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1169
|
-
}
|
|
1170
|
-
return swiper.slides[index];
|
|
1171
|
-
};
|
|
1188
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1189
|
+
|
|
1172
1190
|
// Find slides currently in view
|
|
1173
1191
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1174
1192
|
if (swiper.params.centeredSlides) {
|
|
@@ -1176,9 +1194,9 @@
|
|
|
1176
1194
|
activeSlides.push(slide);
|
|
1177
1195
|
});
|
|
1178
1196
|
} else {
|
|
1179
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1197
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1180
1198
|
const index = swiper.activeIndex + i;
|
|
1181
|
-
if (index > swiper.slides.length
|
|
1199
|
+
if (index > swiper.slides.length) break;
|
|
1182
1200
|
activeSlides.push(getSlideByIndex(index));
|
|
1183
1201
|
}
|
|
1184
1202
|
}
|
|
@@ -1187,18 +1205,23 @@
|
|
|
1187
1205
|
}
|
|
1188
1206
|
|
|
1189
1207
|
// Find new height from highest slide in view
|
|
1190
|
-
|
|
1208
|
+
let newHeight = 0;
|
|
1209
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1191
1210
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1192
|
-
const height = activeSlides[i].offsetHeight;
|
|
1211
|
+
const height = activeSlides[i].swiperSlideHeight ?? activeSlides[i]['offsetHeight'];
|
|
1193
1212
|
newHeight = height > newHeight ? height : newHeight;
|
|
1194
1213
|
}
|
|
1195
1214
|
}
|
|
1196
|
-
|
|
1197
|
-
// Update Height
|
|
1198
1215
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1199
1216
|
}
|
|
1200
1217
|
|
|
1201
|
-
function updateSlidesOffset() {
|
|
1218
|
+
function updateSlidesOffset(params) {
|
|
1219
|
+
const {
|
|
1220
|
+
isCalculatedFromUpdateSlides = false
|
|
1221
|
+
} = params ?? {};
|
|
1222
|
+
if (isCalculatedFromUpdateSlides) {
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1202
1225
|
const swiper = this;
|
|
1203
1226
|
const slides = swiper.slides;
|
|
1204
1227
|
// eslint-disable-next-line
|
|
@@ -1339,46 +1362,16 @@
|
|
|
1339
1362
|
slidesEl,
|
|
1340
1363
|
activeIndex
|
|
1341
1364
|
} = swiper;
|
|
1342
|
-
const
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1346
|
-
};
|
|
1347
|
-
let activeSlide;
|
|
1348
|
-
let prevSlide;
|
|
1365
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1366
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1367
|
+
const activeSlide = slides[activeIndex];
|
|
1349
1368
|
let nextSlide;
|
|
1350
|
-
|
|
1351
|
-
if (params.loop) {
|
|
1352
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
1353
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
1354
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
1355
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
1356
|
-
} else {
|
|
1357
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1358
|
-
}
|
|
1359
|
-
} else {
|
|
1360
|
-
if (gridEnabled) {
|
|
1361
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
1362
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
1363
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
1364
|
-
} else {
|
|
1365
|
-
activeSlide = slides[activeIndex];
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1369
|
+
let prevSlide;
|
|
1368
1370
|
if (activeSlide) {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
nextSlide = slides[0];
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
// Prev Slide
|
|
1377
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1378
|
-
if (params.loop && !prevSlide === 0) {
|
|
1379
|
-
prevSlide = slides[slides.length - 1];
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1371
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1372
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1373
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1374
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1382
1375
|
}
|
|
1383
1376
|
slides.forEach(slideEl => {
|
|
1384
1377
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1469,7 +1462,6 @@
|
|
|
1469
1462
|
activeIndex = i;
|
|
1470
1463
|
}
|
|
1471
1464
|
}
|
|
1472
|
-
// Normalize slideIndex
|
|
1473
1465
|
if (params.normalizeSlideIndex) {
|
|
1474
1466
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1475
1467
|
}
|
|
@@ -1487,16 +1479,6 @@
|
|
|
1487
1479
|
} = swiper;
|
|
1488
1480
|
let activeIndex = newActiveIndex;
|
|
1489
1481
|
let snapIndex;
|
|
1490
|
-
const getVirtualRealIndex = aIndex => {
|
|
1491
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
1492
|
-
if (realIndex < 0) {
|
|
1493
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
1494
|
-
}
|
|
1495
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
1496
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1497
|
-
}
|
|
1498
|
-
return realIndex;
|
|
1499
|
-
};
|
|
1500
1482
|
if (typeof activeIndex === 'undefined') {
|
|
1501
1483
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1502
1484
|
}
|
|
@@ -1514,32 +1496,12 @@
|
|
|
1514
1496
|
}
|
|
1515
1497
|
return;
|
|
1516
1498
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1522
|
-
|
|
1523
|
-
// Get real index
|
|
1524
|
-
let realIndex;
|
|
1525
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1526
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1527
|
-
} else if (gridEnabled) {
|
|
1528
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1529
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1530
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1531
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1532
|
-
}
|
|
1533
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1534
|
-
} else if (swiper.slides[activeIndex]) {
|
|
1499
|
+
let realIndex = activeIndex;
|
|
1500
|
+
if (swiper.slides[activeIndex]) {
|
|
1535
1501
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1536
1502
|
if (slideIndex) {
|
|
1537
1503
|
realIndex = parseInt(slideIndex, 10);
|
|
1538
|
-
} else {
|
|
1539
|
-
realIndex = activeIndex;
|
|
1540
1504
|
}
|
|
1541
|
-
} else {
|
|
1542
|
-
realIndex = activeIndex;
|
|
1543
1505
|
}
|
|
1544
1506
|
Object.assign(swiper, {
|
|
1545
1507
|
previousSnapIndex,
|
|
@@ -1586,11 +1548,7 @@
|
|
|
1586
1548
|
}
|
|
1587
1549
|
if (slide && slideFound) {
|
|
1588
1550
|
swiper.clickedSlide = slide;
|
|
1589
|
-
|
|
1590
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1591
|
-
} else {
|
|
1592
|
-
swiper.clickedIndex = slideIndex;
|
|
1593
|
-
}
|
|
1551
|
+
swiper.clickedIndex = slideIndex;
|
|
1594
1552
|
} else {
|
|
1595
1553
|
swiper.clickedSlide = undefined;
|
|
1596
1554
|
swiper.clickedIndex = undefined;
|
|
@@ -1624,9 +1582,6 @@
|
|
|
1624
1582
|
translate,
|
|
1625
1583
|
wrapperEl
|
|
1626
1584
|
} = swiper;
|
|
1627
|
-
if (params.virtualTranslate) {
|
|
1628
|
-
return rtl ? -translate : translate;
|
|
1629
|
-
}
|
|
1630
1585
|
if (params.cssMode) {
|
|
1631
1586
|
return translate;
|
|
1632
1587
|
}
|
|
@@ -1660,7 +1615,7 @@
|
|
|
1660
1615
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1661
1616
|
if (params.cssMode) {
|
|
1662
1617
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1663
|
-
} else
|
|
1618
|
+
} else {
|
|
1664
1619
|
if (swiper.isHorizontal()) {
|
|
1665
1620
|
x -= swiper.cssOverflowAdjustment();
|
|
1666
1621
|
} else {
|
|
@@ -1897,7 +1852,6 @@
|
|
|
1897
1852
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1898
1853
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1899
1854
|
const translate = -snapGrid[snapIndex];
|
|
1900
|
-
// Normalize slideIndex
|
|
1901
1855
|
if (params.normalizeSlideIndex) {
|
|
1902
1856
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1903
1857
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1914,33 +1868,24 @@
|
|
|
1914
1868
|
}
|
|
1915
1869
|
}
|
|
1916
1870
|
}
|
|
1871
|
+
|
|
1917
1872
|
// Directions locks
|
|
1918
1873
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1919
1874
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1920
1875
|
return false;
|
|
1921
1876
|
}
|
|
1922
1877
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1923
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1924
|
-
return false;
|
|
1925
|
-
}
|
|
1878
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1926
1879
|
}
|
|
1927
1880
|
}
|
|
1928
1881
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1929
1882
|
swiper.emit('beforeSlideChangeStart');
|
|
1930
1883
|
}
|
|
1931
|
-
|
|
1932
|
-
// Update progress
|
|
1933
1884
|
swiper.updateProgress(translate);
|
|
1934
1885
|
let direction;
|
|
1935
1886
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1936
|
-
|
|
1937
|
-
// initial virtual
|
|
1938
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1939
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1940
|
-
// Update Index
|
|
1941
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1887
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1942
1888
|
swiper.updateActiveIndex(slideIndex);
|
|
1943
|
-
// Update Height
|
|
1944
1889
|
if (params.autoHeight) {
|
|
1945
1890
|
swiper.updateAutoHeight();
|
|
1946
1891
|
}
|
|
@@ -1958,24 +1903,7 @@
|
|
|
1958
1903
|
const isH = swiper.isHorizontal();
|
|
1959
1904
|
const t = rtl ? translate : -translate;
|
|
1960
1905
|
if (speed === 0) {
|
|
1961
|
-
|
|
1962
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1963
|
-
swiper._immediateVirtual = true;
|
|
1964
|
-
}
|
|
1965
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1966
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1967
|
-
requestAnimationFrame(() => {
|
|
1968
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1969
|
-
});
|
|
1970
|
-
} else {
|
|
1971
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1972
|
-
}
|
|
1973
|
-
if (isVirtual) {
|
|
1974
|
-
requestAnimationFrame(() => {
|
|
1975
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1976
|
-
swiper._immediateVirtual = false;
|
|
1977
|
-
});
|
|
1978
|
-
}
|
|
1906
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1979
1907
|
} else {
|
|
1980
1908
|
if (!swiper.support.smoothScroll) {
|
|
1981
1909
|
animateCSSModeScroll({
|
|
@@ -1993,10 +1921,7 @@
|
|
|
1993
1921
|
return true;
|
|
1994
1922
|
}
|
|
1995
1923
|
const browser = getBrowser();
|
|
1996
|
-
|
|
1997
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1998
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1999
|
-
}
|
|
1924
|
+
browser.isSafari;
|
|
2000
1925
|
swiper.setTransition(speed);
|
|
2001
1926
|
swiper.setTranslate(translate);
|
|
2002
1927
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2167,8 +2092,6 @@
|
|
|
2167
2092
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2168
2093
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2169
2094
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2170
|
-
|
|
2171
|
-
// Move last item to first position only if active slide is the first slide
|
|
2172
2095
|
const lastSlide = slides[slides.length - 1];
|
|
2173
2096
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2174
2097
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2203,11 +2126,8 @@
|
|
|
2203
2126
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2204
2127
|
}
|
|
2205
2128
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2206
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2207
2129
|
if (params.loop) {
|
|
2208
|
-
if (animating &&
|
|
2209
|
-
|
|
2210
|
-
// Kiểm tra xem loop có bị disable không
|
|
2130
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2211
2131
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2212
2132
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2213
2133
|
swiper.loopFix({
|
|
@@ -2234,7 +2154,6 @@
|
|
|
2234
2154
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2235
2155
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2236
2156
|
if (!swiper.params.loop) return;
|
|
2237
|
-
// Move first item to last position only if active slide is the last slide
|
|
2238
2157
|
const firstSlide = slides[0];
|
|
2239
2158
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2240
2159
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2259,17 +2178,14 @@
|
|
|
2259
2178
|
params,
|
|
2260
2179
|
snapGrid,
|
|
2261
2180
|
slidesGrid,
|
|
2262
|
-
rtlTranslate,
|
|
2263
|
-
enabled
|
|
2264
|
-
animating
|
|
2181
|
+
rtlTranslate: rtlTranslate,
|
|
2182
|
+
enabled
|
|
2265
2183
|
} = swiper;
|
|
2266
2184
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2267
2185
|
if (typeof speed === 'undefined') {
|
|
2268
2186
|
speed = swiper.params.speed;
|
|
2269
2187
|
}
|
|
2270
|
-
swiper.virtual && params.virtual.enabled;
|
|
2271
2188
|
if (params.loop) {
|
|
2272
|
-
// Kiểm tra xem loop có bị disable không
|
|
2273
2189
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2274
2190
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2275
2191
|
swiper.loopFix({
|
|
@@ -2286,18 +2202,16 @@
|
|
|
2286
2202
|
}
|
|
2287
2203
|
const normalizedTranslate = normalize(translate);
|
|
2288
2204
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2289
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2290
2205
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2291
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2206
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2292
2207
|
let prevSnapIndex;
|
|
2293
2208
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2294
2209
|
if (normalizedTranslate >= snap) {
|
|
2295
|
-
// prevSnap = snap;
|
|
2296
2210
|
prevSnapIndex = snapIndex;
|
|
2297
2211
|
}
|
|
2298
2212
|
});
|
|
2299
2213
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2300
|
-
prevSnap =
|
|
2214
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2301
2215
|
}
|
|
2302
2216
|
}
|
|
2303
2217
|
let prevIndex = 0;
|
|
@@ -2310,7 +2224,7 @@
|
|
|
2310
2224
|
}
|
|
2311
2225
|
}
|
|
2312
2226
|
if (params.rewind && swiper.isBeginning) {
|
|
2313
|
-
const lastIndex = swiper.
|
|
2227
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2314
2228
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2315
2229
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2316
2230
|
requestAnimationFrame(() => {
|
|
@@ -2324,8 +2238,6 @@
|
|
|
2324
2238
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2325
2239
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2326
2240
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2327
|
-
|
|
2328
|
-
// Move last item to first position only if active slide is the first slide
|
|
2329
2241
|
if (!swiper.params.loop) return;
|
|
2330
2242
|
const lastSlide = slides[slides.length - 1];
|
|
2331
2243
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2402,20 +2314,19 @@
|
|
|
2402
2314
|
slidesEl
|
|
2403
2315
|
} = swiper;
|
|
2404
2316
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2405
|
-
|
|
2317
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2406
2318
|
let realIndex;
|
|
2407
2319
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2408
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2409
2320
|
if (params.loop) {
|
|
2410
2321
|
if (swiper.animating) return;
|
|
2411
2322
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2412
2323
|
if (params.centeredSlides) {
|
|
2413
2324
|
swiper.slideToLoop(realIndex);
|
|
2414
|
-
} else if (slideToIndex >
|
|
2325
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2415
2326
|
swiper.loopFix();
|
|
2416
|
-
|
|
2327
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2417
2328
|
nextTick(() => {
|
|
2418
|
-
swiper.slideTo(
|
|
2329
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2419
2330
|
});
|
|
2420
2331
|
} else {
|
|
2421
2332
|
swiper.slideTo(slideToIndex);
|
|
@@ -2442,7 +2353,7 @@
|
|
|
2442
2353
|
params,
|
|
2443
2354
|
slidesEl
|
|
2444
2355
|
} = swiper;
|
|
2445
|
-
if (!params.loop
|
|
2356
|
+
if (!params.loop) return;
|
|
2446
2357
|
const initSlides = () => {
|
|
2447
2358
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2448
2359
|
slides.forEach((el, index) => {
|
|
@@ -2451,21 +2362,17 @@
|
|
|
2451
2362
|
};
|
|
2452
2363
|
const clearBlankSlides = () => {
|
|
2453
2364
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2454
|
-
slides.forEach(el =>
|
|
2455
|
-
el.remove();
|
|
2456
|
-
});
|
|
2365
|
+
slides.forEach(el => el.remove());
|
|
2457
2366
|
if (slides.length > 0) {
|
|
2458
2367
|
swiper.recalcSlides();
|
|
2459
2368
|
swiper.updateSlides();
|
|
2460
2369
|
}
|
|
2461
2370
|
};
|
|
2462
|
-
|
|
2463
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2371
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2464
2372
|
clearBlankSlides();
|
|
2465
2373
|
}
|
|
2466
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2374
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2467
2375
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2468
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2469
2376
|
const addBlankSlides = amountOfSlides => {
|
|
2470
2377
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2471
2378
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2482,16 +2389,6 @@
|
|
|
2482
2389
|
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)');
|
|
2483
2390
|
}
|
|
2484
2391
|
initSlides();
|
|
2485
|
-
} else if (shouldFillGrid) {
|
|
2486
|
-
if (params.loopAddBlankSlides) {
|
|
2487
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2488
|
-
addBlankSlides(slidesToAdd);
|
|
2489
|
-
swiper.recalcSlides();
|
|
2490
|
-
swiper.updateSlides();
|
|
2491
|
-
} else {
|
|
2492
|
-
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)');
|
|
2493
|
-
}
|
|
2494
|
-
initSlides();
|
|
2495
2392
|
} else {
|
|
2496
2393
|
initSlides();
|
|
2497
2394
|
}
|
|
@@ -2510,13 +2407,12 @@
|
|
|
2510
2407
|
setTranslate,
|
|
2511
2408
|
activeSlideIndex,
|
|
2512
2409
|
initial,
|
|
2513
|
-
byController,
|
|
2514
2410
|
byMousewheel
|
|
2515
2411
|
} = _temp === void 0 ? {} : _temp;
|
|
2516
2412
|
const swiper = this;
|
|
2517
2413
|
if (!swiper.params.loop) return;
|
|
2518
2414
|
|
|
2519
|
-
// Disable loop mode
|
|
2415
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2520
2416
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2521
2417
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2522
2418
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2536,21 +2432,6 @@
|
|
|
2536
2432
|
} = params;
|
|
2537
2433
|
swiper.allowSlidePrev = true;
|
|
2538
2434
|
swiper.allowSlideNext = true;
|
|
2539
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2540
|
-
if (slideTo) {
|
|
2541
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2542
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2543
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2544
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2545
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2546
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2550
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2551
|
-
swiper.emit('loopFix');
|
|
2552
|
-
return;
|
|
2553
|
-
}
|
|
2554
2435
|
let slidesPerView = params.slidesPerView;
|
|
2555
2436
|
if (slidesPerView === 'auto') {
|
|
2556
2437
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2560,22 +2441,19 @@
|
|
|
2560
2441
|
slidesPerView = slidesPerView + 1;
|
|
2561
2442
|
}
|
|
2562
2443
|
}
|
|
2563
|
-
const slidesPerGroup = params.
|
|
2444
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2564
2445
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2565
2446
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2566
2447
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2567
2448
|
}
|
|
2568
2449
|
loopedSlides += params.loopAdditionalSlides;
|
|
2569
2450
|
swiper.loopedSlides = loopedSlides;
|
|
2570
|
-
|
|
2571
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2451
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2572
2452
|
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');
|
|
2573
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2574
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2575
2453
|
}
|
|
2576
2454
|
const prependSlidesIndexes = [];
|
|
2577
2455
|
const appendSlidesIndexes = [];
|
|
2578
|
-
const cols =
|
|
2456
|
+
const cols = slides.length;
|
|
2579
2457
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2580
2458
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2581
2459
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2587,24 +2465,15 @@
|
|
|
2587
2465
|
const isPrev = direction === 'prev' || !direction;
|
|
2588
2466
|
let slidesPrepended = 0;
|
|
2589
2467
|
let slidesAppended = 0;
|
|
2590
|
-
const activeColIndex =
|
|
2468
|
+
const activeColIndex = activeSlideIndex;
|
|
2591
2469
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2470
|
+
|
|
2592
2471
|
// prepend last slides before start
|
|
2593
2472
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2594
2473
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2595
2474
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2596
2475
|
const index = i - Math.floor(i / cols) * cols;
|
|
2597
|
-
|
|
2598
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2599
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2600
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2601
|
-
}
|
|
2602
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2603
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2604
|
-
// });
|
|
2605
|
-
} else {
|
|
2606
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2607
|
-
}
|
|
2476
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2608
2477
|
}
|
|
2609
2478
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2610
2479
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2613,27 +2482,13 @@
|
|
|
2613
2482
|
}
|
|
2614
2483
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2615
2484
|
const index = i - Math.floor(i / cols) * cols;
|
|
2616
|
-
|
|
2617
|
-
slides.forEach((slide, slideIndex) => {
|
|
2618
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2619
|
-
});
|
|
2620
|
-
} else {
|
|
2621
|
-
appendSlidesIndexes.push(index);
|
|
2622
|
-
}
|
|
2485
|
+
appendSlidesIndexes.push(index);
|
|
2623
2486
|
}
|
|
2624
2487
|
}
|
|
2625
2488
|
swiper.__preventObserver__ = true;
|
|
2626
2489
|
requestAnimationFrame(() => {
|
|
2627
2490
|
swiper.__preventObserver__ = false;
|
|
2628
2491
|
});
|
|
2629
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2630
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2631
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2632
|
-
}
|
|
2633
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2634
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
2492
|
if (isPrev) {
|
|
2638
2493
|
prependSlidesIndexes.forEach(index => {
|
|
2639
2494
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2651,13 +2506,11 @@
|
|
|
2651
2506
|
swiper.recalcSlides();
|
|
2652
2507
|
if (params.slidesPerView === 'auto') {
|
|
2653
2508
|
swiper.updateSlides();
|
|
2654
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2655
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2656
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2657
|
-
});
|
|
2658
2509
|
}
|
|
2659
2510
|
if (params.watchSlidesProgress) {
|
|
2660
|
-
swiper.updateSlidesOffset(
|
|
2511
|
+
swiper.updateSlidesOffset({
|
|
2512
|
+
isCalculatedFromUpdateSlides: params.slidesPerView === 'auto'
|
|
2513
|
+
});
|
|
2661
2514
|
}
|
|
2662
2515
|
if (slideTo) {
|
|
2663
2516
|
if (prependSlidesIndexes.length > 0 && isPrev) {
|
|
@@ -2674,12 +2527,10 @@
|
|
|
2674
2527
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2675
2528
|
}
|
|
2676
2529
|
}
|
|
2677
|
-
} else {
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2682
|
-
}
|
|
2530
|
+
} else if (setTranslate) {
|
|
2531
|
+
const shift = prependSlidesIndexes.length;
|
|
2532
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2533
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2683
2534
|
}
|
|
2684
2535
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2685
2536
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2695,36 +2546,14 @@
|
|
|
2695
2546
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2696
2547
|
}
|
|
2697
2548
|
}
|
|
2698
|
-
} else {
|
|
2699
|
-
const shift =
|
|
2549
|
+
} else if (setTranslate) {
|
|
2550
|
+
const shift = appendSlidesIndexes.length;
|
|
2700
2551
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2701
2552
|
}
|
|
2702
2553
|
}
|
|
2703
2554
|
}
|
|
2704
2555
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2705
2556
|
swiper.allowSlideNext = allowSlideNext;
|
|
2706
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2707
|
-
const loopParams = {
|
|
2708
|
-
slideRealIndex,
|
|
2709
|
-
direction,
|
|
2710
|
-
setTranslate,
|
|
2711
|
-
activeSlideIndex,
|
|
2712
|
-
byController: true
|
|
2713
|
-
};
|
|
2714
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2715
|
-
swiper.controller.control.forEach(c => {
|
|
2716
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2717
|
-
...loopParams,
|
|
2718
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2719
|
-
});
|
|
2720
|
-
});
|
|
2721
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2722
|
-
swiper.controller.control.loopFix({
|
|
2723
|
-
...loopParams,
|
|
2724
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2725
|
-
});
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
2557
|
swiper.emit('loopFix');
|
|
2729
2558
|
}
|
|
2730
2559
|
|
|
@@ -2741,7 +2570,7 @@
|
|
|
2741
2570
|
const swiper = this;
|
|
2742
2571
|
if (!swiper.params.loop) return;
|
|
2743
2572
|
|
|
2744
|
-
// Disable loop mode
|
|
2573
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2745
2574
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2746
2575
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2747
2576
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2780,7 +2609,7 @@
|
|
|
2780
2609
|
}
|
|
2781
2610
|
loopedSlides += params.loopAdditionalSlides;
|
|
2782
2611
|
swiper.loopedSlides = loopedSlides;
|
|
2783
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2612
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2784
2613
|
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');
|
|
2785
2614
|
}
|
|
2786
2615
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2806,20 +2635,16 @@
|
|
|
2806
2635
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2807
2636
|
}
|
|
2808
2637
|
|
|
2809
|
-
//
|
|
2638
|
+
// DocumentFragment to hold slide clones
|
|
2810
2639
|
const cloneFragment = document.createDocumentFragment();
|
|
2811
2640
|
|
|
2812
|
-
// Clone
|
|
2641
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2813
2642
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2814
2643
|
if (slides[index]) {
|
|
2815
2644
|
const originalSlide = slides[index];
|
|
2816
2645
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2817
|
-
|
|
2818
|
-
// Đánh dấu slide clone
|
|
2819
2646
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2820
2647
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2821
|
-
|
|
2822
|
-
// Thêm clone vào fragment
|
|
2823
2648
|
cloneFragment.appendChild(clonedSlide);
|
|
2824
2649
|
}
|
|
2825
2650
|
});
|
|
@@ -2840,32 +2665,28 @@
|
|
|
2840
2665
|
});
|
|
2841
2666
|
}
|
|
2842
2667
|
|
|
2843
|
-
//
|
|
2668
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2844
2669
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2845
2670
|
clonedSlides.sort((a, b) => {
|
|
2846
2671
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2847
2672
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2848
2673
|
return indexA - indexB;
|
|
2849
2674
|
});
|
|
2850
|
-
|
|
2851
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2852
2675
|
cloneFragment.innerHTML = '';
|
|
2853
2676
|
clonedSlides.forEach(slide => {
|
|
2854
2677
|
cloneFragment.appendChild(slide);
|
|
2855
2678
|
});
|
|
2856
2679
|
|
|
2857
|
-
//
|
|
2680
|
+
// Place fragment into the right position
|
|
2858
2681
|
if (isPrev) {
|
|
2859
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2860
2682
|
slidesEl.appendChild(cloneFragment);
|
|
2861
2683
|
} else if (isNext) {
|
|
2862
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2863
2684
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2864
2685
|
}
|
|
2865
2686
|
swiper.recalcSlides();
|
|
2866
2687
|
swiper.updateSlides();
|
|
2867
2688
|
|
|
2868
|
-
//
|
|
2689
|
+
// Find old active slide index after recalculation
|
|
2869
2690
|
let oldActiveIndex = null;
|
|
2870
2691
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2871
2692
|
const child = slidesEl.children[i];
|
|
@@ -2878,7 +2699,7 @@
|
|
|
2878
2699
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2879
2700
|
}
|
|
2880
2701
|
|
|
2881
|
-
//
|
|
2702
|
+
// Update translate after removing clones for animation
|
|
2882
2703
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2883
2704
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2884
2705
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2904,7 +2725,8 @@
|
|
|
2904
2725
|
}
|
|
2905
2726
|
swiper.setTranslate(updateTranslate);
|
|
2906
2727
|
}
|
|
2907
|
-
|
|
2728
|
+
|
|
2729
|
+
// Remove clones
|
|
2908
2730
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2909
2731
|
cloneSlides.forEach(cloneSlide => {
|
|
2910
2732
|
if (cloneSlide.parentNode) {
|
|
@@ -2934,7 +2756,7 @@
|
|
|
2934
2756
|
params,
|
|
2935
2757
|
slidesEl
|
|
2936
2758
|
} = swiper;
|
|
2937
|
-
if (!params.loop || !slidesEl
|
|
2759
|
+
if (!params.loop || !slidesEl) return;
|
|
2938
2760
|
swiper.recalcSlides();
|
|
2939
2761
|
const newSlidesOrder = [];
|
|
2940
2762
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2995,7 +2817,6 @@
|
|
|
2995
2817
|
unsetGrabCursor
|
|
2996
2818
|
};
|
|
2997
2819
|
|
|
2998
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2999
2820
|
function closestElement(selector, base) {
|
|
3000
2821
|
if (base === void 0) {
|
|
3001
2822
|
base = this;
|
|
@@ -3004,9 +2825,7 @@
|
|
|
3004
2825
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
3005
2826
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
3006
2827
|
const found = el.closest(selector);
|
|
3007
|
-
if (!found && !el.getRootNode)
|
|
3008
|
-
return null;
|
|
3009
|
-
}
|
|
2828
|
+
if (!found && !el.getRootNode) return null;
|
|
3010
2829
|
return found || __closestFrom(el.getRootNode().host);
|
|
3011
2830
|
}
|
|
3012
2831
|
return __closestFrom(base);
|
|
@@ -3034,9 +2853,7 @@
|
|
|
3034
2853
|
if (e.originalEvent) e = e.originalEvent;
|
|
3035
2854
|
const data = swiper.touchEventsData;
|
|
3036
2855
|
if (e.type === 'pointerdown') {
|
|
3037
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
3038
|
-
return;
|
|
3039
|
-
}
|
|
2856
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
3040
2857
|
data.pointerId = e.pointerId;
|
|
3041
2858
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
3042
2859
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3053,9 +2870,7 @@
|
|
|
3053
2870
|
} = swiper;
|
|
3054
2871
|
if (!enabled) return;
|
|
3055
2872
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3056
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3057
|
-
return;
|
|
3058
|
-
}
|
|
2873
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3059
2874
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3060
2875
|
swiper.loopFix();
|
|
3061
2876
|
}
|
|
@@ -3066,8 +2881,6 @@
|
|
|
3066
2881
|
if ('which' in e && e.which === 3) return;
|
|
3067
2882
|
if ('button' in e && e.button > 0) return;
|
|
3068
2883
|
if (data.isTouched && data.isMoved) return;
|
|
3069
|
-
|
|
3070
|
-
// change target el for shadow root component
|
|
3071
2884
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3072
2885
|
// eslint-disable-next-line
|
|
3073
2886
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3076,8 +2889,6 @@
|
|
|
3076
2889
|
}
|
|
3077
2890
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3078
2891
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3079
|
-
|
|
3080
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3081
2892
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3082
2893
|
swiper.allowClick = true;
|
|
3083
2894
|
return;
|
|
@@ -3089,12 +2900,7 @@
|
|
|
3089
2900
|
touches.currentY = e.pageY;
|
|
3090
2901
|
const startX = touches.currentX;
|
|
3091
2902
|
const startY = touches.currentY;
|
|
3092
|
-
|
|
3093
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3094
|
-
|
|
3095
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3096
|
-
return;
|
|
3097
|
-
}
|
|
2903
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3098
2904
|
Object.assign(data, {
|
|
3099
2905
|
isTouched: true,
|
|
3100
2906
|
isMoved: false,
|
|
@@ -3123,9 +2929,6 @@
|
|
|
3123
2929
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3124
2930
|
e.preventDefault();
|
|
3125
2931
|
}
|
|
3126
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3127
|
-
swiper.freeMode.onTouchStart();
|
|
3128
|
-
}
|
|
3129
2932
|
swiper.emit('touchStart', e);
|
|
3130
2933
|
}
|
|
3131
2934
|
|
|
@@ -3144,7 +2947,7 @@
|
|
|
3144
2947
|
let e = event;
|
|
3145
2948
|
if (e.originalEvent) e = e.originalEvent;
|
|
3146
2949
|
if (e.type === 'pointermove') {
|
|
3147
|
-
if (data.touchId !== null) return;
|
|
2950
|
+
if (data.touchId !== null) return;
|
|
3148
2951
|
const id = e.pointerId;
|
|
3149
2952
|
if (id !== data.pointerId) return;
|
|
3150
2953
|
}
|
|
@@ -3185,7 +2988,6 @@
|
|
|
3185
2988
|
}
|
|
3186
2989
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3187
2990
|
if (swiper.isVertical()) {
|
|
3188
|
-
// Vertical
|
|
3189
2991
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3190
2992
|
data.isTouched = false;
|
|
3191
2993
|
data.isMoved = false;
|
|
@@ -3287,7 +3089,6 @@
|
|
|
3287
3089
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3288
3090
|
}
|
|
3289
3091
|
data.allowMomentumBounce = false;
|
|
3290
|
-
// Grab Cursor
|
|
3291
3092
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3292
3093
|
swiper.setGrabCursor(true);
|
|
3293
3094
|
}
|
|
@@ -3358,8 +3159,6 @@
|
|
|
3358
3159
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3359
3160
|
data.currentTranslate = data.startTranslate;
|
|
3360
3161
|
}
|
|
3361
|
-
|
|
3362
|
-
// Threshold
|
|
3363
3162
|
if (params.threshold > 0) {
|
|
3364
3163
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3365
3164
|
if (!data.allowThresholdMove) {
|
|
@@ -3377,17 +3176,12 @@
|
|
|
3377
3176
|
}
|
|
3378
3177
|
if (!params.followFinger || params.cssMode) return;
|
|
3379
3178
|
|
|
3380
|
-
//
|
|
3381
|
-
if (params.
|
|
3179
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3180
|
+
if (params.watchSlidesProgress) {
|
|
3382
3181
|
swiper.updateActiveIndex();
|
|
3383
3182
|
swiper.updateSlidesClasses();
|
|
3384
3183
|
}
|
|
3385
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3386
|
-
swiper.freeMode.onTouchMove();
|
|
3387
|
-
}
|
|
3388
|
-
// Update progress
|
|
3389
3184
|
swiper.updateProgress(data.currentTranslate);
|
|
3390
|
-
// Update translate
|
|
3391
3185
|
swiper.setTranslate(data.currentTranslate);
|
|
3392
3186
|
}
|
|
3393
3187
|
|
|
@@ -3399,7 +3193,7 @@
|
|
|
3399
3193
|
let targetTouch;
|
|
3400
3194
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3401
3195
|
if (!isTouchEvent) {
|
|
3402
|
-
if (data.touchId !== null) return;
|
|
3196
|
+
if (data.touchId !== null) return;
|
|
3403
3197
|
if (e.pointerId !== data.pointerId) return;
|
|
3404
3198
|
targetTouch = e;
|
|
3405
3199
|
} else {
|
|
@@ -3408,9 +3202,7 @@
|
|
|
3408
3202
|
}
|
|
3409
3203
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3410
3204
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3411
|
-
if (!proceed)
|
|
3412
|
-
return;
|
|
3413
|
-
}
|
|
3205
|
+
if (!proceed) return;
|
|
3414
3206
|
}
|
|
3415
3207
|
data.pointerId = null;
|
|
3416
3208
|
data.touchId = null;
|
|
@@ -3428,9 +3220,7 @@
|
|
|
3428
3220
|
}
|
|
3429
3221
|
data.allowTouchCallbacks = false;
|
|
3430
3222
|
if (!data.isTouched) {
|
|
3431
|
-
if (data.isMoved && params.grabCursor)
|
|
3432
|
-
swiper.setGrabCursor(false);
|
|
3433
|
-
}
|
|
3223
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3434
3224
|
data.isMoved = false;
|
|
3435
3225
|
data.startMoving = false;
|
|
3436
3226
|
return;
|
|
@@ -3440,8 +3230,6 @@
|
|
|
3440
3230
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3441
3231
|
swiper.setGrabCursor(false);
|
|
3442
3232
|
}
|
|
3443
|
-
|
|
3444
|
-
// Time diff
|
|
3445
3233
|
const touchEndTime = now();
|
|
3446
3234
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3447
3235
|
|
|
@@ -3468,20 +3256,8 @@
|
|
|
3468
3256
|
data.isMoved = false;
|
|
3469
3257
|
data.startMoving = false;
|
|
3470
3258
|
let currentPos;
|
|
3471
|
-
if (params.followFinger)
|
|
3472
|
-
|
|
3473
|
-
} else {
|
|
3474
|
-
currentPos = -data.currentTranslate;
|
|
3475
|
-
}
|
|
3476
|
-
if (params.cssMode) {
|
|
3477
|
-
return;
|
|
3478
|
-
}
|
|
3479
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3480
|
-
swiper.freeMode.onTouchEnd({
|
|
3481
|
-
currentPos
|
|
3482
|
-
});
|
|
3483
|
-
return;
|
|
3484
|
-
}
|
|
3259
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3260
|
+
if (params.cssMode) return;
|
|
3485
3261
|
|
|
3486
3262
|
// Find current slide
|
|
3487
3263
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3503,22 +3279,22 @@
|
|
|
3503
3279
|
let rewindLastIndex = null;
|
|
3504
3280
|
if (params.rewind) {
|
|
3505
3281
|
if (swiper.isBeginning) {
|
|
3506
|
-
rewindLastIndex =
|
|
3282
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3507
3283
|
} else if (swiper.isEnd) {
|
|
3508
3284
|
rewindFirstIndex = 0;
|
|
3509
3285
|
}
|
|
3510
3286
|
}
|
|
3511
|
-
// Find current slide size
|
|
3512
3287
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3513
3288
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3514
3289
|
if (timeDiff > params.longSwipesMs) {
|
|
3515
|
-
// Long touches
|
|
3516
3290
|
if (!params.longSwipes) {
|
|
3517
3291
|
swiper.slideTo(swiper.activeIndex);
|
|
3518
3292
|
return;
|
|
3519
3293
|
}
|
|
3520
3294
|
if (swiper.swipeDirection === 'next') {
|
|
3521
|
-
if (ratio >= params.longSwipesRatio)
|
|
3295
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3296
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3297
|
+
} else swiper.slideTo(stopIndex);
|
|
3522
3298
|
}
|
|
3523
3299
|
if (swiper.swipeDirection === 'prev') {
|
|
3524
3300
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3570,7 +3346,6 @@
|
|
|
3570
3346
|
allowSlidePrev,
|
|
3571
3347
|
snapGrid
|
|
3572
3348
|
} = swiper;
|
|
3573
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3574
3349
|
|
|
3575
3350
|
// Disable locks on resize
|
|
3576
3351
|
swiper.allowSlideNext = true;
|
|
@@ -3578,15 +3353,12 @@
|
|
|
3578
3353
|
swiper.updateSize();
|
|
3579
3354
|
swiper.updateSlides();
|
|
3580
3355
|
swiper.updateSlidesClasses();
|
|
3581
|
-
|
|
3582
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3356
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3583
3357
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3358
|
+
} else if (swiper.params.loop) {
|
|
3359
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3584
3360
|
} else {
|
|
3585
|
-
|
|
3586
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3587
|
-
} else {
|
|
3588
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3589
|
-
}
|
|
3361
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3590
3362
|
}
|
|
3591
3363
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3592
3364
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3596,10 +3368,11 @@
|
|
|
3596
3368
|
}
|
|
3597
3369
|
}, 500);
|
|
3598
3370
|
}
|
|
3371
|
+
|
|
3599
3372
|
// Return locks after resize
|
|
3600
3373
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3601
3374
|
swiper.allowSlideNext = allowSlideNext;
|
|
3602
|
-
if (
|
|
3375
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3603
3376
|
swiper.checkOverflow();
|
|
3604
3377
|
}
|
|
3605
3378
|
}
|
|
@@ -3653,6 +3426,10 @@
|
|
|
3653
3426
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3654
3427
|
return;
|
|
3655
3428
|
}
|
|
3429
|
+
const el = e?.target;
|
|
3430
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3431
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3432
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3656
3433
|
swiper.update();
|
|
3657
3434
|
}
|
|
3658
3435
|
|
|
@@ -3764,8 +3541,15 @@
|
|
|
3764
3541
|
detachEvents
|
|
3765
3542
|
};
|
|
3766
3543
|
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3544
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3545
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3546
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3547
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3548
|
+
swiper[prop].disable();
|
|
3549
|
+
}
|
|
3550
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3551
|
+
swiper[prop].enable();
|
|
3552
|
+
}
|
|
3769
3553
|
};
|
|
3770
3554
|
function setBreakpoint() {
|
|
3771
3555
|
const swiper = this;
|
|
@@ -3786,38 +3570,20 @@
|
|
|
3786
3570
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3787
3571
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3788
3572
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3789
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3790
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3791
3573
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3792
3574
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3793
3575
|
const wasEnabled = params.enabled;
|
|
3794
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3795
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3796
|
-
swiper.emitContainerClasses();
|
|
3797
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3798
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3799
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3800
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3801
|
-
}
|
|
3802
|
-
swiper.emitContainerClasses();
|
|
3803
|
-
}
|
|
3804
3576
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3805
3577
|
swiper.unsetGrabCursor();
|
|
3806
3578
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3807
3579
|
swiper.setGrabCursor();
|
|
3808
3580
|
}
|
|
3809
3581
|
|
|
3810
|
-
//
|
|
3811
|
-
['navigation', 'pagination'
|
|
3582
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3583
|
+
const modules = ['navigation', 'pagination'];
|
|
3584
|
+
modules.forEach(prop => {
|
|
3812
3585
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3813
|
-
|
|
3814
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3815
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3816
|
-
swiper[prop].disable();
|
|
3817
|
-
}
|
|
3818
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3819
|
-
swiper[prop].enable();
|
|
3820
|
-
}
|
|
3586
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3821
3587
|
});
|
|
3822
3588
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3823
3589
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3899,7 +3665,7 @@
|
|
|
3899
3665
|
getBreakpoint
|
|
3900
3666
|
};
|
|
3901
3667
|
|
|
3902
|
-
|
|
3668
|
+
const prepareClasses = (entries, prefix) => {
|
|
3903
3669
|
const resultClasses = [];
|
|
3904
3670
|
entries.forEach(item => {
|
|
3905
3671
|
if (typeof item === 'object') {
|
|
@@ -3913,7 +3679,7 @@
|
|
|
3913
3679
|
}
|
|
3914
3680
|
});
|
|
3915
3681
|
return resultClasses;
|
|
3916
|
-
}
|
|
3682
|
+
};
|
|
3917
3683
|
function addClasses() {
|
|
3918
3684
|
const swiper = this;
|
|
3919
3685
|
const {
|
|
@@ -3923,17 +3689,12 @@
|
|
|
3923
3689
|
el,
|
|
3924
3690
|
device
|
|
3925
3691
|
} = swiper;
|
|
3692
|
+
// core-lite: removed module-specific classes
|
|
3926
3693
|
// prettier-ignore
|
|
3927
3694
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3928
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3929
|
-
}, {
|
|
3930
3695
|
'autoheight': params.autoHeight
|
|
3931
3696
|
}, {
|
|
3932
3697
|
'rtl': rtl
|
|
3933
|
-
}, {
|
|
3934
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3935
|
-
}, {
|
|
3936
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3937
3698
|
}, {
|
|
3938
3699
|
'android': device.android
|
|
3939
3700
|
}, {
|
|
@@ -4030,16 +3791,12 @@
|
|
|
4030
3791
|
autoHeight: false,
|
|
4031
3792
|
// Set wrapper width
|
|
4032
3793
|
setWrapperSize: false,
|
|
4033
|
-
//
|
|
4034
|
-
virtualTranslate: false,
|
|
4035
|
-
// Effects
|
|
3794
|
+
// Effects (core-lite only supports `slide`)
|
|
4036
3795
|
effect: 'slide',
|
|
4037
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
4038
|
-
|
|
4039
3796
|
// Breakpoints
|
|
4040
3797
|
breakpoints: undefined,
|
|
4041
3798
|
breakpointsBase: 'window',
|
|
4042
|
-
// Slides
|
|
3799
|
+
// Slides
|
|
4043
3800
|
spaceBetween: 0,
|
|
4044
3801
|
slidesPerView: 1,
|
|
4045
3802
|
slidesPerGroup: 1,
|
|
@@ -4142,7 +3899,9 @@
|
|
|
4142
3899
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4143
3900
|
params[moduleParamName].auto = true;
|
|
4144
3901
|
}
|
|
4145
|
-
|
|
3902
|
+
|
|
3903
|
+
// Core-lite: keep only pagination auto-init.
|
|
3904
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4146
3905
|
params[moduleParamName].auto = true;
|
|
4147
3906
|
}
|
|
4148
3907
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4268,7 +4027,6 @@
|
|
|
4268
4027
|
// Indexes
|
|
4269
4028
|
activeIndex: 0,
|
|
4270
4029
|
realIndex: 0,
|
|
4271
|
-
//
|
|
4272
4030
|
isBeginning: true,
|
|
4273
4031
|
isEnd: false,
|
|
4274
4032
|
// Props
|
|
@@ -4295,12 +4053,9 @@
|
|
|
4295
4053
|
currentTranslate: undefined,
|
|
4296
4054
|
startTranslate: undefined,
|
|
4297
4055
|
allowThresholdMove: undefined,
|
|
4298
|
-
// Form elements to match
|
|
4299
4056
|
focusableElements: swiper.params.focusableElements,
|
|
4300
|
-
// Last click time
|
|
4301
4057
|
lastClickTime: 0,
|
|
4302
4058
|
clickTimeout: undefined,
|
|
4303
|
-
// Velocities
|
|
4304
4059
|
velocities: [],
|
|
4305
4060
|
allowMomentumBounce: undefined,
|
|
4306
4061
|
startMoving: undefined,
|
|
@@ -4320,7 +4075,8 @@
|
|
|
4320
4075
|
},
|
|
4321
4076
|
// Images
|
|
4322
4077
|
imagesToLoad: [],
|
|
4323
|
-
imagesLoaded: 0
|
|
4078
|
+
imagesLoaded: 0,
|
|
4079
|
+
rtl: params?.rtl
|
|
4324
4080
|
});
|
|
4325
4081
|
swiper.emit('_swiper');
|
|
4326
4082
|
|
|
@@ -4329,7 +4085,6 @@
|
|
|
4329
4085
|
swiper.init();
|
|
4330
4086
|
}
|
|
4331
4087
|
|
|
4332
|
-
// Return app instance
|
|
4333
4088
|
// eslint-disable-next-line no-constructor-return
|
|
4334
4089
|
return swiper;
|
|
4335
4090
|
}
|
|
@@ -4361,16 +4116,6 @@
|
|
|
4361
4116
|
getSlideIndexByData(index) {
|
|
4362
4117
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4363
4118
|
}
|
|
4364
|
-
getSlideIndexWhenGrid(index) {
|
|
4365
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4366
|
-
if (this.params.grid.fill === 'column') {
|
|
4367
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4368
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4369
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4370
|
-
}
|
|
4371
|
-
}
|
|
4372
|
-
return index;
|
|
4373
|
-
}
|
|
4374
4119
|
recalcSlides() {
|
|
4375
4120
|
const swiper = this;
|
|
4376
4121
|
const {
|
|
@@ -4472,21 +4217,15 @@
|
|
|
4472
4217
|
}
|
|
4473
4218
|
}
|
|
4474
4219
|
} else {
|
|
4475
|
-
// eslint-disable-next-line
|
|
4476
4220
|
if (view === 'current') {
|
|
4477
4221
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4478
4222
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4479
|
-
if (slideInView)
|
|
4480
|
-
spv += 1;
|
|
4481
|
-
}
|
|
4223
|
+
if (slideInView) spv += 1;
|
|
4482
4224
|
}
|
|
4483
4225
|
} else {
|
|
4484
|
-
// previous
|
|
4485
4226
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4486
4227
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4487
|
-
if (slideInView)
|
|
4488
|
-
spv += 1;
|
|
4489
|
-
}
|
|
4228
|
+
if (slideInView) spv += 1;
|
|
4490
4229
|
}
|
|
4491
4230
|
}
|
|
4492
4231
|
}
|
|
@@ -4499,14 +4238,11 @@
|
|
|
4499
4238
|
snapGrid,
|
|
4500
4239
|
params
|
|
4501
4240
|
} = swiper;
|
|
4502
|
-
// Breakpoints
|
|
4503
4241
|
if (params.breakpoints) {
|
|
4504
4242
|
swiper.setBreakpoint();
|
|
4505
4243
|
}
|
|
4506
4244
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4507
|
-
if (imageEl.complete)
|
|
4508
|
-
processLazyPreloader(swiper, imageEl);
|
|
4509
|
-
}
|
|
4245
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4510
4246
|
});
|
|
4511
4247
|
swiper.updateSize();
|
|
4512
4248
|
swiper.updateSlides();
|
|
@@ -4520,22 +4256,12 @@
|
|
|
4520
4256
|
swiper.updateSlidesClasses();
|
|
4521
4257
|
}
|
|
4522
4258
|
let translated;
|
|
4523
|
-
if (params.
|
|
4524
|
-
|
|
4525
|
-
if (params.autoHeight) {
|
|
4526
|
-
swiper.updateAutoHeight();
|
|
4527
|
-
}
|
|
4259
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4260
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4528
4261
|
} else {
|
|
4529
|
-
|
|
4530
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4531
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4532
|
-
} else {
|
|
4533
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4534
|
-
}
|
|
4535
|
-
if (!translated) {
|
|
4536
|
-
setTranslate();
|
|
4537
|
-
}
|
|
4262
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4538
4263
|
}
|
|
4264
|
+
if (!translated) setTranslate();
|
|
4539
4265
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4540
4266
|
swiper.checkOverflow();
|
|
4541
4267
|
}
|
|
@@ -4548,7 +4274,6 @@
|
|
|
4548
4274
|
const swiper = this;
|
|
4549
4275
|
const currentDirection = swiper.params.direction;
|
|
4550
4276
|
if (!newDirection) {
|
|
4551
|
-
// eslint-disable-next-line
|
|
4552
4277
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4553
4278
|
}
|
|
4554
4279
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4586,15 +4311,11 @@
|
|
|
4586
4311
|
mount(element) {
|
|
4587
4312
|
const swiper = this;
|
|
4588
4313
|
if (swiper.mounted) return true;
|
|
4589
|
-
|
|
4590
|
-
// Find el
|
|
4591
4314
|
let el = element || swiper.params.el;
|
|
4592
4315
|
if (typeof el === 'string') {
|
|
4593
4316
|
el = document.querySelector(el);
|
|
4594
4317
|
}
|
|
4595
|
-
if (!el)
|
|
4596
|
-
return false;
|
|
4597
|
-
}
|
|
4318
|
+
if (!el) return false;
|
|
4598
4319
|
el.swiper = swiper;
|
|
4599
4320
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4600
4321
|
swiper.isElement = true;
|
|
@@ -4605,12 +4326,10 @@
|
|
|
4605
4326
|
const getWrapper = () => {
|
|
4606
4327
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4607
4328
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4608
|
-
// Children needs to return slot items
|
|
4609
4329
|
return res;
|
|
4610
4330
|
}
|
|
4611
4331
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4612
4332
|
};
|
|
4613
|
-
// Find Wrapper
|
|
4614
4333
|
let wrapperEl = getWrapper();
|
|
4615
4334
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4616
4335
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4619,6 +4338,8 @@
|
|
|
4619
4338
|
wrapperEl.append(slideEl);
|
|
4620
4339
|
});
|
|
4621
4340
|
}
|
|
4341
|
+
const rtl = swiper.params.rtl ?? (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl');
|
|
4342
|
+
const wrongRTL = false;
|
|
4622
4343
|
Object.assign(swiper, {
|
|
4623
4344
|
el,
|
|
4624
4345
|
wrapperEl,
|
|
@@ -4626,9 +4347,9 @@
|
|
|
4626
4347
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4627
4348
|
mounted: true,
|
|
4628
4349
|
// RTL
|
|
4629
|
-
rtl
|
|
4630
|
-
rtlTranslate: swiper.params.direction === 'horizontal' &&
|
|
4631
|
-
wrongRTL
|
|
4350
|
+
rtl,
|
|
4351
|
+
rtlTranslate: swiper.params.direction === 'horizontal' && rtl,
|
|
4352
|
+
wrongRTL
|
|
4632
4353
|
});
|
|
4633
4354
|
return true;
|
|
4634
4355
|
}
|
|
@@ -4645,7 +4366,6 @@
|
|
|
4645
4366
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4646
4367
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4647
4368
|
if (isFirstSlide) {
|
|
4648
|
-
// Move last item to first position when at first slide
|
|
4649
4369
|
const lastSlide = slides.at(-1);
|
|
4650
4370
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4651
4371
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4657,7 +4377,6 @@
|
|
|
4657
4377
|
swiper.setTransition(speed);
|
|
4658
4378
|
swiper.setTranslate(-swiperTranslate);
|
|
4659
4379
|
} else if (isLastSlide) {
|
|
4660
|
-
// Move first item to last position when at last slide
|
|
4661
4380
|
const firstSlide = slides[0];
|
|
4662
4381
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4663
4382
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4678,42 +4397,24 @@
|
|
|
4678
4397
|
const mounted = swiper.mount(el);
|
|
4679
4398
|
if (mounted === false) return swiper;
|
|
4680
4399
|
swiper.emit('beforeInit');
|
|
4681
|
-
|
|
4682
|
-
// Set breakpoint
|
|
4683
4400
|
if (swiper.params.breakpoints) {
|
|
4684
4401
|
swiper.setBreakpoint();
|
|
4685
4402
|
}
|
|
4686
|
-
|
|
4687
|
-
// Add Classes
|
|
4688
4403
|
swiper.addClasses();
|
|
4689
|
-
|
|
4690
|
-
// Update size
|
|
4691
4404
|
swiper.updateSize();
|
|
4692
|
-
|
|
4693
|
-
// Update slides
|
|
4694
4405
|
swiper.updateSlides();
|
|
4695
4406
|
if (swiper.params.watchOverflow) {
|
|
4696
4407
|
swiper.checkOverflow();
|
|
4697
4408
|
}
|
|
4698
|
-
|
|
4699
|
-
// Set Grab Cursor
|
|
4700
4409
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4701
4410
|
swiper.setGrabCursor();
|
|
4702
4411
|
}
|
|
4703
4412
|
|
|
4704
|
-
// Slide
|
|
4705
|
-
|
|
4706
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4707
|
-
} else {
|
|
4708
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4709
|
-
}
|
|
4710
|
-
|
|
4711
|
-
// Create loop
|
|
4413
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4414
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4712
4415
|
if (swiper.params.loop) {
|
|
4713
4416
|
swiper.loopCreate(undefined, true);
|
|
4714
4417
|
}
|
|
4715
|
-
|
|
4716
|
-
// Attach events
|
|
4717
4418
|
swiper.attachEvents();
|
|
4718
4419
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4719
4420
|
if (swiper.isElement) {
|
|
@@ -4723,16 +4424,11 @@
|
|
|
4723
4424
|
if (imageEl.complete) {
|
|
4724
4425
|
processLazyPreloader(swiper, imageEl);
|
|
4725
4426
|
} else {
|
|
4726
|
-
imageEl.addEventListener('load', e =>
|
|
4727
|
-
processLazyPreloader(swiper, e.target);
|
|
4728
|
-
});
|
|
4427
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4729
4428
|
}
|
|
4730
4429
|
});
|
|
4731
4430
|
preload(swiper);
|
|
4732
|
-
|
|
4733
|
-
// Init Flag
|
|
4734
4431
|
swiper.initialized = true;
|
|
4735
|
-
preload(swiper);
|
|
4736
4432
|
|
|
4737
4433
|
// Emit
|
|
4738
4434
|
swiper.emit('init');
|
|
@@ -4757,27 +4453,15 @@
|
|
|
4757
4453
|
return null;
|
|
4758
4454
|
}
|
|
4759
4455
|
swiper.emit('beforeDestroy');
|
|
4760
|
-
|
|
4761
|
-
// Init Flag
|
|
4762
4456
|
swiper.initialized = false;
|
|
4763
|
-
|
|
4764
|
-
// Detach events
|
|
4765
4457
|
swiper.detachEvents();
|
|
4766
|
-
|
|
4767
|
-
// Destroy loop
|
|
4768
4458
|
if (params.loop) {
|
|
4769
4459
|
swiper.loopDestroy();
|
|
4770
4460
|
}
|
|
4771
|
-
|
|
4772
|
-
// Cleanup styles
|
|
4773
4461
|
if (cleanStyles) {
|
|
4774
4462
|
swiper.removeClasses();
|
|
4775
|
-
if (el && typeof el !== 'string')
|
|
4776
|
-
|
|
4777
|
-
}
|
|
4778
|
-
if (wrapperEl) {
|
|
4779
|
-
wrapperEl.removeAttribute('style');
|
|
4780
|
-
}
|
|
4463
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4464
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4781
4465
|
if (slides && slides.length) {
|
|
4782
4466
|
slides.forEach(slideEl => {
|
|
4783
4467
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4787,8 +4471,6 @@
|
|
|
4787
4471
|
}
|
|
4788
4472
|
}
|
|
4789
4473
|
swiper.emit('destroy');
|
|
4790
|
-
|
|
4791
|
-
// Detach emitter events
|
|
4792
4474
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4793
4475
|
swiper.off(eventName);
|
|
4794
4476
|
});
|
|
@@ -10223,7 +9905,7 @@
|
|
|
10223
9905
|
}
|
|
10224
9906
|
|
|
10225
9907
|
/**
|
|
10226
|
-
* Swiper 0.0.
|
|
9908
|
+
* Swiper 0.0.16-dev.1
|
|
10227
9909
|
* Gem SDK - Swiper, Customized of swiper
|
|
10228
9910
|
* https://swiperjs.com
|
|
10229
9911
|
*
|
|
@@ -10565,7 +10247,7 @@
|
|
|
10565
10247
|
}
|
|
10566
10248
|
|
|
10567
10249
|
/**
|
|
10568
|
-
* Swiper Custom Element 0.0.
|
|
10250
|
+
* Swiper Custom Element 0.0.16-dev.1
|
|
10569
10251
|
* Gem SDK - Swiper, Customized of swiper
|
|
10570
10252
|
* https://swiperjs.com
|
|
10571
10253
|
*
|