@gem-sdk/swiper 0.0.14-staging.2 → 0.0.15-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core-bk/core.less +225 -0
- package/core-bk/core.scss +227 -0
- package/package.json +2 -2
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +155 -557
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +159 -561
- package/swiper-bundle.min.css +2 -2
- package/swiper-bundle.min.js +3 -3
- package/swiper-bundle.min.js.map +1 -1
- package/swiper-bundle.min.mjs +2 -2
- package/swiper-bundle.mjs +2 -2
- package/swiper-effect-utils.min.mjs +2 -2
- package/swiper-effect-utils.mjs +2 -2
- package/swiper-element-bundle.js +161 -563
- package/swiper-element-bundle.min.js +3 -3
- package/swiper-element-bundle.min.js.map +1 -1
- package/swiper-element-bundle.min.mjs +2 -2
- package/swiper-element-bundle.mjs +2 -2
- package/swiper-element.js +159 -561
- package/swiper-element.min.js +3 -3
- package/swiper-element.min.js.map +1 -1
- package/swiper-element.min.mjs +2 -2
- package/swiper-element.mjs +2 -2
- package/swiper-react.mjs +2 -2
- package/swiper-vue.mjs +2 -2
- package/swiper.css +2 -2
- package/swiper.js +157 -559
- package/swiper.less +2 -2
- package/swiper.min.css +2 -2
- package/swiper.min.js +3 -3
- package/swiper.min.js.map +1 -1
- package/swiper.min.mjs +2 -2
- package/swiper.mjs +2 -2
- package/swiper.scss +2 -2
package/swiper-element.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 () {
|
|
@@ -841,9 +841,6 @@
|
|
|
841
841
|
|
|
842
842
|
function updateSlides() {
|
|
843
843
|
const swiper = this;
|
|
844
|
-
function getDirectionPropertyValue(node, label) {
|
|
845
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
846
|
-
}
|
|
847
844
|
const params = swiper.params;
|
|
848
845
|
const {
|
|
849
846
|
wrapperEl,
|
|
@@ -852,10 +849,8 @@
|
|
|
852
849
|
rtlTranslate: rtl,
|
|
853
850
|
wrongRTL
|
|
854
851
|
} = swiper;
|
|
855
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
856
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
857
852
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
858
|
-
const slidesLength =
|
|
853
|
+
const slidesLength = slides.length;
|
|
859
854
|
let snapGrid = [];
|
|
860
855
|
const slidesGrid = [];
|
|
861
856
|
const slidesSizesGrid = [];
|
|
@@ -873,15 +868,15 @@
|
|
|
873
868
|
let slidePosition = -offsetBefore;
|
|
874
869
|
let prevSlideSize = 0;
|
|
875
870
|
let index = 0;
|
|
876
|
-
if (typeof swiperSize === 'undefined')
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
871
|
+
if (typeof swiperSize === 'undefined') return;
|
|
879
872
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
880
873
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
881
874
|
} else if (typeof spaceBetween === 'string') {
|
|
882
875
|
spaceBetween = parseFloat(spaceBetween);
|
|
883
876
|
}
|
|
884
|
-
|
|
877
|
+
|
|
878
|
+
// core-lite: compute total slides size without optional modules
|
|
879
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
885
880
|
|
|
886
881
|
// reset margins
|
|
887
882
|
slides.forEach(slideEl => {
|
|
@@ -899,49 +894,34 @@
|
|
|
899
894
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
900
895
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
901
896
|
}
|
|
902
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
903
|
-
if (gridEnabled) {
|
|
904
|
-
swiper.grid.initSlides(slides);
|
|
905
|
-
} else if (swiper.grid) {
|
|
906
|
-
swiper.grid.unsetSlides();
|
|
907
|
-
}
|
|
908
897
|
|
|
909
898
|
// Calc slides
|
|
910
899
|
let slideSize;
|
|
911
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
912
|
-
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
|
913
|
-
}).length > 0;
|
|
900
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
914
901
|
for (let i = 0; i < slidesLength; i += 1) {
|
|
915
902
|
slideSize = 0;
|
|
916
903
|
let slide;
|
|
917
904
|
if (slides[i]) slide = slides[i];
|
|
918
|
-
if (gridEnabled) {
|
|
919
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
920
|
-
}
|
|
921
905
|
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
922
906
|
|
|
923
907
|
if (params.slidesPerView === 'auto') {
|
|
924
|
-
if (shouldResetSlideSize) {
|
|
908
|
+
if (shouldResetSlideSize && slides[i]) {
|
|
925
909
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
926
910
|
}
|
|
927
911
|
const slideStyles = getComputedStyle(slide);
|
|
928
912
|
const currentTransform = slide.style.transform;
|
|
929
913
|
const currentWebKitTransform = slide.style.webkitTransform;
|
|
930
|
-
if (currentTransform)
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
if (currentWebKitTransform) {
|
|
934
|
-
slide.style.webkitTransform = 'none';
|
|
935
|
-
}
|
|
914
|
+
if (currentTransform) slide.style.transform = 'none';
|
|
915
|
+
if (currentWebKitTransform) slide.style.webkitTransform = 'none';
|
|
936
916
|
if (params.roundLengths) {
|
|
937
917
|
slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
|
938
918
|
} else {
|
|
939
919
|
// eslint-disable-next-line
|
|
940
|
-
const width =
|
|
941
|
-
const paddingLeft =
|
|
942
|
-
const paddingRight =
|
|
943
|
-
const marginLeft =
|
|
944
|
-
const marginRight =
|
|
920
|
+
const width = parseFloat(slideStyles.getPropertyValue('width')) || slide.offsetWidth;
|
|
921
|
+
const paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left')) || 0;
|
|
922
|
+
const paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right')) || 0;
|
|
923
|
+
const marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left')) || 0;
|
|
924
|
+
const marginRight = parseFloat(slideStyles.getPropertyValue('margin-right')) || 0;
|
|
945
925
|
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
946
926
|
if (boxSizing && boxSizing === 'border-box') {
|
|
947
927
|
slideSize = width + marginLeft + marginRight;
|
|
@@ -953,12 +933,8 @@
|
|
|
953
933
|
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
954
934
|
}
|
|
955
935
|
}
|
|
956
|
-
if (currentTransform)
|
|
957
|
-
|
|
958
|
-
}
|
|
959
|
-
if (currentWebKitTransform) {
|
|
960
|
-
slide.style.webkitTransform = currentWebKitTransform;
|
|
961
|
-
}
|
|
936
|
+
if (currentTransform) slide.style.transform = currentTransform;
|
|
937
|
+
if (currentWebKitTransform) slide.style.webkitTransform = currentWebKitTransform;
|
|
962
938
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
963
939
|
} else {
|
|
964
940
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
@@ -967,13 +943,13 @@
|
|
|
967
943
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
968
944
|
}
|
|
969
945
|
}
|
|
970
|
-
if (slides[i])
|
|
971
|
-
slides[i].swiperSlideSize = slideSize;
|
|
972
|
-
}
|
|
946
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
973
947
|
slidesSizesGrid.push(slideSize);
|
|
974
948
|
if (params.centeredSlides) {
|
|
975
949
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
976
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
950
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
951
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
952
|
+
}
|
|
977
953
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
978
954
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
979
955
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -981,55 +957,37 @@
|
|
|
981
957
|
slidesGrid.push(slidePosition);
|
|
982
958
|
} else {
|
|
983
959
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
984
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
960
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
961
|
+
snapGrid.push(slidePosition);
|
|
962
|
+
}
|
|
985
963
|
slidesGrid.push(slidePosition);
|
|
986
964
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
987
965
|
}
|
|
988
|
-
swiper.
|
|
966
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
989
967
|
prevSlideSize = slideSize;
|
|
990
968
|
index += 1;
|
|
991
969
|
}
|
|
992
|
-
swiper.
|
|
993
|
-
if (rtl && wrongRTL &&
|
|
994
|
-
wrapperEl.style.width = `${swiper.
|
|
970
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
971
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
972
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
995
973
|
}
|
|
996
974
|
if (params.setWrapperSize) {
|
|
997
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
998
|
-
}
|
|
999
|
-
if (gridEnabled) {
|
|
1000
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
975
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1001
976
|
}
|
|
1002
977
|
|
|
1003
|
-
// Remove last
|
|
978
|
+
// Remove last snap points depending on width (non-centered)
|
|
1004
979
|
if (!params.centeredSlides) {
|
|
1005
980
|
const newSlidesGrid = [];
|
|
1006
981
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
1007
982
|
let slidesGridItem = snapGrid[i];
|
|
1008
983
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
1009
|
-
if (snapGrid[i] <= swiper.
|
|
984
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
1010
985
|
newSlidesGrid.push(slidesGridItem);
|
|
1011
986
|
}
|
|
1012
987
|
}
|
|
1013
988
|
snapGrid = newSlidesGrid;
|
|
1014
|
-
if (Math.floor(swiper.
|
|
1015
|
-
snapGrid.push(swiper.
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
if (isVirtual && params.loop) {
|
|
1019
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
1020
|
-
if (params.slidesPerGroup > 1) {
|
|
1021
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
1022
|
-
const groupSize = size * params.slidesPerGroup;
|
|
1023
|
-
for (let i = 0; i < groups; i += 1) {
|
|
1024
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
1028
|
-
if (params.slidesPerGroup === 1) {
|
|
1029
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
1030
|
-
}
|
|
1031
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
1032
|
-
swiper.virtualSize += size;
|
|
989
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
990
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1033
991
|
}
|
|
1034
992
|
}
|
|
1035
993
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1037,9 +995,7 @@
|
|
|
1037
995
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1038
996
|
slides.filter((_, slideIndex) => {
|
|
1039
997
|
if (!params.cssMode || params.loop) return true;
|
|
1040
|
-
if (slideIndex === slides.length - 1)
|
|
1041
|
-
return false;
|
|
1042
|
-
}
|
|
998
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1043
999
|
return true;
|
|
1044
1000
|
}).forEach(slideEl => {
|
|
1045
1001
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1089,7 +1045,9 @@
|
|
|
1089
1045
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1090
1046
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1091
1047
|
}
|
|
1092
|
-
|
|
1048
|
+
|
|
1049
|
+
// Emit changes
|
|
1050
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
1093
1051
|
swiper.emit('slidesLengthChange');
|
|
1094
1052
|
}
|
|
1095
1053
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1103,7 +1061,7 @@
|
|
|
1103
1061
|
swiper.updateSlidesOffset();
|
|
1104
1062
|
}
|
|
1105
1063
|
swiper.emit('slidesUpdated');
|
|
1106
|
-
if (!
|
|
1064
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1107
1065
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1108
1066
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1109
1067
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1117,20 +1075,13 @@
|
|
|
1117
1075
|
function updateAutoHeight(speed) {
|
|
1118
1076
|
const swiper = this;
|
|
1119
1077
|
const activeSlides = [];
|
|
1120
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1121
|
-
let newHeight = 0;
|
|
1122
|
-
let i;
|
|
1123
1078
|
if (typeof speed === 'number') {
|
|
1124
1079
|
swiper.setTransition(speed);
|
|
1125
1080
|
} else if (speed === true) {
|
|
1126
1081
|
swiper.setTransition(swiper.params.speed);
|
|
1127
1082
|
}
|
|
1128
|
-
const getSlideByIndex = index =>
|
|
1129
|
-
|
|
1130
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1131
|
-
}
|
|
1132
|
-
return swiper.slides[index];
|
|
1133
|
-
};
|
|
1083
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1084
|
+
|
|
1134
1085
|
// Find slides currently in view
|
|
1135
1086
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1136
1087
|
if (swiper.params.centeredSlides) {
|
|
@@ -1138,9 +1089,9 @@
|
|
|
1138
1089
|
activeSlides.push(slide);
|
|
1139
1090
|
});
|
|
1140
1091
|
} else {
|
|
1141
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1092
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1142
1093
|
const index = swiper.activeIndex + i;
|
|
1143
|
-
if (index > swiper.slides.length
|
|
1094
|
+
if (index > swiper.slides.length) break;
|
|
1144
1095
|
activeSlides.push(getSlideByIndex(index));
|
|
1145
1096
|
}
|
|
1146
1097
|
}
|
|
@@ -1149,14 +1100,13 @@
|
|
|
1149
1100
|
}
|
|
1150
1101
|
|
|
1151
1102
|
// Find new height from highest slide in view
|
|
1152
|
-
|
|
1103
|
+
let newHeight = 0;
|
|
1104
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1153
1105
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1154
1106
|
const height = activeSlides[i].offsetHeight;
|
|
1155
1107
|
newHeight = height > newHeight ? height : newHeight;
|
|
1156
1108
|
}
|
|
1157
1109
|
}
|
|
1158
|
-
|
|
1159
|
-
// Update Height
|
|
1160
1110
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1161
1111
|
}
|
|
1162
1112
|
|
|
@@ -1301,46 +1251,16 @@
|
|
|
1301
1251
|
slidesEl,
|
|
1302
1252
|
activeIndex
|
|
1303
1253
|
} = swiper;
|
|
1304
|
-
const
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1307
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1308
|
-
};
|
|
1309
|
-
let activeSlide;
|
|
1310
|
-
let prevSlide;
|
|
1254
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1255
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1256
|
+
const activeSlide = slides[activeIndex];
|
|
1311
1257
|
let nextSlide;
|
|
1312
|
-
|
|
1313
|
-
if (params.loop) {
|
|
1314
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
1315
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
1316
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
1317
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
1318
|
-
} else {
|
|
1319
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1320
|
-
}
|
|
1321
|
-
} else {
|
|
1322
|
-
if (gridEnabled) {
|
|
1323
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
1324
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
1325
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
1326
|
-
} else {
|
|
1327
|
-
activeSlide = slides[activeIndex];
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1258
|
+
let prevSlide;
|
|
1330
1259
|
if (activeSlide) {
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
nextSlide = slides[0];
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
// Prev Slide
|
|
1339
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1340
|
-
if (params.loop && !prevSlide === 0) {
|
|
1341
|
-
prevSlide = slides[slides.length - 1];
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1260
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1261
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1262
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1263
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1344
1264
|
}
|
|
1345
1265
|
slides.forEach(slideEl => {
|
|
1346
1266
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1431,7 +1351,6 @@
|
|
|
1431
1351
|
activeIndex = i;
|
|
1432
1352
|
}
|
|
1433
1353
|
}
|
|
1434
|
-
// Normalize slideIndex
|
|
1435
1354
|
if (params.normalizeSlideIndex) {
|
|
1436
1355
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1437
1356
|
}
|
|
@@ -1449,16 +1368,6 @@
|
|
|
1449
1368
|
} = swiper;
|
|
1450
1369
|
let activeIndex = newActiveIndex;
|
|
1451
1370
|
let snapIndex;
|
|
1452
|
-
const getVirtualRealIndex = aIndex => {
|
|
1453
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
1454
|
-
if (realIndex < 0) {
|
|
1455
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
1456
|
-
}
|
|
1457
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
1458
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1459
|
-
}
|
|
1460
|
-
return realIndex;
|
|
1461
|
-
};
|
|
1462
1371
|
if (typeof activeIndex === 'undefined') {
|
|
1463
1372
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1464
1373
|
}
|
|
@@ -1476,32 +1385,12 @@
|
|
|
1476
1385
|
}
|
|
1477
1386
|
return;
|
|
1478
1387
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
return;
|
|
1482
|
-
}
|
|
1483
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1484
|
-
|
|
1485
|
-
// Get real index
|
|
1486
|
-
let realIndex;
|
|
1487
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1488
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1489
|
-
} else if (gridEnabled) {
|
|
1490
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1491
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1492
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1493
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1494
|
-
}
|
|
1495
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1496
|
-
} else if (swiper.slides[activeIndex]) {
|
|
1388
|
+
let realIndex = activeIndex;
|
|
1389
|
+
if (swiper.slides[activeIndex]) {
|
|
1497
1390
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1498
1391
|
if (slideIndex) {
|
|
1499
1392
|
realIndex = parseInt(slideIndex, 10);
|
|
1500
|
-
} else {
|
|
1501
|
-
realIndex = activeIndex;
|
|
1502
1393
|
}
|
|
1503
|
-
} else {
|
|
1504
|
-
realIndex = activeIndex;
|
|
1505
1394
|
}
|
|
1506
1395
|
Object.assign(swiper, {
|
|
1507
1396
|
previousSnapIndex,
|
|
@@ -1548,11 +1437,7 @@
|
|
|
1548
1437
|
}
|
|
1549
1438
|
if (slide && slideFound) {
|
|
1550
1439
|
swiper.clickedSlide = slide;
|
|
1551
|
-
|
|
1552
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1553
|
-
} else {
|
|
1554
|
-
swiper.clickedIndex = slideIndex;
|
|
1555
|
-
}
|
|
1440
|
+
swiper.clickedIndex = slideIndex;
|
|
1556
1441
|
} else {
|
|
1557
1442
|
swiper.clickedSlide = undefined;
|
|
1558
1443
|
swiper.clickedIndex = undefined;
|
|
@@ -1586,9 +1471,6 @@
|
|
|
1586
1471
|
translate,
|
|
1587
1472
|
wrapperEl
|
|
1588
1473
|
} = swiper;
|
|
1589
|
-
if (params.virtualTranslate) {
|
|
1590
|
-
return rtl ? -translate : translate;
|
|
1591
|
-
}
|
|
1592
1474
|
if (params.cssMode) {
|
|
1593
1475
|
return translate;
|
|
1594
1476
|
}
|
|
@@ -1622,7 +1504,7 @@
|
|
|
1622
1504
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1623
1505
|
if (params.cssMode) {
|
|
1624
1506
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1625
|
-
} else
|
|
1507
|
+
} else {
|
|
1626
1508
|
if (swiper.isHorizontal()) {
|
|
1627
1509
|
x -= swiper.cssOverflowAdjustment();
|
|
1628
1510
|
} else {
|
|
@@ -1859,7 +1741,6 @@
|
|
|
1859
1741
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1860
1742
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1861
1743
|
const translate = -snapGrid[snapIndex];
|
|
1862
|
-
// Normalize slideIndex
|
|
1863
1744
|
if (params.normalizeSlideIndex) {
|
|
1864
1745
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1865
1746
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1876,33 +1757,24 @@
|
|
|
1876
1757
|
}
|
|
1877
1758
|
}
|
|
1878
1759
|
}
|
|
1760
|
+
|
|
1879
1761
|
// Directions locks
|
|
1880
1762
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1881
1763
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1882
1764
|
return false;
|
|
1883
1765
|
}
|
|
1884
1766
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1885
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1886
|
-
return false;
|
|
1887
|
-
}
|
|
1767
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1888
1768
|
}
|
|
1889
1769
|
}
|
|
1890
1770
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1891
1771
|
swiper.emit('beforeSlideChangeStart');
|
|
1892
1772
|
}
|
|
1893
|
-
|
|
1894
|
-
// Update progress
|
|
1895
1773
|
swiper.updateProgress(translate);
|
|
1896
1774
|
let direction;
|
|
1897
1775
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1898
|
-
|
|
1899
|
-
// initial virtual
|
|
1900
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1901
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1902
|
-
// Update Index
|
|
1903
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1776
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1904
1777
|
swiper.updateActiveIndex(slideIndex);
|
|
1905
|
-
// Update Height
|
|
1906
1778
|
if (params.autoHeight) {
|
|
1907
1779
|
swiper.updateAutoHeight();
|
|
1908
1780
|
}
|
|
@@ -1920,24 +1792,7 @@
|
|
|
1920
1792
|
const isH = swiper.isHorizontal();
|
|
1921
1793
|
const t = rtl ? translate : -translate;
|
|
1922
1794
|
if (speed === 0) {
|
|
1923
|
-
|
|
1924
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1925
|
-
swiper._immediateVirtual = true;
|
|
1926
|
-
}
|
|
1927
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1928
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1929
|
-
requestAnimationFrame(() => {
|
|
1930
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1931
|
-
});
|
|
1932
|
-
} else {
|
|
1933
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1934
|
-
}
|
|
1935
|
-
if (isVirtual) {
|
|
1936
|
-
requestAnimationFrame(() => {
|
|
1937
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1938
|
-
swiper._immediateVirtual = false;
|
|
1939
|
-
});
|
|
1940
|
-
}
|
|
1795
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1941
1796
|
} else {
|
|
1942
1797
|
if (!swiper.support.smoothScroll) {
|
|
1943
1798
|
animateCSSModeScroll({
|
|
@@ -1955,10 +1810,7 @@
|
|
|
1955
1810
|
return true;
|
|
1956
1811
|
}
|
|
1957
1812
|
const browser = getBrowser();
|
|
1958
|
-
|
|
1959
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1960
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1961
|
-
}
|
|
1813
|
+
browser.isSafari;
|
|
1962
1814
|
swiper.setTransition(speed);
|
|
1963
1815
|
swiper.setTranslate(translate);
|
|
1964
1816
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2129,8 +1981,6 @@
|
|
|
2129
1981
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2130
1982
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2131
1983
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2132
|
-
|
|
2133
|
-
// Move last item to first position only if active slide is the first slide
|
|
2134
1984
|
const lastSlide = slides[slides.length - 1];
|
|
2135
1985
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2136
1986
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2165,11 +2015,8 @@
|
|
|
2165
2015
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2166
2016
|
}
|
|
2167
2017
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2168
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2169
2018
|
if (params.loop) {
|
|
2170
|
-
if (animating &&
|
|
2171
|
-
|
|
2172
|
-
// Kiểm tra xem loop có bị disable không
|
|
2019
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2173
2020
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2174
2021
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2175
2022
|
swiper.loopFix({
|
|
@@ -2196,7 +2043,6 @@
|
|
|
2196
2043
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2197
2044
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2198
2045
|
if (!swiper.params.loop) return;
|
|
2199
|
-
// Move first item to last position only if active slide is the last slide
|
|
2200
2046
|
const firstSlide = slides[0];
|
|
2201
2047
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2202
2048
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2221,17 +2067,14 @@
|
|
|
2221
2067
|
params,
|
|
2222
2068
|
snapGrid,
|
|
2223
2069
|
slidesGrid,
|
|
2224
|
-
rtlTranslate,
|
|
2225
|
-
enabled
|
|
2226
|
-
animating
|
|
2070
|
+
rtlTranslate: rtlTranslate,
|
|
2071
|
+
enabled
|
|
2227
2072
|
} = swiper;
|
|
2228
2073
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2229
2074
|
if (typeof speed === 'undefined') {
|
|
2230
2075
|
speed = swiper.params.speed;
|
|
2231
2076
|
}
|
|
2232
|
-
swiper.virtual && params.virtual.enabled;
|
|
2233
2077
|
if (params.loop) {
|
|
2234
|
-
// Kiểm tra xem loop có bị disable không
|
|
2235
2078
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2236
2079
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2237
2080
|
swiper.loopFix({
|
|
@@ -2248,18 +2091,16 @@
|
|
|
2248
2091
|
}
|
|
2249
2092
|
const normalizedTranslate = normalize(translate);
|
|
2250
2093
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2251
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2252
2094
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2253
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2095
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2254
2096
|
let prevSnapIndex;
|
|
2255
2097
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2256
2098
|
if (normalizedTranslate >= snap) {
|
|
2257
|
-
// prevSnap = snap;
|
|
2258
2099
|
prevSnapIndex = snapIndex;
|
|
2259
2100
|
}
|
|
2260
2101
|
});
|
|
2261
2102
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2262
|
-
prevSnap =
|
|
2103
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2263
2104
|
}
|
|
2264
2105
|
}
|
|
2265
2106
|
let prevIndex = 0;
|
|
@@ -2272,7 +2113,7 @@
|
|
|
2272
2113
|
}
|
|
2273
2114
|
}
|
|
2274
2115
|
if (params.rewind && swiper.isBeginning) {
|
|
2275
|
-
const lastIndex = swiper.
|
|
2116
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2276
2117
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2277
2118
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2278
2119
|
requestAnimationFrame(() => {
|
|
@@ -2286,8 +2127,6 @@
|
|
|
2286
2127
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2287
2128
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2288
2129
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2289
|
-
|
|
2290
|
-
// Move last item to first position only if active slide is the first slide
|
|
2291
2130
|
if (!swiper.params.loop) return;
|
|
2292
2131
|
const lastSlide = slides[slides.length - 1];
|
|
2293
2132
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2364,20 +2203,19 @@
|
|
|
2364
2203
|
slidesEl
|
|
2365
2204
|
} = swiper;
|
|
2366
2205
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2367
|
-
|
|
2206
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2368
2207
|
let realIndex;
|
|
2369
2208
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2370
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2371
2209
|
if (params.loop) {
|
|
2372
2210
|
if (swiper.animating) return;
|
|
2373
2211
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2374
2212
|
if (params.centeredSlides) {
|
|
2375
2213
|
swiper.slideToLoop(realIndex);
|
|
2376
|
-
} else if (slideToIndex >
|
|
2214
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2377
2215
|
swiper.loopFix();
|
|
2378
|
-
|
|
2216
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2379
2217
|
nextTick(() => {
|
|
2380
|
-
swiper.slideTo(
|
|
2218
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2381
2219
|
});
|
|
2382
2220
|
} else {
|
|
2383
2221
|
swiper.slideTo(slideToIndex);
|
|
@@ -2404,7 +2242,7 @@
|
|
|
2404
2242
|
params,
|
|
2405
2243
|
slidesEl
|
|
2406
2244
|
} = swiper;
|
|
2407
|
-
if (!params.loop
|
|
2245
|
+
if (!params.loop) return;
|
|
2408
2246
|
const initSlides = () => {
|
|
2409
2247
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2410
2248
|
slides.forEach((el, index) => {
|
|
@@ -2413,21 +2251,17 @@
|
|
|
2413
2251
|
};
|
|
2414
2252
|
const clearBlankSlides = () => {
|
|
2415
2253
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2416
|
-
slides.forEach(el =>
|
|
2417
|
-
el.remove();
|
|
2418
|
-
});
|
|
2254
|
+
slides.forEach(el => el.remove());
|
|
2419
2255
|
if (slides.length > 0) {
|
|
2420
2256
|
swiper.recalcSlides();
|
|
2421
2257
|
swiper.updateSlides();
|
|
2422
2258
|
}
|
|
2423
2259
|
};
|
|
2424
|
-
|
|
2425
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2260
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2426
2261
|
clearBlankSlides();
|
|
2427
2262
|
}
|
|
2428
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2263
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2429
2264
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2430
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2431
2265
|
const addBlankSlides = amountOfSlides => {
|
|
2432
2266
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2433
2267
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2444,16 +2278,6 @@
|
|
|
2444
2278
|
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)');
|
|
2445
2279
|
}
|
|
2446
2280
|
initSlides();
|
|
2447
|
-
} else if (shouldFillGrid) {
|
|
2448
|
-
if (params.loopAddBlankSlides) {
|
|
2449
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2450
|
-
addBlankSlides(slidesToAdd);
|
|
2451
|
-
swiper.recalcSlides();
|
|
2452
|
-
swiper.updateSlides();
|
|
2453
|
-
} else {
|
|
2454
|
-
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)');
|
|
2455
|
-
}
|
|
2456
|
-
initSlides();
|
|
2457
2281
|
} else {
|
|
2458
2282
|
initSlides();
|
|
2459
2283
|
}
|
|
@@ -2472,13 +2296,12 @@
|
|
|
2472
2296
|
setTranslate,
|
|
2473
2297
|
activeSlideIndex,
|
|
2474
2298
|
initial,
|
|
2475
|
-
byController,
|
|
2476
2299
|
byMousewheel
|
|
2477
2300
|
} = _temp === void 0 ? {} : _temp;
|
|
2478
2301
|
const swiper = this;
|
|
2479
2302
|
if (!swiper.params.loop) return;
|
|
2480
2303
|
|
|
2481
|
-
// Disable loop mode
|
|
2304
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2482
2305
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2483
2306
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2484
2307
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2498,21 +2321,6 @@
|
|
|
2498
2321
|
} = params;
|
|
2499
2322
|
swiper.allowSlidePrev = true;
|
|
2500
2323
|
swiper.allowSlideNext = true;
|
|
2501
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2502
|
-
if (slideTo) {
|
|
2503
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2504
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2505
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2506
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2507
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2508
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2512
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2513
|
-
swiper.emit('loopFix');
|
|
2514
|
-
return;
|
|
2515
|
-
}
|
|
2516
2324
|
let slidesPerView = params.slidesPerView;
|
|
2517
2325
|
if (slidesPerView === 'auto') {
|
|
2518
2326
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2522,22 +2330,19 @@
|
|
|
2522
2330
|
slidesPerView = slidesPerView + 1;
|
|
2523
2331
|
}
|
|
2524
2332
|
}
|
|
2525
|
-
const slidesPerGroup = params.
|
|
2333
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2526
2334
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2527
2335
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2528
2336
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2529
2337
|
}
|
|
2530
2338
|
loopedSlides += params.loopAdditionalSlides;
|
|
2531
2339
|
swiper.loopedSlides = loopedSlides;
|
|
2532
|
-
|
|
2533
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2340
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2534
2341
|
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');
|
|
2535
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2536
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2537
2342
|
}
|
|
2538
2343
|
const prependSlidesIndexes = [];
|
|
2539
2344
|
const appendSlidesIndexes = [];
|
|
2540
|
-
const cols =
|
|
2345
|
+
const cols = slides.length;
|
|
2541
2346
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2542
2347
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2543
2348
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2549,24 +2354,15 @@
|
|
|
2549
2354
|
const isPrev = direction === 'prev' || !direction;
|
|
2550
2355
|
let slidesPrepended = 0;
|
|
2551
2356
|
let slidesAppended = 0;
|
|
2552
|
-
const activeColIndex =
|
|
2357
|
+
const activeColIndex = activeSlideIndex;
|
|
2553
2358
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2359
|
+
|
|
2554
2360
|
// prepend last slides before start
|
|
2555
2361
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2556
2362
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2557
2363
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2558
2364
|
const index = i - Math.floor(i / cols) * cols;
|
|
2559
|
-
|
|
2560
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2561
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2562
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2563
|
-
}
|
|
2564
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2565
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2566
|
-
// });
|
|
2567
|
-
} else {
|
|
2568
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2569
|
-
}
|
|
2365
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2570
2366
|
}
|
|
2571
2367
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2572
2368
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2575,27 +2371,13 @@
|
|
|
2575
2371
|
}
|
|
2576
2372
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2577
2373
|
const index = i - Math.floor(i / cols) * cols;
|
|
2578
|
-
|
|
2579
|
-
slides.forEach((slide, slideIndex) => {
|
|
2580
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2581
|
-
});
|
|
2582
|
-
} else {
|
|
2583
|
-
appendSlidesIndexes.push(index);
|
|
2584
|
-
}
|
|
2374
|
+
appendSlidesIndexes.push(index);
|
|
2585
2375
|
}
|
|
2586
2376
|
}
|
|
2587
2377
|
swiper.__preventObserver__ = true;
|
|
2588
2378
|
requestAnimationFrame(() => {
|
|
2589
2379
|
swiper.__preventObserver__ = false;
|
|
2590
2380
|
});
|
|
2591
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2592
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2593
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2594
|
-
}
|
|
2595
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2596
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2597
|
-
}
|
|
2598
|
-
}
|
|
2599
2381
|
if (isPrev) {
|
|
2600
2382
|
prependSlidesIndexes.forEach(index => {
|
|
2601
2383
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2613,10 +2395,6 @@
|
|
|
2613
2395
|
swiper.recalcSlides();
|
|
2614
2396
|
if (params.slidesPerView === 'auto') {
|
|
2615
2397
|
swiper.updateSlides();
|
|
2616
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2617
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2618
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2619
|
-
});
|
|
2620
2398
|
}
|
|
2621
2399
|
if (params.watchSlidesProgress) {
|
|
2622
2400
|
swiper.updateSlidesOffset();
|
|
@@ -2636,12 +2414,10 @@
|
|
|
2636
2414
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2637
2415
|
}
|
|
2638
2416
|
}
|
|
2639
|
-
} else {
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2644
|
-
}
|
|
2417
|
+
} else if (setTranslate) {
|
|
2418
|
+
const shift = prependSlidesIndexes.length;
|
|
2419
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2420
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2645
2421
|
}
|
|
2646
2422
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2647
2423
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2657,36 +2433,14 @@
|
|
|
2657
2433
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2658
2434
|
}
|
|
2659
2435
|
}
|
|
2660
|
-
} else {
|
|
2661
|
-
const shift =
|
|
2436
|
+
} else if (setTranslate) {
|
|
2437
|
+
const shift = appendSlidesIndexes.length;
|
|
2662
2438
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2663
2439
|
}
|
|
2664
2440
|
}
|
|
2665
2441
|
}
|
|
2666
2442
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2667
2443
|
swiper.allowSlideNext = allowSlideNext;
|
|
2668
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2669
|
-
const loopParams = {
|
|
2670
|
-
slideRealIndex,
|
|
2671
|
-
direction,
|
|
2672
|
-
setTranslate,
|
|
2673
|
-
activeSlideIndex,
|
|
2674
|
-
byController: true
|
|
2675
|
-
};
|
|
2676
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2677
|
-
swiper.controller.control.forEach(c => {
|
|
2678
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2679
|
-
...loopParams,
|
|
2680
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2681
|
-
});
|
|
2682
|
-
});
|
|
2683
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2684
|
-
swiper.controller.control.loopFix({
|
|
2685
|
-
...loopParams,
|
|
2686
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2687
|
-
});
|
|
2688
|
-
}
|
|
2689
|
-
}
|
|
2690
2444
|
swiper.emit('loopFix');
|
|
2691
2445
|
}
|
|
2692
2446
|
|
|
@@ -2703,7 +2457,7 @@
|
|
|
2703
2457
|
const swiper = this;
|
|
2704
2458
|
if (!swiper.params.loop) return;
|
|
2705
2459
|
|
|
2706
|
-
// Disable loop mode
|
|
2460
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2707
2461
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2708
2462
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2709
2463
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2742,7 +2496,7 @@
|
|
|
2742
2496
|
}
|
|
2743
2497
|
loopedSlides += params.loopAdditionalSlides;
|
|
2744
2498
|
swiper.loopedSlides = loopedSlides;
|
|
2745
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2499
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2746
2500
|
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');
|
|
2747
2501
|
}
|
|
2748
2502
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2768,20 +2522,16 @@
|
|
|
2768
2522
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2769
2523
|
}
|
|
2770
2524
|
|
|
2771
|
-
//
|
|
2525
|
+
// DocumentFragment to hold slide clones
|
|
2772
2526
|
const cloneFragment = document.createDocumentFragment();
|
|
2773
2527
|
|
|
2774
|
-
// Clone
|
|
2528
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2775
2529
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2776
2530
|
if (slides[index]) {
|
|
2777
2531
|
const originalSlide = slides[index];
|
|
2778
2532
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2779
|
-
|
|
2780
|
-
// Đánh dấu slide clone
|
|
2781
2533
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2782
2534
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2783
|
-
|
|
2784
|
-
// Thêm clone vào fragment
|
|
2785
2535
|
cloneFragment.appendChild(clonedSlide);
|
|
2786
2536
|
}
|
|
2787
2537
|
});
|
|
@@ -2802,32 +2552,28 @@
|
|
|
2802
2552
|
});
|
|
2803
2553
|
}
|
|
2804
2554
|
|
|
2805
|
-
//
|
|
2555
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2806
2556
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2807
2557
|
clonedSlides.sort((a, b) => {
|
|
2808
2558
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2809
2559
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2810
2560
|
return indexA - indexB;
|
|
2811
2561
|
});
|
|
2812
|
-
|
|
2813
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2814
2562
|
cloneFragment.innerHTML = '';
|
|
2815
2563
|
clonedSlides.forEach(slide => {
|
|
2816
2564
|
cloneFragment.appendChild(slide);
|
|
2817
2565
|
});
|
|
2818
2566
|
|
|
2819
|
-
//
|
|
2567
|
+
// Place fragment into the right position
|
|
2820
2568
|
if (isPrev) {
|
|
2821
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2822
2569
|
slidesEl.appendChild(cloneFragment);
|
|
2823
2570
|
} else if (isNext) {
|
|
2824
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2825
2571
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2826
2572
|
}
|
|
2827
2573
|
swiper.recalcSlides();
|
|
2828
2574
|
swiper.updateSlides();
|
|
2829
2575
|
|
|
2830
|
-
//
|
|
2576
|
+
// Find old active slide index after recalculation
|
|
2831
2577
|
let oldActiveIndex = null;
|
|
2832
2578
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2833
2579
|
const child = slidesEl.children[i];
|
|
@@ -2840,7 +2586,7 @@
|
|
|
2840
2586
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2841
2587
|
}
|
|
2842
2588
|
|
|
2843
|
-
//
|
|
2589
|
+
// Update translate after removing clones for animation
|
|
2844
2590
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2845
2591
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2846
2592
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2866,7 +2612,8 @@
|
|
|
2866
2612
|
}
|
|
2867
2613
|
swiper.setTranslate(updateTranslate);
|
|
2868
2614
|
}
|
|
2869
|
-
|
|
2615
|
+
|
|
2616
|
+
// Remove clones
|
|
2870
2617
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2871
2618
|
cloneSlides.forEach(cloneSlide => {
|
|
2872
2619
|
if (cloneSlide.parentNode) {
|
|
@@ -2896,7 +2643,7 @@
|
|
|
2896
2643
|
params,
|
|
2897
2644
|
slidesEl
|
|
2898
2645
|
} = swiper;
|
|
2899
|
-
if (!params.loop || !slidesEl
|
|
2646
|
+
if (!params.loop || !slidesEl) return;
|
|
2900
2647
|
swiper.recalcSlides();
|
|
2901
2648
|
const newSlidesOrder = [];
|
|
2902
2649
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2957,7 +2704,6 @@
|
|
|
2957
2704
|
unsetGrabCursor
|
|
2958
2705
|
};
|
|
2959
2706
|
|
|
2960
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2961
2707
|
function closestElement(selector, base) {
|
|
2962
2708
|
if (base === void 0) {
|
|
2963
2709
|
base = this;
|
|
@@ -2966,9 +2712,7 @@
|
|
|
2966
2712
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2967
2713
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2968
2714
|
const found = el.closest(selector);
|
|
2969
|
-
if (!found && !el.getRootNode)
|
|
2970
|
-
return null;
|
|
2971
|
-
}
|
|
2715
|
+
if (!found && !el.getRootNode) return null;
|
|
2972
2716
|
return found || __closestFrom(el.getRootNode().host);
|
|
2973
2717
|
}
|
|
2974
2718
|
return __closestFrom(base);
|
|
@@ -2996,9 +2740,7 @@
|
|
|
2996
2740
|
if (e.originalEvent) e = e.originalEvent;
|
|
2997
2741
|
const data = swiper.touchEventsData;
|
|
2998
2742
|
if (e.type === 'pointerdown') {
|
|
2999
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
3000
|
-
return;
|
|
3001
|
-
}
|
|
2743
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
3002
2744
|
data.pointerId = e.pointerId;
|
|
3003
2745
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
3004
2746
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3015,9 +2757,7 @@
|
|
|
3015
2757
|
} = swiper;
|
|
3016
2758
|
if (!enabled) return;
|
|
3017
2759
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3018
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3019
|
-
return;
|
|
3020
|
-
}
|
|
2760
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3021
2761
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3022
2762
|
swiper.loopFix();
|
|
3023
2763
|
}
|
|
@@ -3028,8 +2768,6 @@
|
|
|
3028
2768
|
if ('which' in e && e.which === 3) return;
|
|
3029
2769
|
if ('button' in e && e.button > 0) return;
|
|
3030
2770
|
if (data.isTouched && data.isMoved) return;
|
|
3031
|
-
|
|
3032
|
-
// change target el for shadow root component
|
|
3033
2771
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3034
2772
|
// eslint-disable-next-line
|
|
3035
2773
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3038,8 +2776,6 @@
|
|
|
3038
2776
|
}
|
|
3039
2777
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3040
2778
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3041
|
-
|
|
3042
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3043
2779
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3044
2780
|
swiper.allowClick = true;
|
|
3045
2781
|
return;
|
|
@@ -3051,12 +2787,7 @@
|
|
|
3051
2787
|
touches.currentY = e.pageY;
|
|
3052
2788
|
const startX = touches.currentX;
|
|
3053
2789
|
const startY = touches.currentY;
|
|
3054
|
-
|
|
3055
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3056
|
-
|
|
3057
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3058
|
-
return;
|
|
3059
|
-
}
|
|
2790
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3060
2791
|
Object.assign(data, {
|
|
3061
2792
|
isTouched: true,
|
|
3062
2793
|
isMoved: false,
|
|
@@ -3085,9 +2816,6 @@
|
|
|
3085
2816
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3086
2817
|
e.preventDefault();
|
|
3087
2818
|
}
|
|
3088
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3089
|
-
swiper.freeMode.onTouchStart();
|
|
3090
|
-
}
|
|
3091
2819
|
swiper.emit('touchStart', e);
|
|
3092
2820
|
}
|
|
3093
2821
|
|
|
@@ -3106,7 +2834,7 @@
|
|
|
3106
2834
|
let e = event;
|
|
3107
2835
|
if (e.originalEvent) e = e.originalEvent;
|
|
3108
2836
|
if (e.type === 'pointermove') {
|
|
3109
|
-
if (data.touchId !== null) return;
|
|
2837
|
+
if (data.touchId !== null) return;
|
|
3110
2838
|
const id = e.pointerId;
|
|
3111
2839
|
if (id !== data.pointerId) return;
|
|
3112
2840
|
}
|
|
@@ -3147,7 +2875,6 @@
|
|
|
3147
2875
|
}
|
|
3148
2876
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3149
2877
|
if (swiper.isVertical()) {
|
|
3150
|
-
// Vertical
|
|
3151
2878
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3152
2879
|
data.isTouched = false;
|
|
3153
2880
|
data.isMoved = false;
|
|
@@ -3249,7 +2976,6 @@
|
|
|
3249
2976
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3250
2977
|
}
|
|
3251
2978
|
data.allowMomentumBounce = false;
|
|
3252
|
-
// Grab Cursor
|
|
3253
2979
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3254
2980
|
swiper.setGrabCursor(true);
|
|
3255
2981
|
}
|
|
@@ -3320,8 +3046,6 @@
|
|
|
3320
3046
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3321
3047
|
data.currentTranslate = data.startTranslate;
|
|
3322
3048
|
}
|
|
3323
|
-
|
|
3324
|
-
// Threshold
|
|
3325
3049
|
if (params.threshold > 0) {
|
|
3326
3050
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3327
3051
|
if (!data.allowThresholdMove) {
|
|
@@ -3339,17 +3063,12 @@
|
|
|
3339
3063
|
}
|
|
3340
3064
|
if (!params.followFinger || params.cssMode) return;
|
|
3341
3065
|
|
|
3342
|
-
//
|
|
3343
|
-
if (params.
|
|
3066
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3067
|
+
if (params.watchSlidesProgress) {
|
|
3344
3068
|
swiper.updateActiveIndex();
|
|
3345
3069
|
swiper.updateSlidesClasses();
|
|
3346
3070
|
}
|
|
3347
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3348
|
-
swiper.freeMode.onTouchMove();
|
|
3349
|
-
}
|
|
3350
|
-
// Update progress
|
|
3351
3071
|
swiper.updateProgress(data.currentTranslate);
|
|
3352
|
-
// Update translate
|
|
3353
3072
|
swiper.setTranslate(data.currentTranslate);
|
|
3354
3073
|
}
|
|
3355
3074
|
|
|
@@ -3361,7 +3080,7 @@
|
|
|
3361
3080
|
let targetTouch;
|
|
3362
3081
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3363
3082
|
if (!isTouchEvent) {
|
|
3364
|
-
if (data.touchId !== null) return;
|
|
3083
|
+
if (data.touchId !== null) return;
|
|
3365
3084
|
if (e.pointerId !== data.pointerId) return;
|
|
3366
3085
|
targetTouch = e;
|
|
3367
3086
|
} else {
|
|
@@ -3370,9 +3089,7 @@
|
|
|
3370
3089
|
}
|
|
3371
3090
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3372
3091
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3373
|
-
if (!proceed)
|
|
3374
|
-
return;
|
|
3375
|
-
}
|
|
3092
|
+
if (!proceed) return;
|
|
3376
3093
|
}
|
|
3377
3094
|
data.pointerId = null;
|
|
3378
3095
|
data.touchId = null;
|
|
@@ -3390,9 +3107,7 @@
|
|
|
3390
3107
|
}
|
|
3391
3108
|
data.allowTouchCallbacks = false;
|
|
3392
3109
|
if (!data.isTouched) {
|
|
3393
|
-
if (data.isMoved && params.grabCursor)
|
|
3394
|
-
swiper.setGrabCursor(false);
|
|
3395
|
-
}
|
|
3110
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3396
3111
|
data.isMoved = false;
|
|
3397
3112
|
data.startMoving = false;
|
|
3398
3113
|
return;
|
|
@@ -3402,8 +3117,6 @@
|
|
|
3402
3117
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3403
3118
|
swiper.setGrabCursor(false);
|
|
3404
3119
|
}
|
|
3405
|
-
|
|
3406
|
-
// Time diff
|
|
3407
3120
|
const touchEndTime = now();
|
|
3408
3121
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3409
3122
|
|
|
@@ -3430,20 +3143,8 @@
|
|
|
3430
3143
|
data.isMoved = false;
|
|
3431
3144
|
data.startMoving = false;
|
|
3432
3145
|
let currentPos;
|
|
3433
|
-
if (params.followFinger)
|
|
3434
|
-
|
|
3435
|
-
} else {
|
|
3436
|
-
currentPos = -data.currentTranslate;
|
|
3437
|
-
}
|
|
3438
|
-
if (params.cssMode) {
|
|
3439
|
-
return;
|
|
3440
|
-
}
|
|
3441
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3442
|
-
swiper.freeMode.onTouchEnd({
|
|
3443
|
-
currentPos
|
|
3444
|
-
});
|
|
3445
|
-
return;
|
|
3446
|
-
}
|
|
3146
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3147
|
+
if (params.cssMode) return;
|
|
3447
3148
|
|
|
3448
3149
|
// Find current slide
|
|
3449
3150
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3465,22 +3166,22 @@
|
|
|
3465
3166
|
let rewindLastIndex = null;
|
|
3466
3167
|
if (params.rewind) {
|
|
3467
3168
|
if (swiper.isBeginning) {
|
|
3468
|
-
rewindLastIndex =
|
|
3169
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3469
3170
|
} else if (swiper.isEnd) {
|
|
3470
3171
|
rewindFirstIndex = 0;
|
|
3471
3172
|
}
|
|
3472
3173
|
}
|
|
3473
|
-
// Find current slide size
|
|
3474
3174
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3475
3175
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3476
3176
|
if (timeDiff > params.longSwipesMs) {
|
|
3477
|
-
// Long touches
|
|
3478
3177
|
if (!params.longSwipes) {
|
|
3479
3178
|
swiper.slideTo(swiper.activeIndex);
|
|
3480
3179
|
return;
|
|
3481
3180
|
}
|
|
3482
3181
|
if (swiper.swipeDirection === 'next') {
|
|
3483
|
-
if (ratio >= params.longSwipesRatio)
|
|
3182
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3183
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3184
|
+
} else swiper.slideTo(stopIndex);
|
|
3484
3185
|
}
|
|
3485
3186
|
if (swiper.swipeDirection === 'prev') {
|
|
3486
3187
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3532,7 +3233,6 @@
|
|
|
3532
3233
|
allowSlidePrev,
|
|
3533
3234
|
snapGrid
|
|
3534
3235
|
} = swiper;
|
|
3535
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3536
3236
|
|
|
3537
3237
|
// Disable locks on resize
|
|
3538
3238
|
swiper.allowSlideNext = true;
|
|
@@ -3540,15 +3240,12 @@
|
|
|
3540
3240
|
swiper.updateSize();
|
|
3541
3241
|
swiper.updateSlides();
|
|
3542
3242
|
swiper.updateSlidesClasses();
|
|
3543
|
-
|
|
3544
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3243
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3545
3244
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3245
|
+
} else if (swiper.params.loop) {
|
|
3246
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3546
3247
|
} else {
|
|
3547
|
-
|
|
3548
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3549
|
-
} else {
|
|
3550
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3551
|
-
}
|
|
3248
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3552
3249
|
}
|
|
3553
3250
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3554
3251
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3558,10 +3255,11 @@
|
|
|
3558
3255
|
}
|
|
3559
3256
|
}, 500);
|
|
3560
3257
|
}
|
|
3258
|
+
|
|
3561
3259
|
// Return locks after resize
|
|
3562
3260
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3563
3261
|
swiper.allowSlideNext = allowSlideNext;
|
|
3564
|
-
if (
|
|
3262
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3565
3263
|
swiper.checkOverflow();
|
|
3566
3264
|
}
|
|
3567
3265
|
}
|
|
@@ -3730,8 +3428,15 @@
|
|
|
3730
3428
|
detachEvents
|
|
3731
3429
|
};
|
|
3732
3430
|
|
|
3733
|
-
const
|
|
3734
|
-
|
|
3431
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3432
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3433
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3434
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3435
|
+
swiper[prop].disable();
|
|
3436
|
+
}
|
|
3437
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3438
|
+
swiper[prop].enable();
|
|
3439
|
+
}
|
|
3735
3440
|
};
|
|
3736
3441
|
function setBreakpoint() {
|
|
3737
3442
|
const swiper = this;
|
|
@@ -3752,38 +3457,20 @@
|
|
|
3752
3457
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3753
3458
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3754
3459
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3755
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3756
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3757
3460
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3758
3461
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3759
3462
|
const wasEnabled = params.enabled;
|
|
3760
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3761
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3762
|
-
swiper.emitContainerClasses();
|
|
3763
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3764
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3765
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3766
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3767
|
-
}
|
|
3768
|
-
swiper.emitContainerClasses();
|
|
3769
|
-
}
|
|
3770
3463
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3771
3464
|
swiper.unsetGrabCursor();
|
|
3772
3465
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3773
3466
|
swiper.setGrabCursor();
|
|
3774
3467
|
}
|
|
3775
3468
|
|
|
3776
|
-
//
|
|
3777
|
-
['navigation', 'pagination'
|
|
3469
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3470
|
+
const modules = ['navigation', 'pagination'];
|
|
3471
|
+
modules.forEach(prop => {
|
|
3778
3472
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3779
|
-
|
|
3780
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3781
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3782
|
-
swiper[prop].disable();
|
|
3783
|
-
}
|
|
3784
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3785
|
-
swiper[prop].enable();
|
|
3786
|
-
}
|
|
3473
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3787
3474
|
});
|
|
3788
3475
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3789
3476
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3865,7 +3552,7 @@
|
|
|
3865
3552
|
getBreakpoint
|
|
3866
3553
|
};
|
|
3867
3554
|
|
|
3868
|
-
|
|
3555
|
+
const prepareClasses = (entries, prefix) => {
|
|
3869
3556
|
const resultClasses = [];
|
|
3870
3557
|
entries.forEach(item => {
|
|
3871
3558
|
if (typeof item === 'object') {
|
|
@@ -3879,7 +3566,7 @@
|
|
|
3879
3566
|
}
|
|
3880
3567
|
});
|
|
3881
3568
|
return resultClasses;
|
|
3882
|
-
}
|
|
3569
|
+
};
|
|
3883
3570
|
function addClasses() {
|
|
3884
3571
|
const swiper = this;
|
|
3885
3572
|
const {
|
|
@@ -3889,17 +3576,12 @@
|
|
|
3889
3576
|
el,
|
|
3890
3577
|
device
|
|
3891
3578
|
} = swiper;
|
|
3579
|
+
// core-lite: removed module-specific classes
|
|
3892
3580
|
// prettier-ignore
|
|
3893
3581
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3894
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3895
|
-
}, {
|
|
3896
3582
|
'autoheight': params.autoHeight
|
|
3897
3583
|
}, {
|
|
3898
3584
|
'rtl': rtl
|
|
3899
|
-
}, {
|
|
3900
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3901
|
-
}, {
|
|
3902
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3903
3585
|
}, {
|
|
3904
3586
|
'android': device.android
|
|
3905
3587
|
}, {
|
|
@@ -3996,16 +3678,12 @@
|
|
|
3996
3678
|
autoHeight: false,
|
|
3997
3679
|
// Set wrapper width
|
|
3998
3680
|
setWrapperSize: false,
|
|
3999
|
-
//
|
|
4000
|
-
virtualTranslate: false,
|
|
4001
|
-
// Effects
|
|
3681
|
+
// Effects (core-lite only supports `slide`)
|
|
4002
3682
|
effect: 'slide',
|
|
4003
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
4004
|
-
|
|
4005
3683
|
// Breakpoints
|
|
4006
3684
|
breakpoints: undefined,
|
|
4007
3685
|
breakpointsBase: 'window',
|
|
4008
|
-
// Slides
|
|
3686
|
+
// Slides
|
|
4009
3687
|
spaceBetween: 0,
|
|
4010
3688
|
slidesPerView: 1,
|
|
4011
3689
|
slidesPerGroup: 1,
|
|
@@ -4108,7 +3786,9 @@
|
|
|
4108
3786
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4109
3787
|
params[moduleParamName].auto = true;
|
|
4110
3788
|
}
|
|
4111
|
-
|
|
3789
|
+
|
|
3790
|
+
// Core-lite: keep only pagination auto-init.
|
|
3791
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4112
3792
|
params[moduleParamName].auto = true;
|
|
4113
3793
|
}
|
|
4114
3794
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4234,7 +3914,6 @@
|
|
|
4234
3914
|
// Indexes
|
|
4235
3915
|
activeIndex: 0,
|
|
4236
3916
|
realIndex: 0,
|
|
4237
|
-
//
|
|
4238
3917
|
isBeginning: true,
|
|
4239
3918
|
isEnd: false,
|
|
4240
3919
|
// Props
|
|
@@ -4261,12 +3940,9 @@
|
|
|
4261
3940
|
currentTranslate: undefined,
|
|
4262
3941
|
startTranslate: undefined,
|
|
4263
3942
|
allowThresholdMove: undefined,
|
|
4264
|
-
// Form elements to match
|
|
4265
3943
|
focusableElements: swiper.params.focusableElements,
|
|
4266
|
-
// Last click time
|
|
4267
3944
|
lastClickTime: 0,
|
|
4268
3945
|
clickTimeout: undefined,
|
|
4269
|
-
// Velocities
|
|
4270
3946
|
velocities: [],
|
|
4271
3947
|
allowMomentumBounce: undefined,
|
|
4272
3948
|
startMoving: undefined,
|
|
@@ -4295,7 +3971,6 @@
|
|
|
4295
3971
|
swiper.init();
|
|
4296
3972
|
}
|
|
4297
3973
|
|
|
4298
|
-
// Return app instance
|
|
4299
3974
|
// eslint-disable-next-line no-constructor-return
|
|
4300
3975
|
return swiper;
|
|
4301
3976
|
}
|
|
@@ -4327,16 +4002,6 @@
|
|
|
4327
4002
|
getSlideIndexByData(index) {
|
|
4328
4003
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4329
4004
|
}
|
|
4330
|
-
getSlideIndexWhenGrid(index) {
|
|
4331
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4332
|
-
if (this.params.grid.fill === 'column') {
|
|
4333
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4334
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4335
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4336
|
-
}
|
|
4337
|
-
}
|
|
4338
|
-
return index;
|
|
4339
|
-
}
|
|
4340
4005
|
recalcSlides() {
|
|
4341
4006
|
const swiper = this;
|
|
4342
4007
|
const {
|
|
@@ -4438,21 +4103,15 @@
|
|
|
4438
4103
|
}
|
|
4439
4104
|
}
|
|
4440
4105
|
} else {
|
|
4441
|
-
// eslint-disable-next-line
|
|
4442
4106
|
if (view === 'current') {
|
|
4443
4107
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4444
4108
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4445
|
-
if (slideInView)
|
|
4446
|
-
spv += 1;
|
|
4447
|
-
}
|
|
4109
|
+
if (slideInView) spv += 1;
|
|
4448
4110
|
}
|
|
4449
4111
|
} else {
|
|
4450
|
-
// previous
|
|
4451
4112
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4452
4113
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4453
|
-
if (slideInView)
|
|
4454
|
-
spv += 1;
|
|
4455
|
-
}
|
|
4114
|
+
if (slideInView) spv += 1;
|
|
4456
4115
|
}
|
|
4457
4116
|
}
|
|
4458
4117
|
}
|
|
@@ -4465,14 +4124,11 @@
|
|
|
4465
4124
|
snapGrid,
|
|
4466
4125
|
params
|
|
4467
4126
|
} = swiper;
|
|
4468
|
-
// Breakpoints
|
|
4469
4127
|
if (params.breakpoints) {
|
|
4470
4128
|
swiper.setBreakpoint();
|
|
4471
4129
|
}
|
|
4472
4130
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4473
|
-
if (imageEl.complete)
|
|
4474
|
-
processLazyPreloader(swiper, imageEl);
|
|
4475
|
-
}
|
|
4131
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4476
4132
|
});
|
|
4477
4133
|
swiper.updateSize();
|
|
4478
4134
|
swiper.updateSlides();
|
|
@@ -4486,22 +4142,12 @@
|
|
|
4486
4142
|
swiper.updateSlidesClasses();
|
|
4487
4143
|
}
|
|
4488
4144
|
let translated;
|
|
4489
|
-
if (params.
|
|
4490
|
-
|
|
4491
|
-
if (params.autoHeight) {
|
|
4492
|
-
swiper.updateAutoHeight();
|
|
4493
|
-
}
|
|
4145
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4146
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4494
4147
|
} else {
|
|
4495
|
-
|
|
4496
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4497
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4498
|
-
} else {
|
|
4499
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4500
|
-
}
|
|
4501
|
-
if (!translated) {
|
|
4502
|
-
setTranslate();
|
|
4503
|
-
}
|
|
4148
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4504
4149
|
}
|
|
4150
|
+
if (!translated) setTranslate();
|
|
4505
4151
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4506
4152
|
swiper.checkOverflow();
|
|
4507
4153
|
}
|
|
@@ -4514,7 +4160,6 @@
|
|
|
4514
4160
|
const swiper = this;
|
|
4515
4161
|
const currentDirection = swiper.params.direction;
|
|
4516
4162
|
if (!newDirection) {
|
|
4517
|
-
// eslint-disable-next-line
|
|
4518
4163
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4519
4164
|
}
|
|
4520
4165
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4552,15 +4197,11 @@
|
|
|
4552
4197
|
mount(element) {
|
|
4553
4198
|
const swiper = this;
|
|
4554
4199
|
if (swiper.mounted) return true;
|
|
4555
|
-
|
|
4556
|
-
// Find el
|
|
4557
4200
|
let el = element || swiper.params.el;
|
|
4558
4201
|
if (typeof el === 'string') {
|
|
4559
4202
|
el = document.querySelector(el);
|
|
4560
4203
|
}
|
|
4561
|
-
if (!el)
|
|
4562
|
-
return false;
|
|
4563
|
-
}
|
|
4204
|
+
if (!el) return false;
|
|
4564
4205
|
el.swiper = swiper;
|
|
4565
4206
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4566
4207
|
swiper.isElement = true;
|
|
@@ -4571,12 +4212,10 @@
|
|
|
4571
4212
|
const getWrapper = () => {
|
|
4572
4213
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4573
4214
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4574
|
-
// Children needs to return slot items
|
|
4575
4215
|
return res;
|
|
4576
4216
|
}
|
|
4577
4217
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4578
4218
|
};
|
|
4579
|
-
// Find Wrapper
|
|
4580
4219
|
let wrapperEl = getWrapper();
|
|
4581
4220
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4582
4221
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4591,7 +4230,6 @@
|
|
|
4591
4230
|
slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
|
4592
4231
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4593
4232
|
mounted: true,
|
|
4594
|
-
// RTL
|
|
4595
4233
|
rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
|
4596
4234
|
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
|
4597
4235
|
wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
|
@@ -4611,7 +4249,6 @@
|
|
|
4611
4249
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4612
4250
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4613
4251
|
if (isFirstSlide) {
|
|
4614
|
-
// Move last item to first position when at first slide
|
|
4615
4252
|
const lastSlide = slides.at(-1);
|
|
4616
4253
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4617
4254
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4623,7 +4260,6 @@
|
|
|
4623
4260
|
swiper.setTransition(speed);
|
|
4624
4261
|
swiper.setTranslate(-swiperTranslate);
|
|
4625
4262
|
} else if (isLastSlide) {
|
|
4626
|
-
// Move first item to last position when at last slide
|
|
4627
4263
|
const firstSlide = slides[0];
|
|
4628
4264
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4629
4265
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4644,42 +4280,24 @@
|
|
|
4644
4280
|
const mounted = swiper.mount(el);
|
|
4645
4281
|
if (mounted === false) return swiper;
|
|
4646
4282
|
swiper.emit('beforeInit');
|
|
4647
|
-
|
|
4648
|
-
// Set breakpoint
|
|
4649
4283
|
if (swiper.params.breakpoints) {
|
|
4650
4284
|
swiper.setBreakpoint();
|
|
4651
4285
|
}
|
|
4652
|
-
|
|
4653
|
-
// Add Classes
|
|
4654
4286
|
swiper.addClasses();
|
|
4655
|
-
|
|
4656
|
-
// Update size
|
|
4657
4287
|
swiper.updateSize();
|
|
4658
|
-
|
|
4659
|
-
// Update slides
|
|
4660
4288
|
swiper.updateSlides();
|
|
4661
4289
|
if (swiper.params.watchOverflow) {
|
|
4662
4290
|
swiper.checkOverflow();
|
|
4663
4291
|
}
|
|
4664
|
-
|
|
4665
|
-
// Set Grab Cursor
|
|
4666
4292
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4667
4293
|
swiper.setGrabCursor();
|
|
4668
4294
|
}
|
|
4669
4295
|
|
|
4670
|
-
// Slide
|
|
4671
|
-
|
|
4672
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4673
|
-
} else {
|
|
4674
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4675
|
-
}
|
|
4676
|
-
|
|
4677
|
-
// Create loop
|
|
4296
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4297
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4678
4298
|
if (swiper.params.loop) {
|
|
4679
4299
|
swiper.loopCreate(undefined, true);
|
|
4680
4300
|
}
|
|
4681
|
-
|
|
4682
|
-
// Attach events
|
|
4683
4301
|
swiper.attachEvents();
|
|
4684
4302
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4685
4303
|
if (swiper.isElement) {
|
|
@@ -4689,18 +4307,12 @@
|
|
|
4689
4307
|
if (imageEl.complete) {
|
|
4690
4308
|
processLazyPreloader(swiper, imageEl);
|
|
4691
4309
|
} else {
|
|
4692
|
-
imageEl.addEventListener('load', e =>
|
|
4693
|
-
processLazyPreloader(swiper, e.target);
|
|
4694
|
-
});
|
|
4310
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4695
4311
|
}
|
|
4696
4312
|
});
|
|
4697
4313
|
preload(swiper);
|
|
4698
|
-
|
|
4699
|
-
// Init Flag
|
|
4700
4314
|
swiper.initialized = true;
|
|
4701
4315
|
preload(swiper);
|
|
4702
|
-
|
|
4703
|
-
// Emit
|
|
4704
4316
|
swiper.emit('init');
|
|
4705
4317
|
swiper.emit('afterInit');
|
|
4706
4318
|
return swiper;
|
|
@@ -4723,27 +4335,15 @@
|
|
|
4723
4335
|
return null;
|
|
4724
4336
|
}
|
|
4725
4337
|
swiper.emit('beforeDestroy');
|
|
4726
|
-
|
|
4727
|
-
// Init Flag
|
|
4728
4338
|
swiper.initialized = false;
|
|
4729
|
-
|
|
4730
|
-
// Detach events
|
|
4731
4339
|
swiper.detachEvents();
|
|
4732
|
-
|
|
4733
|
-
// Destroy loop
|
|
4734
4340
|
if (params.loop) {
|
|
4735
4341
|
swiper.loopDestroy();
|
|
4736
4342
|
}
|
|
4737
|
-
|
|
4738
|
-
// Cleanup styles
|
|
4739
4343
|
if (cleanStyles) {
|
|
4740
4344
|
swiper.removeClasses();
|
|
4741
|
-
if (el && typeof el !== 'string')
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
if (wrapperEl) {
|
|
4745
|
-
wrapperEl.removeAttribute('style');
|
|
4746
|
-
}
|
|
4345
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4346
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4747
4347
|
if (slides && slides.length) {
|
|
4748
4348
|
slides.forEach(slideEl => {
|
|
4749
4349
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4753,8 +4353,6 @@
|
|
|
4753
4353
|
}
|
|
4754
4354
|
}
|
|
4755
4355
|
swiper.emit('destroy');
|
|
4756
|
-
|
|
4757
|
-
// Detach emitter events
|
|
4758
4356
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4759
4357
|
swiper.off(eventName);
|
|
4760
4358
|
});
|
|
@@ -5125,7 +4723,7 @@
|
|
|
5125
4723
|
}
|
|
5126
4724
|
|
|
5127
4725
|
/**
|
|
5128
|
-
* Swiper Custom Element 0.0.
|
|
4726
|
+
* Swiper Custom Element 0.0.15-dev.1
|
|
5129
4727
|
* Gem SDK - Swiper, Customized of swiper
|
|
5130
4728
|
* https://swiperjs.com
|
|
5131
4729
|
*
|
|
@@ -5133,7 +4731,7 @@
|
|
|
5133
4731
|
*
|
|
5134
4732
|
* Released under the MIT License
|
|
5135
4733
|
*
|
|
5136
|
-
* Released on: March
|
|
4734
|
+
* Released on: March 20, 2026
|
|
5137
4735
|
*/
|
|
5138
4736
|
|
|
5139
4737
|
|