@gem-sdk/swiper 0.0.15 → 0.0.17-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 -579
- package/shared/utils.min.mjs +1 -1
- package/shared/utils.min.mjs.map +1 -1
- package/shared/utils.mjs +50 -1
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +297 -584
- 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 +299 -586
- 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 +297 -584
- 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 +295 -582
- 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/types/swiper-options.d.ts +2 -0
package/swiper-element-bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Swiper Custom Element 0.0.
|
|
2
|
+
* Swiper Custom Element 0.0.17-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 23, 2026
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
(function () {
|
|
@@ -189,7 +189,7 @@
|
|
|
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 @@
|
|
|
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) {
|
|
@@ -497,6 +497,55 @@
|
|
|
497
497
|
el.innerHTML = html;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
+
function getComputedStyleValue(params) {
|
|
501
|
+
const {
|
|
502
|
+
styles,
|
|
503
|
+
swiper,
|
|
504
|
+
property
|
|
505
|
+
} = params ?? {};
|
|
506
|
+
return parseFloat(styles.getPropertyValue(swiper.getDirectionLabel(property))) || 0;
|
|
507
|
+
}
|
|
508
|
+
function computeAutoSlideSize(params) {
|
|
509
|
+
const {
|
|
510
|
+
el,
|
|
511
|
+
swiper
|
|
512
|
+
} = params ?? {};
|
|
513
|
+
const styles = getComputedStyle(el);
|
|
514
|
+
const width = getComputedStyleValue({
|
|
515
|
+
styles,
|
|
516
|
+
swiper,
|
|
517
|
+
property: 'width'
|
|
518
|
+
});
|
|
519
|
+
const paddingLeft = getComputedStyleValue({
|
|
520
|
+
styles,
|
|
521
|
+
swiper,
|
|
522
|
+
property: 'padding-left'
|
|
523
|
+
});
|
|
524
|
+
const paddingRight = getComputedStyleValue({
|
|
525
|
+
styles,
|
|
526
|
+
swiper,
|
|
527
|
+
property: 'padding-right'
|
|
528
|
+
});
|
|
529
|
+
const marginLeft = getComputedStyleValue({
|
|
530
|
+
styles,
|
|
531
|
+
swiper,
|
|
532
|
+
property: 'margin-left'
|
|
533
|
+
});
|
|
534
|
+
const marginRight = getComputedStyleValue({
|
|
535
|
+
styles,
|
|
536
|
+
swiper,
|
|
537
|
+
property: 'margin-right'
|
|
538
|
+
});
|
|
539
|
+
const boxSizing = styles.getPropertyValue('box-sizing');
|
|
540
|
+
if (boxSizing && boxSizing === 'border-box') {
|
|
541
|
+
return width + marginLeft + marginRight;
|
|
542
|
+
}
|
|
543
|
+
const {
|
|
544
|
+
clientWidth,
|
|
545
|
+
offsetWidth
|
|
546
|
+
} = slideEl;
|
|
547
|
+
return width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
548
|
+
}
|
|
500
549
|
|
|
501
550
|
let support;
|
|
502
551
|
function calcSupport() {
|
|
@@ -879,9 +928,6 @@
|
|
|
879
928
|
|
|
880
929
|
function updateSlides() {
|
|
881
930
|
const swiper = this;
|
|
882
|
-
function getDirectionPropertyValue(node, label) {
|
|
883
|
-
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
884
|
-
}
|
|
885
931
|
const params = swiper.params;
|
|
886
932
|
const {
|
|
887
933
|
wrapperEl,
|
|
@@ -890,10 +936,8 @@
|
|
|
890
936
|
rtlTranslate: rtl,
|
|
891
937
|
wrongRTL
|
|
892
938
|
} = swiper;
|
|
893
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
894
|
-
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
|
895
939
|
const slides = elementChildren(slidesEl, `.${swiper.params.slideClass}, swiper-slide`);
|
|
896
|
-
const slidesLength =
|
|
940
|
+
const slidesLength = slides.length;
|
|
897
941
|
let snapGrid = [];
|
|
898
942
|
const slidesGrid = [];
|
|
899
943
|
const slidesSizesGrid = [];
|
|
@@ -911,15 +955,15 @@
|
|
|
911
955
|
let slidePosition = -offsetBefore;
|
|
912
956
|
let prevSlideSize = 0;
|
|
913
957
|
let index = 0;
|
|
914
|
-
if (typeof swiperSize === 'undefined')
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
958
|
+
if (typeof swiperSize === 'undefined') return;
|
|
917
959
|
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
|
918
960
|
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
|
919
961
|
} else if (typeof spaceBetween === 'string') {
|
|
920
962
|
spaceBetween = parseFloat(spaceBetween);
|
|
921
963
|
}
|
|
922
|
-
|
|
964
|
+
|
|
965
|
+
// core-lite: compute total slides size without optional modules
|
|
966
|
+
swiper.slidesTotalSize = -spaceBetween;
|
|
923
967
|
|
|
924
968
|
// reset margins
|
|
925
969
|
slides.forEach(slideEl => {
|
|
@@ -937,67 +981,90 @@
|
|
|
937
981
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-before', '');
|
|
938
982
|
setCSSProperty(wrapperEl, '--swiper-centered-offset-after', '');
|
|
939
983
|
}
|
|
940
|
-
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
941
|
-
if (gridEnabled) {
|
|
942
|
-
swiper.grid.initSlides(slides);
|
|
943
|
-
} else if (swiper.grid) {
|
|
944
|
-
swiper.grid.unsetSlides();
|
|
945
|
-
}
|
|
946
984
|
|
|
947
985
|
// Calc slides
|
|
948
986
|
let slideSize;
|
|
949
|
-
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key =>
|
|
950
|
-
|
|
951
|
-
}).length > 0;
|
|
952
|
-
for (let i = 0; i < slidesLength; i += 1) {
|
|
953
|
-
slideSize = 0;
|
|
954
|
-
let slide;
|
|
955
|
-
if (slides[i]) slide = slides[i];
|
|
956
|
-
if (gridEnabled) {
|
|
957
|
-
swiper.grid.updateSlide(i, slide, slides);
|
|
958
|
-
}
|
|
959
|
-
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
987
|
+
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => typeof params.breakpoints[key].slidesPerView !== 'undefined').length > 0;
|
|
988
|
+
const isAutoSlidesPerView = params.slidesPerView === 'auto';
|
|
960
989
|
|
|
961
|
-
|
|
990
|
+
// --- Phase 1: Batch DOM writes (grid updates, width/transform resets) ---
|
|
991
|
+
// Moving all style writes before any reads prevents per-slide forced reflows
|
|
992
|
+
|
|
993
|
+
const savedTransforms = [];
|
|
994
|
+
if (isAutoSlidesPerView) {
|
|
995
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
996
|
+
if (!slides[i]) continue;
|
|
962
997
|
if (shouldResetSlideSize) {
|
|
963
998
|
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
964
999
|
}
|
|
965
|
-
const
|
|
966
|
-
const
|
|
967
|
-
|
|
1000
|
+
const currentTransform = slides[i].style.transform;
|
|
1001
|
+
const currentWebKitTransform = slides[i].style.webkitTransform;
|
|
1002
|
+
savedTransforms[i] = {
|
|
1003
|
+
transform: currentTransform,
|
|
1004
|
+
webkitTransform: currentWebKitTransform
|
|
1005
|
+
};
|
|
968
1006
|
if (currentTransform) {
|
|
969
|
-
|
|
1007
|
+
slides[i].style.transform = 'none';
|
|
970
1008
|
}
|
|
971
1009
|
if (currentWebKitTransform) {
|
|
972
|
-
|
|
1010
|
+
slides[i].style.webkitTransform = 'none';
|
|
973
1011
|
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
// --- Phase 2: Batch DOM reads (single forced reflow for all slides) ---
|
|
1016
|
+
// Read wrapper offset here (before Phase 3 writes) so it's batched with slide reads, not after
|
|
1017
|
+
const wrapperOffset = swiper.isElement ? swiper.wrapperEl[`offset${swiper.isHorizontal() ? 'Left' : 'Top'}`] : 0;
|
|
1018
|
+
const slideVisible = [];
|
|
1019
|
+
const slideSizes = [];
|
|
1020
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1021
|
+
if (!slides[i]) {
|
|
1022
|
+
slideVisible[i] = false;
|
|
1023
|
+
continue;
|
|
1024
|
+
}
|
|
1025
|
+
if (elementStyle(slides[i], 'display') === 'none') {
|
|
1026
|
+
slideVisible[i] = false;
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
slideVisible[i] = true;
|
|
1030
|
+
|
|
1031
|
+
// Cache offsetHeight for autoHeight (batched here to avoid a separate forced reflow in updateAutoHeight)
|
|
1032
|
+
if (params.autoHeight) {
|
|
1033
|
+
slides[i].swiperSlideHeight = slides[i]['offsetHeight'];
|
|
1034
|
+
}
|
|
1035
|
+
if (isAutoSlidesPerView) {
|
|
974
1036
|
if (params.roundLengths) {
|
|
975
|
-
|
|
1037
|
+
slideSizes[i] = swiper.isHorizontal() ? elementOuterSize(slides[i], 'width', true) : elementOuterSize(slides[i], 'height', true);
|
|
976
1038
|
} else {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
|
982
|
-
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
|
983
|
-
const boxSizing = slideStyles.getPropertyValue('box-sizing');
|
|
984
|
-
if (boxSizing && boxSizing === 'border-box') {
|
|
985
|
-
slideSize = width + marginLeft + marginRight;
|
|
986
|
-
} else {
|
|
987
|
-
const {
|
|
988
|
-
clientWidth,
|
|
989
|
-
offsetWidth
|
|
990
|
-
} = slide;
|
|
991
|
-
slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
|
992
|
-
}
|
|
1039
|
+
slideSizes[i] = computeAutoSlideSize({
|
|
1040
|
+
el: slides[i],
|
|
1041
|
+
swiper
|
|
1042
|
+
});
|
|
993
1043
|
}
|
|
994
|
-
if (
|
|
995
|
-
|
|
1044
|
+
if (params.roundLengths) slideSizes[i] = Math.floor(slideSizes[i]);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
// --- Phase 3: Restore transforms (batch write) ---
|
|
1049
|
+
if (isAutoSlidesPerView) {
|
|
1050
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1051
|
+
if (!savedTransforms[i]) continue;
|
|
1052
|
+
if (savedTransforms[i].transform) {
|
|
1053
|
+
slides[i].style.transform = savedTransforms[i].transform;
|
|
996
1054
|
}
|
|
997
|
-
if (
|
|
998
|
-
|
|
1055
|
+
if (savedTransforms[i].webkitTransform) {
|
|
1056
|
+
slides[i].style.webkitTransform = savedTransforms[i].webkitTransform;
|
|
999
1057
|
}
|
|
1000
|
-
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// --- Phase 4: Calculate positions + set sizes (math + deferred writes) ---
|
|
1062
|
+
const cssOverflowAdj = swiper.cssOverflowAdjustment();
|
|
1063
|
+
for (let i = 0; i < slidesLength; i += 1) {
|
|
1064
|
+
slideSize = 0;
|
|
1065
|
+
if (!slideVisible[i]) continue;
|
|
1066
|
+
if (isAutoSlidesPerView) {
|
|
1067
|
+
slideSize = slideSizes[i] || 0;
|
|
1001
1068
|
} else {
|
|
1002
1069
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
1003
1070
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
@@ -1005,13 +1072,13 @@
|
|
|
1005
1072
|
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
1006
1073
|
}
|
|
1007
1074
|
}
|
|
1008
|
-
if (slides[i])
|
|
1009
|
-
slides[i].swiperSlideSize = slideSize;
|
|
1010
|
-
}
|
|
1075
|
+
if (slides[i]) slides[i].swiperSlideSize = slideSize;
|
|
1011
1076
|
slidesSizesGrid.push(slideSize);
|
|
1012
1077
|
if (params.centeredSlides) {
|
|
1013
1078
|
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
|
1014
|
-
if (prevSlideSize === 0 && i !== 0)
|
|
1079
|
+
if (prevSlideSize === 0 && i !== 0) {
|
|
1080
|
+
slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1081
|
+
}
|
|
1015
1082
|
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
|
1016
1083
|
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
|
1017
1084
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
@@ -1019,55 +1086,42 @@
|
|
|
1019
1086
|
slidesGrid.push(slidePosition);
|
|
1020
1087
|
} else {
|
|
1021
1088
|
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
|
1022
|
-
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0)
|
|
1089
|
+
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) {
|
|
1090
|
+
snapGrid.push(slidePosition);
|
|
1091
|
+
}
|
|
1023
1092
|
slidesGrid.push(slidePosition);
|
|
1024
1093
|
slidePosition = slidePosition + slideSize + spaceBetween;
|
|
1025
1094
|
}
|
|
1026
|
-
|
|
1095
|
+
|
|
1096
|
+
// Set swiperSlideOffset from computed grid position (avoids DOM reads in updateSlidesOffset)
|
|
1097
|
+
if (slides[i]) {
|
|
1098
|
+
slides[i].swiperSlideOffset = slidesGrid[slidesGrid.length - 1] - cssOverflowAdj - wrapperOffset;
|
|
1099
|
+
}
|
|
1100
|
+
swiper.slidesTotalSize += slideSize + spaceBetween;
|
|
1027
1101
|
prevSlideSize = slideSize;
|
|
1028
1102
|
index += 1;
|
|
1029
1103
|
}
|
|
1030
|
-
swiper.
|
|
1031
|
-
if (rtl && wrongRTL &&
|
|
1032
|
-
wrapperEl.style.width = `${swiper.
|
|
1104
|
+
swiper.slidesTotalSize = Math.max(swiper.slidesTotalSize, swiperSize) + offsetAfter;
|
|
1105
|
+
if (rtl && wrongRTL && params.effect === 'slide') {
|
|
1106
|
+
wrapperEl.style.width = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1033
1107
|
}
|
|
1034
1108
|
if (params.setWrapperSize) {
|
|
1035
|
-
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.
|
|
1036
|
-
}
|
|
1037
|
-
if (gridEnabled) {
|
|
1038
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
1109
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.slidesTotalSize + spaceBetween}px`;
|
|
1039
1110
|
}
|
|
1040
1111
|
|
|
1041
|
-
// Remove last
|
|
1112
|
+
// Remove last snap points depending on width (non-centered)
|
|
1042
1113
|
if (!params.centeredSlides) {
|
|
1043
1114
|
const newSlidesGrid = [];
|
|
1044
1115
|
for (let i = 0; i < snapGrid.length; i += 1) {
|
|
1045
1116
|
let slidesGridItem = snapGrid[i];
|
|
1046
1117
|
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
|
1047
|
-
if (snapGrid[i] <= swiper.
|
|
1118
|
+
if (snapGrid[i] <= swiper.slidesTotalSize - swiperSize) {
|
|
1048
1119
|
newSlidesGrid.push(slidesGridItem);
|
|
1049
1120
|
}
|
|
1050
1121
|
}
|
|
1051
1122
|
snapGrid = newSlidesGrid;
|
|
1052
|
-
if (Math.floor(swiper.
|
|
1053
|
-
snapGrid.push(swiper.
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
if (isVirtual && params.loop) {
|
|
1057
|
-
const size = slidesSizesGrid[0] + spaceBetween;
|
|
1058
|
-
if (params.slidesPerGroup > 1) {
|
|
1059
|
-
const groups = Math.ceil((swiper.virtual.slidesBefore + swiper.virtual.slidesAfter) / params.slidesPerGroup);
|
|
1060
|
-
const groupSize = size * params.slidesPerGroup;
|
|
1061
|
-
for (let i = 0; i < groups; i += 1) {
|
|
1062
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + groupSize);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
for (let i = 0; i < swiper.virtual.slidesBefore + swiper.virtual.slidesAfter; i += 1) {
|
|
1066
|
-
if (params.slidesPerGroup === 1) {
|
|
1067
|
-
snapGrid.push(snapGrid[snapGrid.length - 1] + size);
|
|
1068
|
-
}
|
|
1069
|
-
slidesGrid.push(slidesGrid[slidesGrid.length - 1] + size);
|
|
1070
|
-
swiper.virtualSize += size;
|
|
1123
|
+
if (Math.floor(swiper.slidesTotalSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
|
1124
|
+
snapGrid.push(swiper.slidesTotalSize - swiperSize);
|
|
1071
1125
|
}
|
|
1072
1126
|
}
|
|
1073
1127
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
@@ -1075,9 +1129,7 @@
|
|
|
1075
1129
|
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1076
1130
|
slides.filter((_, slideIndex) => {
|
|
1077
1131
|
if (!params.cssMode || params.loop) return true;
|
|
1078
|
-
if (slideIndex === slides.length - 1)
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1132
|
+
if (slideIndex === slides.length - 1) return false;
|
|
1081
1133
|
return true;
|
|
1082
1134
|
}).forEach(slideEl => {
|
|
1083
1135
|
slideEl.style[key] = `${spaceBetween}px`;
|
|
@@ -1127,7 +1179,9 @@
|
|
|
1127
1179
|
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
|
1128
1180
|
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
|
1129
1181
|
}
|
|
1130
|
-
|
|
1182
|
+
|
|
1183
|
+
// Emit changes
|
|
1184
|
+
if (slidesLength !== slides.length) {
|
|
1131
1185
|
swiper.emit('slidesLengthChange');
|
|
1132
1186
|
}
|
|
1133
1187
|
if (snapGrid.length !== previousSnapGridLength) {
|
|
@@ -1138,10 +1192,12 @@
|
|
|
1138
1192
|
swiper.emit('slidesGridLengthChange');
|
|
1139
1193
|
}
|
|
1140
1194
|
if (params.watchSlidesProgress) {
|
|
1141
|
-
swiper.updateSlidesOffset(
|
|
1195
|
+
swiper.updateSlidesOffset({
|
|
1196
|
+
isCalculatedFromUpdateSlides: true
|
|
1197
|
+
});
|
|
1142
1198
|
}
|
|
1143
1199
|
swiper.emit('slidesUpdated');
|
|
1144
|
-
if (!
|
|
1200
|
+
if (!params.cssMode && params.effect === 'slide') {
|
|
1145
1201
|
const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
|
|
1146
1202
|
const hasClassBackfaceClassAdded = swiper.el.classList.contains(backFaceHiddenClass);
|
|
1147
1203
|
if (slidesLength <= params.maxBackfaceHiddenSlides) {
|
|
@@ -1155,20 +1211,13 @@
|
|
|
1155
1211
|
function updateAutoHeight(speed) {
|
|
1156
1212
|
const swiper = this;
|
|
1157
1213
|
const activeSlides = [];
|
|
1158
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1159
|
-
let newHeight = 0;
|
|
1160
|
-
let i;
|
|
1161
1214
|
if (typeof speed === 'number') {
|
|
1162
1215
|
swiper.setTransition(speed);
|
|
1163
1216
|
} else if (speed === true) {
|
|
1164
1217
|
swiper.setTransition(swiper.params.speed);
|
|
1165
1218
|
}
|
|
1166
|
-
const getSlideByIndex = index =>
|
|
1167
|
-
|
|
1168
|
-
return swiper.slides[swiper.getSlideIndexByData(index)];
|
|
1169
|
-
}
|
|
1170
|
-
return swiper.slides[index];
|
|
1171
|
-
};
|
|
1219
|
+
const getSlideByIndex = index => swiper.slides[index];
|
|
1220
|
+
|
|
1172
1221
|
// Find slides currently in view
|
|
1173
1222
|
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
|
1174
1223
|
if (swiper.params.centeredSlides) {
|
|
@@ -1176,9 +1225,9 @@
|
|
|
1176
1225
|
activeSlides.push(slide);
|
|
1177
1226
|
});
|
|
1178
1227
|
} else {
|
|
1179
|
-
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1228
|
+
for (let i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
|
1180
1229
|
const index = swiper.activeIndex + i;
|
|
1181
|
-
if (index > swiper.slides.length
|
|
1230
|
+
if (index > swiper.slides.length) break;
|
|
1182
1231
|
activeSlides.push(getSlideByIndex(index));
|
|
1183
1232
|
}
|
|
1184
1233
|
}
|
|
@@ -1187,18 +1236,23 @@
|
|
|
1187
1236
|
}
|
|
1188
1237
|
|
|
1189
1238
|
// Find new height from highest slide in view
|
|
1190
|
-
|
|
1239
|
+
let newHeight = 0;
|
|
1240
|
+
for (let i = 0; i < activeSlides.length; i += 1) {
|
|
1191
1241
|
if (typeof activeSlides[i] !== 'undefined') {
|
|
1192
|
-
const height = activeSlides[i].offsetHeight;
|
|
1242
|
+
const height = activeSlides[i].swiperSlideHeight ?? activeSlides[i]['offsetHeight'];
|
|
1193
1243
|
newHeight = height > newHeight ? height : newHeight;
|
|
1194
1244
|
}
|
|
1195
1245
|
}
|
|
1196
|
-
|
|
1197
|
-
// Update Height
|
|
1198
1246
|
if (newHeight || newHeight === 0) swiper.wrapperEl.style.height = `${newHeight}px`;
|
|
1199
1247
|
}
|
|
1200
1248
|
|
|
1201
|
-
function updateSlidesOffset() {
|
|
1249
|
+
function updateSlidesOffset(params) {
|
|
1250
|
+
const {
|
|
1251
|
+
isCalculatedFromUpdateSlides = false
|
|
1252
|
+
} = params ?? {};
|
|
1253
|
+
if (isCalculatedFromUpdateSlides) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1202
1256
|
const swiper = this;
|
|
1203
1257
|
const slides = swiper.slides;
|
|
1204
1258
|
// eslint-disable-next-line
|
|
@@ -1339,46 +1393,16 @@
|
|
|
1339
1393
|
slidesEl,
|
|
1340
1394
|
activeIndex
|
|
1341
1395
|
} = swiper;
|
|
1342
|
-
const
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1346
|
-
};
|
|
1347
|
-
let activeSlide;
|
|
1348
|
-
let prevSlide;
|
|
1396
|
+
const getNextSlide = slideEl => elementNextAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1397
|
+
const getPrevSlide = slideEl => elementPrevAll(slideEl, `.${params.slideClass}, swiper-slide`)[0];
|
|
1398
|
+
const activeSlide = slides[activeIndex];
|
|
1349
1399
|
let nextSlide;
|
|
1350
|
-
|
|
1351
|
-
if (params.loop) {
|
|
1352
|
-
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
1353
|
-
if (slideIndex < 0) slideIndex = swiper.virtual.slides.length + slideIndex;
|
|
1354
|
-
if (slideIndex >= swiper.virtual.slides.length) slideIndex -= swiper.virtual.slides.length;
|
|
1355
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${slideIndex}"]`);
|
|
1356
|
-
} else {
|
|
1357
|
-
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1358
|
-
}
|
|
1359
|
-
} else {
|
|
1360
|
-
if (gridEnabled) {
|
|
1361
|
-
activeSlide = slides.find(slideEl => slideEl.column === activeIndex);
|
|
1362
|
-
nextSlide = slides.find(slideEl => slideEl.column === activeIndex + 1);
|
|
1363
|
-
prevSlide = slides.find(slideEl => slideEl.column === activeIndex - 1);
|
|
1364
|
-
} else {
|
|
1365
|
-
activeSlide = slides[activeIndex];
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1400
|
+
let prevSlide;
|
|
1368
1401
|
if (activeSlide) {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
nextSlide = slides[0];
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
// Prev Slide
|
|
1377
|
-
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1378
|
-
if (params.loop && !prevSlide === 0) {
|
|
1379
|
-
prevSlide = slides[slides.length - 1];
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1402
|
+
nextSlide = getNextSlide(activeSlide);
|
|
1403
|
+
prevSlide = getPrevSlide(activeSlide);
|
|
1404
|
+
if (params.loop && !nextSlide) nextSlide = slides[0];
|
|
1405
|
+
if (params.loop && !prevSlide) prevSlide = slides[slides.length - 1];
|
|
1382
1406
|
}
|
|
1383
1407
|
slides.forEach(slideEl => {
|
|
1384
1408
|
toggleSlideClasses(slideEl, slideEl === activeSlide, params.slideActiveClass);
|
|
@@ -1469,7 +1493,6 @@
|
|
|
1469
1493
|
activeIndex = i;
|
|
1470
1494
|
}
|
|
1471
1495
|
}
|
|
1472
|
-
// Normalize slideIndex
|
|
1473
1496
|
if (params.normalizeSlideIndex) {
|
|
1474
1497
|
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
|
1475
1498
|
}
|
|
@@ -1487,16 +1510,6 @@
|
|
|
1487
1510
|
} = swiper;
|
|
1488
1511
|
let activeIndex = newActiveIndex;
|
|
1489
1512
|
let snapIndex;
|
|
1490
|
-
const getVirtualRealIndex = aIndex => {
|
|
1491
|
-
let realIndex = aIndex - swiper.virtual.slidesBefore;
|
|
1492
|
-
if (realIndex < 0) {
|
|
1493
|
-
realIndex = swiper.virtual.slides.length + realIndex;
|
|
1494
|
-
}
|
|
1495
|
-
if (realIndex >= swiper.virtual.slides.length) {
|
|
1496
|
-
realIndex -= swiper.virtual.slides.length;
|
|
1497
|
-
}
|
|
1498
|
-
return realIndex;
|
|
1499
|
-
};
|
|
1500
1513
|
if (typeof activeIndex === 'undefined') {
|
|
1501
1514
|
activeIndex = getActiveIndexByTranslate(swiper);
|
|
1502
1515
|
}
|
|
@@ -1514,32 +1527,12 @@
|
|
|
1514
1527
|
}
|
|
1515
1528
|
return;
|
|
1516
1529
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1522
|
-
|
|
1523
|
-
// Get real index
|
|
1524
|
-
let realIndex;
|
|
1525
|
-
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1526
|
-
realIndex = getVirtualRealIndex(activeIndex);
|
|
1527
|
-
} else if (gridEnabled) {
|
|
1528
|
-
const firstSlideInColumn = swiper.slides.find(slideEl => slideEl.column === activeIndex);
|
|
1529
|
-
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1530
|
-
if (Number.isNaN(activeSlideIndex)) {
|
|
1531
|
-
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1532
|
-
}
|
|
1533
|
-
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1534
|
-
} else if (swiper.slides[activeIndex]) {
|
|
1530
|
+
let realIndex = activeIndex;
|
|
1531
|
+
if (swiper.slides[activeIndex]) {
|
|
1535
1532
|
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1536
1533
|
if (slideIndex) {
|
|
1537
1534
|
realIndex = parseInt(slideIndex, 10);
|
|
1538
|
-
} else {
|
|
1539
|
-
realIndex = activeIndex;
|
|
1540
1535
|
}
|
|
1541
|
-
} else {
|
|
1542
|
-
realIndex = activeIndex;
|
|
1543
1536
|
}
|
|
1544
1537
|
Object.assign(swiper, {
|
|
1545
1538
|
previousSnapIndex,
|
|
@@ -1586,11 +1579,7 @@
|
|
|
1586
1579
|
}
|
|
1587
1580
|
if (slide && slideFound) {
|
|
1588
1581
|
swiper.clickedSlide = slide;
|
|
1589
|
-
|
|
1590
|
-
swiper.clickedIndex = parseInt(slide.getAttribute('data-swiper-slide-index'), 10);
|
|
1591
|
-
} else {
|
|
1592
|
-
swiper.clickedIndex = slideIndex;
|
|
1593
|
-
}
|
|
1582
|
+
swiper.clickedIndex = slideIndex;
|
|
1594
1583
|
} else {
|
|
1595
1584
|
swiper.clickedSlide = undefined;
|
|
1596
1585
|
swiper.clickedIndex = undefined;
|
|
@@ -1624,9 +1613,6 @@
|
|
|
1624
1613
|
translate,
|
|
1625
1614
|
wrapperEl
|
|
1626
1615
|
} = swiper;
|
|
1627
|
-
if (params.virtualTranslate) {
|
|
1628
|
-
return rtl ? -translate : translate;
|
|
1629
|
-
}
|
|
1630
1616
|
if (params.cssMode) {
|
|
1631
1617
|
return translate;
|
|
1632
1618
|
}
|
|
@@ -1660,7 +1646,7 @@
|
|
|
1660
1646
|
swiper.translate = swiper.isHorizontal() ? x : y;
|
|
1661
1647
|
if (params.cssMode) {
|
|
1662
1648
|
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
|
1663
|
-
} else
|
|
1649
|
+
} else {
|
|
1664
1650
|
if (swiper.isHorizontal()) {
|
|
1665
1651
|
x -= swiper.cssOverflowAdjustment();
|
|
1666
1652
|
} else {
|
|
@@ -1897,7 +1883,6 @@
|
|
|
1897
1883
|
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
|
1898
1884
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1899
1885
|
const translate = -snapGrid[snapIndex];
|
|
1900
|
-
// Normalize slideIndex
|
|
1901
1886
|
if (params.normalizeSlideIndex) {
|
|
1902
1887
|
for (let i = 0; i < slidesGrid.length; i += 1) {
|
|
1903
1888
|
const normalizedTranslate = -Math.floor(translate * 100);
|
|
@@ -1914,33 +1899,24 @@
|
|
|
1914
1899
|
}
|
|
1915
1900
|
}
|
|
1916
1901
|
}
|
|
1902
|
+
|
|
1917
1903
|
// Directions locks
|
|
1918
1904
|
if (swiper.initialized && slideIndex !== activeIndex) {
|
|
1919
1905
|
if (!swiper.allowSlideNext && (rtl ? translate > swiper.translate && translate > swiper.minTranslate() : translate < swiper.translate && translate < swiper.minTranslate())) {
|
|
1920
1906
|
return false;
|
|
1921
1907
|
}
|
|
1922
1908
|
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
|
1923
|
-
if ((activeIndex || 0) !== slideIndex)
|
|
1924
|
-
return false;
|
|
1925
|
-
}
|
|
1909
|
+
if ((activeIndex || 0) !== slideIndex) return false;
|
|
1926
1910
|
}
|
|
1927
1911
|
}
|
|
1928
1912
|
if (slideIndex !== (previousIndex || 0) && runCallbacks) {
|
|
1929
1913
|
swiper.emit('beforeSlideChangeStart');
|
|
1930
1914
|
}
|
|
1931
|
-
|
|
1932
|
-
// Update progress
|
|
1933
1915
|
swiper.updateProgress(translate);
|
|
1934
1916
|
let direction;
|
|
1935
1917
|
if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
|
1936
|
-
|
|
1937
|
-
// initial virtual
|
|
1938
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
1939
|
-
const isInitialVirtual = isVirtual && initial;
|
|
1940
|
-
// Update Index
|
|
1941
|
-
if (!isInitialVirtual && (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate)) {
|
|
1918
|
+
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
|
1942
1919
|
swiper.updateActiveIndex(slideIndex);
|
|
1943
|
-
// Update Height
|
|
1944
1920
|
if (params.autoHeight) {
|
|
1945
1921
|
swiper.updateAutoHeight();
|
|
1946
1922
|
}
|
|
@@ -1958,24 +1934,7 @@
|
|
|
1958
1934
|
const isH = swiper.isHorizontal();
|
|
1959
1935
|
const t = rtl ? translate : -translate;
|
|
1960
1936
|
if (speed === 0) {
|
|
1961
|
-
|
|
1962
|
-
swiper.wrapperEl.style.scrollSnapType = 'none';
|
|
1963
|
-
swiper._immediateVirtual = true;
|
|
1964
|
-
}
|
|
1965
|
-
if (isVirtual && !swiper._cssModeVirtualInitialSet && swiper.params.initialSlide > 0) {
|
|
1966
|
-
swiper._cssModeVirtualInitialSet = true;
|
|
1967
|
-
requestAnimationFrame(() => {
|
|
1968
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1969
|
-
});
|
|
1970
|
-
} else {
|
|
1971
|
-
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1972
|
-
}
|
|
1973
|
-
if (isVirtual) {
|
|
1974
|
-
requestAnimationFrame(() => {
|
|
1975
|
-
swiper.wrapperEl.style.scrollSnapType = '';
|
|
1976
|
-
swiper._immediateVirtual = false;
|
|
1977
|
-
});
|
|
1978
|
-
}
|
|
1937
|
+
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
|
1979
1938
|
} else {
|
|
1980
1939
|
if (!swiper.support.smoothScroll) {
|
|
1981
1940
|
animateCSSModeScroll({
|
|
@@ -1993,10 +1952,7 @@
|
|
|
1993
1952
|
return true;
|
|
1994
1953
|
}
|
|
1995
1954
|
const browser = getBrowser();
|
|
1996
|
-
|
|
1997
|
-
if (isVirtual && !initial && isSafari && swiper.isElement) {
|
|
1998
|
-
swiper.virtual.update(false, false, slideIndex);
|
|
1999
|
-
}
|
|
1955
|
+
browser.isSafari;
|
|
2000
1956
|
swiper.setTransition(speed);
|
|
2001
1957
|
swiper.setTranslate(translate);
|
|
2002
1958
|
swiper.updateActiveIndex(slideIndex);
|
|
@@ -2167,8 +2123,6 @@
|
|
|
2167
2123
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2168
2124
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2169
2125
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2170
|
-
|
|
2171
|
-
// Move last item to first position only if active slide is the first slide
|
|
2172
2126
|
const lastSlide = slides[slides.length - 1];
|
|
2173
2127
|
lastSlide.swiperLoopMoveDOM = true;
|
|
2174
2128
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -2203,11 +2157,8 @@
|
|
|
2203
2157
|
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
|
2204
2158
|
}
|
|
2205
2159
|
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
|
2206
|
-
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
2207
2160
|
if (params.loop) {
|
|
2208
|
-
if (animating &&
|
|
2209
|
-
|
|
2210
|
-
// Kiểm tra xem loop có bị disable không
|
|
2161
|
+
if (animating && params.loopPreventsSliding) return false;
|
|
2211
2162
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2212
2163
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2213
2164
|
swiper.loopFix({
|
|
@@ -2234,7 +2185,6 @@
|
|
|
2234
2185
|
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2235
2186
|
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
2236
2187
|
if (!swiper.params.loop) return;
|
|
2237
|
-
// Move first item to last position only if active slide is the last slide
|
|
2238
2188
|
const firstSlide = slides[0];
|
|
2239
2189
|
firstSlide.swiperLoopMoveDOM = true;
|
|
2240
2190
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -2259,17 +2209,14 @@
|
|
|
2259
2209
|
params,
|
|
2260
2210
|
snapGrid,
|
|
2261
2211
|
slidesGrid,
|
|
2262
|
-
rtlTranslate,
|
|
2263
|
-
enabled
|
|
2264
|
-
animating
|
|
2212
|
+
rtlTranslate: rtlTranslate,
|
|
2213
|
+
enabled
|
|
2265
2214
|
} = swiper;
|
|
2266
2215
|
if (!enabled || swiper.destroyed) return swiper;
|
|
2267
2216
|
if (typeof speed === 'undefined') {
|
|
2268
2217
|
speed = swiper.params.speed;
|
|
2269
2218
|
}
|
|
2270
|
-
swiper.virtual && params.virtual.enabled;
|
|
2271
2219
|
if (params.loop) {
|
|
2272
|
-
// Kiểm tra xem loop có bị disable không
|
|
2273
2220
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2274
2221
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
2275
2222
|
swiper.loopFix({
|
|
@@ -2286,18 +2233,16 @@
|
|
|
2286
2233
|
}
|
|
2287
2234
|
const normalizedTranslate = normalize(translate);
|
|
2288
2235
|
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
|
2289
|
-
const isFreeMode = params.freeMode && params.freeMode.enabled;
|
|
2290
2236
|
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
|
2291
|
-
if (typeof prevSnap === 'undefined' &&
|
|
2237
|
+
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
|
2292
2238
|
let prevSnapIndex;
|
|
2293
2239
|
snapGrid.forEach((snap, snapIndex) => {
|
|
2294
2240
|
if (normalizedTranslate >= snap) {
|
|
2295
|
-
// prevSnap = snap;
|
|
2296
2241
|
prevSnapIndex = snapIndex;
|
|
2297
2242
|
}
|
|
2298
2243
|
});
|
|
2299
2244
|
if (typeof prevSnapIndex !== 'undefined') {
|
|
2300
|
-
prevSnap =
|
|
2245
|
+
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
|
2301
2246
|
}
|
|
2302
2247
|
}
|
|
2303
2248
|
let prevIndex = 0;
|
|
@@ -2310,7 +2255,7 @@
|
|
|
2310
2255
|
}
|
|
2311
2256
|
}
|
|
2312
2257
|
if (params.rewind && swiper.isBeginning) {
|
|
2313
|
-
const lastIndex = swiper.
|
|
2258
|
+
const lastIndex = swiper.slides.length - 1;
|
|
2314
2259
|
return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
|
|
2315
2260
|
} else if (params.loop && swiper.activeIndex === 0 && params.cssMode) {
|
|
2316
2261
|
requestAnimationFrame(() => {
|
|
@@ -2324,8 +2269,6 @@
|
|
|
2324
2269
|
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
2325
2270
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
2326
2271
|
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
2327
|
-
|
|
2328
|
-
// Move last item to first position only if active slide is the first slide
|
|
2329
2272
|
if (!swiper.params.loop) return;
|
|
2330
2273
|
const lastSlide = slides[slides.length - 1];
|
|
2331
2274
|
lastSlide.swiperLoopMoveDOM = true;
|
|
@@ -2402,20 +2345,19 @@
|
|
|
2402
2345
|
slidesEl
|
|
2403
2346
|
} = swiper;
|
|
2404
2347
|
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
|
2405
|
-
|
|
2348
|
+
const slideToIndex = swiper.clickedIndex;
|
|
2406
2349
|
let realIndex;
|
|
2407
2350
|
const slideSelector = swiper.isElement ? `swiper-slide` : `.${params.slideClass}`;
|
|
2408
|
-
const isGrid = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
2409
2351
|
if (params.loop) {
|
|
2410
2352
|
if (swiper.animating) return;
|
|
2411
2353
|
realIndex = parseInt(swiper.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
|
|
2412
2354
|
if (params.centeredSlides) {
|
|
2413
2355
|
swiper.slideToLoop(realIndex);
|
|
2414
|
-
} else if (slideToIndex >
|
|
2356
|
+
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
|
2415
2357
|
swiper.loopFix();
|
|
2416
|
-
|
|
2358
|
+
const clickedEl = elementChildren(slidesEl, `${slideSelector}[data-swiper-slide-index="${realIndex}"]`)[0];
|
|
2417
2359
|
nextTick(() => {
|
|
2418
|
-
swiper.slideTo(
|
|
2360
|
+
if (clickedEl) swiper.slideTo(swiper.getSlideIndex(clickedEl));
|
|
2419
2361
|
});
|
|
2420
2362
|
} else {
|
|
2421
2363
|
swiper.slideTo(slideToIndex);
|
|
@@ -2442,7 +2384,7 @@
|
|
|
2442
2384
|
params,
|
|
2443
2385
|
slidesEl
|
|
2444
2386
|
} = swiper;
|
|
2445
|
-
if (!params.loop
|
|
2387
|
+
if (!params.loop) return;
|
|
2446
2388
|
const initSlides = () => {
|
|
2447
2389
|
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2448
2390
|
slides.forEach((el, index) => {
|
|
@@ -2451,21 +2393,17 @@
|
|
|
2451
2393
|
};
|
|
2452
2394
|
const clearBlankSlides = () => {
|
|
2453
2395
|
const slides = elementChildren(slidesEl, `.${params.slideBlankClass}`);
|
|
2454
|
-
slides.forEach(el =>
|
|
2455
|
-
el.remove();
|
|
2456
|
-
});
|
|
2396
|
+
slides.forEach(el => el.remove());
|
|
2457
2397
|
if (slides.length > 0) {
|
|
2458
2398
|
swiper.recalcSlides();
|
|
2459
2399
|
swiper.updateSlides();
|
|
2460
2400
|
}
|
|
2461
2401
|
};
|
|
2462
|
-
|
|
2463
|
-
if (params.loopAddBlankSlides && (params.slidesPerGroup > 1 || gridEnabled)) {
|
|
2402
|
+
if (params.loopAddBlankSlides && params.slidesPerGroup > 1) {
|
|
2464
2403
|
clearBlankSlides();
|
|
2465
2404
|
}
|
|
2466
|
-
const slidesPerGroup = params.slidesPerGroup
|
|
2405
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2467
2406
|
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2468
|
-
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2469
2407
|
const addBlankSlides = amountOfSlides => {
|
|
2470
2408
|
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2471
2409
|
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
@@ -2482,16 +2420,6 @@
|
|
|
2482
2420
|
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)');
|
|
2483
2421
|
}
|
|
2484
2422
|
initSlides();
|
|
2485
|
-
} else if (shouldFillGrid) {
|
|
2486
|
-
if (params.loopAddBlankSlides) {
|
|
2487
|
-
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2488
|
-
addBlankSlides(slidesToAdd);
|
|
2489
|
-
swiper.recalcSlides();
|
|
2490
|
-
swiper.updateSlides();
|
|
2491
|
-
} else {
|
|
2492
|
-
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)');
|
|
2493
|
-
}
|
|
2494
|
-
initSlides();
|
|
2495
2423
|
} else {
|
|
2496
2424
|
initSlides();
|
|
2497
2425
|
}
|
|
@@ -2510,13 +2438,12 @@
|
|
|
2510
2438
|
setTranslate,
|
|
2511
2439
|
activeSlideIndex,
|
|
2512
2440
|
initial,
|
|
2513
|
-
byController,
|
|
2514
2441
|
byMousewheel
|
|
2515
2442
|
} = _temp === void 0 ? {} : _temp;
|
|
2516
2443
|
const swiper = this;
|
|
2517
2444
|
if (!swiper.params.loop) return;
|
|
2518
2445
|
|
|
2519
|
-
// Disable loop mode
|
|
2446
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2520
2447
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2521
2448
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2522
2449
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2536,21 +2463,6 @@
|
|
|
2536
2463
|
} = params;
|
|
2537
2464
|
swiper.allowSlidePrev = true;
|
|
2538
2465
|
swiper.allowSlideNext = true;
|
|
2539
|
-
if (swiper.virtual && params.virtual.enabled) {
|
|
2540
|
-
if (slideTo) {
|
|
2541
|
-
if (!params.centeredSlides && swiper.snapIndex === 0) {
|
|
2542
|
-
swiper.slideTo(swiper.virtual.slides.length, 0, false, true);
|
|
2543
|
-
} else if (params.centeredSlides && swiper.snapIndex < params.slidesPerView) {
|
|
2544
|
-
swiper.slideTo(swiper.virtual.slides.length + swiper.snapIndex, 0, false, true);
|
|
2545
|
-
} else if (swiper.snapIndex === swiper.snapGrid.length - 1) {
|
|
2546
|
-
swiper.slideTo(swiper.virtual.slidesBefore, 0, false, true);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
swiper.allowSlidePrev = allowSlidePrev;
|
|
2550
|
-
swiper.allowSlideNext = allowSlideNext;
|
|
2551
|
-
swiper.emit('loopFix');
|
|
2552
|
-
return;
|
|
2553
|
-
}
|
|
2554
2466
|
let slidesPerView = params.slidesPerView;
|
|
2555
2467
|
if (slidesPerView === 'auto') {
|
|
2556
2468
|
slidesPerView = swiper.slidesPerViewDynamic();
|
|
@@ -2560,22 +2472,19 @@
|
|
|
2560
2472
|
slidesPerView = slidesPerView + 1;
|
|
2561
2473
|
}
|
|
2562
2474
|
}
|
|
2563
|
-
const slidesPerGroup = params.
|
|
2475
|
+
const slidesPerGroup = params.slidesPerGroup;
|
|
2564
2476
|
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2565
2477
|
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2566
2478
|
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2567
2479
|
}
|
|
2568
2480
|
loopedSlides += params.loopAdditionalSlides;
|
|
2569
2481
|
swiper.loopedSlides = loopedSlides;
|
|
2570
|
-
|
|
2571
|
-
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2482
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2572
2483
|
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');
|
|
2573
|
-
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2574
|
-
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2575
2484
|
}
|
|
2576
2485
|
const prependSlidesIndexes = [];
|
|
2577
2486
|
const appendSlidesIndexes = [];
|
|
2578
|
-
const cols =
|
|
2487
|
+
const cols = slides.length;
|
|
2579
2488
|
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2580
2489
|
let activeIndex = isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2581
2490
|
if (typeof activeSlideIndex === 'undefined') {
|
|
@@ -2587,24 +2496,15 @@
|
|
|
2587
2496
|
const isPrev = direction === 'prev' || !direction;
|
|
2588
2497
|
let slidesPrepended = 0;
|
|
2589
2498
|
let slidesAppended = 0;
|
|
2590
|
-
const activeColIndex =
|
|
2499
|
+
const activeColIndex = activeSlideIndex;
|
|
2591
2500
|
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2501
|
+
|
|
2592
2502
|
// prepend last slides before start
|
|
2593
2503
|
if (activeColIndexWithShift < loopedSlides) {
|
|
2594
2504
|
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2595
2505
|
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2596
2506
|
const index = i - Math.floor(i / cols) * cols;
|
|
2597
|
-
|
|
2598
|
-
const colIndexToPrepend = cols - index - 1;
|
|
2599
|
-
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2600
|
-
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2601
|
-
}
|
|
2602
|
-
// slides.forEach((slide, slideIndex) => {
|
|
2603
|
-
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2604
|
-
// });
|
|
2605
|
-
} else {
|
|
2606
|
-
prependSlidesIndexes.push(cols - index - 1);
|
|
2607
|
-
}
|
|
2507
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2608
2508
|
}
|
|
2609
2509
|
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2610
2510
|
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
@@ -2613,27 +2513,13 @@
|
|
|
2613
2513
|
}
|
|
2614
2514
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2615
2515
|
const index = i - Math.floor(i / cols) * cols;
|
|
2616
|
-
|
|
2617
|
-
slides.forEach((slide, slideIndex) => {
|
|
2618
|
-
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2619
|
-
});
|
|
2620
|
-
} else {
|
|
2621
|
-
appendSlidesIndexes.push(index);
|
|
2622
|
-
}
|
|
2516
|
+
appendSlidesIndexes.push(index);
|
|
2623
2517
|
}
|
|
2624
2518
|
}
|
|
2625
2519
|
swiper.__preventObserver__ = true;
|
|
2626
2520
|
requestAnimationFrame(() => {
|
|
2627
2521
|
swiper.__preventObserver__ = false;
|
|
2628
2522
|
});
|
|
2629
|
-
if (swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2630
|
-
if (appendSlidesIndexes.includes(activeSlideIndex)) {
|
|
2631
|
-
appendSlidesIndexes.splice(appendSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2632
|
-
}
|
|
2633
|
-
if (prependSlidesIndexes.includes(activeSlideIndex)) {
|
|
2634
|
-
prependSlidesIndexes.splice(prependSlidesIndexes.indexOf(activeSlideIndex), 1);
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
2523
|
if (isPrev) {
|
|
2638
2524
|
prependSlidesIndexes.forEach(index => {
|
|
2639
2525
|
slides[index].swiperLoopMoveDOM = true;
|
|
@@ -2651,13 +2537,11 @@
|
|
|
2651
2537
|
swiper.recalcSlides();
|
|
2652
2538
|
if (params.slidesPerView === 'auto') {
|
|
2653
2539
|
swiper.updateSlides();
|
|
2654
|
-
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2655
|
-
swiper.slides.forEach((slide, slideIndex) => {
|
|
2656
|
-
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2657
|
-
});
|
|
2658
2540
|
}
|
|
2659
2541
|
if (params.watchSlidesProgress) {
|
|
2660
|
-
swiper.updateSlidesOffset(
|
|
2542
|
+
swiper.updateSlidesOffset({
|
|
2543
|
+
isCalculatedFromUpdateSlides: params.slidesPerView === 'auto'
|
|
2544
|
+
});
|
|
2661
2545
|
}
|
|
2662
2546
|
if (slideTo) {
|
|
2663
2547
|
if (prependSlidesIndexes.length > 0 && isPrev) {
|
|
@@ -2674,12 +2558,10 @@
|
|
|
2674
2558
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2675
2559
|
}
|
|
2676
2560
|
}
|
|
2677
|
-
} else {
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2682
|
-
}
|
|
2561
|
+
} else if (setTranslate) {
|
|
2562
|
+
const shift = prependSlidesIndexes.length;
|
|
2563
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2564
|
+
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2683
2565
|
}
|
|
2684
2566
|
} else if (appendSlidesIndexes.length > 0 && isNext) {
|
|
2685
2567
|
if (typeof slideRealIndex === 'undefined') {
|
|
@@ -2695,36 +2577,14 @@
|
|
|
2695
2577
|
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2696
2578
|
}
|
|
2697
2579
|
}
|
|
2698
|
-
} else {
|
|
2699
|
-
const shift =
|
|
2580
|
+
} else if (setTranslate) {
|
|
2581
|
+
const shift = appendSlidesIndexes.length;
|
|
2700
2582
|
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2701
2583
|
}
|
|
2702
2584
|
}
|
|
2703
2585
|
}
|
|
2704
2586
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
2705
2587
|
swiper.allowSlideNext = allowSlideNext;
|
|
2706
|
-
if (swiper.controller && swiper.controller.control && !byController) {
|
|
2707
|
-
const loopParams = {
|
|
2708
|
-
slideRealIndex,
|
|
2709
|
-
direction,
|
|
2710
|
-
setTranslate,
|
|
2711
|
-
activeSlideIndex,
|
|
2712
|
-
byController: true
|
|
2713
|
-
};
|
|
2714
|
-
if (Array.isArray(swiper.controller.control)) {
|
|
2715
|
-
swiper.controller.control.forEach(c => {
|
|
2716
|
-
if (!c.destroyed && c.params.loop) c.loopFix({
|
|
2717
|
-
...loopParams,
|
|
2718
|
-
slideTo: c.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2719
|
-
});
|
|
2720
|
-
});
|
|
2721
|
-
} else if (swiper.controller.control instanceof swiper.constructor && swiper.controller.control.params.loop) {
|
|
2722
|
-
swiper.controller.control.loopFix({
|
|
2723
|
-
...loopParams,
|
|
2724
|
-
slideTo: swiper.controller.control.params.slidesPerView === params.slidesPerView ? slideTo : false
|
|
2725
|
-
});
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
2588
|
swiper.emit('loopFix');
|
|
2729
2589
|
}
|
|
2730
2590
|
|
|
@@ -2741,7 +2601,7 @@
|
|
|
2741
2601
|
const swiper = this;
|
|
2742
2602
|
if (!swiper.params.loop) return;
|
|
2743
2603
|
|
|
2744
|
-
// Disable loop mode
|
|
2604
|
+
// Disable loop mode if number of slides is smaller than slidesPerView
|
|
2745
2605
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2746
2606
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
2747
2607
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2780,7 +2640,7 @@
|
|
|
2780
2640
|
}
|
|
2781
2641
|
loopedSlides += params.loopAdditionalSlides;
|
|
2782
2642
|
swiper.loopedSlides = loopedSlides;
|
|
2783
|
-
if (slides.length < slidesPerView + loopedSlides
|
|
2643
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2784
2644
|
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');
|
|
2785
2645
|
}
|
|
2786
2646
|
const isNext = direction === 'next' || !direction;
|
|
@@ -2806,20 +2666,16 @@
|
|
|
2806
2666
|
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2807
2667
|
}
|
|
2808
2668
|
|
|
2809
|
-
//
|
|
2669
|
+
// DocumentFragment to hold slide clones
|
|
2810
2670
|
const cloneFragment = document.createDocumentFragment();
|
|
2811
2671
|
|
|
2812
|
-
// Clone
|
|
2672
|
+
// Clone slides according to numberOfSlidesNeedClone and append to fragment
|
|
2813
2673
|
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2814
2674
|
if (slides[index]) {
|
|
2815
2675
|
const originalSlide = slides[index];
|
|
2816
2676
|
const clonedSlide = originalSlide.cloneNode(true);
|
|
2817
|
-
|
|
2818
|
-
// Đánh dấu slide clone
|
|
2819
2677
|
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2820
2678
|
clonedSlide.classList.add('swiper-slide-clone');
|
|
2821
|
-
|
|
2822
|
-
// Thêm clone vào fragment
|
|
2823
2679
|
cloneFragment.appendChild(clonedSlide);
|
|
2824
2680
|
}
|
|
2825
2681
|
});
|
|
@@ -2840,32 +2696,28 @@
|
|
|
2840
2696
|
});
|
|
2841
2697
|
}
|
|
2842
2698
|
|
|
2843
|
-
//
|
|
2699
|
+
// Sort cloned slides by data-swiper-slide-index
|
|
2844
2700
|
const clonedSlides = Array.from(cloneFragment.children);
|
|
2845
2701
|
clonedSlides.sort((a, b) => {
|
|
2846
2702
|
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2847
2703
|
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2848
2704
|
return indexA - indexB;
|
|
2849
2705
|
});
|
|
2850
|
-
|
|
2851
|
-
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2852
2706
|
cloneFragment.innerHTML = '';
|
|
2853
2707
|
clonedSlides.forEach(slide => {
|
|
2854
2708
|
cloneFragment.appendChild(slide);
|
|
2855
2709
|
});
|
|
2856
2710
|
|
|
2857
|
-
//
|
|
2711
|
+
// Place fragment into the right position
|
|
2858
2712
|
if (isPrev) {
|
|
2859
|
-
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2860
2713
|
slidesEl.appendChild(cloneFragment);
|
|
2861
2714
|
} else if (isNext) {
|
|
2862
|
-
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2863
2715
|
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2864
2716
|
}
|
|
2865
2717
|
swiper.recalcSlides();
|
|
2866
2718
|
swiper.updateSlides();
|
|
2867
2719
|
|
|
2868
|
-
//
|
|
2720
|
+
// Find old active slide index after recalculation
|
|
2869
2721
|
let oldActiveIndex = null;
|
|
2870
2722
|
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2871
2723
|
const child = slidesEl.children[i];
|
|
@@ -2878,7 +2730,7 @@
|
|
|
2878
2730
|
swiper.slideTo(oldActiveIndex, 0);
|
|
2879
2731
|
}
|
|
2880
2732
|
|
|
2881
|
-
//
|
|
2733
|
+
// Update translate after removing clones for animation
|
|
2882
2734
|
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2883
2735
|
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2884
2736
|
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
@@ -2904,7 +2756,8 @@
|
|
|
2904
2756
|
}
|
|
2905
2757
|
swiper.setTranslate(updateTranslate);
|
|
2906
2758
|
}
|
|
2907
|
-
|
|
2759
|
+
|
|
2760
|
+
// Remove clones
|
|
2908
2761
|
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2909
2762
|
cloneSlides.forEach(cloneSlide => {
|
|
2910
2763
|
if (cloneSlide.parentNode) {
|
|
@@ -2934,7 +2787,7 @@
|
|
|
2934
2787
|
params,
|
|
2935
2788
|
slidesEl
|
|
2936
2789
|
} = swiper;
|
|
2937
|
-
if (!params.loop || !slidesEl
|
|
2790
|
+
if (!params.loop || !slidesEl) return;
|
|
2938
2791
|
swiper.recalcSlides();
|
|
2939
2792
|
const newSlidesOrder = [];
|
|
2940
2793
|
swiper.slides.forEach(slideEl => {
|
|
@@ -2995,7 +2848,6 @@
|
|
|
2995
2848
|
unsetGrabCursor
|
|
2996
2849
|
};
|
|
2997
2850
|
|
|
2998
|
-
// Modified from https://stackoverflow.com/questions/54520554/custom-element-getrootnode-closest-function-crossing-multiple-parent-shadowd
|
|
2999
2851
|
function closestElement(selector, base) {
|
|
3000
2852
|
if (base === void 0) {
|
|
3001
2853
|
base = this;
|
|
@@ -3004,9 +2856,7 @@
|
|
|
3004
2856
|
if (!el || el === getDocument() || el === getWindow()) return null;
|
|
3005
2857
|
if (el.assignedSlot) el = el.assignedSlot;
|
|
3006
2858
|
const found = el.closest(selector);
|
|
3007
|
-
if (!found && !el.getRootNode)
|
|
3008
|
-
return null;
|
|
3009
|
-
}
|
|
2859
|
+
if (!found && !el.getRootNode) return null;
|
|
3010
2860
|
return found || __closestFrom(el.getRootNode().host);
|
|
3011
2861
|
}
|
|
3012
2862
|
return __closestFrom(base);
|
|
@@ -3034,9 +2884,7 @@
|
|
|
3034
2884
|
if (e.originalEvent) e = e.originalEvent;
|
|
3035
2885
|
const data = swiper.touchEventsData;
|
|
3036
2886
|
if (e.type === 'pointerdown') {
|
|
3037
|
-
if (data.pointerId !== null && data.pointerId !== e.pointerId)
|
|
3038
|
-
return;
|
|
3039
|
-
}
|
|
2887
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) return;
|
|
3040
2888
|
data.pointerId = e.pointerId;
|
|
3041
2889
|
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
3042
2890
|
data.touchId = e.targetTouches[0].identifier;
|
|
@@ -3053,9 +2901,7 @@
|
|
|
3053
2901
|
} = swiper;
|
|
3054
2902
|
if (!enabled) return;
|
|
3055
2903
|
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
3056
|
-
if (swiper.animating && params.preventInteractionOnTransition)
|
|
3057
|
-
return;
|
|
3058
|
-
}
|
|
2904
|
+
if (swiper.animating && params.preventInteractionOnTransition) return;
|
|
3059
2905
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
3060
2906
|
swiper.loopFix();
|
|
3061
2907
|
}
|
|
@@ -3066,8 +2912,6 @@
|
|
|
3066
2912
|
if ('which' in e && e.which === 3) return;
|
|
3067
2913
|
if ('button' in e && e.button > 0) return;
|
|
3068
2914
|
if (data.isTouched && data.isMoved) return;
|
|
3069
|
-
|
|
3070
|
-
// change target el for shadow root component
|
|
3071
2915
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
3072
2916
|
// eslint-disable-next-line
|
|
3073
2917
|
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
@@ -3076,8 +2920,6 @@
|
|
|
3076
2920
|
}
|
|
3077
2921
|
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
|
3078
2922
|
const isTargetShadow = !!(e.target && e.target.shadowRoot);
|
|
3079
|
-
|
|
3080
|
-
// use closestElement for shadow root element to get the actual closest for nested shadow root element
|
|
3081
2923
|
if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, targetEl) : targetEl.closest(noSwipingSelector))) {
|
|
3082
2924
|
swiper.allowClick = true;
|
|
3083
2925
|
return;
|
|
@@ -3089,12 +2931,7 @@
|
|
|
3089
2931
|
touches.currentY = e.pageY;
|
|
3090
2932
|
const startX = touches.currentX;
|
|
3091
2933
|
const startY = touches.currentY;
|
|
3092
|
-
|
|
3093
|
-
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
3094
|
-
|
|
3095
|
-
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
3096
|
-
return;
|
|
3097
|
-
}
|
|
2934
|
+
if (!preventEdgeSwipe(swiper, e, startX)) return;
|
|
3098
2935
|
Object.assign(data, {
|
|
3099
2936
|
isTouched: true,
|
|
3100
2937
|
isMoved: false,
|
|
@@ -3123,9 +2960,6 @@
|
|
|
3123
2960
|
if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !targetEl.isContentEditable) {
|
|
3124
2961
|
e.preventDefault();
|
|
3125
2962
|
}
|
|
3126
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
|
|
3127
|
-
swiper.freeMode.onTouchStart();
|
|
3128
|
-
}
|
|
3129
2963
|
swiper.emit('touchStart', e);
|
|
3130
2964
|
}
|
|
3131
2965
|
|
|
@@ -3144,7 +2978,7 @@
|
|
|
3144
2978
|
let e = event;
|
|
3145
2979
|
if (e.originalEvent) e = e.originalEvent;
|
|
3146
2980
|
if (e.type === 'pointermove') {
|
|
3147
|
-
if (data.touchId !== null) return;
|
|
2981
|
+
if (data.touchId !== null) return;
|
|
3148
2982
|
const id = e.pointerId;
|
|
3149
2983
|
if (id !== data.pointerId) return;
|
|
3150
2984
|
}
|
|
@@ -3185,7 +3019,6 @@
|
|
|
3185
3019
|
}
|
|
3186
3020
|
if (params.touchReleaseOnEdges && !params.loop) {
|
|
3187
3021
|
if (swiper.isVertical()) {
|
|
3188
|
-
// Vertical
|
|
3189
3022
|
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
|
3190
3023
|
data.isTouched = false;
|
|
3191
3024
|
data.isMoved = false;
|
|
@@ -3287,7 +3120,6 @@
|
|
|
3287
3120
|
swiper.wrapperEl.dispatchEvent(evt);
|
|
3288
3121
|
}
|
|
3289
3122
|
data.allowMomentumBounce = false;
|
|
3290
|
-
// Grab Cursor
|
|
3291
3123
|
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3292
3124
|
swiper.setGrabCursor(true);
|
|
3293
3125
|
}
|
|
@@ -3358,8 +3190,6 @@
|
|
|
3358
3190
|
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
|
3359
3191
|
data.currentTranslate = data.startTranslate;
|
|
3360
3192
|
}
|
|
3361
|
-
|
|
3362
|
-
// Threshold
|
|
3363
3193
|
if (params.threshold > 0) {
|
|
3364
3194
|
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
|
3365
3195
|
if (!data.allowThresholdMove) {
|
|
@@ -3377,17 +3207,12 @@
|
|
|
3377
3207
|
}
|
|
3378
3208
|
if (!params.followFinger || params.cssMode) return;
|
|
3379
3209
|
|
|
3380
|
-
//
|
|
3381
|
-
if (params.
|
|
3210
|
+
// core-lite: no optional feature updates; only watchSlidesProgress
|
|
3211
|
+
if (params.watchSlidesProgress) {
|
|
3382
3212
|
swiper.updateActiveIndex();
|
|
3383
3213
|
swiper.updateSlidesClasses();
|
|
3384
3214
|
}
|
|
3385
|
-
if (params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
|
3386
|
-
swiper.freeMode.onTouchMove();
|
|
3387
|
-
}
|
|
3388
|
-
// Update progress
|
|
3389
3215
|
swiper.updateProgress(data.currentTranslate);
|
|
3390
|
-
// Update translate
|
|
3391
3216
|
swiper.setTranslate(data.currentTranslate);
|
|
3392
3217
|
}
|
|
3393
3218
|
|
|
@@ -3399,7 +3224,7 @@
|
|
|
3399
3224
|
let targetTouch;
|
|
3400
3225
|
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
3401
3226
|
if (!isTouchEvent) {
|
|
3402
|
-
if (data.touchId !== null) return;
|
|
3227
|
+
if (data.touchId !== null) return;
|
|
3403
3228
|
if (e.pointerId !== data.pointerId) return;
|
|
3404
3229
|
targetTouch = e;
|
|
3405
3230
|
} else {
|
|
@@ -3408,9 +3233,7 @@
|
|
|
3408
3233
|
}
|
|
3409
3234
|
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
3410
3235
|
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
3411
|
-
if (!proceed)
|
|
3412
|
-
return;
|
|
3413
|
-
}
|
|
3236
|
+
if (!proceed) return;
|
|
3414
3237
|
}
|
|
3415
3238
|
data.pointerId = null;
|
|
3416
3239
|
data.touchId = null;
|
|
@@ -3428,9 +3251,7 @@
|
|
|
3428
3251
|
}
|
|
3429
3252
|
data.allowTouchCallbacks = false;
|
|
3430
3253
|
if (!data.isTouched) {
|
|
3431
|
-
if (data.isMoved && params.grabCursor)
|
|
3432
|
-
swiper.setGrabCursor(false);
|
|
3433
|
-
}
|
|
3254
|
+
if (data.isMoved && params.grabCursor) swiper.setGrabCursor(false);
|
|
3434
3255
|
data.isMoved = false;
|
|
3435
3256
|
data.startMoving = false;
|
|
3436
3257
|
return;
|
|
@@ -3440,8 +3261,6 @@
|
|
|
3440
3261
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
3441
3262
|
swiper.setGrabCursor(false);
|
|
3442
3263
|
}
|
|
3443
|
-
|
|
3444
|
-
// Time diff
|
|
3445
3264
|
const touchEndTime = now();
|
|
3446
3265
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
3447
3266
|
|
|
@@ -3468,20 +3287,8 @@
|
|
|
3468
3287
|
data.isMoved = false;
|
|
3469
3288
|
data.startMoving = false;
|
|
3470
3289
|
let currentPos;
|
|
3471
|
-
if (params.followFinger)
|
|
3472
|
-
|
|
3473
|
-
} else {
|
|
3474
|
-
currentPos = -data.currentTranslate;
|
|
3475
|
-
}
|
|
3476
|
-
if (params.cssMode) {
|
|
3477
|
-
return;
|
|
3478
|
-
}
|
|
3479
|
-
if (params.freeMode && params.freeMode.enabled) {
|
|
3480
|
-
swiper.freeMode.onTouchEnd({
|
|
3481
|
-
currentPos
|
|
3482
|
-
});
|
|
3483
|
-
return;
|
|
3484
|
-
}
|
|
3290
|
+
if (params.followFinger) currentPos = rtl ? swiper.translate : -swiper.translate;else currentPos = -data.currentTranslate;
|
|
3291
|
+
if (params.cssMode) return;
|
|
3485
3292
|
|
|
3486
3293
|
// Find current slide
|
|
3487
3294
|
const swipeToLast = currentPos >= -swiper.maxTranslate() && !swiper.params.loop;
|
|
@@ -3503,22 +3310,22 @@
|
|
|
3503
3310
|
let rewindLastIndex = null;
|
|
3504
3311
|
if (params.rewind) {
|
|
3505
3312
|
if (swiper.isBeginning) {
|
|
3506
|
-
rewindLastIndex =
|
|
3313
|
+
rewindLastIndex = swiper.slides.length - 1;
|
|
3507
3314
|
} else if (swiper.isEnd) {
|
|
3508
3315
|
rewindFirstIndex = 0;
|
|
3509
3316
|
}
|
|
3510
3317
|
}
|
|
3511
|
-
// Find current slide size
|
|
3512
3318
|
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
|
3513
3319
|
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
|
3514
3320
|
if (timeDiff > params.longSwipesMs) {
|
|
3515
|
-
// Long touches
|
|
3516
3321
|
if (!params.longSwipes) {
|
|
3517
3322
|
swiper.slideTo(swiper.activeIndex);
|
|
3518
3323
|
return;
|
|
3519
3324
|
}
|
|
3520
3325
|
if (swiper.swipeDirection === 'next') {
|
|
3521
|
-
if (ratio >= params.longSwipesRatio)
|
|
3326
|
+
if (ratio >= params.longSwipesRatio) {
|
|
3327
|
+
swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);
|
|
3328
|
+
} else swiper.slideTo(stopIndex);
|
|
3522
3329
|
}
|
|
3523
3330
|
if (swiper.swipeDirection === 'prev') {
|
|
3524
3331
|
if (ratio > 1 - params.longSwipesRatio) {
|
|
@@ -3570,7 +3377,6 @@
|
|
|
3570
3377
|
allowSlidePrev,
|
|
3571
3378
|
snapGrid
|
|
3572
3379
|
} = swiper;
|
|
3573
|
-
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
|
3574
3380
|
|
|
3575
3381
|
// Disable locks on resize
|
|
3576
3382
|
swiper.allowSlideNext = true;
|
|
@@ -3578,15 +3384,12 @@
|
|
|
3578
3384
|
swiper.updateSize();
|
|
3579
3385
|
swiper.updateSlides();
|
|
3580
3386
|
swiper.updateSlidesClasses();
|
|
3581
|
-
|
|
3582
|
-
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides && !isVirtualLoop) {
|
|
3387
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
|
3583
3388
|
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
3389
|
+
} else if (swiper.params.loop) {
|
|
3390
|
+
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3584
3391
|
} else {
|
|
3585
|
-
|
|
3586
|
-
swiper.slideToLoop(swiper.realIndex, 0, false, true);
|
|
3587
|
-
} else {
|
|
3588
|
-
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3589
|
-
}
|
|
3392
|
+
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
3590
3393
|
}
|
|
3591
3394
|
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
|
3592
3395
|
clearTimeout(swiper.autoplay.resizeTimeout);
|
|
@@ -3596,10 +3399,11 @@
|
|
|
3596
3399
|
}
|
|
3597
3400
|
}, 500);
|
|
3598
3401
|
}
|
|
3402
|
+
|
|
3599
3403
|
// Return locks after resize
|
|
3600
3404
|
swiper.allowSlidePrev = allowSlidePrev;
|
|
3601
3405
|
swiper.allowSlideNext = allowSlideNext;
|
|
3602
|
-
if (
|
|
3406
|
+
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
3603
3407
|
swiper.checkOverflow();
|
|
3604
3408
|
}
|
|
3605
3409
|
}
|
|
@@ -3653,6 +3457,10 @@
|
|
|
3653
3457
|
if (swiper.params.cssMode || swiper.params.slidesPerView !== 'auto' && !swiper.params.autoHeight) {
|
|
3654
3458
|
return;
|
|
3655
3459
|
}
|
|
3460
|
+
const el = e?.target;
|
|
3461
|
+
// IMG, IFRAME, EMBED with width/height attributes don't change slide size — no need to call swiper.update()
|
|
3462
|
+
if (!el || !['IMG', 'IFRAME', 'EMBED'].includes(el.tagName)) return;
|
|
3463
|
+
if (el.hasAttribute('width') && el.hasAttribute('height')) return;
|
|
3656
3464
|
swiper.update();
|
|
3657
3465
|
}
|
|
3658
3466
|
|
|
@@ -3764,8 +3572,15 @@
|
|
|
3764
3572
|
detachEvents
|
|
3765
3573
|
};
|
|
3766
3574
|
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3575
|
+
const toggleModule = (swiper, params, breakpointParams, prop) => {
|
|
3576
|
+
const wasModuleEnabled = params[prop] && params[prop].enabled;
|
|
3577
|
+
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3578
|
+
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3579
|
+
swiper[prop].disable();
|
|
3580
|
+
}
|
|
3581
|
+
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3582
|
+
swiper[prop].enable();
|
|
3583
|
+
}
|
|
3769
3584
|
};
|
|
3770
3585
|
function setBreakpoint() {
|
|
3771
3586
|
const swiper = this;
|
|
@@ -3786,38 +3601,20 @@
|
|
|
3786
3601
|
if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
|
|
3787
3602
|
const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
|
3788
3603
|
const breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
|
3789
|
-
const wasMultiRow = isGridEnabled(swiper, params);
|
|
3790
|
-
const isMultiRow = isGridEnabled(swiper, breakpointParams);
|
|
3791
3604
|
const wasGrabCursor = swiper.params.grabCursor;
|
|
3792
3605
|
const isGrabCursor = breakpointParams.grabCursor;
|
|
3793
3606
|
const wasEnabled = params.enabled;
|
|
3794
|
-
if (wasMultiRow && !isMultiRow) {
|
|
3795
|
-
el.classList.remove(`${params.containerModifierClass}grid`, `${params.containerModifierClass}grid-column`);
|
|
3796
|
-
swiper.emitContainerClasses();
|
|
3797
|
-
} else if (!wasMultiRow && isMultiRow) {
|
|
3798
|
-
el.classList.add(`${params.containerModifierClass}grid`);
|
|
3799
|
-
if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
|
|
3800
|
-
el.classList.add(`${params.containerModifierClass}grid-column`);
|
|
3801
|
-
}
|
|
3802
|
-
swiper.emitContainerClasses();
|
|
3803
|
-
}
|
|
3804
3607
|
if (wasGrabCursor && !isGrabCursor) {
|
|
3805
3608
|
swiper.unsetGrabCursor();
|
|
3806
3609
|
} else if (!wasGrabCursor && isGrabCursor) {
|
|
3807
3610
|
swiper.setGrabCursor();
|
|
3808
3611
|
}
|
|
3809
3612
|
|
|
3810
|
-
//
|
|
3811
|
-
['navigation', 'pagination'
|
|
3613
|
+
// Core-lite: toggle navigation & pagination only.
|
|
3614
|
+
const modules = ['navigation', 'pagination'];
|
|
3615
|
+
modules.forEach(prop => {
|
|
3812
3616
|
if (typeof breakpointParams[prop] === 'undefined') return;
|
|
3813
|
-
|
|
3814
|
-
const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
|
|
3815
|
-
if (wasModuleEnabled && !isModuleEnabled) {
|
|
3816
|
-
swiper[prop].disable();
|
|
3817
|
-
}
|
|
3818
|
-
if (!wasModuleEnabled && isModuleEnabled) {
|
|
3819
|
-
swiper[prop].enable();
|
|
3820
|
-
}
|
|
3617
|
+
toggleModule(swiper, params, breakpointParams, prop);
|
|
3821
3618
|
});
|
|
3822
3619
|
const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
|
3823
3620
|
const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
|
@@ -3899,7 +3696,7 @@
|
|
|
3899
3696
|
getBreakpoint
|
|
3900
3697
|
};
|
|
3901
3698
|
|
|
3902
|
-
|
|
3699
|
+
const prepareClasses = (entries, prefix) => {
|
|
3903
3700
|
const resultClasses = [];
|
|
3904
3701
|
entries.forEach(item => {
|
|
3905
3702
|
if (typeof item === 'object') {
|
|
@@ -3913,7 +3710,7 @@
|
|
|
3913
3710
|
}
|
|
3914
3711
|
});
|
|
3915
3712
|
return resultClasses;
|
|
3916
|
-
}
|
|
3713
|
+
};
|
|
3917
3714
|
function addClasses() {
|
|
3918
3715
|
const swiper = this;
|
|
3919
3716
|
const {
|
|
@@ -3923,17 +3720,12 @@
|
|
|
3923
3720
|
el,
|
|
3924
3721
|
device
|
|
3925
3722
|
} = swiper;
|
|
3723
|
+
// core-lite: removed module-specific classes
|
|
3926
3724
|
// prettier-ignore
|
|
3927
3725
|
const suffixes = prepareClasses(['initialized', params.direction, {
|
|
3928
|
-
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
|
3929
|
-
}, {
|
|
3930
3726
|
'autoheight': params.autoHeight
|
|
3931
3727
|
}, {
|
|
3932
3728
|
'rtl': rtl
|
|
3933
|
-
}, {
|
|
3934
|
-
'grid': params.grid && params.grid.rows > 1
|
|
3935
|
-
}, {
|
|
3936
|
-
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
|
3937
3729
|
}, {
|
|
3938
3730
|
'android': device.android
|
|
3939
3731
|
}, {
|
|
@@ -4030,16 +3822,12 @@
|
|
|
4030
3822
|
autoHeight: false,
|
|
4031
3823
|
// Set wrapper width
|
|
4032
3824
|
setWrapperSize: false,
|
|
4033
|
-
//
|
|
4034
|
-
virtualTranslate: false,
|
|
4035
|
-
// Effects
|
|
3825
|
+
// Effects (core-lite only supports `slide`)
|
|
4036
3826
|
effect: 'slide',
|
|
4037
|
-
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
|
4038
|
-
|
|
4039
3827
|
// Breakpoints
|
|
4040
3828
|
breakpoints: undefined,
|
|
4041
3829
|
breakpointsBase: 'window',
|
|
4042
|
-
// Slides
|
|
3830
|
+
// Slides
|
|
4043
3831
|
spaceBetween: 0,
|
|
4044
3832
|
slidesPerView: 1,
|
|
4045
3833
|
slidesPerGroup: 1,
|
|
@@ -4142,7 +3930,9 @@
|
|
|
4142
3930
|
if (moduleParamName === 'navigation' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].prevEl && !params[moduleParamName].nextEl) {
|
|
4143
3931
|
params[moduleParamName].auto = true;
|
|
4144
3932
|
}
|
|
4145
|
-
|
|
3933
|
+
|
|
3934
|
+
// Core-lite: keep only pagination auto-init.
|
|
3935
|
+
if (moduleParamName === 'pagination' && params[moduleParamName] && params[moduleParamName].enabled && !params[moduleParamName].el) {
|
|
4146
3936
|
params[moduleParamName].auto = true;
|
|
4147
3937
|
}
|
|
4148
3938
|
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
|
@@ -4268,7 +4058,6 @@
|
|
|
4268
4058
|
// Indexes
|
|
4269
4059
|
activeIndex: 0,
|
|
4270
4060
|
realIndex: 0,
|
|
4271
|
-
//
|
|
4272
4061
|
isBeginning: true,
|
|
4273
4062
|
isEnd: false,
|
|
4274
4063
|
// Props
|
|
@@ -4295,12 +4084,9 @@
|
|
|
4295
4084
|
currentTranslate: undefined,
|
|
4296
4085
|
startTranslate: undefined,
|
|
4297
4086
|
allowThresholdMove: undefined,
|
|
4298
|
-
// Form elements to match
|
|
4299
4087
|
focusableElements: swiper.params.focusableElements,
|
|
4300
|
-
// Last click time
|
|
4301
4088
|
lastClickTime: 0,
|
|
4302
4089
|
clickTimeout: undefined,
|
|
4303
|
-
// Velocities
|
|
4304
4090
|
velocities: [],
|
|
4305
4091
|
allowMomentumBounce: undefined,
|
|
4306
4092
|
startMoving: undefined,
|
|
@@ -4320,7 +4106,8 @@
|
|
|
4320
4106
|
},
|
|
4321
4107
|
// Images
|
|
4322
4108
|
imagesToLoad: [],
|
|
4323
|
-
imagesLoaded: 0
|
|
4109
|
+
imagesLoaded: 0,
|
|
4110
|
+
rtl: params?.rtl
|
|
4324
4111
|
});
|
|
4325
4112
|
swiper.emit('_swiper');
|
|
4326
4113
|
|
|
@@ -4329,7 +4116,6 @@
|
|
|
4329
4116
|
swiper.init();
|
|
4330
4117
|
}
|
|
4331
4118
|
|
|
4332
|
-
// Return app instance
|
|
4333
4119
|
// eslint-disable-next-line no-constructor-return
|
|
4334
4120
|
return swiper;
|
|
4335
4121
|
}
|
|
@@ -4361,16 +4147,6 @@
|
|
|
4361
4147
|
getSlideIndexByData(index) {
|
|
4362
4148
|
return this.getSlideIndex(this.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === index));
|
|
4363
4149
|
}
|
|
4364
|
-
getSlideIndexWhenGrid(index) {
|
|
4365
|
-
if (this.grid && this.params.grid && this.params.grid.rows > 1) {
|
|
4366
|
-
if (this.params.grid.fill === 'column') {
|
|
4367
|
-
index = Math.floor(index / this.params.grid.rows);
|
|
4368
|
-
} else if (this.params.grid.fill === 'row') {
|
|
4369
|
-
index = index % Math.ceil(this.slides.length / this.params.grid.rows);
|
|
4370
|
-
}
|
|
4371
|
-
}
|
|
4372
|
-
return index;
|
|
4373
|
-
}
|
|
4374
4150
|
recalcSlides() {
|
|
4375
4151
|
const swiper = this;
|
|
4376
4152
|
const {
|
|
@@ -4472,21 +4248,15 @@
|
|
|
4472
4248
|
}
|
|
4473
4249
|
}
|
|
4474
4250
|
} else {
|
|
4475
|
-
// eslint-disable-next-line
|
|
4476
4251
|
if (view === 'current') {
|
|
4477
4252
|
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
|
4478
4253
|
const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
|
4479
|
-
if (slideInView)
|
|
4480
|
-
spv += 1;
|
|
4481
|
-
}
|
|
4254
|
+
if (slideInView) spv += 1;
|
|
4482
4255
|
}
|
|
4483
4256
|
} else {
|
|
4484
|
-
// previous
|
|
4485
4257
|
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
|
4486
4258
|
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
|
4487
|
-
if (slideInView)
|
|
4488
|
-
spv += 1;
|
|
4489
|
-
}
|
|
4259
|
+
if (slideInView) spv += 1;
|
|
4490
4260
|
}
|
|
4491
4261
|
}
|
|
4492
4262
|
}
|
|
@@ -4499,14 +4269,11 @@
|
|
|
4499
4269
|
snapGrid,
|
|
4500
4270
|
params
|
|
4501
4271
|
} = swiper;
|
|
4502
|
-
// Breakpoints
|
|
4503
4272
|
if (params.breakpoints) {
|
|
4504
4273
|
swiper.setBreakpoint();
|
|
4505
4274
|
}
|
|
4506
4275
|
[...swiper.el.querySelectorAll('[loading="lazy"]')].forEach(imageEl => {
|
|
4507
|
-
if (imageEl.complete)
|
|
4508
|
-
processLazyPreloader(swiper, imageEl);
|
|
4509
|
-
}
|
|
4276
|
+
if (imageEl.complete) processLazyPreloader(swiper, imageEl);
|
|
4510
4277
|
});
|
|
4511
4278
|
swiper.updateSize();
|
|
4512
4279
|
swiper.updateSlides();
|
|
@@ -4520,22 +4287,12 @@
|
|
|
4520
4287
|
swiper.updateSlidesClasses();
|
|
4521
4288
|
}
|
|
4522
4289
|
let translated;
|
|
4523
|
-
if (params.
|
|
4524
|
-
|
|
4525
|
-
if (params.autoHeight) {
|
|
4526
|
-
swiper.updateAutoHeight();
|
|
4527
|
-
}
|
|
4290
|
+
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !params.centeredSlides) {
|
|
4291
|
+
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
|
4528
4292
|
} else {
|
|
4529
|
-
|
|
4530
|
-
const slides = swiper.virtual && params.virtual.enabled ? swiper.virtual.slides : swiper.slides;
|
|
4531
|
-
translated = swiper.slideTo(slides.length - 1, 0, false, true);
|
|
4532
|
-
} else {
|
|
4533
|
-
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4534
|
-
}
|
|
4535
|
-
if (!translated) {
|
|
4536
|
-
setTranslate();
|
|
4537
|
-
}
|
|
4293
|
+
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
|
4538
4294
|
}
|
|
4295
|
+
if (!translated) setTranslate();
|
|
4539
4296
|
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
|
4540
4297
|
swiper.checkOverflow();
|
|
4541
4298
|
}
|
|
@@ -4548,7 +4305,6 @@
|
|
|
4548
4305
|
const swiper = this;
|
|
4549
4306
|
const currentDirection = swiper.params.direction;
|
|
4550
4307
|
if (!newDirection) {
|
|
4551
|
-
// eslint-disable-next-line
|
|
4552
4308
|
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
|
4553
4309
|
}
|
|
4554
4310
|
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
|
@@ -4586,15 +4342,11 @@
|
|
|
4586
4342
|
mount(element) {
|
|
4587
4343
|
const swiper = this;
|
|
4588
4344
|
if (swiper.mounted) return true;
|
|
4589
|
-
|
|
4590
|
-
// Find el
|
|
4591
4345
|
let el = element || swiper.params.el;
|
|
4592
4346
|
if (typeof el === 'string') {
|
|
4593
4347
|
el = document.querySelector(el);
|
|
4594
4348
|
}
|
|
4595
|
-
if (!el)
|
|
4596
|
-
return false;
|
|
4597
|
-
}
|
|
4349
|
+
if (!el) return false;
|
|
4598
4350
|
el.swiper = swiper;
|
|
4599
4351
|
if (el.parentNode && el.parentNode.host && el.parentNode.host.nodeName === swiper.params.swiperElementNodeName.toUpperCase()) {
|
|
4600
4352
|
swiper.isElement = true;
|
|
@@ -4605,12 +4357,10 @@
|
|
|
4605
4357
|
const getWrapper = () => {
|
|
4606
4358
|
if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
|
4607
4359
|
const res = el.shadowRoot.querySelector(getWrapperSelector());
|
|
4608
|
-
// Children needs to return slot items
|
|
4609
4360
|
return res;
|
|
4610
4361
|
}
|
|
4611
4362
|
return elementChildren(el, getWrapperSelector())[0];
|
|
4612
4363
|
};
|
|
4613
|
-
// Find Wrapper
|
|
4614
4364
|
let wrapperEl = getWrapper();
|
|
4615
4365
|
if (!wrapperEl && swiper.params.createElements) {
|
|
4616
4366
|
wrapperEl = createElement('div', swiper.params.wrapperClass);
|
|
@@ -4619,6 +4369,8 @@
|
|
|
4619
4369
|
wrapperEl.append(slideEl);
|
|
4620
4370
|
});
|
|
4621
4371
|
}
|
|
4372
|
+
const rtl = swiper.params.rtl ?? (el.dir.toLowerCase() === 'rtl' || elementStyle(el, 'direction') === 'rtl');
|
|
4373
|
+
const wrongRTL = false;
|
|
4622
4374
|
Object.assign(swiper, {
|
|
4623
4375
|
el,
|
|
4624
4376
|
wrapperEl,
|
|
@@ -4626,9 +4378,9 @@
|
|
|
4626
4378
|
hostEl: swiper.isElement ? el.parentNode.host : el,
|
|
4627
4379
|
mounted: true,
|
|
4628
4380
|
// RTL
|
|
4629
|
-
rtl
|
|
4630
|
-
rtlTranslate: swiper.params.direction === 'horizontal' &&
|
|
4631
|
-
wrongRTL
|
|
4381
|
+
rtl,
|
|
4382
|
+
rtlTranslate: swiper.params.direction === 'horizontal' && rtl,
|
|
4383
|
+
wrongRTL
|
|
4632
4384
|
});
|
|
4633
4385
|
return true;
|
|
4634
4386
|
}
|
|
@@ -4645,7 +4397,6 @@
|
|
|
4645
4397
|
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4646
4398
|
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4647
4399
|
if (isFirstSlide) {
|
|
4648
|
-
// Move last item to first position when at first slide
|
|
4649
4400
|
const lastSlide = slides.at(-1);
|
|
4650
4401
|
lastSlide.swiperLoopMoveDOM = true;
|
|
4651
4402
|
swiper.slidesEl.prepend(lastSlide);
|
|
@@ -4657,7 +4408,6 @@
|
|
|
4657
4408
|
swiper.setTransition(speed);
|
|
4658
4409
|
swiper.setTranslate(-swiperTranslate);
|
|
4659
4410
|
} else if (isLastSlide) {
|
|
4660
|
-
// Move first item to last position when at last slide
|
|
4661
4411
|
const firstSlide = slides[0];
|
|
4662
4412
|
firstSlide.swiperLoopMoveDOM = true;
|
|
4663
4413
|
swiper.slidesEl.append(firstSlide);
|
|
@@ -4678,42 +4428,24 @@
|
|
|
4678
4428
|
const mounted = swiper.mount(el);
|
|
4679
4429
|
if (mounted === false) return swiper;
|
|
4680
4430
|
swiper.emit('beforeInit');
|
|
4681
|
-
|
|
4682
|
-
// Set breakpoint
|
|
4683
4431
|
if (swiper.params.breakpoints) {
|
|
4684
4432
|
swiper.setBreakpoint();
|
|
4685
4433
|
}
|
|
4686
|
-
|
|
4687
|
-
// Add Classes
|
|
4688
4434
|
swiper.addClasses();
|
|
4689
|
-
|
|
4690
|
-
// Update size
|
|
4691
4435
|
swiper.updateSize();
|
|
4692
|
-
|
|
4693
|
-
// Update slides
|
|
4694
4436
|
swiper.updateSlides();
|
|
4695
4437
|
if (swiper.params.watchOverflow) {
|
|
4696
4438
|
swiper.checkOverflow();
|
|
4697
4439
|
}
|
|
4698
|
-
|
|
4699
|
-
// Set Grab Cursor
|
|
4700
4440
|
if (swiper.params.grabCursor && swiper.enabled) {
|
|
4701
4441
|
swiper.setGrabCursor();
|
|
4702
4442
|
}
|
|
4703
4443
|
|
|
4704
|
-
// Slide
|
|
4705
|
-
|
|
4706
|
-
swiper.slideTo(swiper.params.initialSlide + swiper.virtual.slidesBefore, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4707
|
-
} else {
|
|
4708
|
-
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4709
|
-
}
|
|
4710
|
-
|
|
4711
|
-
// Create loop
|
|
4444
|
+
// Slide to initial slide (core-lite: no optional feature initial offsets)
|
|
4445
|
+
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
|
4712
4446
|
if (swiper.params.loop) {
|
|
4713
4447
|
swiper.loopCreate(undefined, true);
|
|
4714
4448
|
}
|
|
4715
|
-
|
|
4716
|
-
// Attach events
|
|
4717
4449
|
swiper.attachEvents();
|
|
4718
4450
|
const lazyElements = [...swiper.el.querySelectorAll('[loading="lazy"]')];
|
|
4719
4451
|
if (swiper.isElement) {
|
|
@@ -4723,16 +4455,11 @@
|
|
|
4723
4455
|
if (imageEl.complete) {
|
|
4724
4456
|
processLazyPreloader(swiper, imageEl);
|
|
4725
4457
|
} else {
|
|
4726
|
-
imageEl.addEventListener('load', e =>
|
|
4727
|
-
processLazyPreloader(swiper, e.target);
|
|
4728
|
-
});
|
|
4458
|
+
imageEl.addEventListener('load', e => processLazyPreloader(swiper, e.target));
|
|
4729
4459
|
}
|
|
4730
4460
|
});
|
|
4731
4461
|
preload(swiper);
|
|
4732
|
-
|
|
4733
|
-
// Init Flag
|
|
4734
4462
|
swiper.initialized = true;
|
|
4735
|
-
preload(swiper);
|
|
4736
4463
|
|
|
4737
4464
|
// Emit
|
|
4738
4465
|
swiper.emit('init');
|
|
@@ -4757,27 +4484,15 @@
|
|
|
4757
4484
|
return null;
|
|
4758
4485
|
}
|
|
4759
4486
|
swiper.emit('beforeDestroy');
|
|
4760
|
-
|
|
4761
|
-
// Init Flag
|
|
4762
4487
|
swiper.initialized = false;
|
|
4763
|
-
|
|
4764
|
-
// Detach events
|
|
4765
4488
|
swiper.detachEvents();
|
|
4766
|
-
|
|
4767
|
-
// Destroy loop
|
|
4768
4489
|
if (params.loop) {
|
|
4769
4490
|
swiper.loopDestroy();
|
|
4770
4491
|
}
|
|
4771
|
-
|
|
4772
|
-
// Cleanup styles
|
|
4773
4492
|
if (cleanStyles) {
|
|
4774
4493
|
swiper.removeClasses();
|
|
4775
|
-
if (el && typeof el !== 'string')
|
|
4776
|
-
|
|
4777
|
-
}
|
|
4778
|
-
if (wrapperEl) {
|
|
4779
|
-
wrapperEl.removeAttribute('style');
|
|
4780
|
-
}
|
|
4494
|
+
if (el && typeof el !== 'string') el.removeAttribute('style');
|
|
4495
|
+
if (wrapperEl) wrapperEl.removeAttribute('style');
|
|
4781
4496
|
if (slides && slides.length) {
|
|
4782
4497
|
slides.forEach(slideEl => {
|
|
4783
4498
|
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
@@ -4787,8 +4502,6 @@
|
|
|
4787
4502
|
}
|
|
4788
4503
|
}
|
|
4789
4504
|
swiper.emit('destroy');
|
|
4790
|
-
|
|
4791
|
-
// Detach emitter events
|
|
4792
4505
|
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
|
4793
4506
|
swiper.off(eventName);
|
|
4794
4507
|
});
|
|
@@ -10223,7 +9936,7 @@
|
|
|
10223
9936
|
}
|
|
10224
9937
|
|
|
10225
9938
|
/**
|
|
10226
|
-
* Swiper 0.0.
|
|
9939
|
+
* Swiper 0.0.17-dev.1
|
|
10227
9940
|
* Gem SDK - Swiper, Customized of swiper
|
|
10228
9941
|
* https://swiperjs.com
|
|
10229
9942
|
*
|
|
@@ -10231,7 +9944,7 @@
|
|
|
10231
9944
|
*
|
|
10232
9945
|
* Released under the MIT License
|
|
10233
9946
|
*
|
|
10234
|
-
* Released on: March
|
|
9947
|
+
* Released on: March 23, 2026
|
|
10235
9948
|
*/
|
|
10236
9949
|
|
|
10237
9950
|
|
|
@@ -10565,7 +10278,7 @@
|
|
|
10565
10278
|
}
|
|
10566
10279
|
|
|
10567
10280
|
/**
|
|
10568
|
-
* Swiper Custom Element 0.0.
|
|
10281
|
+
* Swiper Custom Element 0.0.17-dev.1
|
|
10569
10282
|
* Gem SDK - Swiper, Customized of swiper
|
|
10570
10283
|
* https://swiperjs.com
|
|
10571
10284
|
*
|
|
@@ -10573,7 +10286,7 @@
|
|
|
10573
10286
|
*
|
|
10574
10287
|
* Released under the MIT License
|
|
10575
10288
|
*
|
|
10576
|
-
* Released on: March
|
|
10289
|
+
* Released on: March 23, 2026
|
|
10577
10290
|
*/
|
|
10578
10291
|
|
|
10579
10292
|
|