@gem-sdk/swiper 0.0.14 → 0.0.15-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core-bk/core.less +225 -0
- package/core-bk/core.scss +227 -0
- package/package.json +2 -2
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +161 -558
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +165 -562
- 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 +167 -564
- 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 +165 -562
- 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 +163 -560
- 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/swiper-element-bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper Custom Element 0.0.
|
|
2
|
+
* Swiper Custom Element 0.0.15-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 20, 2026
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
(function () {
|
|
@@ -879,9 +879,6 @@
|
|
|
879
879
|
|
|
880
880
|
function updateSlides() {
|
|
881
881
|
const swiper = this;
|
|
882
|
-
function getDirectionPropertyValue(node, label) {
|
|
883
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
884
|
-
}
|
|
885
882
|
const params = swiper.params;
|
|
886
883
|
const {
|
|
887
884
|
wrapperEl,
|
|
@@ -890,10 +887,8 @@
|
|
|
890
887
|
rtlTranslate: rtl,
|
|
891
888
|
wrongRTL
|
|
892
889
|
} = swiper;
|
|
893
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
894
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
895
890
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
896
|
-
const slidesLength =
|
|
891
|
+
const slidesLength = slides.length;
|
|
897
892
|
let snapGrid = [];
|
|
898
893
|
const slidesGrid = [];
|
|
899
894
|
const slidesSizesGrid = [];
|
|
@@ -911,15 +906,15 @@
|
|
|
911
906
|
let slidePosition = -offsetBefore;
|
|
912
907
|
let prevSlideSize = 0;
|
|
913
908
|
let index = 0;
|
|
914
|
-
if (typeof swiperSize === 'undefined')
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
909
|
+
if (typeof swiperSize === 'undefined') return;
|
|
917
910
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
918
911
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
919
912
|
} else if (typeof spaceBetween === 'string') {
|
|
920
913
|
spaceBetween = parseFloat(spaceBetween);
|
|
921
914
|
}
|
|
922
|
-
|
|
915
|
+
|
|
916
|
+
// core-lite: compute total slides size without optional modules
|
|
917
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
923
918
|
|
|
924
919
|
// reset margins
|
|
925
920
|
slides.forEach(slideEl => {
|
|
@@ -937,49 +932,34 @@
|
|
|
937
932
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
938
933
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
939
934
|
}
|
|
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
935
|
|
|
947
936
|
// Calc slides
|
|
948
937
|
let slideSize;
|
|
949
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
950
|
-
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
|
951
|
-
}).length > 0;
|
|
938
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
952
939
|
for (let i = 0; i < slidesLength; i += 1) {
|
|
953
940
|
slideSize = 0;
|
|
954
941
|
let slide;
|
|
955
942
|
if (slides[i]) slide = slides[i];
|
|
956
|
-
if (gridEnabled) {
|
|
957
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
958
|
-
}
|
|
959
943
|
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
960
944
|
|
|
961
945
|
if (params.slidesPerView === 'auto') {
|
|
962
|
-
if (shouldResetSlideSize) {
|
|
946
|
+
if (shouldResetSlideSize && slides[i]) {
|
|
963
947
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
964
948
|
}
|
|
965
949
|
const slideStyles = getComputedStyle(slide);
|
|
966
950
|
const currentTransform = slide.style.transform;
|
|
967
951
|
const currentWebKitTransform = slide.style.webkitTransform;
|
|
968
|
-
if (currentTransform)
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
if (currentWebKitTransform) {
|
|
972
|
-
slide.style.webkitTransform = 'none';
|
|
973
|
-
}
|
|
952
|
+
if (currentTransform) slide.style.transform = 'none';
|
|
953
|
+
if (currentWebKitTransform) slide.style.webkitTransform = 'none';
|
|
974
954
|
if (params.roundLengths) {
|
|
975
955
|
slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
|
976
956
|
} else {
|
|
977
957
|
// eslint-disable-next-line
|
|
978
|
-
const width =
|
|
979
|
-
const paddingLeft =
|
|
980
|
-
const paddingRight =
|
|
981
|
-
const marginLeft =
|
|
982
|
-
const marginRight =
|
|
958
|
+
const width = parseFloat(slideStyles.getPropertyValue('width')) || slide.offsetWidth;
|
|
959
|
+
const paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left')) || 0;
|
|
960
|
+
const paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right')) || 0;
|
|
961
|
+
const marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left')) || 0;
|
|
962
|
+
const marginRight = parseFloat(slideStyles.getPropertyValue('margin-right')) || 0;
|
|
983
963
|
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
984
964
|
if (boxSizing && boxSizing === 'border-box') {
|
|
985
965
|
slideSize = width + marginLeft + marginRight;
|
|
@@ -991,12 +971,8 @@
|
|
|
991
971
|
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
992
972
|
}
|
|
993
973
|
}
|
|
994
|
-
if (currentTransform)
|
|
995
|
-
|
|
996
|
-
}
|
|
997
|
-
if (currentWebKitTransform) {
|
|
998
|
-
slide.style.webkitTransform = currentWebKitTransform;
|
|
999
|
-
}
|
|
974
|
+
if (currentTransform) slide.style.transform = currentTransform;
|
|
975
|
+
if (currentWebKitTransform) slide.style.webkitTransform = currentWebKitTransform;
|
|
1000
976
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
1001
977
|
} else {
|
|
1002
978
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
@@ -1005,13 +981,13 @@
|
|
|
1005
981
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
1006
982
|
}
|
|
1007
983
|
}
|
|
1008
|
-
if (slides[i])
|
|
1009
|
-
slides[i].swiperSlideSize = slideSize;
|
|
1010
|
-
}
|
|
984
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
1011
985
|
slidesSizesGrid.push(slideSize);
|
|
1012
986
|
if (params.centeredSlides) {
|
|
1013
987
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
1014
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
988
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
989
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
990
|
+
}
|
|
1015
991
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1016
992
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
1017
993
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -1019,55 +995,37 @@
|
|
|
1019
995
|
slidesGrid.push(slidePosition);
|
|
1020
996
|
} else {
|
|
1021
997
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
1022
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
998
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
999
|
+
snapGrid.push(slidePosition);
|
|
1000
|
+
}
|
|
1023
1001
|
slidesGrid.push(slidePosition);
|
|
1024
1002
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
1025
1003
|
}
|
|
1026
|
-
swiper.
|
|
1004
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
1027
1005
|
prevSlideSize = slideSize;
|
|
1028
1006
|
index += 1;
|
|
1029
1007
|
}
|
|
1030
|
-
swiper.
|
|
1031
|
-
if (rtl && wrongRTL &&
|
|
1032
|
-
wrapperEl.style.width = `${swiper.
|
|
1008
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
1009
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
1010
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1033
1011
|
}
|
|
1034
1012
|
if (params.setWrapperSize) {
|
|
1035
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
1036
|
-
}
|
|
1037
|
-
if (gridEnabled) {
|
|
1038
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
1013
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1039
1014
|
}
|
|
1040
1015
|
|
|
1041
|
-
// Remove last
|
|
1016
|
+
// Remove last snap points depending on width (non-centered)
|
|
1042
1017
|
if (!params.centeredSlides) {
|
|
1043
1018
|
const newSlidesGrid = [];
|
|
1044
1019
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
1045
1020
|
let slidesGridItem = snapGrid[i];
|
|
1046
1021
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
1047
|
-
if (snapGrid[i] <= swiper.
|
|
1022
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
1048
1023
|
newSlidesGrid.push(slidesGridItem);
|
|
1049
1024
|
}
|
|
1050
1025
|
}
|
|
1051
1026
|
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;
|
|
1027
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
1028
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1071
1029
|
}
|
|
1072
1030
|
}
|
|
1073
1031
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1075,9 +1033,7 @@
|
|
|
1075
1033
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1076
1034
|
slides.filter((_, slideIndex) => {
|
|
1077
1035
|
if (!params.cssMode || params.loop) return true;
|
|
1078
|
-
if (slideIndex === slides.length - 1)
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1036
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1081
1037
|
return true;
|
|
1082
1038
|
}).forEach(slideEl => {
|
|
1083
1039
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1127,7 +1083,9 @@
|
|
|
1127
1083
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1128
1084
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1129
1085
|
}
|
|
1130
|
-
|
|
1086
|
+
|
|
1087
|
+
// Emit changes
|
|
1088
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
1131
1089
|
swiper.emit('slidesLengthChange');
|
|
1132
1090
|
}
|
|
1133
1091
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1141,7 +1099,7 @@
|
|
|
1141
1099
|
swiper.updateSlidesOffset();
|
|
1142
1100
|
}
|
|
1143
1101
|
swiper.emit('slidesUpdated');
|
|
1144
|
-
if (!
|
|
1102
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1145
1103
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1146
1104
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1147
1105
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1155,20 +1113,13 @@
|
|
|
1155
1113
|
function updateAutoHeight(speed) {
|
|
1156
1114
|
const swiper = this;
|
|
1157
1115
|
const activeSlides = [];
|
|
1158
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1159
|
-
let newHeight = 0;
|
|
1160
|
-
let i;
|
|
1161
1116
|
if (typeof speed === 'number') {
|
|
1162
1117
|
swiper.setTransition(speed);
|
|
1163
1118
|
} else if (speed === true) {
|
|
1164
1119
|
swiper.setTransition(swiper.params.speed);
|
|
1165
1120
|
}
|
|
1166
|
-
const getSlideByIndex = index =>
|
|
1167
|
-
|
|
1168
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1169
|
-
}
|
|
1170
|
-
return swiper.slides[index];
|
|
1171
|
-
};
|
|
1121
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1122
|
+
|
|
1172
1123
|
// Find slides currently in view
|
|
1173
1124
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1174
1125
|
if (swiper.params.centeredSlides) {
|
|
@@ -1176,9 +1127,9 @@
|
|
|
1176
1127
|
activeSlides.push(slide);
|
|
1177
1128
|
});
|
|
1178
1129
|
} else {
|
|
1179
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1130
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1180
1131
|
const index = swiper.activeIndex + i;
|
|
1181
|
-
if (index > swiper.slides.length
|
|
1132
|
+
if (index > swiper.slides.length) break;
|
|
1182
1133
|
activeSlides.push(getSlideByIndex(index));
|
|
1183
1134
|
}
|
|
1184
1135
|
}
|
|
@@ -1187,14 +1138,13 @@
|
|
|
1187
1138
|
}
|
|
1188
1139
|
|
|
1189
1140
|
// Find new height from highest slide in view
|
|
1190
|
-
|
|
1141
|
+
let newHeight = 0;
|
|
1142
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1191
1143
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1192
1144
|
const height = activeSlides[i].offsetHeight;
|
|
1193
1145
|
newHeight = height > newHeight ? height : newHeight;
|
|
1194
1146
|
}
|
|
1195
1147
|
}
|
|
1196
|
-
|
|
1197
|
-
// Update Height
|
|
1198
1148
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1199
1149
|
}
|
|
1200
1150
|
|
|
@@ -1339,46 +1289,16 @@
|
|
|
1339
1289
|
slidesEl,
|
|
1340
1290
|
activeIndex
|
|
1341
1291
|
} = 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;
|
|
1292
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1293
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1294
|
+
const activeSlide = slides[activeIndex];
|
|
1349
1295
|
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
|
-
}
|
|
1296
|
+
let prevSlide;
|
|
1368
1297
|
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
|
-
}
|
|
1298
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1299
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1300
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1301
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1382
1302
|
}
|
|
1383
1303
|
slides.forEach(slideEl => {
|
|
1384
1304
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1469,7 +1389,6 @@
|
|
|
1469
1389
|
activeIndex = i;
|
|
1470
1390
|
}
|
|
1471
1391
|
}
|
|
1472
|
-
// Normalize slideIndex
|
|
1473
1392
|
if (params.normalizeSlideIndex) {
|
|
1474
1393
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1475
1394
|
}
|
|
@@ -1487,16 +1406,6 @@
|
|
|
1487
1406
|
} = swiper;
|
|
1488
1407
|
let activeIndex = newActiveIndex;
|
|
1489
1408
|
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
1409
|
if (typeof activeIndex === 'undefined') {
|
|
1501
1410
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1502
1411
|
}
|
|
@@ -1514,32 +1423,12 @@
|
|
|
1514
1423
|
}
|
|
1515
1424
|
return;
|
|
1516
1425
|
}
|
|
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]) {
|
|
1426
|
+
let realIndex = activeIndex;
|
|
1427
|
+
if (swiper.slides[activeIndex]) {
|
|
1535
1428
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1536
1429
|
if (slideIndex) {
|
|
1537
1430
|
realIndex = parseInt(slideIndex, 10);
|
|
1538
|
-
} else {
|
|
1539
|
-
realIndex = activeIndex;
|
|
1540
1431
|
}
|
|
1541
|
-
} else {
|
|
1542
|
-
realIndex = activeIndex;
|
|
1543
1432
|
}
|
|
1544
1433
|
Object.assign(swiper, {
|
|
1545
1434
|
previousSnapIndex,
|
|
@@ -1586,11 +1475,7 @@
|
|
|
1586
1475
|
}
|
|
1587
1476
|
if (slide && slideFound) {
|
|
1588
1477
|
swiper.clickedSlide = slide;
|
|
1589
|
-
|
|
1590
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1591
|
-
} else {
|
|
1592
|
-
swiper.clickedIndex = slideIndex;
|
|
1593
|
-
}
|
|
1478
|
+
swiper.clickedIndex = slideIndex;
|
|
1594
1479
|
} else {
|
|
1595
1480
|
swiper.clickedSlide = undefined;
|
|
1596
1481
|
swiper.clickedIndex = undefined;
|
|
@@ -1624,9 +1509,6 @@
|
|
|
1624
1509
|
translate,
|
|
1625
1510
|
wrapperEl
|
|
1626
1511
|
} = swiper;
|
|
1627
|
-
if (params.virtualTranslate) {
|
|
1628
|
-
return rtl ? -translate : translate;
|
|
1629
|
-
}
|
|
1630
1512
|
if (params.cssMode) {
|
|
1631
1513
|
return translate;
|
|
1632
1514
|
}
|
|
@@ -1660,7 +1542,7 @@
|
|
|
1660
1542
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1661
1543
|
if (params.cssMode) {
|
|
1662
1544
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1663
|
-
} else
|
|
1545
|
+
} else {
|
|
1664
1546
|
if (swiper.isHorizontal()) {
|
|
1665
1547
|
x -= swiper.cssOverflowAdjustment();
|
|
1666
1548
|
} else {
|
|
@@ -1897,7 +1779,6 @@
|
|
|
1897
1779
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1898
1780
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1899
1781
|
const translate = -snapGrid[snapIndex];
|
|
1900
|
-
// Normalize slideIndex
|
|
1901
1782
|
if (params.normalizeSlideIndex) {
|
|
1902
1783
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1903
1784
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1914,33 +1795,24 @@
|
|
|
1914
1795
|
}
|
|
1915
1796
|
}
|
|
1916
1797
|
}
|
|
1798
|
+
|
|
1917
1799
|
// Directions locks
|
|
1918
1800
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1919
1801
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1920
1802
|
return false;
|
|
1921
1803
|
}
|
|
1922
1804
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1923
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1924
|
-
return false;
|
|
1925
|
-
}
|
|
1805
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1926
1806
|
}
|
|
1927
1807
|
}
|
|
1928
1808
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1929
1809
|
swiper.emit('beforeSlideChangeStart');
|
|
1930
1810
|
}
|
|
1931
|
-
|
|
1932
|
-
// Update progress
|
|
1933
1811
|
swiper.updateProgress(translate);
|
|
1934
1812
|
let direction;
|
|
1935
1813
|
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)) {
|
|
1814
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1942
1815
|
swiper.updateActiveIndex(slideIndex);
|
|
1943
|
-
// Update Height
|
|
1944
1816
|
if (params.autoHeight) {
|
|
1945
1817
|
swiper.updateAutoHeight();
|
|
1946
1818
|
}
|
|
@@ -1958,24 +1830,7 @@
|
|
|
1958
1830
|
const isH = swiper.isHorizontal();
|
|
1959
1831
|
const t = rtl ? translate : -translate;
|
|
1960
1832
|
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
|
-
}
|
|
1833
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1979
1834
|
} else {
|
|
1980
1835
|
if (!swiper.support.smoothScroll) {
|
|
1981
1836
|
animateCSSModeScroll({
|
|
@@ -1993,10 +1848,7 @@
|
|
|
1993
1848
|
return true;
|
|
1994
1849
|
}
|
|
1995
1850
|
const browser = getBrowser();
|
|
1996
|
-
|
|
1997
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1998
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1999
|
-
}
|
|
1851
|
+
browser.isSafari;
|
|
2000
1852
|
swiper.setTransition(speed);
|
|
2001
1853
|
swiper.setTranslate(translate);
|
|
2002
1854
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2167,8 +2019,6 @@
|
|
|
2167
2019
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2168
2020
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2169
2021
|
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
2022
|
const lastSlide = slides[slides.length - 1];
|
|
2173
2023
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2174
2024
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2203,11 +2053,8 @@
|
|
|
2203
2053
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2204
2054
|
}
|
|
2205
2055
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2206
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2207
2056
|
if (params.loop) {
|
|
2208
|
-
if (animating &&
|
|
2209
|
-
|
|
2210
|
-
// Kiểm tra xem loop có bị disable không
|
|
2057
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2211
2058
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2212
2059
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2213
2060
|
swiper.loopFix({
|
|
@@ -2233,8 +2080,7 @@
|
|
|
2233
2080
|
const lastSnapGridIndex = swiper.snapGrid.length - 1;
|
|
2234
2081
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2235
2082
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2236
|
-
|
|
2237
|
-
// Move first item to last position only if active slide is the last slide
|
|
2083
|
+
if (!swiper.params.loop) return;
|
|
2238
2084
|
const firstSlide = slides[0];
|
|
2239
2085
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2240
2086
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2259,17 +2105,14 @@
|
|
|
2259
2105
|
params,
|
|
2260
2106
|
snapGrid,
|
|
2261
2107
|
slidesGrid,
|
|
2262
|
-
rtlTranslate,
|
|
2263
|
-
enabled
|
|
2264
|
-
animating
|
|
2108
|
+
rtlTranslate: rtlTranslate,
|
|
2109
|
+
enabled
|
|
2265
2110
|
} = swiper;
|
|
2266
2111
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2267
2112
|
if (typeof speed === 'undefined') {
|
|
2268
2113
|
speed = swiper.params.speed;
|
|
2269
2114
|
}
|
|
2270
|
-
swiper.virtual && params.virtual.enabled;
|
|
2271
2115
|
if (params.loop) {
|
|
2272
|
-
// Kiểm tra xem loop có bị disable không
|
|
2273
2116
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2274
2117
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2275
2118
|
swiper.loopFix({
|
|
@@ -2286,18 +2129,16 @@
|
|
|
2286
2129
|
}
|
|
2287
2130
|
const normalizedTranslate = normalize(translate);
|
|
2288
2131
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2289
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2290
2132
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2291
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2133
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2292
2134
|
let prevSnapIndex;
|
|
2293
2135
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2294
2136
|
if (normalizedTranslate >= snap) {
|
|
2295
|
-
// prevSnap = snap;
|
|
2296
2137
|
prevSnapIndex = snapIndex;
|
|
2297
2138
|
}
|
|
2298
2139
|
});
|
|
2299
2140
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2300
|
-
prevSnap =
|
|
2141
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2301
2142
|
}
|
|
2302
2143
|
}
|
|
2303
2144
|
let prevIndex = 0;
|
|
@@ -2310,7 +2151,7 @@
|
|
|
2310
2151
|
}
|
|
2311
2152
|
}
|
|
2312
2153
|
if (params.rewind && swiper.isBeginning) {
|
|
2313
|
-
const lastIndex = swiper.
|
|
2154
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2314
2155
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2315
2156
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2316
2157
|
requestAnimationFrame(() => {
|
|
@@ -2324,8 +2165,7 @@
|
|
|
2324
2165
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2325
2166
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2326
2167
|
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
|
|
2168
|
+
if (!swiper.params.loop) return;
|
|
2329
2169
|
const lastSlide = slides[slides.length - 1];
|
|
2330
2170
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2331
2171
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2401,20 +2241,19 @@
|
|
|
2401
2241
|
slidesEl
|
|
2402
2242
|
} = swiper;
|
|
2403
2243
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2404
|
-
|
|
2244
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2405
2245
|
let realIndex;
|
|
2406
2246
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2407
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2408
2247
|
if (params.loop) {
|
|
2409
2248
|
if (swiper.animating) return;
|
|
2410
2249
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2411
2250
|
if (params.centeredSlides) {
|
|
2412
2251
|
swiper.slideToLoop(realIndex);
|
|
2413
|
-
} else if (slideToIndex >
|
|
2252
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2414
2253
|
swiper.loopFix();
|
|
2415
|
-
|
|
2254
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2416
2255
|
nextTick(() => {
|
|
2417
|
-
swiper.slideTo(
|
|
2256
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2418
2257
|
});
|
|
2419
2258
|
} else {
|
|
2420
2259
|
swiper.slideTo(slideToIndex);
|
|
@@ -2441,7 +2280,7 @@
|
|
|
2441
2280
|
params,
|
|
2442
2281
|
slidesEl
|
|
2443
2282
|
} = swiper;
|
|
2444
|
-
if (!params.loop
|
|
2283
|
+
if (!params.loop) return;
|
|
2445
2284
|
const initSlides = () => {
|
|
2446
2285
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2447
2286
|
slides.forEach((el, index) => {
|
|
@@ -2450,21 +2289,17 @@
|
|
|
2450
2289
|
};
|
|
2451
2290
|
const clearBlankSlides = () => {
|
|
2452
2291
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2453
|
-
slides.forEach(el =>
|
|
2454
|
-
el.remove();
|
|
2455
|
-
});
|
|
2292
|
+
slides.forEach(el => el.remove());
|
|
2456
2293
|
if (slides.length > 0) {
|
|
2457
2294
|
swiper.recalcSlides();
|
|
2458
2295
|
swiper.updateSlides();
|
|
2459
2296
|
}
|
|
2460
2297
|
};
|
|
2461
|
-
|
|
2462
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2298
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2463
2299
|
clearBlankSlides();
|
|
2464
2300
|
}
|
|
2465
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2301
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2466
2302
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2467
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2468
2303
|
const addBlankSlides = amountOfSlides => {
|
|
2469
2304
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2470
2305
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2481,16 +2316,6 @@
|
|
|
2481
2316
|
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)');
|
|
2482
2317
|
}
|
|
2483
2318
|
initSlides();
|
|
2484
|
-
} else if (shouldFillGrid) {
|
|
2485
|
-
if (params.loopAddBlankSlides) {
|
|
2486
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2487
|
-
addBlankSlides(slidesToAdd);
|
|
2488
|
-
swiper.recalcSlides();
|
|
2489
|
-
swiper.updateSlides();
|
|
2490
|
-
} else {
|
|
2491
|
-
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)');
|
|
2492
|
-
}
|
|
2493
|
-
initSlides();
|
|
2494
2319
|
} else {
|
|
2495
2320
|
initSlides();
|
|
2496
2321
|
}
|
|
@@ -2509,13 +2334,12 @@
|
|
|
2509
2334
|
setTranslate,
|
|
2510
2335
|
activeSlideIndex,
|
|
2511
2336
|
initial,
|
|
2512
|
-
byController,
|
|
2513
2337
|
byMousewheel
|
|
2514
2338
|
} = _temp === void 0 ? {} : _temp;
|
|
2515
2339
|
const swiper = this;
|
|
2516
2340
|
if (!swiper.params.loop) return;
|
|
2517
2341
|
|
|
2518
|
-
// Disable loop mode
|
|
2342
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2519
2343
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2520
2344
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2521
2345
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2535,21 +2359,6 @@
|
|
|
2535
2359
|
} = params;
|
|
2536
2360
|
swiper.allowSlidePrev = true;
|
|
2537
2361
|
swiper.allowSlideNext = true;
|
|
2538
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2539
|
-
if (slideTo) {
|
|
2540
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2541
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2542
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2543
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2544
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2545
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2549
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2550
|
-
swiper.emit('loopFix');
|
|
2551
|
-
return;
|
|
2552
|
-
}
|
|
2553
2362
|
let slidesPerView = params.slidesPerView;
|
|
2554
2363
|
if (slidesPerView === 'auto') {
|
|
2555
2364
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2559,22 +2368,19 @@
|
|
|
2559
2368
|
slidesPerView = slidesPerView + 1;
|
|
2560
2369
|
}
|
|
2561
2370
|
}
|
|
2562
|
-
const slidesPerGroup = params.
|
|
2371
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2563
2372
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2564
2373
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2565
2374
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2566
2375
|
}
|
|
2567
2376
|
loopedSlides += params.loopAdditionalSlides;
|
|
2568
2377
|
swiper.loopedSlides = loopedSlides;
|
|
2569
|
-
|
|
2570
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2378
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2571
2379
|
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');
|
|
2572
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2573
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2574
2380
|
}
|
|
2575
2381
|
const prependSlidesIndexes = [];
|
|
2576
2382
|
const appendSlidesIndexes = [];
|
|
2577
|
-
const cols =
|
|
2383
|
+
const cols = slides.length;
|
|
2578
2384
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2579
2385
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2580
2386
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2586,24 +2392,15 @@
|
|
|
2586
2392
|
const isPrev = direction === 'prev' || !direction;
|
|
2587
2393
|
let slidesPrepended = 0;
|
|
2588
2394
|
let slidesAppended = 0;
|
|
2589
|
-
const activeColIndex =
|
|
2395
|
+
const activeColIndex = activeSlideIndex;
|
|
2590
2396
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2397
|
+
|
|
2591
2398
|
// prepend last slides before start
|
|
2592
2399
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2593
2400
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2594
2401
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2595
2402
|
const index = i - Math.floor(i / cols) * cols;
|
|
2596
|
-
|
|
2597
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2598
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2599
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2600
|
-
}
|
|
2601
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2602
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2603
|
-
// });
|
|
2604
|
-
} else {
|
|
2605
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2606
|
-
}
|
|
2403
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2607
2404
|
}
|
|
2608
2405
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2609
2406
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2612,27 +2409,13 @@
|
|
|
2612
2409
|
}
|
|
2613
2410
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2614
2411
|
const index = i - Math.floor(i / cols) * cols;
|
|
2615
|
-
|
|
2616
|
-
slides.forEach((slide, slideIndex) => {
|
|
2617
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2618
|
-
});
|
|
2619
|
-
} else {
|
|
2620
|
-
appendSlidesIndexes.push(index);
|
|
2621
|
-
}
|
|
2412
|
+
appendSlidesIndexes.push(index);
|
|
2622
2413
|
}
|
|
2623
2414
|
}
|
|
2624
2415
|
swiper.__preventObserver__ = true;
|
|
2625
2416
|
requestAnimationFrame(() => {
|
|
2626
2417
|
swiper.__preventObserver__ = false;
|
|
2627
2418
|
});
|
|
2628
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2629
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2630
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2631
|
-
}
|
|
2632
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2633
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
2419
|
if (isPrev) {
|
|
2637
2420
|
prependSlidesIndexes.forEach(index => {
|
|
2638
2421
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2650,10 +2433,6 @@
|
|
|
2650
2433
|
swiper.recalcSlides();
|
|
2651
2434
|
if (params.slidesPerView === 'auto') {
|
|
2652
2435
|
swiper.updateSlides();
|
|
2653
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2654
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2655
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2656
|
-
});
|
|
2657
2436
|
}
|
|
2658
2437
|
if (params.watchSlidesProgress) {
|
|
2659
2438
|
swiper.updateSlidesOffset();
|
|
@@ -2673,12 +2452,10 @@
|
|
|
2673
2452
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2674
2453
|
}
|
|
2675
2454
|
}
|
|
2676
|
-
} else {
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2681
|
-
}
|
|
2455
|
+
} else if (setTranslate) {
|
|
2456
|
+
const shift = prependSlidesIndexes.length;
|
|
2457
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2458
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2682
2459
|
}
|
|
2683
2460
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2684
2461
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2694,36 +2471,14 @@
|
|
|
2694
2471
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2695
2472
|
}
|
|
2696
2473
|
}
|
|
2697
|
-
} else {
|
|
2698
|
-
const shift =
|
|
2474
|
+
} else if (setTranslate) {
|
|
2475
|
+
const shift = appendSlidesIndexes.length;
|
|
2699
2476
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2700
2477
|
}
|
|
2701
2478
|
}
|
|
2702
2479
|
}
|
|
2703
2480
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2704
2481
|
swiper.allowSlideNext = allowSlideNext;
|
|
2705
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2706
|
-
const loopParams = {
|
|
2707
|
-
slideRealIndex,
|
|
2708
|
-
direction,
|
|
2709
|
-
setTranslate,
|
|
2710
|
-
activeSlideIndex,
|
|
2711
|
-
byController: true
|
|
2712
|
-
};
|
|
2713
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2714
|
-
swiper.controller.control.forEach(c => {
|
|
2715
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2716
|
-
...loopParams,
|
|
2717
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2718
|
-
});
|
|
2719
|
-
});
|
|
2720
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2721
|
-
swiper.controller.control.loopFix({
|
|
2722
|
-
...loopParams,
|
|
2723
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2724
|
-
});
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
2482
|
swiper.emit('loopFix');
|
|
2728
2483
|
}
|
|
2729
2484
|
|
|
@@ -2740,7 +2495,7 @@
|
|
|
2740
2495
|
const swiper = this;
|
|
2741
2496
|
if (!swiper.params.loop) return;
|
|
2742
2497
|
|
|
2743
|
-
// Disable loop mode
|
|
2498
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2744
2499
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2745
2500
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2746
2501
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2779,7 +2534,7 @@
|
|
|
2779
2534
|
}
|
|
2780
2535
|
loopedSlides += params.loopAdditionalSlides;
|
|
2781
2536
|
swiper.loopedSlides = loopedSlides;
|
|
2782
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2537
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2783
2538
|
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');
|
|
2784
2539
|
}
|
|
2785
2540
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2805,20 +2560,16 @@
|
|
|
2805
2560
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2806
2561
|
}
|
|
2807
2562
|
|
|
2808
|
-
//
|
|
2563
|
+
// DocumentFragment to hold slide clones
|
|
2809
2564
|
const cloneFragment = document.createDocumentFragment();
|
|
2810
2565
|
|
|
2811
|
-
// Clone
|
|
2566
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2812
2567
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2813
2568
|
if (slides[index]) {
|
|
2814
2569
|
const originalSlide = slides[index];
|
|
2815
2570
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2816
|
-
|
|
2817
|
-
// Đánh dấu slide clone
|
|
2818
2571
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2819
2572
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2820
|
-
|
|
2821
|
-
// Thêm clone vào fragment
|
|
2822
2573
|
cloneFragment.appendChild(clonedSlide);
|
|
2823
2574
|
}
|
|
2824
2575
|
});
|
|
@@ -2839,32 +2590,28 @@
|
|
|
2839
2590
|
});
|
|
2840
2591
|
}
|
|
2841
2592
|
|
|
2842
|
-
//
|
|
2593
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2843
2594
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2844
2595
|
clonedSlides.sort((a, b) => {
|
|
2845
2596
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2846
2597
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2847
2598
|
return indexA - indexB;
|
|
2848
2599
|
});
|
|
2849
|
-
|
|
2850
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2851
2600
|
cloneFragment.innerHTML = '';
|
|
2852
2601
|
clonedSlides.forEach(slide => {
|
|
2853
2602
|
cloneFragment.appendChild(slide);
|
|
2854
2603
|
});
|
|
2855
2604
|
|
|
2856
|
-
//
|
|
2605
|
+
// Place fragment into the right position
|
|
2857
2606
|
if (isPrev) {
|
|
2858
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2859
2607
|
slidesEl.appendChild(cloneFragment);
|
|
2860
2608
|
} else if (isNext) {
|
|
2861
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2862
2609
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2863
2610
|
}
|
|
2864
2611
|
swiper.recalcSlides();
|
|
2865
2612
|
swiper.updateSlides();
|
|
2866
2613
|
|
|
2867
|
-
//
|
|
2614
|
+
// Find old active slide index after recalculation
|
|
2868
2615
|
let oldActiveIndex = null;
|
|
2869
2616
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2870
2617
|
const child = slidesEl.children[i];
|
|
@@ -2877,7 +2624,7 @@
|
|
|
2877
2624
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2878
2625
|
}
|
|
2879
2626
|
|
|
2880
|
-
//
|
|
2627
|
+
// Update translate after removing clones for animation
|
|
2881
2628
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2882
2629
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2883
2630
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2903,7 +2650,8 @@
|
|
|
2903
2650
|
}
|
|
2904
2651
|
swiper.setTranslate(updateTranslate);
|
|
2905
2652
|
}
|
|
2906
|
-
|
|
2653
|
+
|
|
2654
|
+
// Remove clones
|
|
2907
2655
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2908
2656
|
cloneSlides.forEach(cloneSlide => {
|
|
2909
2657
|
if (cloneSlide.parentNode) {
|
|
@@ -2933,7 +2681,7 @@
|
|
|
2933
2681
|
params,
|
|
2934
2682
|
slidesEl
|
|
2935
2683
|
} = swiper;
|
|
2936
|
-
if (!params.loop || !slidesEl
|
|
2684
|
+
if (!params.loop || !slidesEl) return;
|
|
2937
2685
|
swiper.recalcSlides();
|
|
2938
2686
|
const newSlidesOrder = [];
|
|
2939
2687
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2994,7 +2742,6 @@
|
|
|
2994
2742
|
unsetGrabCursor
|
|
2995
2743
|
};
|
|
2996
2744
|
|
|
2997
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2998
2745
|
function closestElement(selector, base) {
|
|
2999
2746
|
if (base === void 0) {
|
|
3000
2747
|
base = this;
|
|
@@ -3003,9 +2750,7 @@
|
|
|
3003
2750
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
3004
2751
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
3005
2752
|
const found = el.closest(selector);
|
|
3006
|
-
if (!found && !el.getRootNode)
|
|
3007
|
-
return null;
|
|
3008
|
-
}
|
|
2753
|
+
if (!found && !el.getRootNode) return null;
|
|
3009
2754
|
return found || __closestFrom(el.getRootNode().host);
|
|
3010
2755
|
}
|
|
3011
2756
|
return __closestFrom(base);
|
|
@@ -3033,9 +2778,7 @@
|
|
|
3033
2778
|
if (e.originalEvent) e = e.originalEvent;
|
|
3034
2779
|
const data = swiper.touchEventsData;
|
|
3035
2780
|
if (e.type === 'pointerdown') {
|
|
3036
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
3037
|
-
return;
|
|
3038
|
-
}
|
|
2781
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
3039
2782
|
data.pointerId = e.pointerId;
|
|
3040
2783
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
3041
2784
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3052,9 +2795,7 @@
|
|
|
3052
2795
|
} = swiper;
|
|
3053
2796
|
if (!enabled) return;
|
|
3054
2797
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3055
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3056
|
-
return;
|
|
3057
|
-
}
|
|
2798
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3058
2799
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3059
2800
|
swiper.loopFix();
|
|
3060
2801
|
}
|
|
@@ -3065,8 +2806,6 @@
|
|
|
3065
2806
|
if ('which' in e && e.which === 3) return;
|
|
3066
2807
|
if ('button' in e && e.button > 0) return;
|
|
3067
2808
|
if (data.isTouched && data.isMoved) return;
|
|
3068
|
-
|
|
3069
|
-
// change target el for shadow root component
|
|
3070
2809
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3071
2810
|
// eslint-disable-next-line
|
|
3072
2811
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3075,8 +2814,6 @@
|
|
|
3075
2814
|
}
|
|
3076
2815
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3077
2816
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3078
|
-
|
|
3079
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3080
2817
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3081
2818
|
swiper.allowClick = true;
|
|
3082
2819
|
return;
|
|
@@ -3088,12 +2825,7 @@
|
|
|
3088
2825
|
touches.currentY = e.pageY;
|
|
3089
2826
|
const startX = touches.currentX;
|
|
3090
2827
|
const startY = touches.currentY;
|
|
3091
|
-
|
|
3092
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3093
|
-
|
|
3094
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3095
|
-
return;
|
|
3096
|
-
}
|
|
2828
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3097
2829
|
Object.assign(data, {
|
|
3098
2830
|
isTouched: true,
|
|
3099
2831
|
isMoved: false,
|
|
@@ -3122,9 +2854,6 @@
|
|
|
3122
2854
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3123
2855
|
e.preventDefault();
|
|
3124
2856
|
}
|
|
3125
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3126
|
-
swiper.freeMode.onTouchStart();
|
|
3127
|
-
}
|
|
3128
2857
|
swiper.emit('touchStart', e);
|
|
3129
2858
|
}
|
|
3130
2859
|
|
|
@@ -3143,7 +2872,7 @@
|
|
|
3143
2872
|
let e = event;
|
|
3144
2873
|
if (e.originalEvent) e = e.originalEvent;
|
|
3145
2874
|
if (e.type === 'pointermove') {
|
|
3146
|
-
if (data.touchId !== null) return;
|
|
2875
|
+
if (data.touchId !== null) return;
|
|
3147
2876
|
const id = e.pointerId;
|
|
3148
2877
|
if (id !== data.pointerId) return;
|
|
3149
2878
|
}
|
|
@@ -3184,7 +2913,6 @@
|
|
|
3184
2913
|
}
|
|
3185
2914
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3186
2915
|
if (swiper.isVertical()) {
|
|
3187
|
-
// Vertical
|
|
3188
2916
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3189
2917
|
data.isTouched = false;
|
|
3190
2918
|
data.isMoved = false;
|
|
@@ -3286,7 +3014,6 @@
|
|
|
3286
3014
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3287
3015
|
}
|
|
3288
3016
|
data.allowMomentumBounce = false;
|
|
3289
|
-
// Grab Cursor
|
|
3290
3017
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3291
3018
|
swiper.setGrabCursor(true);
|
|
3292
3019
|
}
|
|
@@ -3357,8 +3084,6 @@
|
|
|
3357
3084
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3358
3085
|
data.currentTranslate = data.startTranslate;
|
|
3359
3086
|
}
|
|
3360
|
-
|
|
3361
|
-
// Threshold
|
|
3362
3087
|
if (params.threshold > 0) {
|
|
3363
3088
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3364
3089
|
if (!data.allowThresholdMove) {
|
|
@@ -3376,17 +3101,12 @@
|
|
|
3376
3101
|
}
|
|
3377
3102
|
if (!params.followFinger || params.cssMode) return;
|
|
3378
3103
|
|
|
3379
|
-
//
|
|
3380
|
-
if (params.
|
|
3104
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3105
|
+
if (params.watchSlidesProgress) {
|
|
3381
3106
|
swiper.updateActiveIndex();
|
|
3382
3107
|
swiper.updateSlidesClasses();
|
|
3383
3108
|
}
|
|
3384
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3385
|
-
swiper.freeMode.onTouchMove();
|
|
3386
|
-
}
|
|
3387
|
-
// Update progress
|
|
3388
3109
|
swiper.updateProgress(data.currentTranslate);
|
|
3389
|
-
// Update translate
|
|
3390
3110
|
swiper.setTranslate(data.currentTranslate);
|
|
3391
3111
|
}
|
|
3392
3112
|
|
|
@@ -3398,7 +3118,7 @@
|
|
|
3398
3118
|
let targetTouch;
|
|
3399
3119
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3400
3120
|
if (!isTouchEvent) {
|
|
3401
|
-
if (data.touchId !== null) return;
|
|
3121
|
+
if (data.touchId !== null) return;
|
|
3402
3122
|
if (e.pointerId !== data.pointerId) return;
|
|
3403
3123
|
targetTouch = e;
|
|
3404
3124
|
} else {
|
|
@@ -3407,9 +3127,7 @@
|
|
|
3407
3127
|
}
|
|
3408
3128
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3409
3129
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3410
|
-
if (!proceed)
|
|
3411
|
-
return;
|
|
3412
|
-
}
|
|
3130
|
+
if (!proceed) return;
|
|
3413
3131
|
}
|
|
3414
3132
|
data.pointerId = null;
|
|
3415
3133
|
data.touchId = null;
|
|
@@ -3427,9 +3145,7 @@
|
|
|
3427
3145
|
}
|
|
3428
3146
|
data.allowTouchCallbacks = false;
|
|
3429
3147
|
if (!data.isTouched) {
|
|
3430
|
-
if (data.isMoved && params.grabCursor)
|
|
3431
|
-
swiper.setGrabCursor(false);
|
|
3432
|
-
}
|
|
3148
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3433
3149
|
data.isMoved = false;
|
|
3434
3150
|
data.startMoving = false;
|
|
3435
3151
|
return;
|
|
@@ -3439,8 +3155,6 @@
|
|
|
3439
3155
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3440
3156
|
swiper.setGrabCursor(false);
|
|
3441
3157
|
}
|
|
3442
|
-
|
|
3443
|
-
// Time diff
|
|
3444
3158
|
const touchEndTime = now();
|
|
3445
3159
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3446
3160
|
|
|
@@ -3467,20 +3181,8 @@
|
|
|
3467
3181
|
data.isMoved = false;
|
|
3468
3182
|
data.startMoving = false;
|
|
3469
3183
|
let currentPos;
|
|
3470
|
-
if (params.followFinger)
|
|
3471
|
-
|
|
3472
|
-
} else {
|
|
3473
|
-
currentPos = -data.currentTranslate;
|
|
3474
|
-
}
|
|
3475
|
-
if (params.cssMode) {
|
|
3476
|
-
return;
|
|
3477
|
-
}
|
|
3478
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3479
|
-
swiper.freeMode.onTouchEnd({
|
|
3480
|
-
currentPos
|
|
3481
|
-
});
|
|
3482
|
-
return;
|
|
3483
|
-
}
|
|
3184
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3185
|
+
if (params.cssMode) return;
|
|
3484
3186
|
|
|
3485
3187
|
// Find current slide
|
|
3486
3188
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3502,22 +3204,22 @@
|
|
|
3502
3204
|
let rewindLastIndex = null;
|
|
3503
3205
|
if (params.rewind) {
|
|
3504
3206
|
if (swiper.isBeginning) {
|
|
3505
|
-
rewindLastIndex =
|
|
3207
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3506
3208
|
} else if (swiper.isEnd) {
|
|
3507
3209
|
rewindFirstIndex = 0;
|
|
3508
3210
|
}
|
|
3509
3211
|
}
|
|
3510
|
-
// Find current slide size
|
|
3511
3212
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3512
3213
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3513
3214
|
if (timeDiff > params.longSwipesMs) {
|
|
3514
|
-
// Long touches
|
|
3515
3215
|
if (!params.longSwipes) {
|
|
3516
3216
|
swiper.slideTo(swiper.activeIndex);
|
|
3517
3217
|
return;
|
|
3518
3218
|
}
|
|
3519
3219
|
if (swiper.swipeDirection === 'next') {
|
|
3520
|
-
if (ratio >= params.longSwipesRatio)
|
|
3220
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3221
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3222
|
+
} else swiper.slideTo(stopIndex);
|
|
3521
3223
|
}
|
|
3522
3224
|
if (swiper.swipeDirection === 'prev') {
|
|
3523
3225
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3569,7 +3271,6 @@
|
|
|
3569
3271
|
allowSlidePrev,
|
|
3570
3272
|
snapGrid
|
|
3571
3273
|
} = swiper;
|
|
3572
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3573
3274
|
|
|
3574
3275
|
// Disable locks on resize
|
|
3575
3276
|
swiper.allowSlideNext = true;
|
|
@@ -3577,15 +3278,12 @@
|
|
|
3577
3278
|
swiper.updateSize();
|
|
3578
3279
|
swiper.updateSlides();
|
|
3579
3280
|
swiper.updateSlidesClasses();
|
|
3580
|
-
|
|
3581
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3281
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3582
3282
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3283
|
+
} else if (swiper.params.loop) {
|
|
3284
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3583
3285
|
} else {
|
|
3584
|
-
|
|
3585
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3586
|
-
} else {
|
|
3587
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3588
|
-
}
|
|
3286
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3589
3287
|
}
|
|
3590
3288
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3591
3289
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3595,10 +3293,11 @@
|
|
|
3595
3293
|
}
|
|
3596
3294
|
}, 500);
|
|
3597
3295
|
}
|
|
3296
|
+
|
|
3598
3297
|
// Return locks after resize
|
|
3599
3298
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3600
3299
|
swiper.allowSlideNext = allowSlideNext;
|
|
3601
|
-
if (
|
|
3300
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3602
3301
|
swiper.checkOverflow();
|
|
3603
3302
|
}
|
|
3604
3303
|
}
|
|
@@ -3652,6 +3351,10 @@
|
|
|
3652
3351
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3653
3352
|
return;
|
|
3654
3353
|
}
|
|
3354
|
+
const el = e?.target;
|
|
3355
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3356
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3357
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3655
3358
|
swiper.update();
|
|
3656
3359
|
}
|
|
3657
3360
|
|
|
@@ -3763,8 +3466,15 @@
|
|
|
3763
3466
|
detachEvents
|
|
3764
3467
|
};
|
|
3765
3468
|
|
|
3766
|
-
const
|
|
3767
|
-
|
|
3469
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3470
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3471
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3472
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3473
|
+
swiper[prop].disable();
|
|
3474
|
+
}
|
|
3475
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3476
|
+
swiper[prop].enable();
|
|
3477
|
+
}
|
|
3768
3478
|
};
|
|
3769
3479
|
function setBreakpoint() {
|
|
3770
3480
|
const swiper = this;
|
|
@@ -3785,38 +3495,20 @@
|
|
|
3785
3495
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3786
3496
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3787
3497
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3788
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3789
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3790
3498
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3791
3499
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3792
3500
|
const wasEnabled = params.enabled;
|
|
3793
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3794
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3795
|
-
swiper.emitContainerClasses();
|
|
3796
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3797
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3798
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3799
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3800
|
-
}
|
|
3801
|
-
swiper.emitContainerClasses();
|
|
3802
|
-
}
|
|
3803
3501
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3804
3502
|
swiper.unsetGrabCursor();
|
|
3805
3503
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3806
3504
|
swiper.setGrabCursor();
|
|
3807
3505
|
}
|
|
3808
3506
|
|
|
3809
|
-
//
|
|
3810
|
-
['navigation', 'pagination'
|
|
3507
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3508
|
+
const modules = ['navigation', 'pagination'];
|
|
3509
|
+
modules.forEach(prop => {
|
|
3811
3510
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3812
|
-
|
|
3813
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3814
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3815
|
-
swiper[prop].disable();
|
|
3816
|
-
}
|
|
3817
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3818
|
-
swiper[prop].enable();
|
|
3819
|
-
}
|
|
3511
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3820
3512
|
});
|
|
3821
3513
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3822
3514
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3898,7 +3590,7 @@
|
|
|
3898
3590
|
getBreakpoint
|
|
3899
3591
|
};
|
|
3900
3592
|
|
|
3901
|
-
|
|
3593
|
+
const prepareClasses = (entries, prefix) => {
|
|
3902
3594
|
const resultClasses = [];
|
|
3903
3595
|
entries.forEach(item => {
|
|
3904
3596
|
if (typeof item === 'object') {
|
|
@@ -3912,7 +3604,7 @@
|
|
|
3912
3604
|
}
|
|
3913
3605
|
});
|
|
3914
3606
|
return resultClasses;
|
|
3915
|
-
}
|
|
3607
|
+
};
|
|
3916
3608
|
function addClasses() {
|
|
3917
3609
|
const swiper = this;
|
|
3918
3610
|
const {
|
|
@@ -3922,17 +3614,12 @@
|
|
|
3922
3614
|
el,
|
|
3923
3615
|
device
|
|
3924
3616
|
} = swiper;
|
|
3617
|
+
// core-lite: removed module-specific classes
|
|
3925
3618
|
// prettier-ignore
|
|
3926
3619
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3927
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3928
|
-
}, {
|
|
3929
3620
|
'autoheight': params.autoHeight
|
|
3930
3621
|
}, {
|
|
3931
3622
|
'rtl': rtl
|
|
3932
|
-
}, {
|
|
3933
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3934
|
-
}, {
|
|
3935
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3936
3623
|
}, {
|
|
3937
3624
|
'android': device.android
|
|
3938
3625
|
}, {
|
|
@@ -4029,16 +3716,12 @@
|
|
|
4029
3716
|
autoHeight: false,
|
|
4030
3717
|
// Set wrapper width
|
|
4031
3718
|
setWrapperSize: false,
|
|
4032
|
-
//
|
|
4033
|
-
virtualTranslate: false,
|
|
4034
|
-
// Effects
|
|
3719
|
+
// Effects (core-lite only supports `slide`)
|
|
4035
3720
|
effect: 'slide',
|
|
4036
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
4037
|
-
|
|
4038
3721
|
// Breakpoints
|
|
4039
3722
|
breakpoints: undefined,
|
|
4040
3723
|
breakpointsBase: 'window',
|
|
4041
|
-
// Slides
|
|
3724
|
+
// Slides
|
|
4042
3725
|
spaceBetween: 0,
|
|
4043
3726
|
slidesPerView: 1,
|
|
4044
3727
|
slidesPerGroup: 1,
|
|
@@ -4141,7 +3824,9 @@
|
|
|
4141
3824
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4142
3825
|
params[moduleParamName].auto = true;
|
|
4143
3826
|
}
|
|
4144
|
-
|
|
3827
|
+
|
|
3828
|
+
// Core-lite: keep only pagination auto-init.
|
|
3829
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4145
3830
|
params[moduleParamName].auto = true;
|
|
4146
3831
|
}
|
|
4147
3832
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4267,7 +3952,6 @@
|
|
|
4267
3952
|
// Indexes
|
|
4268
3953
|
activeIndex: 0,
|
|
4269
3954
|
realIndex: 0,
|
|
4270
|
-
//
|
|
4271
3955
|
isBeginning: true,
|
|
4272
3956
|
isEnd: false,
|
|
4273
3957
|
// Props
|
|
@@ -4294,12 +3978,9 @@
|
|
|
4294
3978
|
currentTranslate: undefined,
|
|
4295
3979
|
startTranslate: undefined,
|
|
4296
3980
|
allowThresholdMove: undefined,
|
|
4297
|
-
// Form elements to match
|
|
4298
3981
|
focusableElements: swiper.params.focusableElements,
|
|
4299
|
-
// Last click time
|
|
4300
3982
|
lastClickTime: 0,
|
|
4301
3983
|
clickTimeout: undefined,
|
|
4302
|
-
// Velocities
|
|
4303
3984
|
velocities: [],
|
|
4304
3985
|
allowMomentumBounce: undefined,
|
|
4305
3986
|
startMoving: undefined,
|
|
@@ -4328,7 +4009,6 @@
|
|
|
4328
4009
|
swiper.init();
|
|
4329
4010
|
}
|
|
4330
4011
|
|
|
4331
|
-
// Return app instance
|
|
4332
4012
|
// eslint-disable-next-line no-constructor-return
|
|
4333
4013
|
return swiper;
|
|
4334
4014
|
}
|
|
@@ -4360,16 +4040,6 @@
|
|
|
4360
4040
|
getSlideIndexByData(index) {
|
|
4361
4041
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4362
4042
|
}
|
|
4363
|
-
getSlideIndexWhenGrid(index) {
|
|
4364
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4365
|
-
if (this.params.grid.fill === 'column') {
|
|
4366
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4367
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4368
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4369
|
-
}
|
|
4370
|
-
}
|
|
4371
|
-
return index;
|
|
4372
|
-
}
|
|
4373
4043
|
recalcSlides() {
|
|
4374
4044
|
const swiper = this;
|
|
4375
4045
|
const {
|
|
@@ -4471,21 +4141,15 @@
|
|
|
4471
4141
|
}
|
|
4472
4142
|
}
|
|
4473
4143
|
} else {
|
|
4474
|
-
// eslint-disable-next-line
|
|
4475
4144
|
if (view === 'current') {
|
|
4476
4145
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4477
4146
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4478
|
-
if (slideInView)
|
|
4479
|
-
spv += 1;
|
|
4480
|
-
}
|
|
4147
|
+
if (slideInView) spv += 1;
|
|
4481
4148
|
}
|
|
4482
4149
|
} else {
|
|
4483
|
-
// previous
|
|
4484
4150
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4485
4151
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4486
|
-
if (slideInView)
|
|
4487
|
-
spv += 1;
|
|
4488
|
-
}
|
|
4152
|
+
if (slideInView) spv += 1;
|
|
4489
4153
|
}
|
|
4490
4154
|
}
|
|
4491
4155
|
}
|
|
@@ -4498,14 +4162,11 @@
|
|
|
4498
4162
|
snapGrid,
|
|
4499
4163
|
params
|
|
4500
4164
|
} = swiper;
|
|
4501
|
-
// Breakpoints
|
|
4502
4165
|
if (params.breakpoints) {
|
|
4503
4166
|
swiper.setBreakpoint();
|
|
4504
4167
|
}
|
|
4505
4168
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4506
|
-
if (imageEl.complete)
|
|
4507
|
-
processLazyPreloader(swiper, imageEl);
|
|
4508
|
-
}
|
|
4169
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4509
4170
|
});
|
|
4510
4171
|
swiper.updateSize();
|
|
4511
4172
|
swiper.updateSlides();
|
|
@@ -4519,22 +4180,12 @@
|
|
|
4519
4180
|
swiper.updateSlidesClasses();
|
|
4520
4181
|
}
|
|
4521
4182
|
let translated;
|
|
4522
|
-
if (params.
|
|
4523
|
-
|
|
4524
|
-
if (params.autoHeight) {
|
|
4525
|
-
swiper.updateAutoHeight();
|
|
4526
|
-
}
|
|
4183
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4184
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4527
4185
|
} else {
|
|
4528
|
-
|
|
4529
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4530
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4531
|
-
} else {
|
|
4532
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4533
|
-
}
|
|
4534
|
-
if (!translated) {
|
|
4535
|
-
setTranslate();
|
|
4536
|
-
}
|
|
4186
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4537
4187
|
}
|
|
4188
|
+
if (!translated) setTranslate();
|
|
4538
4189
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4539
4190
|
swiper.checkOverflow();
|
|
4540
4191
|
}
|
|
@@ -4547,7 +4198,6 @@
|
|
|
4547
4198
|
const swiper = this;
|
|
4548
4199
|
const currentDirection = swiper.params.direction;
|
|
4549
4200
|
if (!newDirection) {
|
|
4550
|
-
// eslint-disable-next-line
|
|
4551
4201
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4552
4202
|
}
|
|
4553
4203
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4585,15 +4235,11 @@
|
|
|
4585
4235
|
mount(element) {
|
|
4586
4236
|
const swiper = this;
|
|
4587
4237
|
if (swiper.mounted) return true;
|
|
4588
|
-
|
|
4589
|
-
// Find el
|
|
4590
4238
|
let el = element || swiper.params.el;
|
|
4591
4239
|
if (typeof el === 'string') {
|
|
4592
4240
|
el = document.querySelector(el);
|
|
4593
4241
|
}
|
|
4594
|
-
if (!el)
|
|
4595
|
-
return false;
|
|
4596
|
-
}
|
|
4242
|
+
if (!el) return false;
|
|
4597
4243
|
el.swiper = swiper;
|
|
4598
4244
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4599
4245
|
swiper.isElement = true;
|
|
@@ -4604,12 +4250,10 @@
|
|
|
4604
4250
|
const getWrapper = () => {
|
|
4605
4251
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4606
4252
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4607
|
-
// Children needs to return slot items
|
|
4608
4253
|
return res;
|
|
4609
4254
|
}
|
|
4610
4255
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4611
4256
|
};
|
|
4612
|
-
// Find Wrapper
|
|
4613
4257
|
let wrapperEl = getWrapper();
|
|
4614
4258
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4615
4259
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4624,7 +4268,6 @@
|
|
|
4624
4268
|
slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
|
4625
4269
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4626
4270
|
mounted: true,
|
|
4627
|
-
// RTL
|
|
4628
4271
|
rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
|
4629
4272
|
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
|
4630
4273
|
wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
|
@@ -4644,7 +4287,6 @@
|
|
|
4644
4287
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4645
4288
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4646
4289
|
if (isFirstSlide) {
|
|
4647
|
-
// Move last item to first position when at first slide
|
|
4648
4290
|
const lastSlide = slides.at(-1);
|
|
4649
4291
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4650
4292
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4656,7 +4298,6 @@
|
|
|
4656
4298
|
swiper.setTransition(speed);
|
|
4657
4299
|
swiper.setTranslate(-swiperTranslate);
|
|
4658
4300
|
} else if (isLastSlide) {
|
|
4659
|
-
// Move first item to last position when at last slide
|
|
4660
4301
|
const firstSlide = slides[0];
|
|
4661
4302
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4662
4303
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4677,42 +4318,24 @@
|
|
|
4677
4318
|
const mounted = swiper.mount(el);
|
|
4678
4319
|
if (mounted === false) return swiper;
|
|
4679
4320
|
swiper.emit('beforeInit');
|
|
4680
|
-
|
|
4681
|
-
// Set breakpoint
|
|
4682
4321
|
if (swiper.params.breakpoints) {
|
|
4683
4322
|
swiper.setBreakpoint();
|
|
4684
4323
|
}
|
|
4685
|
-
|
|
4686
|
-
// Add Classes
|
|
4687
4324
|
swiper.addClasses();
|
|
4688
|
-
|
|
4689
|
-
// Update size
|
|
4690
4325
|
swiper.updateSize();
|
|
4691
|
-
|
|
4692
|
-
// Update slides
|
|
4693
4326
|
swiper.updateSlides();
|
|
4694
4327
|
if (swiper.params.watchOverflow) {
|
|
4695
4328
|
swiper.checkOverflow();
|
|
4696
4329
|
}
|
|
4697
|
-
|
|
4698
|
-
// Set Grab Cursor
|
|
4699
4330
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4700
4331
|
swiper.setGrabCursor();
|
|
4701
4332
|
}
|
|
4702
4333
|
|
|
4703
|
-
// Slide
|
|
4704
|
-
|
|
4705
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4706
|
-
} else {
|
|
4707
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4708
|
-
}
|
|
4709
|
-
|
|
4710
|
-
// Create loop
|
|
4334
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4335
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4711
4336
|
if (swiper.params.loop) {
|
|
4712
4337
|
swiper.loopCreate(undefined, true);
|
|
4713
4338
|
}
|
|
4714
|
-
|
|
4715
|
-
// Attach events
|
|
4716
4339
|
swiper.attachEvents();
|
|
4717
4340
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4718
4341
|
if (swiper.isElement) {
|
|
@@ -4722,18 +4345,12 @@
|
|
|
4722
4345
|
if (imageEl.complete) {
|
|
4723
4346
|
processLazyPreloader(swiper, imageEl);
|
|
4724
4347
|
} else {
|
|
4725
|
-
imageEl.addEventListener('load', e =>
|
|
4726
|
-
processLazyPreloader(swiper, e.target);
|
|
4727
|
-
});
|
|
4348
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4728
4349
|
}
|
|
4729
4350
|
});
|
|
4730
4351
|
preload(swiper);
|
|
4731
|
-
|
|
4732
|
-
// Init Flag
|
|
4733
4352
|
swiper.initialized = true;
|
|
4734
4353
|
preload(swiper);
|
|
4735
|
-
|
|
4736
|
-
// Emit
|
|
4737
4354
|
swiper.emit('init');
|
|
4738
4355
|
swiper.emit('afterInit');
|
|
4739
4356
|
return swiper;
|
|
@@ -4756,27 +4373,15 @@
|
|
|
4756
4373
|
return null;
|
|
4757
4374
|
}
|
|
4758
4375
|
swiper.emit('beforeDestroy');
|
|
4759
|
-
|
|
4760
|
-
// Init Flag
|
|
4761
4376
|
swiper.initialized = false;
|
|
4762
|
-
|
|
4763
|
-
// Detach events
|
|
4764
4377
|
swiper.detachEvents();
|
|
4765
|
-
|
|
4766
|
-
// Destroy loop
|
|
4767
4378
|
if (params.loop) {
|
|
4768
4379
|
swiper.loopDestroy();
|
|
4769
4380
|
}
|
|
4770
|
-
|
|
4771
|
-
// Cleanup styles
|
|
4772
4381
|
if (cleanStyles) {
|
|
4773
4382
|
swiper.removeClasses();
|
|
4774
|
-
if (el && typeof el !== 'string')
|
|
4775
|
-
|
|
4776
|
-
}
|
|
4777
|
-
if (wrapperEl) {
|
|
4778
|
-
wrapperEl.removeAttribute('style');
|
|
4779
|
-
}
|
|
4383
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4384
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4780
4385
|
if (slides && slides.length) {
|
|
4781
4386
|
slides.forEach(slideEl => {
|
|
4782
4387
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4786,8 +4391,6 @@
|
|
|
4786
4391
|
}
|
|
4787
4392
|
}
|
|
4788
4393
|
swiper.emit('destroy');
|
|
4789
|
-
|
|
4790
|
-
// Detach emitter events
|
|
4791
4394
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4792
4395
|
swiper.off(eventName);
|
|
4793
4396
|
});
|
|
@@ -10222,7 +9825,7 @@
|
|
|
10222
9825
|
}
|
|
10223
9826
|
|
|
10224
9827
|
/**
|
|
10225
|
-
* Swiper 0.0.
|
|
9828
|
+
* Swiper 0.0.15-dev.1
|
|
10226
9829
|
* Gem SDK - Swiper, Customized of swiper
|
|
10227
9830
|
* https://swiperjs.com
|
|
10228
9831
|
*
|
|
@@ -10230,7 +9833,7 @@
|
|
|
10230
9833
|
*
|
|
10231
9834
|
* Released under the MIT License
|
|
10232
9835
|
*
|
|
10233
|
-
* Released on: March
|
|
9836
|
+
* Released on: March 20, 2026
|
|
10234
9837
|
*/
|
|
10235
9838
|
|
|
10236
9839
|
|
|
@@ -10564,7 +10167,7 @@
|
|
|
10564
10167
|
}
|
|
10565
10168
|
|
|
10566
10169
|
/**
|
|
10567
|
-
* Swiper Custom Element 0.0.
|
|
10170
|
+
* Swiper Custom Element 0.0.15-dev.1
|
|
10568
10171
|
* Gem SDK - Swiper, Customized of swiper
|
|
10569
10172
|
* https://swiperjs.com
|
|
10570
10173
|
*
|
|
@@ -10572,7 +10175,7 @@
|
|
|
10572
10175
|
*
|
|
10573
10176
|
* Released under the MIT License
|
|
10574
10177
|
*
|
|
10575
|
-
* Released on: March
|
|
10178
|
+
* Released on: March 20, 2026
|
|
10576
10179
|
*/
|
|
10577
10180
|
|
|
10578
10181
|
|