@gem-sdk/swiper 0.0.15 → 0.0.16-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core-bk/core.less +225 -0
- package/core-bk/core.scss +227 -0
- package/package.json +1 -1
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +243 -578
- package/shared/utils.min.mjs +1 -1
- package/shared/utils.min.mjs.map +1 -1
- package/shared/utils.mjs +18 -1
- package/swiper-bundle.css +1 -1
- package/swiper-bundle.js +263 -581
- package/swiper-bundle.min.css +1 -1
- package/swiper-bundle.min.js +2 -2
- package/swiper-bundle.min.js.map +1 -1
- package/swiper-bundle.min.mjs +1 -1
- package/swiper-bundle.mjs +1 -1
- package/swiper-effect-utils.min.mjs +1 -1
- package/swiper-effect-utils.mjs +1 -1
- package/swiper-element-bundle.js +264 -582
- package/swiper-element-bundle.min.js +2 -2
- package/swiper-element-bundle.min.js.map +1 -1
- package/swiper-element-bundle.min.mjs +1 -1
- package/swiper-element-bundle.mjs +1 -1
- package/swiper-element.js +263 -581
- package/swiper-element.min.js +2 -2
- package/swiper-element.min.js.map +1 -1
- package/swiper-element.min.mjs +1 -1
- package/swiper-element.mjs +1 -1
- package/swiper-react.mjs +1 -1
- package/swiper-vue.mjs +1 -1
- package/swiper.css +1 -1
- package/swiper.js +262 -580
- package/swiper.less +1 -1
- package/swiper.min.css +1 -1
- package/swiper.min.js +2 -2
- package/swiper.min.js.map +1 -1
- package/swiper.min.mjs +1 -1
- package/swiper.mjs +1 -1
- package/swiper.scss +1 -1
- package/types/swiper-options.d.ts +2 -0
package/swiper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper 0.0.
|
|
2
|
+
* Swiper 0.0.16-dev.1
|
|
3
3
|
* Gem SDK - Swiper, Customized of swiper
|
|
4
4
|
* https://swiperjs.com
|
|
5
5
|
*
|
|
@@ -189,7 +189,7 @@ var Swiper = (function () {
|
|
|
189
189
|
function now() {
|
|
190
190
|
return Date.now();
|
|
191
191
|
}
|
|
192
|
-
function getComputedStyle
|
|
192
|
+
function getComputedStyle(el) {
|
|
193
193
|
const window = getWindow();
|
|
194
194
|
let style;
|
|
195
195
|
if (window.getComputedStyle) {
|
|
@@ -211,7 +211,7 @@ var Swiper = (function () {
|
|
|
211
211
|
let matrix;
|
|
212
212
|
let curTransform;
|
|
213
213
|
let transformMatrix;
|
|
214
|
-
const curStyle = getComputedStyle
|
|
214
|
+
const curStyle = getComputedStyle(el);
|
|
215
215
|
if (window.WebKitCSSMatrix) {
|
|
216
216
|
curTransform = curStyle.transform || curStyle.webkitTransform;
|
|
217
217
|
if (curTransform.split(',').length > 6) {
|
|
@@ -447,6 +447,23 @@ var Swiper = (function () {
|
|
|
447
447
|
}
|
|
448
448
|
return el.offsetWidth;
|
|
449
449
|
}
|
|
450
|
+
function computeAutoSlideSize(slideEl, getDirectionPropValue) {
|
|
451
|
+
const styles = getComputedStyle(slideEl);
|
|
452
|
+
const width = getDirectionPropValue(styles, 'width');
|
|
453
|
+
const paddingLeft = getDirectionPropValue(styles, 'padding-left');
|
|
454
|
+
const paddingRight = getDirectionPropValue(styles, 'padding-right');
|
|
455
|
+
const marginLeft = getDirectionPropValue(styles, 'margin-left');
|
|
456
|
+
const marginRight = getDirectionPropValue(styles, 'margin-right');
|
|
457
|
+
const boxSizing = styles.getPropertyValue('box-sizing');
|
|
458
|
+
if (boxSizing && boxSizing === 'border-box') {
|
|
459
|
+
return width + marginLeft + marginRight;
|
|
460
|
+
}
|
|
461
|
+
const {
|
|
462
|
+
clientWidth,
|
|
463
|
+
offsetWidth
|
|
464
|
+
} = slideEl;
|
|
465
|
+
return width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
466
|
+
}
|
|
450
467
|
|
|
451
468
|
let support;
|
|
452
469
|
function calcSupport() {
|
|
@@ -829,9 +846,6 @@ var Swiper = (function () {
|
|
|
829
846
|
|
|
830
847
|
function updateSlides() {
|
|
831
848
|
const swiper = this;
|
|
832
|
-
function getDirectionPropertyValue(node, label) {
|
|
833
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
834
|
-
}
|
|
835
849
|
const params = swiper.params;
|
|
836
850
|
const {
|
|
837
851
|
wrapperEl,
|
|
@@ -840,10 +854,8 @@ var Swiper = (function () {
|
|
|
840
854
|
rtlTranslate: rtl,
|
|
841
855
|
wrongRTL
|
|
842
856
|
} = swiper;
|
|
843
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
844
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
845
857
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
846
|
-
const slidesLength =
|
|
858
|
+
const slidesLength = slides.length;
|
|
847
859
|
let snapGrid = [];
|
|
848
860
|
const slidesGrid = [];
|
|
849
861
|
const slidesSizesGrid = [];
|
|
@@ -861,15 +873,15 @@ var Swiper = (function () {
|
|
|
861
873
|
let slidePosition = -offsetBefore;
|
|
862
874
|
let prevSlideSize = 0;
|
|
863
875
|
let index = 0;
|
|
864
|
-
if (typeof swiperSize === 'undefined')
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
876
|
+
if (typeof swiperSize === 'undefined') return;
|
|
867
877
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
868
878
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
869
879
|
} else if (typeof spaceBetween === 'string') {
|
|
870
880
|
spaceBetween = parseFloat(spaceBetween);
|
|
871
881
|
}
|
|
872
|
-
|
|
882
|
+
|
|
883
|
+
// core-lite: compute total slides size without optional modules
|
|
884
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
873
885
|
|
|
874
886
|
// reset margins
|
|
875
887
|
slides.forEach(slideEl => {
|
|
@@ -887,67 +899,91 @@ var Swiper = (function () {
|
|
|
887
899
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
888
900
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
889
901
|
}
|
|
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
902
|
|
|
897
903
|
// Calc slides
|
|
898
904
|
let slideSize;
|
|
899
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
900
|
-
|
|
901
|
-
}).length > 0;
|
|
902
|
-
for (let i = 0; i < slidesLength; i += 1) {
|
|
903
|
-
slideSize = 0;
|
|
904
|
-
let slide;
|
|
905
|
-
if (slides[i]) slide = slides[i];
|
|
906
|
-
if (gridEnabled) {
|
|
907
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
908
|
-
}
|
|
909
|
-
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
905
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
906
|
+
const isAutoSlides = params.slidesPerView === 'auto';
|
|
910
907
|
|
|
911
|
-
|
|
908
|
+
// --- Phase 1: Batch DOM writes (grid updates, width/transform resets) ---
|
|
909
|
+
// Moving all style writes before any reads prevents per-slide forced reflows
|
|
910
|
+
if (gridEnabled) {
|
|
911
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
912
|
+
if (slides[i]) swiper.grid.updateSlide(i, slides[i], slides);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
const savedTransforms = [];
|
|
916
|
+
if (isAutoSlides) {
|
|
917
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
918
|
+
if (!slides[i]) continue;
|
|
912
919
|
if (shouldResetSlideSize) {
|
|
913
920
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
914
921
|
}
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
-
|
|
922
|
+
const currentTransform = slides[i].style.transform;
|
|
923
|
+
const currentWebKitTransform = slides[i].style.webkitTransform;
|
|
924
|
+
savedTransforms[i] = {
|
|
925
|
+
transform: currentTransform,
|
|
926
|
+
webkitTransform: currentWebKitTransform
|
|
927
|
+
};
|
|
918
928
|
if (currentTransform) {
|
|
919
|
-
|
|
929
|
+
slides[i].style.transform = 'none';
|
|
920
930
|
}
|
|
921
931
|
if (currentWebKitTransform) {
|
|
922
|
-
|
|
932
|
+
slides[i].style.webkitTransform = 'none';
|
|
923
933
|
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// --- Phase 2: Batch DOM reads (single forced reflow for all slides) ---
|
|
938
|
+
// Read wrapper offset here (before Phase 3 writes) so it's batched with slide reads, not after
|
|
939
|
+
const wrapperOffset = swiper.isElement ? swiper.wrapperEl[`offset${swiper.isHorizontal() ? 'Left' : 'Top'}`] : 0;
|
|
940
|
+
const slideVisible = [];
|
|
941
|
+
const slideSizes = [];
|
|
942
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
943
|
+
if (!slides[i]) {
|
|
944
|
+
slideVisible[i] = false;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
if (elementStyle(slides[i], 'display') === 'none') {
|
|
948
|
+
slideVisible[i] = false;
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
slideVisible[i] = true;
|
|
952
|
+
|
|
953
|
+
// Cache offsetHeight for autoHeight (batched here to avoid a separate forced reflow in updateAutoHeight)
|
|
954
|
+
if (params.autoHeight) {
|
|
955
|
+
slides[i].swiperSlideHeight = slides[i]['offsetHeight'];
|
|
956
|
+
}
|
|
957
|
+
if (isAutoSlides) {
|
|
924
958
|
if (params.roundLengths) {
|
|
925
|
-
|
|
959
|
+
slideSizes[i] = swiper.isHorizontal() ? elementOuterSize(slides[i], 'width', true) : elementOuterSize(slides[i], 'height', true);
|
|
926
960
|
} else {
|
|
927
|
-
|
|
928
|
-
const width = getDirectionPropertyValue(slideStyles, 'width');
|
|
929
|
-
const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
|
930
|
-
const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
|
931
|
-
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
|
932
|
-
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
|
933
|
-
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
934
|
-
if (boxSizing && boxSizing === 'border-box') {
|
|
935
|
-
slideSize = width + marginLeft + marginRight;
|
|
936
|
-
} else {
|
|
937
|
-
const {
|
|
938
|
-
clientWidth,
|
|
939
|
-
offsetWidth
|
|
940
|
-
} = slide;
|
|
941
|
-
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
942
|
-
}
|
|
961
|
+
slideSizes[i] = computeAutoSlideSize(slides[i], getDirectionPropertyValue);
|
|
943
962
|
}
|
|
944
|
-
if (
|
|
945
|
-
|
|
963
|
+
if (params.roundLengths) slideSizes[i] = Math.floor(slideSizes[i]);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// --- Phase 3: Restore transforms (batch write) ---
|
|
968
|
+
if (isAutoSlides) {
|
|
969
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
970
|
+
if (!savedTransforms[i]) continue;
|
|
971
|
+
if (savedTransforms[i].transform) {
|
|
972
|
+
slides[i].style.transform = savedTransforms[i].transform;
|
|
946
973
|
}
|
|
947
|
-
if (
|
|
948
|
-
|
|
974
|
+
if (savedTransforms[i].webkitTransform) {
|
|
975
|
+
slides[i].style.webkitTransform = savedTransforms[i].webkitTransform;
|
|
949
976
|
}
|
|
950
|
-
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// --- Phase 4: Calculate positions + set sizes (math + deferred writes) ---
|
|
981
|
+
const cssOverflowAdj = swiper.cssOverflowAdjustment();
|
|
982
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
983
|
+
slideSize = 0;
|
|
984
|
+
if (!slideVisible[i]) continue;
|
|
985
|
+
if (isAutoSlides) {
|
|
986
|
+
slideSize = slideSizes[i] || 0;
|
|
951
987
|
} else {
|
|
952
988
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
953
989
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
@@ -955,13 +991,13 @@ var Swiper = (function () {
|
|
|
955
991
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
956
992
|
}
|
|
957
993
|
}
|
|
958
|
-
if (slides[i])
|
|
959
|
-
slides[i].swiperSlideSize = slideSize;
|
|
960
|
-
}
|
|
994
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
961
995
|
slidesSizesGrid.push(slideSize);
|
|
962
996
|
if (params.centeredSlides) {
|
|
963
997
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
964
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
998
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
999
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1000
|
+
}
|
|
965
1001
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
966
1002
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
967
1003
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -969,55 +1005,42 @@ var Swiper = (function () {
|
|
|
969
1005
|
slidesGrid.push(slidePosition);
|
|
970
1006
|
} else {
|
|
971
1007
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
972
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
1008
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
1009
|
+
snapGrid.push(slidePosition);
|
|
1010
|
+
}
|
|
973
1011
|
slidesGrid.push(slidePosition);
|
|
974
1012
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
975
1013
|
}
|
|
1014
|
+
|
|
1015
|
+
// Set swiperSlideOffset from computed grid position (avoids DOM reads in updateSlidesOffset)
|
|
1016
|
+
if (slides[i]) {
|
|
1017
|
+
slides[i].swiperSlideOffset = slidesGrid[slidesGrid.length - 1] - cssOverflowAdj - wrapperOffset;
|
|
1018
|
+
}
|
|
976
1019
|
swiper.virtualSize += slideSize + spaceBetween;
|
|
977
1020
|
prevSlideSize = slideSize;
|
|
978
1021
|
index += 1;
|
|
979
1022
|
}
|
|
980
|
-
swiper.
|
|
981
|
-
if (rtl && wrongRTL &&
|
|
982
|
-
wrapperEl.style.width = `${swiper.
|
|
1023
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
1024
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
1025
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
983
1026
|
}
|
|
984
1027
|
if (params.setWrapperSize) {
|
|
985
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
986
|
-
}
|
|
987
|
-
if (gridEnabled) {
|
|
988
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
1028
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
989
1029
|
}
|
|
990
1030
|
|
|
991
|
-
// Remove last
|
|
1031
|
+
// Remove last snap points depending on width (non-centered)
|
|
992
1032
|
if (!params.centeredSlides) {
|
|
993
1033
|
const newSlidesGrid = [];
|
|
994
1034
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
995
1035
|
let slidesGridItem = snapGrid[i];
|
|
996
1036
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
997
|
-
if (snapGrid[i] <= swiper.
|
|
1037
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
998
1038
|
newSlidesGrid.push(slidesGridItem);
|
|
999
1039
|
}
|
|
1000
1040
|
}
|
|
1001
1041
|
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;
|
|
1042
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
1043
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1021
1044
|
}
|
|
1022
1045
|
}
|
|
1023
1046
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1025,9 +1048,7 @@ var Swiper = (function () {
|
|
|
1025
1048
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1026
1049
|
slides.filter((_, slideIndex) => {
|
|
1027
1050
|
if (!params.cssMode || params.loop) return true;
|
|
1028
|
-
if (slideIndex === slides.length - 1)
|
|
1029
|
-
return false;
|
|
1030
|
-
}
|
|
1051
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1031
1052
|
return true;
|
|
1032
1053
|
}).forEach(slideEl => {
|
|
1033
1054
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1077,7 +1098,9 @@ var Swiper = (function () {
|
|
|
1077
1098
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1078
1099
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1079
1100
|
}
|
|
1080
|
-
|
|
1101
|
+
|
|
1102
|
+
// Emit changes
|
|
1103
|
+
if (slidesLength !== (previousSlidesGridLength ? slides.length : slides.length)) {
|
|
1081
1104
|
swiper.emit('slidesLengthChange');
|
|
1082
1105
|
}
|
|
1083
1106
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1088,10 +1111,12 @@ var Swiper = (function () {
|
|
|
1088
1111
|
swiper.emit('slidesGridLengthChange');
|
|
1089
1112
|
}
|
|
1090
1113
|
if (params.watchSlidesProgress) {
|
|
1091
|
-
swiper.updateSlidesOffset(
|
|
1114
|
+
swiper.updateSlidesOffset({
|
|
1115
|
+
isCalculatedFromUpdateSlides: false
|
|
1116
|
+
});
|
|
1092
1117
|
}
|
|
1093
1118
|
swiper.emit('slidesUpdated');
|
|
1094
|
-
if (!
|
|
1119
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1095
1120
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1096
1121
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1097
1122
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1105,20 +1130,13 @@ var Swiper = (function () {
|
|
|
1105
1130
|
function updateAutoHeight(speed) {
|
|
1106
1131
|
const swiper = this;
|
|
1107
1132
|
const activeSlides = [];
|
|
1108
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1109
|
-
let newHeight = 0;
|
|
1110
|
-
let i;
|
|
1111
1133
|
if (typeof speed === 'number') {
|
|
1112
1134
|
swiper.setTransition(speed);
|
|
1113
1135
|
} else if (speed === true) {
|
|
1114
1136
|
swiper.setTransition(swiper.params.speed);
|
|
1115
1137
|
}
|
|
1116
|
-
const getSlideByIndex = index =>
|
|
1117
|
-
|
|
1118
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1119
|
-
}
|
|
1120
|
-
return swiper.slides[index];
|
|
1121
|
-
};
|
|
1138
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1139
|
+
|
|
1122
1140
|
// Find slides currently in view
|
|
1123
1141
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1124
1142
|
if (swiper.params.centeredSlides) {
|
|
@@ -1126,9 +1144,9 @@ var Swiper = (function () {
|
|
|
1126
1144
|
activeSlides.push(slide);
|
|
1127
1145
|
});
|
|
1128
1146
|
} else {
|
|
1129
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1147
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1130
1148
|
const index = swiper.activeIndex + i;
|
|
1131
|
-
if (index > swiper.slides.length
|
|
1149
|
+
if (index > swiper.slides.length) break;
|
|
1132
1150
|
activeSlides.push(getSlideByIndex(index));
|
|
1133
1151
|
}
|
|
1134
1152
|
}
|
|
@@ -1137,18 +1155,23 @@ var Swiper = (function () {
|
|
|
1137
1155
|
}
|
|
1138
1156
|
|
|
1139
1157
|
// Find new height from highest slide in view
|
|
1140
|
-
|
|
1158
|
+
let newHeight = 0;
|
|
1159
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1141
1160
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1142
|
-
const height = activeSlides[i].offsetHeight;
|
|
1161
|
+
const height = activeSlides[i].swiperSlideHeight ?? activeSlides[i]['offsetHeight'];
|
|
1143
1162
|
newHeight = height > newHeight ? height : newHeight;
|
|
1144
1163
|
}
|
|
1145
1164
|
}
|
|
1146
|
-
|
|
1147
|
-
// Update Height
|
|
1148
1165
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1149
1166
|
}
|
|
1150
1167
|
|
|
1151
|
-
function updateSlidesOffset() {
|
|
1168
|
+
function updateSlidesOffset(params) {
|
|
1169
|
+
const {
|
|
1170
|
+
isCalculatedFromUpdateSlides = false
|
|
1171
|
+
} = params ?? {};
|
|
1172
|
+
if (isCalculatedFromUpdateSlides) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1152
1175
|
const swiper = this;
|
|
1153
1176
|
const slides = swiper.slides;
|
|
1154
1177
|
// eslint-disable-next-line
|
|
@@ -1289,46 +1312,16 @@ var Swiper = (function () {
|
|
|
1289
1312
|
slidesEl,
|
|
1290
1313
|
activeIndex
|
|
1291
1314
|
} = 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;
|
|
1315
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1316
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1317
|
+
const activeSlide = slides[activeIndex];
|
|
1299
1318
|
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
|
-
}
|
|
1319
|
+
let prevSlide;
|
|
1318
1320
|
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
|
-
}
|
|
1321
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1322
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1323
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1324
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1332
1325
|
}
|
|
1333
1326
|
slides.forEach(slideEl => {
|
|
1334
1327
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1419,7 +1412,6 @@ var Swiper = (function () {
|
|
|
1419
1412
|
activeIndex = i;
|
|
1420
1413
|
}
|
|
1421
1414
|
}
|
|
1422
|
-
// Normalize slideIndex
|
|
1423
1415
|
if (params.normalizeSlideIndex) {
|
|
1424
1416
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1425
1417
|
}
|
|
@@ -1437,16 +1429,6 @@ var Swiper = (function () {
|
|
|
1437
1429
|
} = swiper;
|
|
1438
1430
|
let activeIndex = newActiveIndex;
|
|
1439
1431
|
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
1432
|
if (typeof activeIndex === 'undefined') {
|
|
1451
1433
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1452
1434
|
}
|
|
@@ -1464,32 +1446,12 @@ var Swiper = (function () {
|
|
|
1464
1446
|
}
|
|
1465
1447
|
return;
|
|
1466
1448
|
}
|
|
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]) {
|
|
1449
|
+
let realIndex = activeIndex;
|
|
1450
|
+
if (swiper.slides[activeIndex]) {
|
|
1485
1451
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1486
1452
|
if (slideIndex) {
|
|
1487
1453
|
realIndex = parseInt(slideIndex, 10);
|
|
1488
|
-
} else {
|
|
1489
|
-
realIndex = activeIndex;
|
|
1490
1454
|
}
|
|
1491
|
-
} else {
|
|
1492
|
-
realIndex = activeIndex;
|
|
1493
1455
|
}
|
|
1494
1456
|
Object.assign(swiper, {
|
|
1495
1457
|
previousSnapIndex,
|
|
@@ -1536,11 +1498,7 @@ var Swiper = (function () {
|
|
|
1536
1498
|
}
|
|
1537
1499
|
if (slide && slideFound) {
|
|
1538
1500
|
swiper.clickedSlide = slide;
|
|
1539
|
-
|
|
1540
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1541
|
-
} else {
|
|
1542
|
-
swiper.clickedIndex = slideIndex;
|
|
1543
|
-
}
|
|
1501
|
+
swiper.clickedIndex = slideIndex;
|
|
1544
1502
|
} else {
|
|
1545
1503
|
swiper.clickedSlide = undefined;
|
|
1546
1504
|
swiper.clickedIndex = undefined;
|
|
@@ -1574,9 +1532,6 @@ var Swiper = (function () {
|
|
|
1574
1532
|
translate,
|
|
1575
1533
|
wrapperEl
|
|
1576
1534
|
} = swiper;
|
|
1577
|
-
if (params.virtualTranslate) {
|
|
1578
|
-
return rtl ? -translate : translate;
|
|
1579
|
-
}
|
|
1580
1535
|
if (params.cssMode) {
|
|
1581
1536
|
return translate;
|
|
1582
1537
|
}
|
|
@@ -1610,7 +1565,7 @@ var Swiper = (function () {
|
|
|
1610
1565
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1611
1566
|
if (params.cssMode) {
|
|
1612
1567
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1613
|
-
} else
|
|
1568
|
+
} else {
|
|
1614
1569
|
if (swiper.isHorizontal()) {
|
|
1615
1570
|
x -= swiper.cssOverflowAdjustment();
|
|
1616
1571
|
} else {
|
|
@@ -1847,7 +1802,6 @@ var Swiper = (function () {
|
|
|
1847
1802
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1848
1803
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1849
1804
|
const translate = -snapGrid[snapIndex];
|
|
1850
|
-
// Normalize slideIndex
|
|
1851
1805
|
if (params.normalizeSlideIndex) {
|
|
1852
1806
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1853
1807
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1864,33 +1818,24 @@ var Swiper = (function () {
|
|
|
1864
1818
|
}
|
|
1865
1819
|
}
|
|
1866
1820
|
}
|
|
1821
|
+
|
|
1867
1822
|
// Directions locks
|
|
1868
1823
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1869
1824
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1870
1825
|
return false;
|
|
1871
1826
|
}
|
|
1872
1827
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1873
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1874
|
-
return false;
|
|
1875
|
-
}
|
|
1828
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1876
1829
|
}
|
|
1877
1830
|
}
|
|
1878
1831
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1879
1832
|
swiper.emit('beforeSlideChangeStart');
|
|
1880
1833
|
}
|
|
1881
|
-
|
|
1882
|
-
// Update progress
|
|
1883
1834
|
swiper.updateProgress(translate);
|
|
1884
1835
|
let direction;
|
|
1885
1836
|
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)) {
|
|
1837
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1892
1838
|
swiper.updateActiveIndex(slideIndex);
|
|
1893
|
-
// Update Height
|
|
1894
1839
|
if (params.autoHeight) {
|
|
1895
1840
|
swiper.updateAutoHeight();
|
|
1896
1841
|
}
|
|
@@ -1908,24 +1853,7 @@ var Swiper = (function () {
|
|
|
1908
1853
|
const isH = swiper.isHorizontal();
|
|
1909
1854
|
const t = rtl ? translate : -translate;
|
|
1910
1855
|
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
|
-
}
|
|
1856
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1929
1857
|
} else {
|
|
1930
1858
|
if (!swiper.support.smoothScroll) {
|
|
1931
1859
|
animateCSSModeScroll({
|
|
@@ -1943,10 +1871,7 @@ var Swiper = (function () {
|
|
|
1943
1871
|
return true;
|
|
1944
1872
|
}
|
|
1945
1873
|
const browser = getBrowser();
|
|
1946
|
-
|
|
1947
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1948
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1949
|
-
}
|
|
1874
|
+
browser.isSafari;
|
|
1950
1875
|
swiper.setTransition(speed);
|
|
1951
1876
|
swiper.setTranslate(translate);
|
|
1952
1877
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2117,8 +2042,6 @@ var Swiper = (function () {
|
|
|
2117
2042
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2118
2043
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2119
2044
|
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
2045
|
const lastSlide = slides[slides.length - 1];
|
|
2123
2046
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2124
2047
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2153,11 +2076,8 @@ var Swiper = (function () {
|
|
|
2153
2076
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2154
2077
|
}
|
|
2155
2078
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2156
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2157
2079
|
if (params.loop) {
|
|
2158
|
-
if (animating &&
|
|
2159
|
-
|
|
2160
|
-
// Kiểm tra xem loop có bị disable không
|
|
2080
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2161
2081
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2162
2082
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2163
2083
|
swiper.loopFix({
|
|
@@ -2184,7 +2104,6 @@ var Swiper = (function () {
|
|
|
2184
2104
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2185
2105
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2186
2106
|
if (!swiper.params.loop) return;
|
|
2187
|
-
// Move first item to last position only if active slide is the last slide
|
|
2188
2107
|
const firstSlide = slides[0];
|
|
2189
2108
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2190
2109
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2209,17 +2128,14 @@ var Swiper = (function () {
|
|
|
2209
2128
|
params,
|
|
2210
2129
|
snapGrid,
|
|
2211
2130
|
slidesGrid,
|
|
2212
|
-
rtlTranslate,
|
|
2213
|
-
enabled
|
|
2214
|
-
animating
|
|
2131
|
+
rtlTranslate: rtlTranslate,
|
|
2132
|
+
enabled
|
|
2215
2133
|
} = swiper;
|
|
2216
2134
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2217
2135
|
if (typeof speed === 'undefined') {
|
|
2218
2136
|
speed = swiper.params.speed;
|
|
2219
2137
|
}
|
|
2220
|
-
swiper.virtual && params.virtual.enabled;
|
|
2221
2138
|
if (params.loop) {
|
|
2222
|
-
// Kiểm tra xem loop có bị disable không
|
|
2223
2139
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2224
2140
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2225
2141
|
swiper.loopFix({
|
|
@@ -2236,18 +2152,16 @@ var Swiper = (function () {
|
|
|
2236
2152
|
}
|
|
2237
2153
|
const normalizedTranslate = normalize(translate);
|
|
2238
2154
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2239
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2240
2155
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2241
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2156
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2242
2157
|
let prevSnapIndex;
|
|
2243
2158
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2244
2159
|
if (normalizedTranslate >= snap) {
|
|
2245
|
-
// prevSnap = snap;
|
|
2246
2160
|
prevSnapIndex = snapIndex;
|
|
2247
2161
|
}
|
|
2248
2162
|
});
|
|
2249
2163
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2250
|
-
prevSnap =
|
|
2164
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2251
2165
|
}
|
|
2252
2166
|
}
|
|
2253
2167
|
let prevIndex = 0;
|
|
@@ -2260,7 +2174,7 @@ var Swiper = (function () {
|
|
|
2260
2174
|
}
|
|
2261
2175
|
}
|
|
2262
2176
|
if (params.rewind && swiper.isBeginning) {
|
|
2263
|
-
const lastIndex = swiper.
|
|
2177
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2264
2178
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2265
2179
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2266
2180
|
requestAnimationFrame(() => {
|
|
@@ -2274,8 +2188,6 @@ var Swiper = (function () {
|
|
|
2274
2188
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2275
2189
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2276
2190
|
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
2191
|
if (!swiper.params.loop) return;
|
|
2280
2192
|
const lastSlide = slides[slides.length - 1];
|
|
2281
2193
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2352,20 +2264,19 @@ var Swiper = (function () {
|
|
|
2352
2264
|
slidesEl
|
|
2353
2265
|
} = swiper;
|
|
2354
2266
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2355
|
-
|
|
2267
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2356
2268
|
let realIndex;
|
|
2357
2269
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2358
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2359
2270
|
if (params.loop) {
|
|
2360
2271
|
if (swiper.animating) return;
|
|
2361
2272
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2362
2273
|
if (params.centeredSlides) {
|
|
2363
2274
|
swiper.slideToLoop(realIndex);
|
|
2364
|
-
} else if (slideToIndex >
|
|
2275
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2365
2276
|
swiper.loopFix();
|
|
2366
|
-
|
|
2277
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2367
2278
|
nextTick(() => {
|
|
2368
|
-
swiper.slideTo(
|
|
2279
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2369
2280
|
});
|
|
2370
2281
|
} else {
|
|
2371
2282
|
swiper.slideTo(slideToIndex);
|
|
@@ -2392,7 +2303,7 @@ var Swiper = (function () {
|
|
|
2392
2303
|
params,
|
|
2393
2304
|
slidesEl
|
|
2394
2305
|
} = swiper;
|
|
2395
|
-
if (!params.loop
|
|
2306
|
+
if (!params.loop) return;
|
|
2396
2307
|
const initSlides = () => {
|
|
2397
2308
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2398
2309
|
slides.forEach((el, index) => {
|
|
@@ -2401,21 +2312,17 @@ var Swiper = (function () {
|
|
|
2401
2312
|
};
|
|
2402
2313
|
const clearBlankSlides = () => {
|
|
2403
2314
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2404
|
-
slides.forEach(el =>
|
|
2405
|
-
el.remove();
|
|
2406
|
-
});
|
|
2315
|
+
slides.forEach(el => el.remove());
|
|
2407
2316
|
if (slides.length > 0) {
|
|
2408
2317
|
swiper.recalcSlides();
|
|
2409
2318
|
swiper.updateSlides();
|
|
2410
2319
|
}
|
|
2411
2320
|
};
|
|
2412
|
-
|
|
2413
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2321
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2414
2322
|
clearBlankSlides();
|
|
2415
2323
|
}
|
|
2416
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2324
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2417
2325
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2418
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2419
2326
|
const addBlankSlides = amountOfSlides => {
|
|
2420
2327
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2421
2328
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2432,16 +2339,6 @@ var Swiper = (function () {
|
|
|
2432
2339
|
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
2340
|
}
|
|
2434
2341
|
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
2342
|
} else {
|
|
2446
2343
|
initSlides();
|
|
2447
2344
|
}
|
|
@@ -2460,13 +2357,12 @@ var Swiper = (function () {
|
|
|
2460
2357
|
setTranslate,
|
|
2461
2358
|
activeSlideIndex,
|
|
2462
2359
|
initial,
|
|
2463
|
-
byController,
|
|
2464
2360
|
byMousewheel
|
|
2465
2361
|
} = _temp === void 0 ? {} : _temp;
|
|
2466
2362
|
const swiper = this;
|
|
2467
2363
|
if (!swiper.params.loop) return;
|
|
2468
2364
|
|
|
2469
|
-
// Disable loop mode
|
|
2365
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2470
2366
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2471
2367
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2472
2368
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2486,21 +2382,6 @@ var Swiper = (function () {
|
|
|
2486
2382
|
} = params;
|
|
2487
2383
|
swiper.allowSlidePrev = true;
|
|
2488
2384
|
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
2385
|
let slidesPerView = params.slidesPerView;
|
|
2505
2386
|
if (slidesPerView === 'auto') {
|
|
2506
2387
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2510,22 +2391,19 @@ var Swiper = (function () {
|
|
|
2510
2391
|
slidesPerView = slidesPerView + 1;
|
|
2511
2392
|
}
|
|
2512
2393
|
}
|
|
2513
|
-
const slidesPerGroup = params.
|
|
2394
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2514
2395
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2515
2396
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2516
2397
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2517
2398
|
}
|
|
2518
2399
|
loopedSlides += params.loopAdditionalSlides;
|
|
2519
2400
|
swiper.loopedSlides = loopedSlides;
|
|
2520
|
-
|
|
2521
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2401
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2522
2402
|
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
2403
|
}
|
|
2526
2404
|
const prependSlidesIndexes = [];
|
|
2527
2405
|
const appendSlidesIndexes = [];
|
|
2528
|
-
const cols =
|
|
2406
|
+
const cols = slides.length;
|
|
2529
2407
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2530
2408
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2531
2409
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2537,24 +2415,15 @@ var Swiper = (function () {
|
|
|
2537
2415
|
const isPrev = direction === 'prev' || !direction;
|
|
2538
2416
|
let slidesPrepended = 0;
|
|
2539
2417
|
let slidesAppended = 0;
|
|
2540
|
-
const activeColIndex =
|
|
2418
|
+
const activeColIndex = activeSlideIndex;
|
|
2541
2419
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2420
|
+
|
|
2542
2421
|
// prepend last slides before start
|
|
2543
2422
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2544
2423
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2545
2424
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2546
2425
|
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
|
-
}
|
|
2426
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2558
2427
|
}
|
|
2559
2428
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2560
2429
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2563,27 +2432,13 @@ var Swiper = (function () {
|
|
|
2563
2432
|
}
|
|
2564
2433
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2565
2434
|
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
|
-
}
|
|
2435
|
+
appendSlidesIndexes.push(index);
|
|
2573
2436
|
}
|
|
2574
2437
|
}
|
|
2575
2438
|
swiper.__preventObserver__ = true;
|
|
2576
2439
|
requestAnimationFrame(() => {
|
|
2577
2440
|
swiper.__preventObserver__ = false;
|
|
2578
2441
|
});
|
|
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
2442
|
if (isPrev) {
|
|
2588
2443
|
prependSlidesIndexes.forEach(index => {
|
|
2589
2444
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2601,13 +2456,11 @@ var Swiper = (function () {
|
|
|
2601
2456
|
swiper.recalcSlides();
|
|
2602
2457
|
if (params.slidesPerView === 'auto') {
|
|
2603
2458
|
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
2459
|
}
|
|
2609
2460
|
if (params.watchSlidesProgress) {
|
|
2610
|
-
swiper.updateSlidesOffset(
|
|
2461
|
+
swiper.updateSlidesOffset({
|
|
2462
|
+
isCalculatedFromUpdateSlides: params.slidesPerView === 'auto'
|
|
2463
|
+
});
|
|
2611
2464
|
}
|
|
2612
2465
|
if (slideTo) {
|
|
2613
2466
|
if (prependSlidesIndexes.length > 0 && isPrev) {
|
|
@@ -2624,12 +2477,10 @@ var Swiper = (function () {
|
|
|
2624
2477
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2625
2478
|
}
|
|
2626
2479
|
}
|
|
2627
|
-
} else {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2632
|
-
}
|
|
2480
|
+
} else if (setTranslate) {
|
|
2481
|
+
const shift = prependSlidesIndexes.length;
|
|
2482
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2483
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2633
2484
|
}
|
|
2634
2485
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2635
2486
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2645,36 +2496,14 @@ var Swiper = (function () {
|
|
|
2645
2496
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2646
2497
|
}
|
|
2647
2498
|
}
|
|
2648
|
-
} else {
|
|
2649
|
-
const shift =
|
|
2499
|
+
} else if (setTranslate) {
|
|
2500
|
+
const shift = appendSlidesIndexes.length;
|
|
2650
2501
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2651
2502
|
}
|
|
2652
2503
|
}
|
|
2653
2504
|
}
|
|
2654
2505
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2655
2506
|
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
2507
|
swiper.emit('loopFix');
|
|
2679
2508
|
}
|
|
2680
2509
|
|
|
@@ -2691,7 +2520,7 @@ var Swiper = (function () {
|
|
|
2691
2520
|
const swiper = this;
|
|
2692
2521
|
if (!swiper.params.loop) return;
|
|
2693
2522
|
|
|
2694
|
-
// Disable loop mode
|
|
2523
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2695
2524
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2696
2525
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2697
2526
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2730,7 +2559,7 @@ var Swiper = (function () {
|
|
|
2730
2559
|
}
|
|
2731
2560
|
loopedSlides += params.loopAdditionalSlides;
|
|
2732
2561
|
swiper.loopedSlides = loopedSlides;
|
|
2733
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2562
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2734
2563
|
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
2564
|
}
|
|
2736
2565
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2756,20 +2585,16 @@ var Swiper = (function () {
|
|
|
2756
2585
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2757
2586
|
}
|
|
2758
2587
|
|
|
2759
|
-
//
|
|
2588
|
+
// DocumentFragment to hold slide clones
|
|
2760
2589
|
const cloneFragment = document.createDocumentFragment();
|
|
2761
2590
|
|
|
2762
|
-
// Clone
|
|
2591
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2763
2592
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2764
2593
|
if (slides[index]) {
|
|
2765
2594
|
const originalSlide = slides[index];
|
|
2766
2595
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2767
|
-
|
|
2768
|
-
// Đánh dấu slide clone
|
|
2769
2596
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2770
2597
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2771
|
-
|
|
2772
|
-
// Thêm clone vào fragment
|
|
2773
2598
|
cloneFragment.appendChild(clonedSlide);
|
|
2774
2599
|
}
|
|
2775
2600
|
});
|
|
@@ -2790,32 +2615,28 @@ var Swiper = (function () {
|
|
|
2790
2615
|
});
|
|
2791
2616
|
}
|
|
2792
2617
|
|
|
2793
|
-
//
|
|
2618
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2794
2619
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2795
2620
|
clonedSlides.sort((a, b) => {
|
|
2796
2621
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2797
2622
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2798
2623
|
return indexA - indexB;
|
|
2799
2624
|
});
|
|
2800
|
-
|
|
2801
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2802
2625
|
cloneFragment.innerHTML = '';
|
|
2803
2626
|
clonedSlides.forEach(slide => {
|
|
2804
2627
|
cloneFragment.appendChild(slide);
|
|
2805
2628
|
});
|
|
2806
2629
|
|
|
2807
|
-
//
|
|
2630
|
+
// Place fragment into the right position
|
|
2808
2631
|
if (isPrev) {
|
|
2809
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2810
2632
|
slidesEl.appendChild(cloneFragment);
|
|
2811
2633
|
} else if (isNext) {
|
|
2812
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2813
2634
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2814
2635
|
}
|
|
2815
2636
|
swiper.recalcSlides();
|
|
2816
2637
|
swiper.updateSlides();
|
|
2817
2638
|
|
|
2818
|
-
//
|
|
2639
|
+
// Find old active slide index after recalculation
|
|
2819
2640
|
let oldActiveIndex = null;
|
|
2820
2641
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2821
2642
|
const child = slidesEl.children[i];
|
|
@@ -2828,7 +2649,7 @@ var Swiper = (function () {
|
|
|
2828
2649
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2829
2650
|
}
|
|
2830
2651
|
|
|
2831
|
-
//
|
|
2652
|
+
// Update translate after removing clones for animation
|
|
2832
2653
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2833
2654
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2834
2655
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2854,7 +2675,8 @@ var Swiper = (function () {
|
|
|
2854
2675
|
}
|
|
2855
2676
|
swiper.setTranslate(updateTranslate);
|
|
2856
2677
|
}
|
|
2857
|
-
|
|
2678
|
+
|
|
2679
|
+
// Remove clones
|
|
2858
2680
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2859
2681
|
cloneSlides.forEach(cloneSlide => {
|
|
2860
2682
|
if (cloneSlide.parentNode) {
|
|
@@ -2884,7 +2706,7 @@ var Swiper = (function () {
|
|
|
2884
2706
|
params,
|
|
2885
2707
|
slidesEl
|
|
2886
2708
|
} = swiper;
|
|
2887
|
-
if (!params.loop || !slidesEl
|
|
2709
|
+
if (!params.loop || !slidesEl) return;
|
|
2888
2710
|
swiper.recalcSlides();
|
|
2889
2711
|
const newSlidesOrder = [];
|
|
2890
2712
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2945,7 +2767,6 @@ var Swiper = (function () {
|
|
|
2945
2767
|
unsetGrabCursor
|
|
2946
2768
|
};
|
|
2947
2769
|
|
|
2948
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2949
2770
|
function closestElement(selector, base) {
|
|
2950
2771
|
if (base === void 0) {
|
|
2951
2772
|
base = this;
|
|
@@ -2954,9 +2775,7 @@ var Swiper = (function () {
|
|
|
2954
2775
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
2955
2776
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
2956
2777
|
const found = el.closest(selector);
|
|
2957
|
-
if (!found && !el.getRootNode)
|
|
2958
|
-
return null;
|
|
2959
|
-
}
|
|
2778
|
+
if (!found && !el.getRootNode) return null;
|
|
2960
2779
|
return found || __closestFrom(el.getRootNode().host);
|
|
2961
2780
|
}
|
|
2962
2781
|
return __closestFrom(base);
|
|
@@ -2984,9 +2803,7 @@ var Swiper = (function () {
|
|
|
2984
2803
|
if (e.originalEvent) e = e.originalEvent;
|
|
2985
2804
|
const data = swiper.touchEventsData;
|
|
2986
2805
|
if (e.type === 'pointerdown') {
|
|
2987
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
2988
|
-
return;
|
|
2989
|
-
}
|
|
2806
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
2990
2807
|
data.pointerId = e.pointerId;
|
|
2991
2808
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2992
2809
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3003,9 +2820,7 @@ var Swiper = (function () {
|
|
|
3003
2820
|
} = swiper;
|
|
3004
2821
|
if (!enabled) return;
|
|
3005
2822
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3006
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3007
|
-
return;
|
|
3008
|
-
}
|
|
2823
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3009
2824
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3010
2825
|
swiper.loopFix();
|
|
3011
2826
|
}
|
|
@@ -3016,8 +2831,6 @@ var Swiper = (function () {
|
|
|
3016
2831
|
if ('which' in e && e.which === 3) return;
|
|
3017
2832
|
if ('button' in e && e.button > 0) return;
|
|
3018
2833
|
if (data.isTouched && data.isMoved) return;
|
|
3019
|
-
|
|
3020
|
-
// change target el for shadow root component
|
|
3021
2834
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3022
2835
|
// eslint-disable-next-line
|
|
3023
2836
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3026,8 +2839,6 @@ var Swiper = (function () {
|
|
|
3026
2839
|
}
|
|
3027
2840
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3028
2841
|
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
2842
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3032
2843
|
swiper.allowClick = true;
|
|
3033
2844
|
return;
|
|
@@ -3039,12 +2850,7 @@ var Swiper = (function () {
|
|
|
3039
2850
|
touches.currentY = e.pageY;
|
|
3040
2851
|
const startX = touches.currentX;
|
|
3041
2852
|
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
|
-
}
|
|
2853
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3048
2854
|
Object.assign(data, {
|
|
3049
2855
|
isTouched: true,
|
|
3050
2856
|
isMoved: false,
|
|
@@ -3073,9 +2879,6 @@ var Swiper = (function () {
|
|
|
3073
2879
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3074
2880
|
e.preventDefault();
|
|
3075
2881
|
}
|
|
3076
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3077
|
-
swiper.freeMode.onTouchStart();
|
|
3078
|
-
}
|
|
3079
2882
|
swiper.emit('touchStart', e);
|
|
3080
2883
|
}
|
|
3081
2884
|
|
|
@@ -3094,7 +2897,7 @@ var Swiper = (function () {
|
|
|
3094
2897
|
let e = event;
|
|
3095
2898
|
if (e.originalEvent) e = e.originalEvent;
|
|
3096
2899
|
if (e.type === 'pointermove') {
|
|
3097
|
-
if (data.touchId !== null) return;
|
|
2900
|
+
if (data.touchId !== null) return;
|
|
3098
2901
|
const id = e.pointerId;
|
|
3099
2902
|
if (id !== data.pointerId) return;
|
|
3100
2903
|
}
|
|
@@ -3135,7 +2938,6 @@ var Swiper = (function () {
|
|
|
3135
2938
|
}
|
|
3136
2939
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3137
2940
|
if (swiper.isVertical()) {
|
|
3138
|
-
// Vertical
|
|
3139
2941
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3140
2942
|
data.isTouched = false;
|
|
3141
2943
|
data.isMoved = false;
|
|
@@ -3237,7 +3039,6 @@ var Swiper = (function () {
|
|
|
3237
3039
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3238
3040
|
}
|
|
3239
3041
|
data.allowMomentumBounce = false;
|
|
3240
|
-
// Grab Cursor
|
|
3241
3042
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3242
3043
|
swiper.setGrabCursor(true);
|
|
3243
3044
|
}
|
|
@@ -3308,8 +3109,6 @@ var Swiper = (function () {
|
|
|
3308
3109
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3309
3110
|
data.currentTranslate = data.startTranslate;
|
|
3310
3111
|
}
|
|
3311
|
-
|
|
3312
|
-
// Threshold
|
|
3313
3112
|
if (params.threshold > 0) {
|
|
3314
3113
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3315
3114
|
if (!data.allowThresholdMove) {
|
|
@@ -3327,17 +3126,12 @@ var Swiper = (function () {
|
|
|
3327
3126
|
}
|
|
3328
3127
|
if (!params.followFinger || params.cssMode) return;
|
|
3329
3128
|
|
|
3330
|
-
//
|
|
3331
|
-
if (params.
|
|
3129
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3130
|
+
if (params.watchSlidesProgress) {
|
|
3332
3131
|
swiper.updateActiveIndex();
|
|
3333
3132
|
swiper.updateSlidesClasses();
|
|
3334
3133
|
}
|
|
3335
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3336
|
-
swiper.freeMode.onTouchMove();
|
|
3337
|
-
}
|
|
3338
|
-
// Update progress
|
|
3339
3134
|
swiper.updateProgress(data.currentTranslate);
|
|
3340
|
-
// Update translate
|
|
3341
3135
|
swiper.setTranslate(data.currentTranslate);
|
|
3342
3136
|
}
|
|
3343
3137
|
|
|
@@ -3349,7 +3143,7 @@ var Swiper = (function () {
|
|
|
3349
3143
|
let targetTouch;
|
|
3350
3144
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3351
3145
|
if (!isTouchEvent) {
|
|
3352
|
-
if (data.touchId !== null) return;
|
|
3146
|
+
if (data.touchId !== null) return;
|
|
3353
3147
|
if (e.pointerId !== data.pointerId) return;
|
|
3354
3148
|
targetTouch = e;
|
|
3355
3149
|
} else {
|
|
@@ -3358,9 +3152,7 @@ var Swiper = (function () {
|
|
|
3358
3152
|
}
|
|
3359
3153
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3360
3154
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3361
|
-
if (!proceed)
|
|
3362
|
-
return;
|
|
3363
|
-
}
|
|
3155
|
+
if (!proceed) return;
|
|
3364
3156
|
}
|
|
3365
3157
|
data.pointerId = null;
|
|
3366
3158
|
data.touchId = null;
|
|
@@ -3378,9 +3170,7 @@ var Swiper = (function () {
|
|
|
3378
3170
|
}
|
|
3379
3171
|
data.allowTouchCallbacks = false;
|
|
3380
3172
|
if (!data.isTouched) {
|
|
3381
|
-
if (data.isMoved && params.grabCursor)
|
|
3382
|
-
swiper.setGrabCursor(false);
|
|
3383
|
-
}
|
|
3173
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3384
3174
|
data.isMoved = false;
|
|
3385
3175
|
data.startMoving = false;
|
|
3386
3176
|
return;
|
|
@@ -3390,8 +3180,6 @@ var Swiper = (function () {
|
|
|
3390
3180
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3391
3181
|
swiper.setGrabCursor(false);
|
|
3392
3182
|
}
|
|
3393
|
-
|
|
3394
|
-
// Time diff
|
|
3395
3183
|
const touchEndTime = now();
|
|
3396
3184
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3397
3185
|
|
|
@@ -3418,20 +3206,8 @@ var Swiper = (function () {
|
|
|
3418
3206
|
data.isMoved = false;
|
|
3419
3207
|
data.startMoving = false;
|
|
3420
3208
|
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
|
-
}
|
|
3209
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3210
|
+
if (params.cssMode) return;
|
|
3435
3211
|
|
|
3436
3212
|
// Find current slide
|
|
3437
3213
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3453,22 +3229,22 @@ var Swiper = (function () {
|
|
|
3453
3229
|
let rewindLastIndex = null;
|
|
3454
3230
|
if (params.rewind) {
|
|
3455
3231
|
if (swiper.isBeginning) {
|
|
3456
|
-
rewindLastIndex =
|
|
3232
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3457
3233
|
} else if (swiper.isEnd) {
|
|
3458
3234
|
rewindFirstIndex = 0;
|
|
3459
3235
|
}
|
|
3460
3236
|
}
|
|
3461
|
-
// Find current slide size
|
|
3462
3237
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3463
3238
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3464
3239
|
if (timeDiff > params.longSwipesMs) {
|
|
3465
|
-
// Long touches
|
|
3466
3240
|
if (!params.longSwipes) {
|
|
3467
3241
|
swiper.slideTo(swiper.activeIndex);
|
|
3468
3242
|
return;
|
|
3469
3243
|
}
|
|
3470
3244
|
if (swiper.swipeDirection === 'next') {
|
|
3471
|
-
if (ratio >= params.longSwipesRatio)
|
|
3245
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3246
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3247
|
+
} else swiper.slideTo(stopIndex);
|
|
3472
3248
|
}
|
|
3473
3249
|
if (swiper.swipeDirection === 'prev') {
|
|
3474
3250
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3520,7 +3296,6 @@ var Swiper = (function () {
|
|
|
3520
3296
|
allowSlidePrev,
|
|
3521
3297
|
snapGrid
|
|
3522
3298
|
} = swiper;
|
|
3523
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3524
3299
|
|
|
3525
3300
|
// Disable locks on resize
|
|
3526
3301
|
swiper.allowSlideNext = true;
|
|
@@ -3528,15 +3303,12 @@ var Swiper = (function () {
|
|
|
3528
3303
|
swiper.updateSize();
|
|
3529
3304
|
swiper.updateSlides();
|
|
3530
3305
|
swiper.updateSlidesClasses();
|
|
3531
|
-
|
|
3532
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3306
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3533
3307
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3308
|
+
} else if (swiper.params.loop) {
|
|
3309
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3534
3310
|
} else {
|
|
3535
|
-
|
|
3536
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3537
|
-
} else {
|
|
3538
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3539
|
-
}
|
|
3311
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3540
3312
|
}
|
|
3541
3313
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3542
3314
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3546,10 +3318,11 @@ var Swiper = (function () {
|
|
|
3546
3318
|
}
|
|
3547
3319
|
}, 500);
|
|
3548
3320
|
}
|
|
3321
|
+
|
|
3549
3322
|
// Return locks after resize
|
|
3550
3323
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3551
3324
|
swiper.allowSlideNext = allowSlideNext;
|
|
3552
|
-
if (
|
|
3325
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3553
3326
|
swiper.checkOverflow();
|
|
3554
3327
|
}
|
|
3555
3328
|
}
|
|
@@ -3603,6 +3376,10 @@ var Swiper = (function () {
|
|
|
3603
3376
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3604
3377
|
return;
|
|
3605
3378
|
}
|
|
3379
|
+
const el = e?.target;
|
|
3380
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3381
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3382
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3606
3383
|
swiper.update();
|
|
3607
3384
|
}
|
|
3608
3385
|
|
|
@@ -3714,8 +3491,15 @@ var Swiper = (function () {
|
|
|
3714
3491
|
detachEvents
|
|
3715
3492
|
};
|
|
3716
3493
|
|
|
3717
|
-
const
|
|
3718
|
-
|
|
3494
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3495
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3496
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3497
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3498
|
+
swiper[prop].disable();
|
|
3499
|
+
}
|
|
3500
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3501
|
+
swiper[prop].enable();
|
|
3502
|
+
}
|
|
3719
3503
|
};
|
|
3720
3504
|
function setBreakpoint() {
|
|
3721
3505
|
const swiper = this;
|
|
@@ -3736,38 +3520,20 @@ var Swiper = (function () {
|
|
|
3736
3520
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3737
3521
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3738
3522
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3739
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3740
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3741
3523
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3742
3524
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3743
3525
|
const wasEnabled = params.enabled;
|
|
3744
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3745
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3746
|
-
swiper.emitContainerClasses();
|
|
3747
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3748
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3749
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3750
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3751
|
-
}
|
|
3752
|
-
swiper.emitContainerClasses();
|
|
3753
|
-
}
|
|
3754
3526
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3755
3527
|
swiper.unsetGrabCursor();
|
|
3756
3528
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3757
3529
|
swiper.setGrabCursor();
|
|
3758
3530
|
}
|
|
3759
3531
|
|
|
3760
|
-
//
|
|
3761
|
-
['navigation', 'pagination'
|
|
3532
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3533
|
+
const modules = ['navigation', 'pagination'];
|
|
3534
|
+
modules.forEach(prop => {
|
|
3762
3535
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3763
|
-
|
|
3764
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3765
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3766
|
-
swiper[prop].disable();
|
|
3767
|
-
}
|
|
3768
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3769
|
-
swiper[prop].enable();
|
|
3770
|
-
}
|
|
3536
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3771
3537
|
});
|
|
3772
3538
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3773
3539
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3849,7 +3615,7 @@ var Swiper = (function () {
|
|
|
3849
3615
|
getBreakpoint
|
|
3850
3616
|
};
|
|
3851
3617
|
|
|
3852
|
-
|
|
3618
|
+
const prepareClasses = (entries, prefix) => {
|
|
3853
3619
|
const resultClasses = [];
|
|
3854
3620
|
entries.forEach(item => {
|
|
3855
3621
|
if (typeof item === 'object') {
|
|
@@ -3863,7 +3629,7 @@ var Swiper = (function () {
|
|
|
3863
3629
|
}
|
|
3864
3630
|
});
|
|
3865
3631
|
return resultClasses;
|
|
3866
|
-
}
|
|
3632
|
+
};
|
|
3867
3633
|
function addClasses() {
|
|
3868
3634
|
const swiper = this;
|
|
3869
3635
|
const {
|
|
@@ -3873,17 +3639,12 @@ var Swiper = (function () {
|
|
|
3873
3639
|
el,
|
|
3874
3640
|
device
|
|
3875
3641
|
} = swiper;
|
|
3642
|
+
// core-lite: removed module-specific classes
|
|
3876
3643
|
// prettier-ignore
|
|
3877
3644
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3878
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3879
|
-
}, {
|
|
3880
3645
|
'autoheight': params.autoHeight
|
|
3881
3646
|
}, {
|
|
3882
3647
|
'rtl': rtl
|
|
3883
|
-
}, {
|
|
3884
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3885
|
-
}, {
|
|
3886
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3887
3648
|
}, {
|
|
3888
3649
|
'android': device.android
|
|
3889
3650
|
}, {
|
|
@@ -3980,16 +3741,12 @@ var Swiper = (function () {
|
|
|
3980
3741
|
autoHeight: false,
|
|
3981
3742
|
// Set wrapper width
|
|
3982
3743
|
setWrapperSize: false,
|
|
3983
|
-
//
|
|
3984
|
-
virtualTranslate: false,
|
|
3985
|
-
// Effects
|
|
3744
|
+
// Effects (core-lite only supports `slide`)
|
|
3986
3745
|
effect: 'slide',
|
|
3987
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
3988
|
-
|
|
3989
3746
|
// Breakpoints
|
|
3990
3747
|
breakpoints: undefined,
|
|
3991
3748
|
breakpointsBase: 'window',
|
|
3992
|
-
// Slides
|
|
3749
|
+
// Slides
|
|
3993
3750
|
spaceBetween: 0,
|
|
3994
3751
|
slidesPerView: 1,
|
|
3995
3752
|
slidesPerGroup: 1,
|
|
@@ -4092,7 +3849,9 @@ var Swiper = (function () {
|
|
|
4092
3849
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4093
3850
|
params[moduleParamName].auto = true;
|
|
4094
3851
|
}
|
|
4095
|
-
|
|
3852
|
+
|
|
3853
|
+
// Core-lite: keep only pagination auto-init.
|
|
3854
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4096
3855
|
params[moduleParamName].auto = true;
|
|
4097
3856
|
}
|
|
4098
3857
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4218,7 +3977,6 @@ var Swiper = (function () {
|
|
|
4218
3977
|
// Indexes
|
|
4219
3978
|
activeIndex: 0,
|
|
4220
3979
|
realIndex: 0,
|
|
4221
|
-
//
|
|
4222
3980
|
isBeginning: true,
|
|
4223
3981
|
isEnd: false,
|
|
4224
3982
|
// Props
|
|
@@ -4245,12 +4003,9 @@ var Swiper = (function () {
|
|
|
4245
4003
|
currentTranslate: undefined,
|
|
4246
4004
|
startTranslate: undefined,
|
|
4247
4005
|
allowThresholdMove: undefined,
|
|
4248
|
-
// Form elements to match
|
|
4249
4006
|
focusableElements: swiper.params.focusableElements,
|
|
4250
|
-
// Last click time
|
|
4251
4007
|
lastClickTime: 0,
|
|
4252
4008
|
clickTimeout: undefined,
|
|
4253
|
-
// Velocities
|
|
4254
4009
|
velocities: [],
|
|
4255
4010
|
allowMomentumBounce: undefined,
|
|
4256
4011
|
startMoving: undefined,
|
|
@@ -4270,7 +4025,8 @@ var Swiper = (function () {
|
|
|
4270
4025
|
},
|
|
4271
4026
|
// Images
|
|
4272
4027
|
imagesToLoad: [],
|
|
4273
|
-
imagesLoaded: 0
|
|
4028
|
+
imagesLoaded: 0,
|
|
4029
|
+
rtl: params?.rtl
|
|
4274
4030
|
});
|
|
4275
4031
|
swiper.emit('_swiper');
|
|
4276
4032
|
|
|
@@ -4279,7 +4035,6 @@ var Swiper = (function () {
|
|
|
4279
4035
|
swiper.init();
|
|
4280
4036
|
}
|
|
4281
4037
|
|
|
4282
|
-
// Return app instance
|
|
4283
4038
|
// eslint-disable-next-line no-constructor-return
|
|
4284
4039
|
return swiper;
|
|
4285
4040
|
}
|
|
@@ -4311,16 +4066,6 @@ var Swiper = (function () {
|
|
|
4311
4066
|
getSlideIndexByData(index) {
|
|
4312
4067
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4313
4068
|
}
|
|
4314
|
-
getSlideIndexWhenGrid(index) {
|
|
4315
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4316
|
-
if (this.params.grid.fill === 'column') {
|
|
4317
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4318
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4319
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4320
|
-
}
|
|
4321
|
-
}
|
|
4322
|
-
return index;
|
|
4323
|
-
}
|
|
4324
4069
|
recalcSlides() {
|
|
4325
4070
|
const swiper = this;
|
|
4326
4071
|
const {
|
|
@@ -4422,21 +4167,15 @@ var Swiper = (function () {
|
|
|
4422
4167
|
}
|
|
4423
4168
|
}
|
|
4424
4169
|
} else {
|
|
4425
|
-
// eslint-disable-next-line
|
|
4426
4170
|
if (view === 'current') {
|
|
4427
4171
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4428
4172
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4429
|
-
if (slideInView)
|
|
4430
|
-
spv += 1;
|
|
4431
|
-
}
|
|
4173
|
+
if (slideInView) spv += 1;
|
|
4432
4174
|
}
|
|
4433
4175
|
} else {
|
|
4434
|
-
// previous
|
|
4435
4176
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4436
4177
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4437
|
-
if (slideInView)
|
|
4438
|
-
spv += 1;
|
|
4439
|
-
}
|
|
4178
|
+
if (slideInView) spv += 1;
|
|
4440
4179
|
}
|
|
4441
4180
|
}
|
|
4442
4181
|
}
|
|
@@ -4449,14 +4188,11 @@ var Swiper = (function () {
|
|
|
4449
4188
|
snapGrid,
|
|
4450
4189
|
params
|
|
4451
4190
|
} = swiper;
|
|
4452
|
-
// Breakpoints
|
|
4453
4191
|
if (params.breakpoints) {
|
|
4454
4192
|
swiper.setBreakpoint();
|
|
4455
4193
|
}
|
|
4456
4194
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4457
|
-
if (imageEl.complete)
|
|
4458
|
-
processLazyPreloader(swiper, imageEl);
|
|
4459
|
-
}
|
|
4195
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4460
4196
|
});
|
|
4461
4197
|
swiper.updateSize();
|
|
4462
4198
|
swiper.updateSlides();
|
|
@@ -4470,22 +4206,12 @@ var Swiper = (function () {
|
|
|
4470
4206
|
swiper.updateSlidesClasses();
|
|
4471
4207
|
}
|
|
4472
4208
|
let translated;
|
|
4473
|
-
if (params.
|
|
4474
|
-
|
|
4475
|
-
if (params.autoHeight) {
|
|
4476
|
-
swiper.updateAutoHeight();
|
|
4477
|
-
}
|
|
4209
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4210
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4478
4211
|
} else {
|
|
4479
|
-
|
|
4480
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4481
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4482
|
-
} else {
|
|
4483
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4484
|
-
}
|
|
4485
|
-
if (!translated) {
|
|
4486
|
-
setTranslate();
|
|
4487
|
-
}
|
|
4212
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4488
4213
|
}
|
|
4214
|
+
if (!translated) setTranslate();
|
|
4489
4215
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4490
4216
|
swiper.checkOverflow();
|
|
4491
4217
|
}
|
|
@@ -4498,7 +4224,6 @@ var Swiper = (function () {
|
|
|
4498
4224
|
const swiper = this;
|
|
4499
4225
|
const currentDirection = swiper.params.direction;
|
|
4500
4226
|
if (!newDirection) {
|
|
4501
|
-
// eslint-disable-next-line
|
|
4502
4227
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4503
4228
|
}
|
|
4504
4229
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4536,15 +4261,11 @@ var Swiper = (function () {
|
|
|
4536
4261
|
mount(element) {
|
|
4537
4262
|
const swiper = this;
|
|
4538
4263
|
if (swiper.mounted) return true;
|
|
4539
|
-
|
|
4540
|
-
// Find el
|
|
4541
4264
|
let el = element || swiper.params.el;
|
|
4542
4265
|
if (typeof el === 'string') {
|
|
4543
4266
|
el = document.querySelector(el);
|
|
4544
4267
|
}
|
|
4545
|
-
if (!el)
|
|
4546
|
-
return false;
|
|
4547
|
-
}
|
|
4268
|
+
if (!el) return false;
|
|
4548
4269
|
el.swiper = swiper;
|
|
4549
4270
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4550
4271
|
swiper.isElement = true;
|
|
@@ -4555,12 +4276,10 @@ var Swiper = (function () {
|
|
|
4555
4276
|
const getWrapper = () => {
|
|
4556
4277
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4557
4278
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4558
|
-
// Children needs to return slot items
|
|
4559
4279
|
return res;
|
|
4560
4280
|
}
|
|
4561
4281
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4562
4282
|
};
|
|
4563
|
-
// Find Wrapper
|
|
4564
4283
|
let wrapperEl = getWrapper();
|
|
4565
4284
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4566
4285
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4569,6 +4288,8 @@ var Swiper = (function () {
|
|
|
4569
4288
|
wrapperEl.append(slideEl);
|
|
4570
4289
|
});
|
|
4571
4290
|
}
|
|
4291
|
+
const rtl = swiper.params.rtl ?? (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl');
|
|
4292
|
+
const wrongRTL = false;
|
|
4572
4293
|
Object.assign(swiper, {
|
|
4573
4294
|
el,
|
|
4574
4295
|
wrapperEl,
|
|
@@ -4576,9 +4297,9 @@ var Swiper = (function () {
|
|
|
4576
4297
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4577
4298
|
mounted: true,
|
|
4578
4299
|
// RTL
|
|
4579
|
-
rtl
|
|
4580
|
-
rtlTranslate: swiper.params.direction === 'horizontal' &&
|
|
4581
|
-
wrongRTL
|
|
4300
|
+
rtl,
|
|
4301
|
+
rtlTranslate: swiper.params.direction === 'horizontal' && rtl,
|
|
4302
|
+
wrongRTL
|
|
4582
4303
|
});
|
|
4583
4304
|
return true;
|
|
4584
4305
|
}
|
|
@@ -4595,7 +4316,6 @@ var Swiper = (function () {
|
|
|
4595
4316
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4596
4317
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4597
4318
|
if (isFirstSlide) {
|
|
4598
|
-
// Move last item to first position when at first slide
|
|
4599
4319
|
const lastSlide = slides.at(-1);
|
|
4600
4320
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4601
4321
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4607,7 +4327,6 @@ var Swiper = (function () {
|
|
|
4607
4327
|
swiper.setTransition(speed);
|
|
4608
4328
|
swiper.setTranslate(-swiperTranslate);
|
|
4609
4329
|
} else if (isLastSlide) {
|
|
4610
|
-
// Move first item to last position when at last slide
|
|
4611
4330
|
const firstSlide = slides[0];
|
|
4612
4331
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4613
4332
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4628,42 +4347,24 @@ var Swiper = (function () {
|
|
|
4628
4347
|
const mounted = swiper.mount(el);
|
|
4629
4348
|
if (mounted === false) return swiper;
|
|
4630
4349
|
swiper.emit('beforeInit');
|
|
4631
|
-
|
|
4632
|
-
// Set breakpoint
|
|
4633
4350
|
if (swiper.params.breakpoints) {
|
|
4634
4351
|
swiper.setBreakpoint();
|
|
4635
4352
|
}
|
|
4636
|
-
|
|
4637
|
-
// Add Classes
|
|
4638
4353
|
swiper.addClasses();
|
|
4639
|
-
|
|
4640
|
-
// Update size
|
|
4641
4354
|
swiper.updateSize();
|
|
4642
|
-
|
|
4643
|
-
// Update slides
|
|
4644
4355
|
swiper.updateSlides();
|
|
4645
4356
|
if (swiper.params.watchOverflow) {
|
|
4646
4357
|
swiper.checkOverflow();
|
|
4647
4358
|
}
|
|
4648
|
-
|
|
4649
|
-
// Set Grab Cursor
|
|
4650
4359
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4651
4360
|
swiper.setGrabCursor();
|
|
4652
4361
|
}
|
|
4653
4362
|
|
|
4654
|
-
// Slide
|
|
4655
|
-
|
|
4656
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4657
|
-
} else {
|
|
4658
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4661
|
-
// Create loop
|
|
4363
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4364
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4662
4365
|
if (swiper.params.loop) {
|
|
4663
4366
|
swiper.loopCreate(undefined, true);
|
|
4664
4367
|
}
|
|
4665
|
-
|
|
4666
|
-
// Attach events
|
|
4667
4368
|
swiper.attachEvents();
|
|
4668
4369
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4669
4370
|
if (swiper.isElement) {
|
|
@@ -4673,16 +4374,11 @@ var Swiper = (function () {
|
|
|
4673
4374
|
if (imageEl.complete) {
|
|
4674
4375
|
processLazyPreloader(swiper, imageEl);
|
|
4675
4376
|
} else {
|
|
4676
|
-
imageEl.addEventListener('load', e =>
|
|
4677
|
-
processLazyPreloader(swiper, e.target);
|
|
4678
|
-
});
|
|
4377
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4679
4378
|
}
|
|
4680
4379
|
});
|
|
4681
4380
|
preload(swiper);
|
|
4682
|
-
|
|
4683
|
-
// Init Flag
|
|
4684
4381
|
swiper.initialized = true;
|
|
4685
|
-
preload(swiper);
|
|
4686
4382
|
|
|
4687
4383
|
// Emit
|
|
4688
4384
|
swiper.emit('init');
|
|
@@ -4707,27 +4403,15 @@ var Swiper = (function () {
|
|
|
4707
4403
|
return null;
|
|
4708
4404
|
}
|
|
4709
4405
|
swiper.emit('beforeDestroy');
|
|
4710
|
-
|
|
4711
|
-
// Init Flag
|
|
4712
4406
|
swiper.initialized = false;
|
|
4713
|
-
|
|
4714
|
-
// Detach events
|
|
4715
4407
|
swiper.detachEvents();
|
|
4716
|
-
|
|
4717
|
-
// Destroy loop
|
|
4718
4408
|
if (params.loop) {
|
|
4719
4409
|
swiper.loopDestroy();
|
|
4720
4410
|
}
|
|
4721
|
-
|
|
4722
|
-
// Cleanup styles
|
|
4723
4411
|
if (cleanStyles) {
|
|
4724
4412
|
swiper.removeClasses();
|
|
4725
|
-
if (el && typeof el !== 'string')
|
|
4726
|
-
|
|
4727
|
-
}
|
|
4728
|
-
if (wrapperEl) {
|
|
4729
|
-
wrapperEl.removeAttribute('style');
|
|
4730
|
-
}
|
|
4413
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4414
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4731
4415
|
if (slides && slides.length) {
|
|
4732
4416
|
slides.forEach(slideEl => {
|
|
4733
4417
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4737,8 +4421,6 @@ var Swiper = (function () {
|
|
|
4737
4421
|
}
|
|
4738
4422
|
}
|
|
4739
4423
|
swiper.emit('destroy');
|
|
4740
|
-
|
|
4741
|
-
// Detach emitter events
|
|
4742
4424
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4743
4425
|
swiper.off(eventName);
|
|
4744
4426
|
});
|