@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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper 0.0.
|
|
2
|
+
* Swiper 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
|
var Swiper = (function () {
|
|
@@ -829,9 +829,6 @@ var Swiper = (function () {
|
|
|
829
829
|
|
|
830
830
|
function updateSlides() {
|
|
831
831
|
const swiper = this;
|
|
832
|
-
function getDirectionPropertyValue(node, label) {
|
|
833
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
834
|
-
}
|
|
835
832
|
const params = swiper.params;
|
|
836
833
|
const {
|
|
837
834
|
wrapperEl,
|
|
@@ -840,10 +837,8 @@ var Swiper = (function () {
|
|
|
840
837
|
rtlTranslate: rtl,
|
|
841
838
|
wrongRTL
|
|
842
839
|
} = swiper;
|
|
843
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
844
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
845
840
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
846
|
-
const slidesLength =
|
|
841
|
+
const slidesLength = slides.length;
|
|
847
842
|
let snapGrid = [];
|
|
848
843
|
const slidesGrid = [];
|
|
849
844
|
const slidesSizesGrid = [];
|
|
@@ -861,15 +856,15 @@ var Swiper = (function () {
|
|
|
861
856
|
let slidePosition = -offsetBefore;
|
|
862
857
|
let prevSlideSize = 0;
|
|
863
858
|
let index = 0;
|
|
864
|
-
if (typeof swiperSize === 'undefined')
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
859
|
+
if (typeof swiperSize === 'undefined') return;
|
|
867
860
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
868
861
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
869
862
|
} else if (typeof spaceBetween === 'string') {
|
|
870
863
|
spaceBetween = parseFloat(spaceBetween);
|
|
871
864
|
}
|
|
872
|
-
|
|
865
|
+
|
|
866
|
+
// core-lite: compute total slides size without optional modules
|
|
867
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
873
868
|
|
|
874
869
|
// reset margins
|
|
875
870
|
slides.forEach(slideEl => {
|
|
@@ -887,49 +882,34 @@ var Swiper = (function () {
|
|
|
887
882
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
888
883
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
889
884
|
}
|
|
890
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
891
|
-
if (gridEnabled) {
|
|
892
|
-
swiper.grid.initSlides(slides);
|
|
893
|
-
} else if (swiper.grid) {
|
|
894
|
-
swiper.grid.unsetSlides();
|
|
895
|
-
}
|
|
896
885
|
|
|
897
886
|
// Calc slides
|
|
898
887
|
let slideSize;
|
|
899
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
900
|
-
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
|
901
|
-
}).length > 0;
|
|
888
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
902
889
|
for (let i = 0; i < slidesLength; i += 1) {
|
|
903
890
|
slideSize = 0;
|
|
904
891
|
let slide;
|
|
905
892
|
if (slides[i]) slide = slides[i];
|
|
906
|
-
if (gridEnabled) {
|
|
907
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
908
|
-
}
|
|
909
893
|
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
910
894
|
|
|
911
895
|
if (params.slidesPerView === 'auto') {
|
|
912
|
-
if (shouldResetSlideSize) {
|
|
896
|
+
if (shouldResetSlideSize && slides[i]) {
|
|
913
897
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
914
898
|
}
|
|
915
899
|
const slideStyles = getComputedStyle(slide);
|
|
916
900
|
const currentTransform = slide.style.transform;
|
|
917
901
|
const currentWebKitTransform = slide.style.webkitTransform;
|
|
918
|
-
if (currentTransform)
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
if (currentWebKitTransform) {
|
|
922
|
-
slide.style.webkitTransform = 'none';
|
|
923
|
-
}
|
|
902
|
+
if (currentTransform) slide.style.transform = 'none';
|
|
903
|
+
if (currentWebKitTransform) slide.style.webkitTransform = 'none';
|
|
924
904
|
if (params.roundLengths) {
|
|
925
905
|
slideSize = swiper.isHorizontal() ? elementOuterSize(slide, 'width', true) : elementOuterSize(slide, 'height', true);
|
|
926
906
|
} else {
|
|
927
907
|
// eslint-disable-next-line
|
|
928
|
-
const width =
|
|
929
|
-
const paddingLeft =
|
|
930
|
-
const paddingRight =
|
|
931
|
-
const marginLeft =
|
|
932
|
-
const marginRight =
|
|
908
|
+
const width = parseFloat(slideStyles.getPropertyValue('width')) || slide.offsetWidth;
|
|
909
|
+
const paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left')) || 0;
|
|
910
|
+
const paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right')) || 0;
|
|
911
|
+
const marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left')) || 0;
|
|
912
|
+
const marginRight = parseFloat(slideStyles.getPropertyValue('margin-right')) || 0;
|
|
933
913
|
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
934
914
|
if (boxSizing && boxSizing === 'border-box') {
|
|
935
915
|
slideSize = width + marginLeft + marginRight;
|
|
@@ -941,12 +921,8 @@ var Swiper = (function () {
|
|
|
941
921
|
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
942
922
|
}
|
|
943
923
|
}
|
|
944
|
-
if (currentTransform)
|
|
945
|
-
|
|
946
|
-
}
|
|
947
|
-
if (currentWebKitTransform) {
|
|
948
|
-
slide.style.webkitTransform = currentWebKitTransform;
|
|
949
|
-
}
|
|
924
|
+
if (currentTransform) slide.style.transform = currentTransform;
|
|
925
|
+
if (currentWebKitTransform) slide.style.webkitTransform = currentWebKitTransform;
|
|
950
926
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
951
927
|
} else {
|
|
952
928
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
@@ -955,13 +931,13 @@ var Swiper = (function () {
|
|
|
955
931
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
956
932
|
}
|
|
957
933
|
}
|
|
958
|
-
if (slides[i])
|
|
959
|
-
slides[i].swiperSlideSize = slideSize;
|
|
960
|
-
}
|
|
934
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
961
935
|
slidesSizesGrid.push(slideSize);
|
|
962
936
|
if (params.centeredSlides) {
|
|
963
937
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
964
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
938
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
939
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
940
|
+
}
|
|
965
941
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
966
942
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
967
943
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -969,55 +945,37 @@ var Swiper = (function () {
|
|
|
969
945
|
slidesGrid.push(slidePosition);
|
|
970
946
|
} else {
|
|
971
947
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
972
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
948
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
949
|
+
snapGrid.push(slidePosition);
|
|
950
|
+
}
|
|
973
951
|
slidesGrid.push(slidePosition);
|
|
974
952
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
975
953
|
}
|
|
976
|
-
swiper.
|
|
954
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
977
955
|
prevSlideSize = slideSize;
|
|
978
956
|
index += 1;
|
|
979
957
|
}
|
|
980
|
-
swiper.
|
|
981
|
-
if (rtl && wrongRTL &&
|
|
982
|
-
wrapperEl.style.width = `${swiper.
|
|
958
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
959
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
960
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
983
961
|
}
|
|
984
962
|
if (params.setWrapperSize) {
|
|
985
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
986
|
-
}
|
|
987
|
-
if (gridEnabled) {
|
|
988
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
963
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
989
964
|
}
|
|
990
965
|
|
|
991
|
-
// Remove last
|
|
966
|
+
// Remove last snap points depending on width (non-centered)
|
|
992
967
|
if (!params.centeredSlides) {
|
|
993
968
|
const newSlidesGrid = [];
|
|
994
969
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
995
970
|
let slidesGridItem = snapGrid[i];
|
|
996
971
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
997
|
-
if (snapGrid[i] <= swiper.
|
|
972
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
998
973
|
newSlidesGrid.push(slidesGridItem);
|
|
999
974
|
}
|
|
1000
975
|
}
|
|
1001
976
|
snapGrid = newSlidesGrid;
|
|
1002
|
-
if (Math.floor(swiper.
|
|
1003
|
-
snapGrid.push(swiper.
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
if (isVirtual && params.loop) {
|
|
1007
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
1008
|
-
if (params.slidesPerGroup > 1) {
|
|
1009
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
1010
|
-
const groupSize = size * params.slidesPerGroup;
|
|
1011
|
-
for (let i = 0; i < groups; i += 1) {
|
|
1012
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
1016
|
-
if (params.slidesPerGroup === 1) {
|
|
1017
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
1018
|
-
}
|
|
1019
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
1020
|
-
swiper.virtualSize += size;
|
|
977
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
978
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1021
979
|
}
|
|
1022
980
|
}
|
|
1023
981
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1025,9 +983,7 @@ var Swiper = (function () {
|
|
|
1025
983
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1026
984
|
slides.filter((_, slideIndex) => {
|
|
1027
985
|
if (!params.cssMode || params.loop) return true;
|
|
1028
|
-
if (slideIndex === slides.length - 1)
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
986
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1031
987
|
return true;
|
|
1032
988
|
}).forEach(slideEl => {
|
|
1033
989
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1077,7 +1033,9 @@ var Swiper = (function () {
|
|
|
1077
1033
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1078
1034
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1079
1035
|
}
|
|
1080
|
-
|
|
1036
|
+
|
|
1037
|
+
// Emit changes
|
|
1038
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
1081
1039
|
swiper.emit('slidesLengthChange');
|
|
1082
1040
|
}
|
|
1083
1041
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1091,7 +1049,7 @@ var Swiper = (function () {
|
|
|
1091
1049
|
swiper.updateSlidesOffset();
|
|
1092
1050
|
}
|
|
1093
1051
|
swiper.emit('slidesUpdated');
|
|
1094
|
-
if (!
|
|
1052
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1095
1053
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1096
1054
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1097
1055
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1105,20 +1063,13 @@ var Swiper = (function () {
|
|
|
1105
1063
|
function updateAutoHeight(speed) {
|
|
1106
1064
|
const swiper = this;
|
|
1107
1065
|
const activeSlides = [];
|
|
1108
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1109
|
-
let newHeight = 0;
|
|
1110
|
-
let i;
|
|
1111
1066
|
if (typeof speed === 'number') {
|
|
1112
1067
|
swiper.setTransition(speed);
|
|
1113
1068
|
} else if (speed === true) {
|
|
1114
1069
|
swiper.setTransition(swiper.params.speed);
|
|
1115
1070
|
}
|
|
1116
|
-
const getSlideByIndex = index =>
|
|
1117
|
-
|
|
1118
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1119
|
-
}
|
|
1120
|
-
return swiper.slides[index];
|
|
1121
|
-
};
|
|
1071
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1072
|
+
|
|
1122
1073
|
// Find slides currently in view
|
|
1123
1074
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1124
1075
|
if (swiper.params.centeredSlides) {
|
|
@@ -1126,9 +1077,9 @@ var Swiper = (function () {
|
|
|
1126
1077
|
activeSlides.push(slide);
|
|
1127
1078
|
});
|
|
1128
1079
|
} else {
|
|
1129
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1080
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1130
1081
|
const index = swiper.activeIndex + i;
|
|
1131
|
-
if (index > swiper.slides.length
|
|
1082
|
+
if (index > swiper.slides.length) break;
|
|
1132
1083
|
activeSlides.push(getSlideByIndex(index));
|
|
1133
1084
|
}
|
|
1134
1085
|
}
|
|
@@ -1137,14 +1088,13 @@ var Swiper = (function () {
|
|
|
1137
1088
|
}
|
|
1138
1089
|
|
|
1139
1090
|
// Find new height from highest slide in view
|
|
1140
|
-
|
|
1091
|
+
let newHeight = 0;
|
|
1092
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1141
1093
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1142
1094
|
const height = activeSlides[i].offsetHeight;
|
|
1143
1095
|
newHeight = height > newHeight ? height : newHeight;
|
|
1144
1096
|
}
|
|
1145
1097
|
}
|
|
1146
|
-
|
|
1147
|
-
// Update Height
|
|
1148
1098
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1149
1099
|
}
|
|
1150
1100
|
|
|
@@ -1289,46 +1239,16 @@ var Swiper = (function () {
|
|
|
1289
1239
|
slidesEl,
|
|
1290
1240
|
activeIndex
|
|
1291
1241
|
} = swiper;
|
|
1292
|
-
const
|
|
1293
|
-
const
|
|
1294
|
-
const
|
|
1295
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1296
|
-
};
|
|
1297
|
-
let activeSlide;
|
|
1298
|
-
let prevSlide;
|
|
1242
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1243
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1244
|
+
const activeSlide = slides[activeIndex];
|
|
1299
1245
|
let nextSlide;
|
|
1300
|
-
|
|
1301
|
-
if (params.loop) {
|
|
1302
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
1303
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
1304
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
1305
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
1306
|
-
} else {
|
|
1307
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1308
|
-
}
|
|
1309
|
-
} else {
|
|
1310
|
-
if (gridEnabled) {
|
|
1311
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
1312
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
1313
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
1314
|
-
} else {
|
|
1315
|
-
activeSlide = slides[activeIndex];
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1246
|
+
let prevSlide;
|
|
1318
1247
|
if (activeSlide) {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
nextSlide = slides[0];
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
// Prev Slide
|
|
1327
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1328
|
-
if (params.loop && !prevSlide === 0) {
|
|
1329
|
-
prevSlide = slides[slides.length - 1];
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1248
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1249
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1250
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1251
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1332
1252
|
}
|
|
1333
1253
|
slides.forEach(slideEl => {
|
|
1334
1254
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1419,7 +1339,6 @@ var Swiper = (function () {
|
|
|
1419
1339
|
activeIndex = i;
|
|
1420
1340
|
}
|
|
1421
1341
|
}
|
|
1422
|
-
// Normalize slideIndex
|
|
1423
1342
|
if (params.normalizeSlideIndex) {
|
|
1424
1343
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1425
1344
|
}
|
|
@@ -1437,16 +1356,6 @@ var Swiper = (function () {
|
|
|
1437
1356
|
} = swiper;
|
|
1438
1357
|
let activeIndex = newActiveIndex;
|
|
1439
1358
|
let snapIndex;
|
|
1440
|
-
const getVirtualRealIndex = aIndex => {
|
|
1441
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
1442
|
-
if (realIndex < 0) {
|
|
1443
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
1444
|
-
}
|
|
1445
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
1446
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1447
|
-
}
|
|
1448
|
-
return realIndex;
|
|
1449
|
-
};
|
|
1450
1359
|
if (typeof activeIndex === 'undefined') {
|
|
1451
1360
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1452
1361
|
}
|
|
@@ -1464,32 +1373,12 @@ var Swiper = (function () {
|
|
|
1464
1373
|
}
|
|
1465
1374
|
return;
|
|
1466
1375
|
}
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
return;
|
|
1470
|
-
}
|
|
1471
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1472
|
-
|
|
1473
|
-
// Get real index
|
|
1474
|
-
let realIndex;
|
|
1475
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1476
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1477
|
-
} else if (gridEnabled) {
|
|
1478
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1479
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1480
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1481
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1482
|
-
}
|
|
1483
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1484
|
-
} else if (swiper.slides[activeIndex]) {
|
|
1376
|
+
let realIndex = activeIndex;
|
|
1377
|
+
if (swiper.slides[activeIndex]) {
|
|
1485
1378
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1486
1379
|
if (slideIndex) {
|
|
1487
1380
|
realIndex = parseInt(slideIndex, 10);
|
|
1488
|
-
} else {
|
|
1489
|
-
realIndex = activeIndex;
|
|
1490
1381
|
}
|
|
1491
|
-
} else {
|
|
1492
|
-
realIndex = activeIndex;
|
|
1493
1382
|
}
|
|
1494
1383
|
Object.assign(swiper, {
|
|
1495
1384
|
previousSnapIndex,
|
|
@@ -1536,11 +1425,7 @@ var Swiper = (function () {
|
|
|
1536
1425
|
}
|
|
1537
1426
|
if (slide && slideFound) {
|
|
1538
1427
|
swiper.clickedSlide = slide;
|
|
1539
|
-
|
|
1540
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1541
|
-
} else {
|
|
1542
|
-
swiper.clickedIndex = slideIndex;
|
|
1543
|
-
}
|
|
1428
|
+
swiper.clickedIndex = slideIndex;
|
|
1544
1429
|
} else {
|
|
1545
1430
|
swiper.clickedSlide = undefined;
|
|
1546
1431
|
swiper.clickedIndex = undefined;
|
|
@@ -1574,9 +1459,6 @@ var Swiper = (function () {
|
|
|
1574
1459
|
translate,
|
|
1575
1460
|
wrapperEl
|
|
1576
1461
|
} = swiper;
|
|
1577
|
-
if (params.virtualTranslate) {
|
|
1578
|
-
return rtl ? -translate : translate;
|
|
1579
|
-
}
|
|
1580
1462
|
if (params.cssMode) {
|
|
1581
1463
|
return translate;
|
|
1582
1464
|
}
|
|
@@ -1610,7 +1492,7 @@ var Swiper = (function () {
|
|
|
1610
1492
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1611
1493
|
if (params.cssMode) {
|
|
1612
1494
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1613
|
-
} else
|
|
1495
|
+
} else {
|
|
1614
1496
|
if (swiper.isHorizontal()) {
|
|
1615
1497
|
x -= swiper.cssOverflowAdjustment();
|
|
1616
1498
|
} else {
|
|
@@ -1847,7 +1729,6 @@ var Swiper = (function () {
|
|
|
1847
1729
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1848
1730
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1849
1731
|
const translate = -snapGrid[snapIndex];
|
|
1850
|
-
// Normalize slideIndex
|
|
1851
1732
|
if (params.normalizeSlideIndex) {
|
|
1852
1733
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1853
1734
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1864,33 +1745,24 @@ var Swiper = (function () {
|
|
|
1864
1745
|
}
|
|
1865
1746
|
}
|
|
1866
1747
|
}
|
|
1748
|
+
|
|
1867
1749
|
// Directions locks
|
|
1868
1750
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1869
1751
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1870
1752
|
return false;
|
|
1871
1753
|
}
|
|
1872
1754
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1873
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1874
|
-
return false;
|
|
1875
|
-
}
|
|
1755
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1876
1756
|
}
|
|
1877
1757
|
}
|
|
1878
1758
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1879
1759
|
swiper.emit('beforeSlideChangeStart');
|
|
1880
1760
|
}
|
|
1881
|
-
|
|
1882
|
-
// Update progress
|
|
1883
1761
|
swiper.updateProgress(translate);
|
|
1884
1762
|
let direction;
|
|
1885
1763
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1886
|
-
|
|
1887
|
-
// initial virtual
|
|
1888
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1889
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1890
|
-
// Update Index
|
|
1891
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1764
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1892
1765
|
swiper.updateActiveIndex(slideIndex);
|
|
1893
|
-
// Update Height
|
|
1894
1766
|
if (params.autoHeight) {
|
|
1895
1767
|
swiper.updateAutoHeight();
|
|
1896
1768
|
}
|
|
@@ -1908,24 +1780,7 @@ var Swiper = (function () {
|
|
|
1908
1780
|
const isH = swiper.isHorizontal();
|
|
1909
1781
|
const t = rtl ? translate : -translate;
|
|
1910
1782
|
if (speed === 0) {
|
|
1911
|
-
|
|
1912
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1913
|
-
swiper._immediateVirtual = true;
|
|
1914
|
-
}
|
|
1915
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1916
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1917
|
-
requestAnimationFrame(() => {
|
|
1918
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1919
|
-
});
|
|
1920
|
-
} else {
|
|
1921
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1922
|
-
}
|
|
1923
|
-
if (isVirtual) {
|
|
1924
|
-
requestAnimationFrame(() => {
|
|
1925
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1926
|
-
swiper._immediateVirtual = false;
|
|
1927
|
-
});
|
|
1928
|
-
}
|
|
1783
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1929
1784
|
} else {
|
|
1930
1785
|
if (!swiper.support.smoothScroll) {
|
|
1931
1786
|
animateCSSModeScroll({
|
|
@@ -1943,10 +1798,7 @@ var Swiper = (function () {
|
|
|
1943
1798
|
return true;
|
|
1944
1799
|
}
|
|
1945
1800
|
const browser = getBrowser();
|
|
1946
|
-
|
|
1947
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1948
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1949
|
-
}
|
|
1801
|
+
browser.isSafari;
|
|
1950
1802
|
swiper.setTransition(speed);
|
|
1951
1803
|
swiper.setTranslate(translate);
|
|
1952
1804
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2117,8 +1969,6 @@ var Swiper = (function () {
|
|
|
2117
1969
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2118
1970
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2119
1971
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2120
|
-
|
|
2121
|
-
// Move last item to first position only if active slide is the first slide
|
|
2122
1972
|
const lastSlide = slides[slides.length - 1];
|
|
2123
1973
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2124
1974
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2153,11 +2003,8 @@ var Swiper = (function () {
|
|
|
2153
2003
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2154
2004
|
}
|
|
2155
2005
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2156
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2157
2006
|
if (params.loop) {
|
|
2158
|
-
if (animating &&
|
|
2159
|
-
|
|
2160
|
-
// Kiểm tra xem loop có bị disable không
|
|
2007
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2161
2008
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2162
2009
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2163
2010
|
swiper.loopFix({
|
|
@@ -2183,8 +2030,7 @@ var Swiper = (function () {
|
|
|
2183
2030
|
const lastSnapGridIndex = swiper.snapGrid.length - 1;
|
|
2184
2031
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2185
2032
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2186
|
-
|
|
2187
|
-
// Move first item to last position only if active slide is the last slide
|
|
2033
|
+
if (!swiper.params.loop) return;
|
|
2188
2034
|
const firstSlide = slides[0];
|
|
2189
2035
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2190
2036
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2209,17 +2055,14 @@ var Swiper = (function () {
|
|
|
2209
2055
|
params,
|
|
2210
2056
|
snapGrid,
|
|
2211
2057
|
slidesGrid,
|
|
2212
|
-
rtlTranslate,
|
|
2213
|
-
enabled
|
|
2214
|
-
animating
|
|
2058
|
+
rtlTranslate: rtlTranslate,
|
|
2059
|
+
enabled
|
|
2215
2060
|
} = swiper;
|
|
2216
2061
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2217
2062
|
if (typeof speed === 'undefined') {
|
|
2218
2063
|
speed = swiper.params.speed;
|
|
2219
2064
|
}
|
|
2220
|
-
swiper.virtual && params.virtual.enabled;
|
|
2221
2065
|
if (params.loop) {
|
|
2222
|
-
// Kiểm tra xem loop có bị disable không
|
|
2223
2066
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2224
2067
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2225
2068
|
swiper.loopFix({
|
|
@@ -2236,18 +2079,16 @@ var Swiper = (function () {
|
|
|
2236
2079
|
}
|
|
2237
2080
|
const normalizedTranslate = normalize(translate);
|
|
2238
2081
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2239
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2240
2082
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2241
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2083
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2242
2084
|
let prevSnapIndex;
|
|
2243
2085
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2244
2086
|
if (normalizedTranslate >= snap) {
|
|
2245
|
-
// prevSnap = snap;
|
|
2246
2087
|
prevSnapIndex = snapIndex;
|
|
2247
2088
|
}
|
|
2248
2089
|
});
|
|
2249
2090
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2250
|
-
prevSnap =
|
|
2091
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2251
2092
|
}
|
|
2252
2093
|
}
|
|
2253
2094
|
let prevIndex = 0;
|
|
@@ -2260,7 +2101,7 @@ var Swiper = (function () {
|
|
|
2260
2101
|
}
|
|
2261
2102
|
}
|
|
2262
2103
|
if (params.rewind && swiper.isBeginning) {
|
|
2263
|
-
const lastIndex = swiper.
|
|
2104
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2264
2105
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2265
2106
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2266
2107
|
requestAnimationFrame(() => {
|
|
@@ -2274,8 +2115,7 @@ var Swiper = (function () {
|
|
|
2274
2115
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2275
2116
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2276
2117
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2277
|
-
|
|
2278
|
-
// Move last item to first position only if active slide is the first slide
|
|
2118
|
+
if (!swiper.params.loop) return;
|
|
2279
2119
|
const lastSlide = slides[slides.length - 1];
|
|
2280
2120
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2281
2121
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2351,20 +2191,19 @@ var Swiper = (function () {
|
|
|
2351
2191
|
slidesEl
|
|
2352
2192
|
} = swiper;
|
|
2353
2193
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2354
|
-
|
|
2194
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2355
2195
|
let realIndex;
|
|
2356
2196
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2357
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2358
2197
|
if (params.loop) {
|
|
2359
2198
|
if (swiper.animating) return;
|
|
2360
2199
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2361
2200
|
if (params.centeredSlides) {
|
|
2362
2201
|
swiper.slideToLoop(realIndex);
|
|
2363
|
-
} else if (slideToIndex >
|
|
2202
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2364
2203
|
swiper.loopFix();
|
|
2365
|
-
|
|
2204
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2366
2205
|
nextTick(() => {
|
|
2367
|
-
swiper.slideTo(
|
|
2206
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2368
2207
|
});
|
|
2369
2208
|
} else {
|
|
2370
2209
|
swiper.slideTo(slideToIndex);
|
|
@@ -2391,7 +2230,7 @@ var Swiper = (function () {
|
|
|
2391
2230
|
params,
|
|
2392
2231
|
slidesEl
|
|
2393
2232
|
} = swiper;
|
|
2394
|
-
if (!params.loop
|
|
2233
|
+
if (!params.loop) return;
|
|
2395
2234
|
const initSlides = () => {
|
|
2396
2235
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2397
2236
|
slides.forEach((el, index) => {
|
|
@@ -2400,21 +2239,17 @@ var Swiper = (function () {
|
|
|
2400
2239
|
};
|
|
2401
2240
|
const clearBlankSlides = () => {
|
|
2402
2241
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2403
|
-
slides.forEach(el =>
|
|
2404
|
-
el.remove();
|
|
2405
|
-
});
|
|
2242
|
+
slides.forEach(el => el.remove());
|
|
2406
2243
|
if (slides.length > 0) {
|
|
2407
2244
|
swiper.recalcSlides();
|
|
2408
2245
|
swiper.updateSlides();
|
|
2409
2246
|
}
|
|
2410
2247
|
};
|
|
2411
|
-
|
|
2412
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2248
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2413
2249
|
clearBlankSlides();
|
|
2414
2250
|
}
|
|
2415
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2251
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2416
2252
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2417
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2418
2253
|
const addBlankSlides = amountOfSlides => {
|
|
2419
2254
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2420
2255
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2431,16 +2266,6 @@ var Swiper = (function () {
|
|
|
2431
2266
|
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)');
|
|
2432
2267
|
}
|
|
2433
2268
|
initSlides();
|
|
2434
|
-
} else if (shouldFillGrid) {
|
|
2435
|
-
if (params.loopAddBlankSlides) {
|
|
2436
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2437
|
-
addBlankSlides(slidesToAdd);
|
|
2438
|
-
swiper.recalcSlides();
|
|
2439
|
-
swiper.updateSlides();
|
|
2440
|
-
} else {
|
|
2441
|
-
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)');
|
|
2442
|
-
}
|
|
2443
|
-
initSlides();
|
|
2444
2269
|
} else {
|
|
2445
2270
|
initSlides();
|
|
2446
2271
|
}
|
|
@@ -2459,13 +2284,12 @@ var Swiper = (function () {
|
|
|
2459
2284
|
setTranslate,
|
|
2460
2285
|
activeSlideIndex,
|
|
2461
2286
|
initial,
|
|
2462
|
-
byController,
|
|
2463
2287
|
byMousewheel
|
|
2464
2288
|
} = _temp === void 0 ? {} : _temp;
|
|
2465
2289
|
const swiper = this;
|
|
2466
2290
|
if (!swiper.params.loop) return;
|
|
2467
2291
|
|
|
2468
|
-
// Disable loop mode
|
|
2292
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2469
2293
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2470
2294
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2471
2295
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2485,21 +2309,6 @@ var Swiper = (function () {
|
|
|
2485
2309
|
} = params;
|
|
2486
2310
|
swiper.allowSlidePrev = true;
|
|
2487
2311
|
swiper.allowSlideNext = true;
|
|
2488
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2489
|
-
if (slideTo) {
|
|
2490
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2491
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2492
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2493
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2494
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2495
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2499
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2500
|
-
swiper.emit('loopFix');
|
|
2501
|
-
return;
|
|
2502
|
-
}
|
|
2503
2312
|
let slidesPerView = params.slidesPerView;
|
|
2504
2313
|
if (slidesPerView === 'auto') {
|
|
2505
2314
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2509,22 +2318,19 @@ var Swiper = (function () {
|
|
|
2509
2318
|
slidesPerView = slidesPerView + 1;
|
|
2510
2319
|
}
|
|
2511
2320
|
}
|
|
2512
|
-
const slidesPerGroup = params.
|
|
2321
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2513
2322
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2514
2323
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2515
2324
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2516
2325
|
}
|
|
2517
2326
|
loopedSlides += params.loopAdditionalSlides;
|
|
2518
2327
|
swiper.loopedSlides = loopedSlides;
|
|
2519
|
-
|
|
2520
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2328
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2521
2329
|
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');
|
|
2522
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2523
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2524
2330
|
}
|
|
2525
2331
|
const prependSlidesIndexes = [];
|
|
2526
2332
|
const appendSlidesIndexes = [];
|
|
2527
|
-
const cols =
|
|
2333
|
+
const cols = slides.length;
|
|
2528
2334
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2529
2335
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2530
2336
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2536,24 +2342,15 @@ var Swiper = (function () {
|
|
|
2536
2342
|
const isPrev = direction === 'prev' || !direction;
|
|
2537
2343
|
let slidesPrepended = 0;
|
|
2538
2344
|
let slidesAppended = 0;
|
|
2539
|
-
const activeColIndex =
|
|
2345
|
+
const activeColIndex = activeSlideIndex;
|
|
2540
2346
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2347
|
+
|
|
2541
2348
|
// prepend last slides before start
|
|
2542
2349
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2543
2350
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2544
2351
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2545
2352
|
const index = i - Math.floor(i / cols) * cols;
|
|
2546
|
-
|
|
2547
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2548
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2549
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2550
|
-
}
|
|
2551
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2552
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2553
|
-
// });
|
|
2554
|
-
} else {
|
|
2555
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2556
|
-
}
|
|
2353
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2557
2354
|
}
|
|
2558
2355
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2559
2356
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2562,27 +2359,13 @@ var Swiper = (function () {
|
|
|
2562
2359
|
}
|
|
2563
2360
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2564
2361
|
const index = i - Math.floor(i / cols) * cols;
|
|
2565
|
-
|
|
2566
|
-
slides.forEach((slide, slideIndex) => {
|
|
2567
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2568
|
-
});
|
|
2569
|
-
} else {
|
|
2570
|
-
appendSlidesIndexes.push(index);
|
|
2571
|
-
}
|
|
2362
|
+
appendSlidesIndexes.push(index);
|
|
2572
2363
|
}
|
|
2573
2364
|
}
|
|
2574
2365
|
swiper.__preventObserver__ = true;
|
|
2575
2366
|
requestAnimationFrame(() => {
|
|
2576
2367
|
swiper.__preventObserver__ = false;
|
|
2577
2368
|
});
|
|
2578
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2579
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2580
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2581
|
-
}
|
|
2582
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2583
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
2369
|
if (isPrev) {
|
|
2587
2370
|
prependSlidesIndexes.forEach(index => {
|
|
2588
2371
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2600,10 +2383,6 @@ var Swiper = (function () {
|
|
|
2600
2383
|
swiper.recalcSlides();
|
|
2601
2384
|
if (params.slidesPerView === 'auto') {
|
|
2602
2385
|
swiper.updateSlides();
|
|
2603
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2604
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2605
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2606
|
-
});
|
|
2607
2386
|
}
|
|
2608
2387
|
if (params.watchSlidesProgress) {
|
|
2609
2388
|
swiper.updateSlidesOffset();
|
|
@@ -2623,12 +2402,10 @@ var Swiper = (function () {
|
|
|
2623
2402
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2624
2403
|
}
|
|
2625
2404
|
}
|
|
2626
|
-
} else {
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2631
|
-
}
|
|
2405
|
+
} else if (setTranslate) {
|
|
2406
|
+
const shift = prependSlidesIndexes.length;
|
|
2407
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2408
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2632
2409
|
}
|
|
2633
2410
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2634
2411
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2644,36 +2421,14 @@ var Swiper = (function () {
|
|
|
2644
2421
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2645
2422
|
}
|
|
2646
2423
|
}
|
|
2647
|
-
} else {
|
|
2648
|
-
const shift =
|
|
2424
|
+
} else if (setTranslate) {
|
|
2425
|
+
const shift = appendSlidesIndexes.length;
|
|
2649
2426
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2650
2427
|
}
|
|
2651
2428
|
}
|
|
2652
2429
|
}
|
|
2653
2430
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2654
2431
|
swiper.allowSlideNext = allowSlideNext;
|
|
2655
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2656
|
-
const loopParams = {
|
|
2657
|
-
slideRealIndex,
|
|
2658
|
-
direction,
|
|
2659
|
-
setTranslate,
|
|
2660
|
-
activeSlideIndex,
|
|
2661
|
-
byController: true
|
|
2662
|
-
};
|
|
2663
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2664
|
-
swiper.controller.control.forEach(c => {
|
|
2665
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2666
|
-
...loopParams,
|
|
2667
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2668
|
-
});
|
|
2669
|
-
});
|
|
2670
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2671
|
-
swiper.controller.control.loopFix({
|
|
2672
|
-
...loopParams,
|
|
2673
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
2432
|
swiper.emit('loopFix');
|
|
2678
2433
|
}
|
|
2679
2434
|
|
|
@@ -2690,7 +2445,7 @@ var Swiper = (function () {
|
|
|
2690
2445
|
const swiper = this;
|
|
2691
2446
|
if (!swiper.params.loop) return;
|
|
2692
2447
|
|
|
2693
|
-
// Disable loop mode
|
|
2448
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2694
2449
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2695
2450
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2696
2451
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2729,7 +2484,7 @@ var Swiper = (function () {
|
|
|
2729
2484
|
}
|
|
2730
2485
|
loopedSlides += params.loopAdditionalSlides;
|
|
2731
2486
|
swiper.loopedSlides = loopedSlides;
|
|
2732
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2487
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2733
2488
|
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');
|
|
2734
2489
|
}
|
|
2735
2490
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2755,20 +2510,16 @@ var Swiper = (function () {
|
|
|
2755
2510
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2756
2511
|
}
|
|
2757
2512
|
|
|
2758
|
-
//
|
|
2513
|
+
// DocumentFragment to hold slide clones
|
|
2759
2514
|
const cloneFragment = document.createDocumentFragment();
|
|
2760
2515
|
|
|
2761
|
-
// Clone
|
|
2516
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2762
2517
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2763
2518
|
if (slides[index]) {
|
|
2764
2519
|
const originalSlide = slides[index];
|
|
2765
2520
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2766
|
-
|
|
2767
|
-
// Đánh dấu slide clone
|
|
2768
2521
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2769
2522
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2770
|
-
|
|
2771
|
-
// Thêm clone vào fragment
|
|
2772
2523
|
cloneFragment.appendChild(clonedSlide);
|
|
2773
2524
|
}
|
|
2774
2525
|
});
|
|
@@ -2789,32 +2540,28 @@ var Swiper = (function () {
|
|
|
2789
2540
|
});
|
|
2790
2541
|
}
|
|
2791
2542
|
|
|
2792
|
-
//
|
|
2543
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2793
2544
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2794
2545
|
clonedSlides.sort((a, b) => {
|
|
2795
2546
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2796
2547
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2797
2548
|
return indexA - indexB;
|
|
2798
2549
|
});
|
|
2799
|
-
|
|
2800
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2801
2550
|
cloneFragment.innerHTML = '';
|
|
2802
2551
|
clonedSlides.forEach(slide => {
|
|
2803
2552
|
cloneFragment.appendChild(slide);
|
|
2804
2553
|
});
|
|
2805
2554
|
|
|
2806
|
-
//
|
|
2555
|
+
// Place fragment into the right position
|
|
2807
2556
|
if (isPrev) {
|
|
2808
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2809
2557
|
slidesEl.appendChild(cloneFragment);
|
|
2810
2558
|
} else if (isNext) {
|
|
2811
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2812
2559
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2813
2560
|
}
|
|
2814
2561
|
swiper.recalcSlides();
|
|
2815
2562
|
swiper.updateSlides();
|
|
2816
2563
|
|
|
2817
|
-
//
|
|
2564
|
+
// Find old active slide index after recalculation
|
|
2818
2565
|
let oldActiveIndex = null;
|
|
2819
2566
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2820
2567
|
const child = slidesEl.children[i];
|
|
@@ -2827,7 +2574,7 @@ var Swiper = (function () {
|
|
|
2827
2574
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2828
2575
|
}
|
|
2829
2576
|
|
|
2830
|
-
//
|
|
2577
|
+
// Update translate after removing clones for animation
|
|
2831
2578
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2832
2579
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2833
2580
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2853,7 +2600,8 @@ var Swiper = (function () {
|
|
|
2853
2600
|
}
|
|
2854
2601
|
swiper.setTranslate(updateTranslate);
|
|
2855
2602
|
}
|
|
2856
|
-
|
|
2603
|
+
|
|
2604
|
+
// Remove clones
|
|
2857
2605
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2858
2606
|
cloneSlides.forEach(cloneSlide => {
|
|
2859
2607
|
if (cloneSlide.parentNode) {
|
|
@@ -2883,7 +2631,7 @@ var Swiper = (function () {
|
|
|
2883
2631
|
params,
|
|
2884
2632
|
slidesEl
|
|
2885
2633
|
} = swiper;
|
|
2886
|
-
if (!params.loop || !slidesEl
|
|
2634
|
+
if (!params.loop || !slidesEl) return;
|
|
2887
2635
|
swiper.recalcSlides();
|
|
2888
2636
|
const newSlidesOrder = [];
|
|
2889
2637
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2944,7 +2692,6 @@ var Swiper = (function () {
|
|
|
2944
2692
|
unsetGrabCursor
|
|
2945
2693
|
};
|
|
2946
2694
|
|
|
2947
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2948
2695
|
function closestElement(selector, base) {
|
|
2949
2696
|
if (base === void 0) {
|
|
2950
2697
|
base = this;
|
|
@@ -2953,9 +2700,7 @@ var Swiper = (function () {
|
|
|
2953
2700
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2954
2701
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2955
2702
|
const found = el.closest(selector);
|
|
2956
|
-
if (!found && !el.getRootNode)
|
|
2957
|
-
return null;
|
|
2958
|
-
}
|
|
2703
|
+
if (!found && !el.getRootNode) return null;
|
|
2959
2704
|
return found || __closestFrom(el.getRootNode().host);
|
|
2960
2705
|
}
|
|
2961
2706
|
return __closestFrom(base);
|
|
@@ -2983,9 +2728,7 @@ var Swiper = (function () {
|
|
|
2983
2728
|
if (e.originalEvent) e = e.originalEvent;
|
|
2984
2729
|
const data = swiper.touchEventsData;
|
|
2985
2730
|
if (e.type === 'pointerdown') {
|
|
2986
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
2987
|
-
return;
|
|
2988
|
-
}
|
|
2731
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
2989
2732
|
data.pointerId = e.pointerId;
|
|
2990
2733
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2991
2734
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3002,9 +2745,7 @@ var Swiper = (function () {
|
|
|
3002
2745
|
} = swiper;
|
|
3003
2746
|
if (!enabled) return;
|
|
3004
2747
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3005
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3006
|
-
return;
|
|
3007
|
-
}
|
|
2748
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3008
2749
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3009
2750
|
swiper.loopFix();
|
|
3010
2751
|
}
|
|
@@ -3015,8 +2756,6 @@ var Swiper = (function () {
|
|
|
3015
2756
|
if ('which' in e && e.which === 3) return;
|
|
3016
2757
|
if ('button' in e && e.button > 0) return;
|
|
3017
2758
|
if (data.isTouched && data.isMoved) return;
|
|
3018
|
-
|
|
3019
|
-
// change target el for shadow root component
|
|
3020
2759
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3021
2760
|
// eslint-disable-next-line
|
|
3022
2761
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3025,8 +2764,6 @@ var Swiper = (function () {
|
|
|
3025
2764
|
}
|
|
3026
2765
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3027
2766
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3028
|
-
|
|
3029
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3030
2767
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3031
2768
|
swiper.allowClick = true;
|
|
3032
2769
|
return;
|
|
@@ -3038,12 +2775,7 @@ var Swiper = (function () {
|
|
|
3038
2775
|
touches.currentY = e.pageY;
|
|
3039
2776
|
const startX = touches.currentX;
|
|
3040
2777
|
const startY = touches.currentY;
|
|
3041
|
-
|
|
3042
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3043
|
-
|
|
3044
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3045
|
-
return;
|
|
3046
|
-
}
|
|
2778
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3047
2779
|
Object.assign(data, {
|
|
3048
2780
|
isTouched: true,
|
|
3049
2781
|
isMoved: false,
|
|
@@ -3072,9 +2804,6 @@ var Swiper = (function () {
|
|
|
3072
2804
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3073
2805
|
e.preventDefault();
|
|
3074
2806
|
}
|
|
3075
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3076
|
-
swiper.freeMode.onTouchStart();
|
|
3077
|
-
}
|
|
3078
2807
|
swiper.emit('touchStart', e);
|
|
3079
2808
|
}
|
|
3080
2809
|
|
|
@@ -3093,7 +2822,7 @@ var Swiper = (function () {
|
|
|
3093
2822
|
let e = event;
|
|
3094
2823
|
if (e.originalEvent) e = e.originalEvent;
|
|
3095
2824
|
if (e.type === 'pointermove') {
|
|
3096
|
-
if (data.touchId !== null) return;
|
|
2825
|
+
if (data.touchId !== null) return;
|
|
3097
2826
|
const id = e.pointerId;
|
|
3098
2827
|
if (id !== data.pointerId) return;
|
|
3099
2828
|
}
|
|
@@ -3134,7 +2863,6 @@ var Swiper = (function () {
|
|
|
3134
2863
|
}
|
|
3135
2864
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3136
2865
|
if (swiper.isVertical()) {
|
|
3137
|
-
// Vertical
|
|
3138
2866
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3139
2867
|
data.isTouched = false;
|
|
3140
2868
|
data.isMoved = false;
|
|
@@ -3236,7 +2964,6 @@ var Swiper = (function () {
|
|
|
3236
2964
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3237
2965
|
}
|
|
3238
2966
|
data.allowMomentumBounce = false;
|
|
3239
|
-
// Grab Cursor
|
|
3240
2967
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3241
2968
|
swiper.setGrabCursor(true);
|
|
3242
2969
|
}
|
|
@@ -3307,8 +3034,6 @@ var Swiper = (function () {
|
|
|
3307
3034
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3308
3035
|
data.currentTranslate = data.startTranslate;
|
|
3309
3036
|
}
|
|
3310
|
-
|
|
3311
|
-
// Threshold
|
|
3312
3037
|
if (params.threshold > 0) {
|
|
3313
3038
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3314
3039
|
if (!data.allowThresholdMove) {
|
|
@@ -3326,17 +3051,12 @@ var Swiper = (function () {
|
|
|
3326
3051
|
}
|
|
3327
3052
|
if (!params.followFinger || params.cssMode) return;
|
|
3328
3053
|
|
|
3329
|
-
//
|
|
3330
|
-
if (params.
|
|
3054
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3055
|
+
if (params.watchSlidesProgress) {
|
|
3331
3056
|
swiper.updateActiveIndex();
|
|
3332
3057
|
swiper.updateSlidesClasses();
|
|
3333
3058
|
}
|
|
3334
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3335
|
-
swiper.freeMode.onTouchMove();
|
|
3336
|
-
}
|
|
3337
|
-
// Update progress
|
|
3338
3059
|
swiper.updateProgress(data.currentTranslate);
|
|
3339
|
-
// Update translate
|
|
3340
3060
|
swiper.setTranslate(data.currentTranslate);
|
|
3341
3061
|
}
|
|
3342
3062
|
|
|
@@ -3348,7 +3068,7 @@ var Swiper = (function () {
|
|
|
3348
3068
|
let targetTouch;
|
|
3349
3069
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3350
3070
|
if (!isTouchEvent) {
|
|
3351
|
-
if (data.touchId !== null) return;
|
|
3071
|
+
if (data.touchId !== null) return;
|
|
3352
3072
|
if (e.pointerId !== data.pointerId) return;
|
|
3353
3073
|
targetTouch = e;
|
|
3354
3074
|
} else {
|
|
@@ -3357,9 +3077,7 @@ var Swiper = (function () {
|
|
|
3357
3077
|
}
|
|
3358
3078
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3359
3079
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3360
|
-
if (!proceed)
|
|
3361
|
-
return;
|
|
3362
|
-
}
|
|
3080
|
+
if (!proceed) return;
|
|
3363
3081
|
}
|
|
3364
3082
|
data.pointerId = null;
|
|
3365
3083
|
data.touchId = null;
|
|
@@ -3377,9 +3095,7 @@ var Swiper = (function () {
|
|
|
3377
3095
|
}
|
|
3378
3096
|
data.allowTouchCallbacks = false;
|
|
3379
3097
|
if (!data.isTouched) {
|
|
3380
|
-
if (data.isMoved && params.grabCursor)
|
|
3381
|
-
swiper.setGrabCursor(false);
|
|
3382
|
-
}
|
|
3098
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3383
3099
|
data.isMoved = false;
|
|
3384
3100
|
data.startMoving = false;
|
|
3385
3101
|
return;
|
|
@@ -3389,8 +3105,6 @@ var Swiper = (function () {
|
|
|
3389
3105
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3390
3106
|
swiper.setGrabCursor(false);
|
|
3391
3107
|
}
|
|
3392
|
-
|
|
3393
|
-
// Time diff
|
|
3394
3108
|
const touchEndTime = now();
|
|
3395
3109
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3396
3110
|
|
|
@@ -3417,20 +3131,8 @@ var Swiper = (function () {
|
|
|
3417
3131
|
data.isMoved = false;
|
|
3418
3132
|
data.startMoving = false;
|
|
3419
3133
|
let currentPos;
|
|
3420
|
-
if (params.followFinger)
|
|
3421
|
-
|
|
3422
|
-
} else {
|
|
3423
|
-
currentPos = -data.currentTranslate;
|
|
3424
|
-
}
|
|
3425
|
-
if (params.cssMode) {
|
|
3426
|
-
return;
|
|
3427
|
-
}
|
|
3428
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3429
|
-
swiper.freeMode.onTouchEnd({
|
|
3430
|
-
currentPos
|
|
3431
|
-
});
|
|
3432
|
-
return;
|
|
3433
|
-
}
|
|
3134
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3135
|
+
if (params.cssMode) return;
|
|
3434
3136
|
|
|
3435
3137
|
// Find current slide
|
|
3436
3138
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3452,22 +3154,22 @@ var Swiper = (function () {
|
|
|
3452
3154
|
let rewindLastIndex = null;
|
|
3453
3155
|
if (params.rewind) {
|
|
3454
3156
|
if (swiper.isBeginning) {
|
|
3455
|
-
rewindLastIndex =
|
|
3157
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3456
3158
|
} else if (swiper.isEnd) {
|
|
3457
3159
|
rewindFirstIndex = 0;
|
|
3458
3160
|
}
|
|
3459
3161
|
}
|
|
3460
|
-
// Find current slide size
|
|
3461
3162
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3462
3163
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3463
3164
|
if (timeDiff > params.longSwipesMs) {
|
|
3464
|
-
// Long touches
|
|
3465
3165
|
if (!params.longSwipes) {
|
|
3466
3166
|
swiper.slideTo(swiper.activeIndex);
|
|
3467
3167
|
return;
|
|
3468
3168
|
}
|
|
3469
3169
|
if (swiper.swipeDirection === 'next') {
|
|
3470
|
-
if (ratio >= params.longSwipesRatio)
|
|
3170
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3171
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3172
|
+
} else swiper.slideTo(stopIndex);
|
|
3471
3173
|
}
|
|
3472
3174
|
if (swiper.swipeDirection === 'prev') {
|
|
3473
3175
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3519,7 +3221,6 @@ var Swiper = (function () {
|
|
|
3519
3221
|
allowSlidePrev,
|
|
3520
3222
|
snapGrid
|
|
3521
3223
|
} = swiper;
|
|
3522
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3523
3224
|
|
|
3524
3225
|
// Disable locks on resize
|
|
3525
3226
|
swiper.allowSlideNext = true;
|
|
@@ -3527,15 +3228,12 @@ var Swiper = (function () {
|
|
|
3527
3228
|
swiper.updateSize();
|
|
3528
3229
|
swiper.updateSlides();
|
|
3529
3230
|
swiper.updateSlidesClasses();
|
|
3530
|
-
|
|
3531
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3231
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3532
3232
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3233
|
+
} else if (swiper.params.loop) {
|
|
3234
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3533
3235
|
} else {
|
|
3534
|
-
|
|
3535
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3536
|
-
} else {
|
|
3537
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3538
|
-
}
|
|
3236
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3539
3237
|
}
|
|
3540
3238
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3541
3239
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3545,10 +3243,11 @@ var Swiper = (function () {
|
|
|
3545
3243
|
}
|
|
3546
3244
|
}, 500);
|
|
3547
3245
|
}
|
|
3246
|
+
|
|
3548
3247
|
// Return locks after resize
|
|
3549
3248
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3550
3249
|
swiper.allowSlideNext = allowSlideNext;
|
|
3551
|
-
if (
|
|
3250
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3552
3251
|
swiper.checkOverflow();
|
|
3553
3252
|
}
|
|
3554
3253
|
}
|
|
@@ -3602,6 +3301,10 @@ var Swiper = (function () {
|
|
|
3602
3301
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3603
3302
|
return;
|
|
3604
3303
|
}
|
|
3304
|
+
const el = e?.target;
|
|
3305
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3306
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3307
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3605
3308
|
swiper.update();
|
|
3606
3309
|
}
|
|
3607
3310
|
|
|
@@ -3713,8 +3416,15 @@ var Swiper = (function () {
|
|
|
3713
3416
|
detachEvents
|
|
3714
3417
|
};
|
|
3715
3418
|
|
|
3716
|
-
const
|
|
3717
|
-
|
|
3419
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3420
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3421
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3422
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3423
|
+
swiper[prop].disable();
|
|
3424
|
+
}
|
|
3425
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3426
|
+
swiper[prop].enable();
|
|
3427
|
+
}
|
|
3718
3428
|
};
|
|
3719
3429
|
function setBreakpoint() {
|
|
3720
3430
|
const swiper = this;
|
|
@@ -3735,38 +3445,20 @@ var Swiper = (function () {
|
|
|
3735
3445
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3736
3446
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3737
3447
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3738
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3739
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3740
3448
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3741
3449
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3742
3450
|
const wasEnabled = params.enabled;
|
|
3743
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3744
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3745
|
-
swiper.emitContainerClasses();
|
|
3746
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3747
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3748
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3749
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3750
|
-
}
|
|
3751
|
-
swiper.emitContainerClasses();
|
|
3752
|
-
}
|
|
3753
3451
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3754
3452
|
swiper.unsetGrabCursor();
|
|
3755
3453
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3756
3454
|
swiper.setGrabCursor();
|
|
3757
3455
|
}
|
|
3758
3456
|
|
|
3759
|
-
//
|
|
3760
|
-
['navigation', 'pagination'
|
|
3457
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3458
|
+
const modules = ['navigation', 'pagination'];
|
|
3459
|
+
modules.forEach(prop => {
|
|
3761
3460
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3762
|
-
|
|
3763
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3764
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3765
|
-
swiper[prop].disable();
|
|
3766
|
-
}
|
|
3767
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3768
|
-
swiper[prop].enable();
|
|
3769
|
-
}
|
|
3461
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3770
3462
|
});
|
|
3771
3463
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3772
3464
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3848,7 +3540,7 @@ var Swiper = (function () {
|
|
|
3848
3540
|
getBreakpoint
|
|
3849
3541
|
};
|
|
3850
3542
|
|
|
3851
|
-
|
|
3543
|
+
const prepareClasses = (entries, prefix) => {
|
|
3852
3544
|
const resultClasses = [];
|
|
3853
3545
|
entries.forEach(item => {
|
|
3854
3546
|
if (typeof item === 'object') {
|
|
@@ -3862,7 +3554,7 @@ var Swiper = (function () {
|
|
|
3862
3554
|
}
|
|
3863
3555
|
});
|
|
3864
3556
|
return resultClasses;
|
|
3865
|
-
}
|
|
3557
|
+
};
|
|
3866
3558
|
function addClasses() {
|
|
3867
3559
|
const swiper = this;
|
|
3868
3560
|
const {
|
|
@@ -3872,17 +3564,12 @@ var Swiper = (function () {
|
|
|
3872
3564
|
el,
|
|
3873
3565
|
device
|
|
3874
3566
|
} = swiper;
|
|
3567
|
+
// core-lite: removed module-specific classes
|
|
3875
3568
|
// prettier-ignore
|
|
3876
3569
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3877
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3878
|
-
}, {
|
|
3879
3570
|
'autoheight': params.autoHeight
|
|
3880
3571
|
}, {
|
|
3881
3572
|
'rtl': rtl
|
|
3882
|
-
}, {
|
|
3883
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3884
|
-
}, {
|
|
3885
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3886
3573
|
}, {
|
|
3887
3574
|
'android': device.android
|
|
3888
3575
|
}, {
|
|
@@ -3979,16 +3666,12 @@ var Swiper = (function () {
|
|
|
3979
3666
|
autoHeight: false,
|
|
3980
3667
|
// Set wrapper width
|
|
3981
3668
|
setWrapperSize: false,
|
|
3982
|
-
//
|
|
3983
|
-
virtualTranslate: false,
|
|
3984
|
-
// Effects
|
|
3669
|
+
// Effects (core-lite only supports `slide`)
|
|
3985
3670
|
effect: 'slide',
|
|
3986
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
3987
|
-
|
|
3988
3671
|
// Breakpoints
|
|
3989
3672
|
breakpoints: undefined,
|
|
3990
3673
|
breakpointsBase: 'window',
|
|
3991
|
-
// Slides
|
|
3674
|
+
// Slides
|
|
3992
3675
|
spaceBetween: 0,
|
|
3993
3676
|
slidesPerView: 1,
|
|
3994
3677
|
slidesPerGroup: 1,
|
|
@@ -4091,7 +3774,9 @@ var Swiper = (function () {
|
|
|
4091
3774
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4092
3775
|
params[moduleParamName].auto = true;
|
|
4093
3776
|
}
|
|
4094
|
-
|
|
3777
|
+
|
|
3778
|
+
// Core-lite: keep only pagination auto-init.
|
|
3779
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4095
3780
|
params[moduleParamName].auto = true;
|
|
4096
3781
|
}
|
|
4097
3782
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4217,7 +3902,6 @@ var Swiper = (function () {
|
|
|
4217
3902
|
// Indexes
|
|
4218
3903
|
activeIndex: 0,
|
|
4219
3904
|
realIndex: 0,
|
|
4220
|
-
//
|
|
4221
3905
|
isBeginning: true,
|
|
4222
3906
|
isEnd: false,
|
|
4223
3907
|
// Props
|
|
@@ -4244,12 +3928,9 @@ var Swiper = (function () {
|
|
|
4244
3928
|
currentTranslate: undefined,
|
|
4245
3929
|
startTranslate: undefined,
|
|
4246
3930
|
allowThresholdMove: undefined,
|
|
4247
|
-
// Form elements to match
|
|
4248
3931
|
focusableElements: swiper.params.focusableElements,
|
|
4249
|
-
// Last click time
|
|
4250
3932
|
lastClickTime: 0,
|
|
4251
3933
|
clickTimeout: undefined,
|
|
4252
|
-
// Velocities
|
|
4253
3934
|
velocities: [],
|
|
4254
3935
|
allowMomentumBounce: undefined,
|
|
4255
3936
|
startMoving: undefined,
|
|
@@ -4278,7 +3959,6 @@ var Swiper = (function () {
|
|
|
4278
3959
|
swiper.init();
|
|
4279
3960
|
}
|
|
4280
3961
|
|
|
4281
|
-
// Return app instance
|
|
4282
3962
|
// eslint-disable-next-line no-constructor-return
|
|
4283
3963
|
return swiper;
|
|
4284
3964
|
}
|
|
@@ -4310,16 +3990,6 @@ var Swiper = (function () {
|
|
|
4310
3990
|
getSlideIndexByData(index) {
|
|
4311
3991
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4312
3992
|
}
|
|
4313
|
-
getSlideIndexWhenGrid(index) {
|
|
4314
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4315
|
-
if (this.params.grid.fill === 'column') {
|
|
4316
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4317
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4318
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
return index;
|
|
4322
|
-
}
|
|
4323
3993
|
recalcSlides() {
|
|
4324
3994
|
const swiper = this;
|
|
4325
3995
|
const {
|
|
@@ -4421,21 +4091,15 @@ var Swiper = (function () {
|
|
|
4421
4091
|
}
|
|
4422
4092
|
}
|
|
4423
4093
|
} else {
|
|
4424
|
-
// eslint-disable-next-line
|
|
4425
4094
|
if (view === 'current') {
|
|
4426
4095
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4427
4096
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4428
|
-
if (slideInView)
|
|
4429
|
-
spv += 1;
|
|
4430
|
-
}
|
|
4097
|
+
if (slideInView) spv += 1;
|
|
4431
4098
|
}
|
|
4432
4099
|
} else {
|
|
4433
|
-
// previous
|
|
4434
4100
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4435
4101
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4436
|
-
if (slideInView)
|
|
4437
|
-
spv += 1;
|
|
4438
|
-
}
|
|
4102
|
+
if (slideInView) spv += 1;
|
|
4439
4103
|
}
|
|
4440
4104
|
}
|
|
4441
4105
|
}
|
|
@@ -4448,14 +4112,11 @@ var Swiper = (function () {
|
|
|
4448
4112
|
snapGrid,
|
|
4449
4113
|
params
|
|
4450
4114
|
} = swiper;
|
|
4451
|
-
// Breakpoints
|
|
4452
4115
|
if (params.breakpoints) {
|
|
4453
4116
|
swiper.setBreakpoint();
|
|
4454
4117
|
}
|
|
4455
4118
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4456
|
-
if (imageEl.complete)
|
|
4457
|
-
processLazyPreloader(swiper, imageEl);
|
|
4458
|
-
}
|
|
4119
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4459
4120
|
});
|
|
4460
4121
|
swiper.updateSize();
|
|
4461
4122
|
swiper.updateSlides();
|
|
@@ -4469,22 +4130,12 @@ var Swiper = (function () {
|
|
|
4469
4130
|
swiper.updateSlidesClasses();
|
|
4470
4131
|
}
|
|
4471
4132
|
let translated;
|
|
4472
|
-
if (params.
|
|
4473
|
-
|
|
4474
|
-
if (params.autoHeight) {
|
|
4475
|
-
swiper.updateAutoHeight();
|
|
4476
|
-
}
|
|
4133
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4134
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4477
4135
|
} else {
|
|
4478
|
-
|
|
4479
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4480
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4481
|
-
} else {
|
|
4482
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4483
|
-
}
|
|
4484
|
-
if (!translated) {
|
|
4485
|
-
setTranslate();
|
|
4486
|
-
}
|
|
4136
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4487
4137
|
}
|
|
4138
|
+
if (!translated) setTranslate();
|
|
4488
4139
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4489
4140
|
swiper.checkOverflow();
|
|
4490
4141
|
}
|
|
@@ -4497,7 +4148,6 @@ var Swiper = (function () {
|
|
|
4497
4148
|
const swiper = this;
|
|
4498
4149
|
const currentDirection = swiper.params.direction;
|
|
4499
4150
|
if (!newDirection) {
|
|
4500
|
-
// eslint-disable-next-line
|
|
4501
4151
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4502
4152
|
}
|
|
4503
4153
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4535,15 +4185,11 @@ var Swiper = (function () {
|
|
|
4535
4185
|
mount(element) {
|
|
4536
4186
|
const swiper = this;
|
|
4537
4187
|
if (swiper.mounted) return true;
|
|
4538
|
-
|
|
4539
|
-
// Find el
|
|
4540
4188
|
let el = element || swiper.params.el;
|
|
4541
4189
|
if (typeof el === 'string') {
|
|
4542
4190
|
el = document.querySelector(el);
|
|
4543
4191
|
}
|
|
4544
|
-
if (!el)
|
|
4545
|
-
return false;
|
|
4546
|
-
}
|
|
4192
|
+
if (!el) return false;
|
|
4547
4193
|
el.swiper = swiper;
|
|
4548
4194
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4549
4195
|
swiper.isElement = true;
|
|
@@ -4554,12 +4200,10 @@ var Swiper = (function () {
|
|
|
4554
4200
|
const getWrapper = () => {
|
|
4555
4201
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4556
4202
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4557
|
-
// Children needs to return slot items
|
|
4558
4203
|
return res;
|
|
4559
4204
|
}
|
|
4560
4205
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4561
4206
|
};
|
|
4562
|
-
// Find Wrapper
|
|
4563
4207
|
let wrapperEl = getWrapper();
|
|
4564
4208
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4565
4209
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4574,7 +4218,6 @@ var Swiper = (function () {
|
|
|
4574
4218
|
slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
|
4575
4219
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4576
4220
|
mounted: true,
|
|
4577
|
-
// RTL
|
|
4578
4221
|
rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
|
4579
4222
|
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
|
4580
4223
|
wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
|
@@ -4594,7 +4237,6 @@ var Swiper = (function () {
|
|
|
4594
4237
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4595
4238
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4596
4239
|
if (isFirstSlide) {
|
|
4597
|
-
// Move last item to first position when at first slide
|
|
4598
4240
|
const lastSlide = slides.at(-1);
|
|
4599
4241
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4600
4242
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4606,7 +4248,6 @@ var Swiper = (function () {
|
|
|
4606
4248
|
swiper.setTransition(speed);
|
|
4607
4249
|
swiper.setTranslate(-swiperTranslate);
|
|
4608
4250
|
} else if (isLastSlide) {
|
|
4609
|
-
// Move first item to last position when at last slide
|
|
4610
4251
|
const firstSlide = slides[0];
|
|
4611
4252
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4612
4253
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4627,42 +4268,24 @@ var Swiper = (function () {
|
|
|
4627
4268
|
const mounted = swiper.mount(el);
|
|
4628
4269
|
if (mounted === false) return swiper;
|
|
4629
4270
|
swiper.emit('beforeInit');
|
|
4630
|
-
|
|
4631
|
-
// Set breakpoint
|
|
4632
4271
|
if (swiper.params.breakpoints) {
|
|
4633
4272
|
swiper.setBreakpoint();
|
|
4634
4273
|
}
|
|
4635
|
-
|
|
4636
|
-
// Add Classes
|
|
4637
4274
|
swiper.addClasses();
|
|
4638
|
-
|
|
4639
|
-
// Update size
|
|
4640
4275
|
swiper.updateSize();
|
|
4641
|
-
|
|
4642
|
-
// Update slides
|
|
4643
4276
|
swiper.updateSlides();
|
|
4644
4277
|
if (swiper.params.watchOverflow) {
|
|
4645
4278
|
swiper.checkOverflow();
|
|
4646
4279
|
}
|
|
4647
|
-
|
|
4648
|
-
// Set Grab Cursor
|
|
4649
4280
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4650
4281
|
swiper.setGrabCursor();
|
|
4651
4282
|
}
|
|
4652
4283
|
|
|
4653
|
-
// Slide
|
|
4654
|
-
|
|
4655
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4656
|
-
} else {
|
|
4657
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4658
|
-
}
|
|
4659
|
-
|
|
4660
|
-
// Create loop
|
|
4284
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4285
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4661
4286
|
if (swiper.params.loop) {
|
|
4662
4287
|
swiper.loopCreate(undefined, true);
|
|
4663
4288
|
}
|
|
4664
|
-
|
|
4665
|
-
// Attach events
|
|
4666
4289
|
swiper.attachEvents();
|
|
4667
4290
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4668
4291
|
if (swiper.isElement) {
|
|
@@ -4672,18 +4295,12 @@ var Swiper = (function () {
|
|
|
4672
4295
|
if (imageEl.complete) {
|
|
4673
4296
|
processLazyPreloader(swiper, imageEl);
|
|
4674
4297
|
} else {
|
|
4675
|
-
imageEl.addEventListener('load', e =>
|
|
4676
|
-
processLazyPreloader(swiper, e.target);
|
|
4677
|
-
});
|
|
4298
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4678
4299
|
}
|
|
4679
4300
|
});
|
|
4680
4301
|
preload(swiper);
|
|
4681
|
-
|
|
4682
|
-
// Init Flag
|
|
4683
4302
|
swiper.initialized = true;
|
|
4684
4303
|
preload(swiper);
|
|
4685
|
-
|
|
4686
|
-
// Emit
|
|
4687
4304
|
swiper.emit('init');
|
|
4688
4305
|
swiper.emit('afterInit');
|
|
4689
4306
|
return swiper;
|
|
@@ -4706,27 +4323,15 @@ var Swiper = (function () {
|
|
|
4706
4323
|
return null;
|
|
4707
4324
|
}
|
|
4708
4325
|
swiper.emit('beforeDestroy');
|
|
4709
|
-
|
|
4710
|
-
// Init Flag
|
|
4711
4326
|
swiper.initialized = false;
|
|
4712
|
-
|
|
4713
|
-
// Detach events
|
|
4714
4327
|
swiper.detachEvents();
|
|
4715
|
-
|
|
4716
|
-
// Destroy loop
|
|
4717
4328
|
if (params.loop) {
|
|
4718
4329
|
swiper.loopDestroy();
|
|
4719
4330
|
}
|
|
4720
|
-
|
|
4721
|
-
// Cleanup styles
|
|
4722
4331
|
if (cleanStyles) {
|
|
4723
4332
|
swiper.removeClasses();
|
|
4724
|
-
if (el && typeof el !== 'string')
|
|
4725
|
-
|
|
4726
|
-
}
|
|
4727
|
-
if (wrapperEl) {
|
|
4728
|
-
wrapperEl.removeAttribute('style');
|
|
4729
|
-
}
|
|
4333
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4334
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4730
4335
|
if (slides && slides.length) {
|
|
4731
4336
|
slides.forEach(slideEl => {
|
|
4732
4337
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4736,8 +4341,6 @@ var Swiper = (function () {
|
|
|
4736
4341
|
}
|
|
4737
4342
|
}
|
|
4738
4343
|
swiper.emit('destroy');
|
|
4739
|
-
|
|
4740
|
-
// Detach emitter events
|
|
4741
4344
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4742
4345
|
swiper.off(eventName);
|
|
4743
4346
|
});
|