@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.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({
|
|
@@ -2184,7 +2031,6 @@ var Swiper = (function () {
|
|
|
2184
2031
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2185
2032
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2186
2033
|
if (!swiper.params.loop) return;
|
|
2187
|
-
// Move first item to last position only if active slide is the last slide
|
|
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,6 @@ 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
|
|
2279
2118
|
if (!swiper.params.loop) return;
|
|
2280
2119
|
const lastSlide = slides[slides.length - 1];
|
|
2281
2120
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2352,20 +2191,19 @@ var Swiper = (function () {
|
|
|
2352
2191
|
slidesEl
|
|
2353
2192
|
} = swiper;
|
|
2354
2193
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2355
|
-
|
|
2194
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2356
2195
|
let realIndex;
|
|
2357
2196
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2358
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2359
2197
|
if (params.loop) {
|
|
2360
2198
|
if (swiper.animating) return;
|
|
2361
2199
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2362
2200
|
if (params.centeredSlides) {
|
|
2363
2201
|
swiper.slideToLoop(realIndex);
|
|
2364
|
-
} else if (slideToIndex >
|
|
2202
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2365
2203
|
swiper.loopFix();
|
|
2366
|
-
|
|
2204
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2367
2205
|
nextTick(() => {
|
|
2368
|
-
swiper.slideTo(
|
|
2206
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2369
2207
|
});
|
|
2370
2208
|
} else {
|
|
2371
2209
|
swiper.slideTo(slideToIndex);
|
|
@@ -2392,7 +2230,7 @@ var Swiper = (function () {
|
|
|
2392
2230
|
params,
|
|
2393
2231
|
slidesEl
|
|
2394
2232
|
} = swiper;
|
|
2395
|
-
if (!params.loop
|
|
2233
|
+
if (!params.loop) return;
|
|
2396
2234
|
const initSlides = () => {
|
|
2397
2235
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2398
2236
|
slides.forEach((el, index) => {
|
|
@@ -2401,21 +2239,17 @@ var Swiper = (function () {
|
|
|
2401
2239
|
};
|
|
2402
2240
|
const clearBlankSlides = () => {
|
|
2403
2241
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2404
|
-
slides.forEach(el =>
|
|
2405
|
-
el.remove();
|
|
2406
|
-
});
|
|
2242
|
+
slides.forEach(el => el.remove());
|
|
2407
2243
|
if (slides.length > 0) {
|
|
2408
2244
|
swiper.recalcSlides();
|
|
2409
2245
|
swiper.updateSlides();
|
|
2410
2246
|
}
|
|
2411
2247
|
};
|
|
2412
|
-
|
|
2413
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2248
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2414
2249
|
clearBlankSlides();
|
|
2415
2250
|
}
|
|
2416
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2251
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2417
2252
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2418
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2419
2253
|
const addBlankSlides = amountOfSlides => {
|
|
2420
2254
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2421
2255
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2432,16 +2266,6 @@ var Swiper = (function () {
|
|
|
2432
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)');
|
|
2433
2267
|
}
|
|
2434
2268
|
initSlides();
|
|
2435
|
-
} else if (shouldFillGrid) {
|
|
2436
|
-
if (params.loopAddBlankSlides) {
|
|
2437
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2438
|
-
addBlankSlides(slidesToAdd);
|
|
2439
|
-
swiper.recalcSlides();
|
|
2440
|
-
swiper.updateSlides();
|
|
2441
|
-
} else {
|
|
2442
|
-
showWarning('Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)');
|
|
2443
|
-
}
|
|
2444
|
-
initSlides();
|
|
2445
2269
|
} else {
|
|
2446
2270
|
initSlides();
|
|
2447
2271
|
}
|
|
@@ -2460,13 +2284,12 @@ var Swiper = (function () {
|
|
|
2460
2284
|
setTranslate,
|
|
2461
2285
|
activeSlideIndex,
|
|
2462
2286
|
initial,
|
|
2463
|
-
byController,
|
|
2464
2287
|
byMousewheel
|
|
2465
2288
|
} = _temp === void 0 ? {} : _temp;
|
|
2466
2289
|
const swiper = this;
|
|
2467
2290
|
if (!swiper.params.loop) return;
|
|
2468
2291
|
|
|
2469
|
-
// Disable loop mode
|
|
2292
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2470
2293
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2471
2294
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2472
2295
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2486,21 +2309,6 @@ var Swiper = (function () {
|
|
|
2486
2309
|
} = params;
|
|
2487
2310
|
swiper.allowSlidePrev = true;
|
|
2488
2311
|
swiper.allowSlideNext = true;
|
|
2489
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2490
|
-
if (slideTo) {
|
|
2491
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2492
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2493
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2494
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2495
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2496
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2500
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2501
|
-
swiper.emit('loopFix');
|
|
2502
|
-
return;
|
|
2503
|
-
}
|
|
2504
2312
|
let slidesPerView = params.slidesPerView;
|
|
2505
2313
|
if (slidesPerView === 'auto') {
|
|
2506
2314
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2510,22 +2318,19 @@ var Swiper = (function () {
|
|
|
2510
2318
|
slidesPerView = slidesPerView + 1;
|
|
2511
2319
|
}
|
|
2512
2320
|
}
|
|
2513
|
-
const slidesPerGroup = params.
|
|
2321
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2514
2322
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2515
2323
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2516
2324
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2517
2325
|
}
|
|
2518
2326
|
loopedSlides += params.loopAdditionalSlides;
|
|
2519
2327
|
swiper.loopedSlides = loopedSlides;
|
|
2520
|
-
|
|
2521
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2328
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2522
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');
|
|
2523
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2524
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2525
2330
|
}
|
|
2526
2331
|
const prependSlidesIndexes = [];
|
|
2527
2332
|
const appendSlidesIndexes = [];
|
|
2528
|
-
const cols =
|
|
2333
|
+
const cols = slides.length;
|
|
2529
2334
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2530
2335
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2531
2336
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2537,24 +2342,15 @@ var Swiper = (function () {
|
|
|
2537
2342
|
const isPrev = direction === 'prev' || !direction;
|
|
2538
2343
|
let slidesPrepended = 0;
|
|
2539
2344
|
let slidesAppended = 0;
|
|
2540
|
-
const activeColIndex =
|
|
2345
|
+
const activeColIndex = activeSlideIndex;
|
|
2541
2346
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2347
|
+
|
|
2542
2348
|
// prepend last slides before start
|
|
2543
2349
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2544
2350
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2545
2351
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2546
2352
|
const index = i - Math.floor(i / cols) * cols;
|
|
2547
|
-
|
|
2548
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2549
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2550
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2551
|
-
}
|
|
2552
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2553
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2554
|
-
// });
|
|
2555
|
-
} else {
|
|
2556
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2557
|
-
}
|
|
2353
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2558
2354
|
}
|
|
2559
2355
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2560
2356
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2563,27 +2359,13 @@ var Swiper = (function () {
|
|
|
2563
2359
|
}
|
|
2564
2360
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2565
2361
|
const index = i - Math.floor(i / cols) * cols;
|
|
2566
|
-
|
|
2567
|
-
slides.forEach((slide, slideIndex) => {
|
|
2568
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2569
|
-
});
|
|
2570
|
-
} else {
|
|
2571
|
-
appendSlidesIndexes.push(index);
|
|
2572
|
-
}
|
|
2362
|
+
appendSlidesIndexes.push(index);
|
|
2573
2363
|
}
|
|
2574
2364
|
}
|
|
2575
2365
|
swiper.__preventObserver__ = true;
|
|
2576
2366
|
requestAnimationFrame(() => {
|
|
2577
2367
|
swiper.__preventObserver__ = false;
|
|
2578
2368
|
});
|
|
2579
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2580
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2581
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2582
|
-
}
|
|
2583
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2584
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
2369
|
if (isPrev) {
|
|
2588
2370
|
prependSlidesIndexes.forEach(index => {
|
|
2589
2371
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2601,10 +2383,6 @@ var Swiper = (function () {
|
|
|
2601
2383
|
swiper.recalcSlides();
|
|
2602
2384
|
if (params.slidesPerView === 'auto') {
|
|
2603
2385
|
swiper.updateSlides();
|
|
2604
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2605
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2606
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2607
|
-
});
|
|
2608
2386
|
}
|
|
2609
2387
|
if (params.watchSlidesProgress) {
|
|
2610
2388
|
swiper.updateSlidesOffset();
|
|
@@ -2624,12 +2402,10 @@ var Swiper = (function () {
|
|
|
2624
2402
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2625
2403
|
}
|
|
2626
2404
|
}
|
|
2627
|
-
} else {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2632
|
-
}
|
|
2405
|
+
} else if (setTranslate) {
|
|
2406
|
+
const shift = prependSlidesIndexes.length;
|
|
2407
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2408
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2633
2409
|
}
|
|
2634
2410
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2635
2411
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2645,36 +2421,14 @@ var Swiper = (function () {
|
|
|
2645
2421
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2646
2422
|
}
|
|
2647
2423
|
}
|
|
2648
|
-
} else {
|
|
2649
|
-
const shift =
|
|
2424
|
+
} else if (setTranslate) {
|
|
2425
|
+
const shift = appendSlidesIndexes.length;
|
|
2650
2426
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2651
2427
|
}
|
|
2652
2428
|
}
|
|
2653
2429
|
}
|
|
2654
2430
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2655
2431
|
swiper.allowSlideNext = allowSlideNext;
|
|
2656
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2657
|
-
const loopParams = {
|
|
2658
|
-
slideRealIndex,
|
|
2659
|
-
direction,
|
|
2660
|
-
setTranslate,
|
|
2661
|
-
activeSlideIndex,
|
|
2662
|
-
byController: true
|
|
2663
|
-
};
|
|
2664
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2665
|
-
swiper.controller.control.forEach(c => {
|
|
2666
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2667
|
-
...loopParams,
|
|
2668
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2669
|
-
});
|
|
2670
|
-
});
|
|
2671
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2672
|
-
swiper.controller.control.loopFix({
|
|
2673
|
-
...loopParams,
|
|
2674
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
2432
|
swiper.emit('loopFix');
|
|
2679
2433
|
}
|
|
2680
2434
|
|
|
@@ -2691,7 +2445,7 @@ var Swiper = (function () {
|
|
|
2691
2445
|
const swiper = this;
|
|
2692
2446
|
if (!swiper.params.loop) return;
|
|
2693
2447
|
|
|
2694
|
-
// Disable loop mode
|
|
2448
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2695
2449
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2696
2450
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2697
2451
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2730,7 +2484,7 @@ var Swiper = (function () {
|
|
|
2730
2484
|
}
|
|
2731
2485
|
loopedSlides += params.loopAdditionalSlides;
|
|
2732
2486
|
swiper.loopedSlides = loopedSlides;
|
|
2733
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2487
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2734
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');
|
|
2735
2489
|
}
|
|
2736
2490
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2756,20 +2510,16 @@ var Swiper = (function () {
|
|
|
2756
2510
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2757
2511
|
}
|
|
2758
2512
|
|
|
2759
|
-
//
|
|
2513
|
+
// DocumentFragment to hold slide clones
|
|
2760
2514
|
const cloneFragment = document.createDocumentFragment();
|
|
2761
2515
|
|
|
2762
|
-
// Clone
|
|
2516
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2763
2517
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2764
2518
|
if (slides[index]) {
|
|
2765
2519
|
const originalSlide = slides[index];
|
|
2766
2520
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2767
|
-
|
|
2768
|
-
// Đánh dấu slide clone
|
|
2769
2521
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2770
2522
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2771
|
-
|
|
2772
|
-
// Thêm clone vào fragment
|
|
2773
2523
|
cloneFragment.appendChild(clonedSlide);
|
|
2774
2524
|
}
|
|
2775
2525
|
});
|
|
@@ -2790,32 +2540,28 @@ var Swiper = (function () {
|
|
|
2790
2540
|
});
|
|
2791
2541
|
}
|
|
2792
2542
|
|
|
2793
|
-
//
|
|
2543
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2794
2544
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2795
2545
|
clonedSlides.sort((a, b) => {
|
|
2796
2546
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2797
2547
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2798
2548
|
return indexA - indexB;
|
|
2799
2549
|
});
|
|
2800
|
-
|
|
2801
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2802
2550
|
cloneFragment.innerHTML = '';
|
|
2803
2551
|
clonedSlides.forEach(slide => {
|
|
2804
2552
|
cloneFragment.appendChild(slide);
|
|
2805
2553
|
});
|
|
2806
2554
|
|
|
2807
|
-
//
|
|
2555
|
+
// Place fragment into the right position
|
|
2808
2556
|
if (isPrev) {
|
|
2809
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2810
2557
|
slidesEl.appendChild(cloneFragment);
|
|
2811
2558
|
} else if (isNext) {
|
|
2812
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2813
2559
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2814
2560
|
}
|
|
2815
2561
|
swiper.recalcSlides();
|
|
2816
2562
|
swiper.updateSlides();
|
|
2817
2563
|
|
|
2818
|
-
//
|
|
2564
|
+
// Find old active slide index after recalculation
|
|
2819
2565
|
let oldActiveIndex = null;
|
|
2820
2566
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2821
2567
|
const child = slidesEl.children[i];
|
|
@@ -2828,7 +2574,7 @@ var Swiper = (function () {
|
|
|
2828
2574
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2829
2575
|
}
|
|
2830
2576
|
|
|
2831
|
-
//
|
|
2577
|
+
// Update translate after removing clones for animation
|
|
2832
2578
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2833
2579
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2834
2580
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2854,7 +2600,8 @@ var Swiper = (function () {
|
|
|
2854
2600
|
}
|
|
2855
2601
|
swiper.setTranslate(updateTranslate);
|
|
2856
2602
|
}
|
|
2857
|
-
|
|
2603
|
+
|
|
2604
|
+
// Remove clones
|
|
2858
2605
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2859
2606
|
cloneSlides.forEach(cloneSlide => {
|
|
2860
2607
|
if (cloneSlide.parentNode) {
|
|
@@ -2884,7 +2631,7 @@ var Swiper = (function () {
|
|
|
2884
2631
|
params,
|
|
2885
2632
|
slidesEl
|
|
2886
2633
|
} = swiper;
|
|
2887
|
-
if (!params.loop || !slidesEl
|
|
2634
|
+
if (!params.loop || !slidesEl) return;
|
|
2888
2635
|
swiper.recalcSlides();
|
|
2889
2636
|
const newSlidesOrder = [];
|
|
2890
2637
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2945,7 +2692,6 @@ var Swiper = (function () {
|
|
|
2945
2692
|
unsetGrabCursor
|
|
2946
2693
|
};
|
|
2947
2694
|
|
|
2948
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2949
2695
|
function closestElement(selector, base) {
|
|
2950
2696
|
if (base === void 0) {
|
|
2951
2697
|
base = this;
|
|
@@ -2954,9 +2700,7 @@ var Swiper = (function () {
|
|
|
2954
2700
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2955
2701
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2956
2702
|
const found = el.closest(selector);
|
|
2957
|
-
if (!found && !el.getRootNode)
|
|
2958
|
-
return null;
|
|
2959
|
-
}
|
|
2703
|
+
if (!found && !el.getRootNode) return null;
|
|
2960
2704
|
return found || __closestFrom(el.getRootNode().host);
|
|
2961
2705
|
}
|
|
2962
2706
|
return __closestFrom(base);
|
|
@@ -2984,9 +2728,7 @@ var Swiper = (function () {
|
|
|
2984
2728
|
if (e.originalEvent) e = e.originalEvent;
|
|
2985
2729
|
const data = swiper.touchEventsData;
|
|
2986
2730
|
if (e.type === 'pointerdown') {
|
|
2987
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
2988
|
-
return;
|
|
2989
|
-
}
|
|
2731
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
2990
2732
|
data.pointerId = e.pointerId;
|
|
2991
2733
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2992
2734
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3003,9 +2745,7 @@ var Swiper = (function () {
|
|
|
3003
2745
|
} = swiper;
|
|
3004
2746
|
if (!enabled) return;
|
|
3005
2747
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3006
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3007
|
-
return;
|
|
3008
|
-
}
|
|
2748
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3009
2749
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3010
2750
|
swiper.loopFix();
|
|
3011
2751
|
}
|
|
@@ -3016,8 +2756,6 @@ var Swiper = (function () {
|
|
|
3016
2756
|
if ('which' in e && e.which === 3) return;
|
|
3017
2757
|
if ('button' in e && e.button > 0) return;
|
|
3018
2758
|
if (data.isTouched && data.isMoved) return;
|
|
3019
|
-
|
|
3020
|
-
// change target el for shadow root component
|
|
3021
2759
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3022
2760
|
// eslint-disable-next-line
|
|
3023
2761
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3026,8 +2764,6 @@ var Swiper = (function () {
|
|
|
3026
2764
|
}
|
|
3027
2765
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3028
2766
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3029
|
-
|
|
3030
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3031
2767
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3032
2768
|
swiper.allowClick = true;
|
|
3033
2769
|
return;
|
|
@@ -3039,12 +2775,7 @@ var Swiper = (function () {
|
|
|
3039
2775
|
touches.currentY = e.pageY;
|
|
3040
2776
|
const startX = touches.currentX;
|
|
3041
2777
|
const startY = touches.currentY;
|
|
3042
|
-
|
|
3043
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3044
|
-
|
|
3045
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
2778
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3048
2779
|
Object.assign(data, {
|
|
3049
2780
|
isTouched: true,
|
|
3050
2781
|
isMoved: false,
|
|
@@ -3073,9 +2804,6 @@ var Swiper = (function () {
|
|
|
3073
2804
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3074
2805
|
e.preventDefault();
|
|
3075
2806
|
}
|
|
3076
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3077
|
-
swiper.freeMode.onTouchStart();
|
|
3078
|
-
}
|
|
3079
2807
|
swiper.emit('touchStart', e);
|
|
3080
2808
|
}
|
|
3081
2809
|
|
|
@@ -3094,7 +2822,7 @@ var Swiper = (function () {
|
|
|
3094
2822
|
let e = event;
|
|
3095
2823
|
if (e.originalEvent) e = e.originalEvent;
|
|
3096
2824
|
if (e.type === 'pointermove') {
|
|
3097
|
-
if (data.touchId !== null) return;
|
|
2825
|
+
if (data.touchId !== null) return;
|
|
3098
2826
|
const id = e.pointerId;
|
|
3099
2827
|
if (id !== data.pointerId) return;
|
|
3100
2828
|
}
|
|
@@ -3135,7 +2863,6 @@ var Swiper = (function () {
|
|
|
3135
2863
|
}
|
|
3136
2864
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3137
2865
|
if (swiper.isVertical()) {
|
|
3138
|
-
// Vertical
|
|
3139
2866
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3140
2867
|
data.isTouched = false;
|
|
3141
2868
|
data.isMoved = false;
|
|
@@ -3237,7 +2964,6 @@ var Swiper = (function () {
|
|
|
3237
2964
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3238
2965
|
}
|
|
3239
2966
|
data.allowMomentumBounce = false;
|
|
3240
|
-
// Grab Cursor
|
|
3241
2967
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3242
2968
|
swiper.setGrabCursor(true);
|
|
3243
2969
|
}
|
|
@@ -3308,8 +3034,6 @@ var Swiper = (function () {
|
|
|
3308
3034
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3309
3035
|
data.currentTranslate = data.startTranslate;
|
|
3310
3036
|
}
|
|
3311
|
-
|
|
3312
|
-
// Threshold
|
|
3313
3037
|
if (params.threshold > 0) {
|
|
3314
3038
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3315
3039
|
if (!data.allowThresholdMove) {
|
|
@@ -3327,17 +3051,12 @@ var Swiper = (function () {
|
|
|
3327
3051
|
}
|
|
3328
3052
|
if (!params.followFinger || params.cssMode) return;
|
|
3329
3053
|
|
|
3330
|
-
//
|
|
3331
|
-
if (params.
|
|
3054
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3055
|
+
if (params.watchSlidesProgress) {
|
|
3332
3056
|
swiper.updateActiveIndex();
|
|
3333
3057
|
swiper.updateSlidesClasses();
|
|
3334
3058
|
}
|
|
3335
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3336
|
-
swiper.freeMode.onTouchMove();
|
|
3337
|
-
}
|
|
3338
|
-
// Update progress
|
|
3339
3059
|
swiper.updateProgress(data.currentTranslate);
|
|
3340
|
-
// Update translate
|
|
3341
3060
|
swiper.setTranslate(data.currentTranslate);
|
|
3342
3061
|
}
|
|
3343
3062
|
|
|
@@ -3349,7 +3068,7 @@ var Swiper = (function () {
|
|
|
3349
3068
|
let targetTouch;
|
|
3350
3069
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3351
3070
|
if (!isTouchEvent) {
|
|
3352
|
-
if (data.touchId !== null) return;
|
|
3071
|
+
if (data.touchId !== null) return;
|
|
3353
3072
|
if (e.pointerId !== data.pointerId) return;
|
|
3354
3073
|
targetTouch = e;
|
|
3355
3074
|
} else {
|
|
@@ -3358,9 +3077,7 @@ var Swiper = (function () {
|
|
|
3358
3077
|
}
|
|
3359
3078
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3360
3079
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3361
|
-
if (!proceed)
|
|
3362
|
-
return;
|
|
3363
|
-
}
|
|
3080
|
+
if (!proceed) return;
|
|
3364
3081
|
}
|
|
3365
3082
|
data.pointerId = null;
|
|
3366
3083
|
data.touchId = null;
|
|
@@ -3378,9 +3095,7 @@ var Swiper = (function () {
|
|
|
3378
3095
|
}
|
|
3379
3096
|
data.allowTouchCallbacks = false;
|
|
3380
3097
|
if (!data.isTouched) {
|
|
3381
|
-
if (data.isMoved && params.grabCursor)
|
|
3382
|
-
swiper.setGrabCursor(false);
|
|
3383
|
-
}
|
|
3098
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3384
3099
|
data.isMoved = false;
|
|
3385
3100
|
data.startMoving = false;
|
|
3386
3101
|
return;
|
|
@@ -3390,8 +3105,6 @@ var Swiper = (function () {
|
|
|
3390
3105
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3391
3106
|
swiper.setGrabCursor(false);
|
|
3392
3107
|
}
|
|
3393
|
-
|
|
3394
|
-
// Time diff
|
|
3395
3108
|
const touchEndTime = now();
|
|
3396
3109
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3397
3110
|
|
|
@@ -3418,20 +3131,8 @@ var Swiper = (function () {
|
|
|
3418
3131
|
data.isMoved = false;
|
|
3419
3132
|
data.startMoving = false;
|
|
3420
3133
|
let currentPos;
|
|
3421
|
-
if (params.followFinger)
|
|
3422
|
-
|
|
3423
|
-
} else {
|
|
3424
|
-
currentPos = -data.currentTranslate;
|
|
3425
|
-
}
|
|
3426
|
-
if (params.cssMode) {
|
|
3427
|
-
return;
|
|
3428
|
-
}
|
|
3429
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3430
|
-
swiper.freeMode.onTouchEnd({
|
|
3431
|
-
currentPos
|
|
3432
|
-
});
|
|
3433
|
-
return;
|
|
3434
|
-
}
|
|
3134
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3135
|
+
if (params.cssMode) return;
|
|
3435
3136
|
|
|
3436
3137
|
// Find current slide
|
|
3437
3138
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3453,22 +3154,22 @@ var Swiper = (function () {
|
|
|
3453
3154
|
let rewindLastIndex = null;
|
|
3454
3155
|
if (params.rewind) {
|
|
3455
3156
|
if (swiper.isBeginning) {
|
|
3456
|
-
rewindLastIndex =
|
|
3157
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3457
3158
|
} else if (swiper.isEnd) {
|
|
3458
3159
|
rewindFirstIndex = 0;
|
|
3459
3160
|
}
|
|
3460
3161
|
}
|
|
3461
|
-
// Find current slide size
|
|
3462
3162
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3463
3163
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3464
3164
|
if (timeDiff > params.longSwipesMs) {
|
|
3465
|
-
// Long touches
|
|
3466
3165
|
if (!params.longSwipes) {
|
|
3467
3166
|
swiper.slideTo(swiper.activeIndex);
|
|
3468
3167
|
return;
|
|
3469
3168
|
}
|
|
3470
3169
|
if (swiper.swipeDirection === 'next') {
|
|
3471
|
-
if (ratio >= params.longSwipesRatio)
|
|
3170
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3171
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3172
|
+
} else swiper.slideTo(stopIndex);
|
|
3472
3173
|
}
|
|
3473
3174
|
if (swiper.swipeDirection === 'prev') {
|
|
3474
3175
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3520,7 +3221,6 @@ var Swiper = (function () {
|
|
|
3520
3221
|
allowSlidePrev,
|
|
3521
3222
|
snapGrid
|
|
3522
3223
|
} = swiper;
|
|
3523
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3524
3224
|
|
|
3525
3225
|
// Disable locks on resize
|
|
3526
3226
|
swiper.allowSlideNext = true;
|
|
@@ -3528,15 +3228,12 @@ var Swiper = (function () {
|
|
|
3528
3228
|
swiper.updateSize();
|
|
3529
3229
|
swiper.updateSlides();
|
|
3530
3230
|
swiper.updateSlidesClasses();
|
|
3531
|
-
|
|
3532
|
-
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) {
|
|
3533
3232
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3233
|
+
} else if (swiper.params.loop) {
|
|
3234
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3534
3235
|
} else {
|
|
3535
|
-
|
|
3536
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3537
|
-
} else {
|
|
3538
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3539
|
-
}
|
|
3236
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3540
3237
|
}
|
|
3541
3238
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3542
3239
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3546,10 +3243,11 @@ var Swiper = (function () {
|
|
|
3546
3243
|
}
|
|
3547
3244
|
}, 500);
|
|
3548
3245
|
}
|
|
3246
|
+
|
|
3549
3247
|
// Return locks after resize
|
|
3550
3248
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3551
3249
|
swiper.allowSlideNext = allowSlideNext;
|
|
3552
|
-
if (
|
|
3250
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3553
3251
|
swiper.checkOverflow();
|
|
3554
3252
|
}
|
|
3555
3253
|
}
|
|
@@ -3718,8 +3416,15 @@ var Swiper = (function () {
|
|
|
3718
3416
|
detachEvents
|
|
3719
3417
|
};
|
|
3720
3418
|
|
|
3721
|
-
const
|
|
3722
|
-
|
|
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
|
+
}
|
|
3723
3428
|
};
|
|
3724
3429
|
function setBreakpoint() {
|
|
3725
3430
|
const swiper = this;
|
|
@@ -3740,38 +3445,20 @@ var Swiper = (function () {
|
|
|
3740
3445
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3741
3446
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3742
3447
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3743
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3744
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3745
3448
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3746
3449
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3747
3450
|
const wasEnabled = params.enabled;
|
|
3748
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3749
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3750
|
-
swiper.emitContainerClasses();
|
|
3751
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3752
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3753
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3754
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3755
|
-
}
|
|
3756
|
-
swiper.emitContainerClasses();
|
|
3757
|
-
}
|
|
3758
3451
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3759
3452
|
swiper.unsetGrabCursor();
|
|
3760
3453
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3761
3454
|
swiper.setGrabCursor();
|
|
3762
3455
|
}
|
|
3763
3456
|
|
|
3764
|
-
//
|
|
3765
|
-
['navigation', 'pagination'
|
|
3457
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3458
|
+
const modules = ['navigation', 'pagination'];
|
|
3459
|
+
modules.forEach(prop => {
|
|
3766
3460
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3767
|
-
|
|
3768
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3769
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3770
|
-
swiper[prop].disable();
|
|
3771
|
-
}
|
|
3772
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3773
|
-
swiper[prop].enable();
|
|
3774
|
-
}
|
|
3461
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3775
3462
|
});
|
|
3776
3463
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3777
3464
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3853,7 +3540,7 @@ var Swiper = (function () {
|
|
|
3853
3540
|
getBreakpoint
|
|
3854
3541
|
};
|
|
3855
3542
|
|
|
3856
|
-
|
|
3543
|
+
const prepareClasses = (entries, prefix) => {
|
|
3857
3544
|
const resultClasses = [];
|
|
3858
3545
|
entries.forEach(item => {
|
|
3859
3546
|
if (typeof item === 'object') {
|
|
@@ -3867,7 +3554,7 @@ var Swiper = (function () {
|
|
|
3867
3554
|
}
|
|
3868
3555
|
});
|
|
3869
3556
|
return resultClasses;
|
|
3870
|
-
}
|
|
3557
|
+
};
|
|
3871
3558
|
function addClasses() {
|
|
3872
3559
|
const swiper = this;
|
|
3873
3560
|
const {
|
|
@@ -3877,17 +3564,12 @@ var Swiper = (function () {
|
|
|
3877
3564
|
el,
|
|
3878
3565
|
device
|
|
3879
3566
|
} = swiper;
|
|
3567
|
+
// core-lite: removed module-specific classes
|
|
3880
3568
|
// prettier-ignore
|
|
3881
3569
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3882
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3883
|
-
}, {
|
|
3884
3570
|
'autoheight': params.autoHeight
|
|
3885
3571
|
}, {
|
|
3886
3572
|
'rtl': rtl
|
|
3887
|
-
}, {
|
|
3888
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3889
|
-
}, {
|
|
3890
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3891
3573
|
}, {
|
|
3892
3574
|
'android': device.android
|
|
3893
3575
|
}, {
|
|
@@ -3984,16 +3666,12 @@ var Swiper = (function () {
|
|
|
3984
3666
|
autoHeight: false,
|
|
3985
3667
|
// Set wrapper width
|
|
3986
3668
|
setWrapperSize: false,
|
|
3987
|
-
//
|
|
3988
|
-
virtualTranslate: false,
|
|
3989
|
-
// Effects
|
|
3669
|
+
// Effects (core-lite only supports `slide`)
|
|
3990
3670
|
effect: 'slide',
|
|
3991
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
3992
|
-
|
|
3993
3671
|
// Breakpoints
|
|
3994
3672
|
breakpoints: undefined,
|
|
3995
3673
|
breakpointsBase: 'window',
|
|
3996
|
-
// Slides
|
|
3674
|
+
// Slides
|
|
3997
3675
|
spaceBetween: 0,
|
|
3998
3676
|
slidesPerView: 1,
|
|
3999
3677
|
slidesPerGroup: 1,
|
|
@@ -4096,7 +3774,9 @@ var Swiper = (function () {
|
|
|
4096
3774
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4097
3775
|
params[moduleParamName].auto = true;
|
|
4098
3776
|
}
|
|
4099
|
-
|
|
3777
|
+
|
|
3778
|
+
// Core-lite: keep only pagination auto-init.
|
|
3779
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4100
3780
|
params[moduleParamName].auto = true;
|
|
4101
3781
|
}
|
|
4102
3782
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4222,7 +3902,6 @@ var Swiper = (function () {
|
|
|
4222
3902
|
// Indexes
|
|
4223
3903
|
activeIndex: 0,
|
|
4224
3904
|
realIndex: 0,
|
|
4225
|
-
//
|
|
4226
3905
|
isBeginning: true,
|
|
4227
3906
|
isEnd: false,
|
|
4228
3907
|
// Props
|
|
@@ -4249,12 +3928,9 @@ var Swiper = (function () {
|
|
|
4249
3928
|
currentTranslate: undefined,
|
|
4250
3929
|
startTranslate: undefined,
|
|
4251
3930
|
allowThresholdMove: undefined,
|
|
4252
|
-
// Form elements to match
|
|
4253
3931
|
focusableElements: swiper.params.focusableElements,
|
|
4254
|
-
// Last click time
|
|
4255
3932
|
lastClickTime: 0,
|
|
4256
3933
|
clickTimeout: undefined,
|
|
4257
|
-
// Velocities
|
|
4258
3934
|
velocities: [],
|
|
4259
3935
|
allowMomentumBounce: undefined,
|
|
4260
3936
|
startMoving: undefined,
|
|
@@ -4283,7 +3959,6 @@ var Swiper = (function () {
|
|
|
4283
3959
|
swiper.init();
|
|
4284
3960
|
}
|
|
4285
3961
|
|
|
4286
|
-
// Return app instance
|
|
4287
3962
|
// eslint-disable-next-line no-constructor-return
|
|
4288
3963
|
return swiper;
|
|
4289
3964
|
}
|
|
@@ -4315,16 +3990,6 @@ var Swiper = (function () {
|
|
|
4315
3990
|
getSlideIndexByData(index) {
|
|
4316
3991
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4317
3992
|
}
|
|
4318
|
-
getSlideIndexWhenGrid(index) {
|
|
4319
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4320
|
-
if (this.params.grid.fill === 'column') {
|
|
4321
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4322
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4323
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4324
|
-
}
|
|
4325
|
-
}
|
|
4326
|
-
return index;
|
|
4327
|
-
}
|
|
4328
3993
|
recalcSlides() {
|
|
4329
3994
|
const swiper = this;
|
|
4330
3995
|
const {
|
|
@@ -4426,21 +4091,15 @@ var Swiper = (function () {
|
|
|
4426
4091
|
}
|
|
4427
4092
|
}
|
|
4428
4093
|
} else {
|
|
4429
|
-
// eslint-disable-next-line
|
|
4430
4094
|
if (view === 'current') {
|
|
4431
4095
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4432
4096
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4433
|
-
if (slideInView)
|
|
4434
|
-
spv += 1;
|
|
4435
|
-
}
|
|
4097
|
+
if (slideInView) spv += 1;
|
|
4436
4098
|
}
|
|
4437
4099
|
} else {
|
|
4438
|
-
// previous
|
|
4439
4100
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4440
4101
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4441
|
-
if (slideInView)
|
|
4442
|
-
spv += 1;
|
|
4443
|
-
}
|
|
4102
|
+
if (slideInView) spv += 1;
|
|
4444
4103
|
}
|
|
4445
4104
|
}
|
|
4446
4105
|
}
|
|
@@ -4453,14 +4112,11 @@ var Swiper = (function () {
|
|
|
4453
4112
|
snapGrid,
|
|
4454
4113
|
params
|
|
4455
4114
|
} = swiper;
|
|
4456
|
-
// Breakpoints
|
|
4457
4115
|
if (params.breakpoints) {
|
|
4458
4116
|
swiper.setBreakpoint();
|
|
4459
4117
|
}
|
|
4460
4118
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4461
|
-
if (imageEl.complete)
|
|
4462
|
-
processLazyPreloader(swiper, imageEl);
|
|
4463
|
-
}
|
|
4119
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4464
4120
|
});
|
|
4465
4121
|
swiper.updateSize();
|
|
4466
4122
|
swiper.updateSlides();
|
|
@@ -4474,22 +4130,12 @@ var Swiper = (function () {
|
|
|
4474
4130
|
swiper.updateSlidesClasses();
|
|
4475
4131
|
}
|
|
4476
4132
|
let translated;
|
|
4477
|
-
if (params.
|
|
4478
|
-
|
|
4479
|
-
if (params.autoHeight) {
|
|
4480
|
-
swiper.updateAutoHeight();
|
|
4481
|
-
}
|
|
4133
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4134
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4482
4135
|
} else {
|
|
4483
|
-
|
|
4484
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4485
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4486
|
-
} else {
|
|
4487
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4488
|
-
}
|
|
4489
|
-
if (!translated) {
|
|
4490
|
-
setTranslate();
|
|
4491
|
-
}
|
|
4136
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4492
4137
|
}
|
|
4138
|
+
if (!translated) setTranslate();
|
|
4493
4139
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4494
4140
|
swiper.checkOverflow();
|
|
4495
4141
|
}
|
|
@@ -4502,7 +4148,6 @@ var Swiper = (function () {
|
|
|
4502
4148
|
const swiper = this;
|
|
4503
4149
|
const currentDirection = swiper.params.direction;
|
|
4504
4150
|
if (!newDirection) {
|
|
4505
|
-
// eslint-disable-next-line
|
|
4506
4151
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4507
4152
|
}
|
|
4508
4153
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4540,15 +4185,11 @@ var Swiper = (function () {
|
|
|
4540
4185
|
mount(element) {
|
|
4541
4186
|
const swiper = this;
|
|
4542
4187
|
if (swiper.mounted) return true;
|
|
4543
|
-
|
|
4544
|
-
// Find el
|
|
4545
4188
|
let el = element || swiper.params.el;
|
|
4546
4189
|
if (typeof el === 'string') {
|
|
4547
4190
|
el = document.querySelector(el);
|
|
4548
4191
|
}
|
|
4549
|
-
if (!el)
|
|
4550
|
-
return false;
|
|
4551
|
-
}
|
|
4192
|
+
if (!el) return false;
|
|
4552
4193
|
el.swiper = swiper;
|
|
4553
4194
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4554
4195
|
swiper.isElement = true;
|
|
@@ -4559,12 +4200,10 @@ var Swiper = (function () {
|
|
|
4559
4200
|
const getWrapper = () => {
|
|
4560
4201
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4561
4202
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4562
|
-
// Children needs to return slot items
|
|
4563
4203
|
return res;
|
|
4564
4204
|
}
|
|
4565
4205
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4566
4206
|
};
|
|
4567
|
-
// Find Wrapper
|
|
4568
4207
|
let wrapperEl = getWrapper();
|
|
4569
4208
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4570
4209
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4579,7 +4218,6 @@ var Swiper = (function () {
|
|
|
4579
4218
|
slidesEl: swiper.isElement && !el.parentNode.host.slideSlots ? el.parentNode.host : wrapperEl,
|
|
4580
4219
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4581
4220
|
mounted: true,
|
|
4582
|
-
// RTL
|
|
4583
4221
|
rtl: el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl',
|
|
4584
4222
|
rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl'),
|
|
4585
4223
|
wrongRTL: elementStyle(wrapperEl, 'display') === '-webkit-box'
|
|
@@ -4599,7 +4237,6 @@ var Swiper = (function () {
|
|
|
4599
4237
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4600
4238
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4601
4239
|
if (isFirstSlide) {
|
|
4602
|
-
// Move last item to first position when at first slide
|
|
4603
4240
|
const lastSlide = slides.at(-1);
|
|
4604
4241
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4605
4242
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4611,7 +4248,6 @@ var Swiper = (function () {
|
|
|
4611
4248
|
swiper.setTransition(speed);
|
|
4612
4249
|
swiper.setTranslate(-swiperTranslate);
|
|
4613
4250
|
} else if (isLastSlide) {
|
|
4614
|
-
// Move first item to last position when at last slide
|
|
4615
4251
|
const firstSlide = slides[0];
|
|
4616
4252
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4617
4253
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4632,42 +4268,24 @@ var Swiper = (function () {
|
|
|
4632
4268
|
const mounted = swiper.mount(el);
|
|
4633
4269
|
if (mounted === false) return swiper;
|
|
4634
4270
|
swiper.emit('beforeInit');
|
|
4635
|
-
|
|
4636
|
-
// Set breakpoint
|
|
4637
4271
|
if (swiper.params.breakpoints) {
|
|
4638
4272
|
swiper.setBreakpoint();
|
|
4639
4273
|
}
|
|
4640
|
-
|
|
4641
|
-
// Add Classes
|
|
4642
4274
|
swiper.addClasses();
|
|
4643
|
-
|
|
4644
|
-
// Update size
|
|
4645
4275
|
swiper.updateSize();
|
|
4646
|
-
|
|
4647
|
-
// Update slides
|
|
4648
4276
|
swiper.updateSlides();
|
|
4649
4277
|
if (swiper.params.watchOverflow) {
|
|
4650
4278
|
swiper.checkOverflow();
|
|
4651
4279
|
}
|
|
4652
|
-
|
|
4653
|
-
// Set Grab Cursor
|
|
4654
4280
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4655
4281
|
swiper.setGrabCursor();
|
|
4656
4282
|
}
|
|
4657
4283
|
|
|
4658
|
-
// Slide
|
|
4659
|
-
|
|
4660
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4661
|
-
} else {
|
|
4662
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
|
-
// 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);
|
|
4666
4286
|
if (swiper.params.loop) {
|
|
4667
4287
|
swiper.loopCreate(undefined, true);
|
|
4668
4288
|
}
|
|
4669
|
-
|
|
4670
|
-
// Attach events
|
|
4671
4289
|
swiper.attachEvents();
|
|
4672
4290
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4673
4291
|
if (swiper.isElement) {
|
|
@@ -4677,18 +4295,12 @@ var Swiper = (function () {
|
|
|
4677
4295
|
if (imageEl.complete) {
|
|
4678
4296
|
processLazyPreloader(swiper, imageEl);
|
|
4679
4297
|
} else {
|
|
4680
|
-
imageEl.addEventListener('load', e =>
|
|
4681
|
-
processLazyPreloader(swiper, e.target);
|
|
4682
|
-
});
|
|
4298
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4683
4299
|
}
|
|
4684
4300
|
});
|
|
4685
4301
|
preload(swiper);
|
|
4686
|
-
|
|
4687
|
-
// Init Flag
|
|
4688
4302
|
swiper.initialized = true;
|
|
4689
4303
|
preload(swiper);
|
|
4690
|
-
|
|
4691
|
-
// Emit
|
|
4692
4304
|
swiper.emit('init');
|
|
4693
4305
|
swiper.emit('afterInit');
|
|
4694
4306
|
return swiper;
|
|
@@ -4711,27 +4323,15 @@ var Swiper = (function () {
|
|
|
4711
4323
|
return null;
|
|
4712
4324
|
}
|
|
4713
4325
|
swiper.emit('beforeDestroy');
|
|
4714
|
-
|
|
4715
|
-
// Init Flag
|
|
4716
4326
|
swiper.initialized = false;
|
|
4717
|
-
|
|
4718
|
-
// Detach events
|
|
4719
4327
|
swiper.detachEvents();
|
|
4720
|
-
|
|
4721
|
-
// Destroy loop
|
|
4722
4328
|
if (params.loop) {
|
|
4723
4329
|
swiper.loopDestroy();
|
|
4724
4330
|
}
|
|
4725
|
-
|
|
4726
|
-
// Cleanup styles
|
|
4727
4331
|
if (cleanStyles) {
|
|
4728
4332
|
swiper.removeClasses();
|
|
4729
|
-
if (el && typeof el !== 'string')
|
|
4730
|
-
|
|
4731
|
-
}
|
|
4732
|
-
if (wrapperEl) {
|
|
4733
|
-
wrapperEl.removeAttribute('style');
|
|
4734
|
-
}
|
|
4333
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4334
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4735
4335
|
if (slides && slides.length) {
|
|
4736
4336
|
slides.forEach(slideEl => {
|
|
4737
4337
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4741,8 +4341,6 @@ var Swiper = (function () {
|
|
|
4741
4341
|
}
|
|
4742
4342
|
}
|
|
4743
4343
|
swiper.emit('destroy');
|
|
4744
|
-
|
|
4745
|
-
// Detach emitter events
|
|
4746
4344
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4747
4345
|
swiper.off(eventName);
|
|
4748
4346
|
});
|