@itcase/ui 1.0.77 → 1.0.79
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/dist/components/Accordion.js +2 -0
- package/dist/components/Avatar.js +58 -21
- package/dist/components/Badge.js +28 -4
- package/dist/components/Breadcrumbs.js +2 -0
- package/dist/components/Button.js +2 -0
- package/dist/components/Cell.js +2 -0
- package/dist/components/Choice.js +1 -1
- package/dist/components/ContextMenu.js +2 -0
- package/dist/components/CookiesWarning.js +2 -0
- package/dist/components/DatePicker.js +2 -0
- package/dist/components/Empty.js +2 -0
- package/dist/components/FormField.js +2 -0
- package/dist/components/Icon.js +11 -13
- package/dist/components/InputPassword.js +2 -0
- package/dist/components/LanguageSelector.js +2 -0
- package/dist/components/Search.js +2 -0
- package/dist/components/Select.js +143 -42
- package/dist/components/SiteMenu.js +2 -0
- package/dist/components/Swiper.js +383 -133
- package/dist/constants/componentProps/iconFillSize.js +5 -0
- package/dist/constants/componentProps/sizePX.js +1 -1
- package/dist/constants.js +2 -0
- package/dist/css/components/Avatar/Avatar.css +20 -13
- package/dist/css/components/Badge/Badge.css +25 -7
- package/dist/css/components/Swiper/Swiper.css +8 -6
- package/dist/hooks/styleAttributes.js +1 -1
- package/package.json +16 -16
|
@@ -175,6 +175,13 @@ function getWindow() {
|
|
|
175
175
|
return win;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
function classesToTokens(classes) {
|
|
179
|
+
if (classes === void 0) {
|
|
180
|
+
classes = '';
|
|
181
|
+
}
|
|
182
|
+
return classes.trim().split(' ').filter(c => !!c.trim());
|
|
183
|
+
}
|
|
184
|
+
|
|
178
185
|
function deleteProps(obj) {
|
|
179
186
|
const object = obj;
|
|
180
187
|
Object.keys(object).forEach(key => {
|
|
@@ -351,12 +358,20 @@ function elementChildren(element, selector) {
|
|
|
351
358
|
}
|
|
352
359
|
return [...element.children].filter(el => el.matches(selector));
|
|
353
360
|
}
|
|
361
|
+
function showWarning(text) {
|
|
362
|
+
try {
|
|
363
|
+
console.warn(text);
|
|
364
|
+
return;
|
|
365
|
+
} catch (err) {
|
|
366
|
+
// err
|
|
367
|
+
}
|
|
368
|
+
}
|
|
354
369
|
function createElement(tag, classes) {
|
|
355
370
|
if (classes === void 0) {
|
|
356
371
|
classes = [];
|
|
357
372
|
}
|
|
358
373
|
const el = document.createElement(tag);
|
|
359
|
-
el.classList.add(...(Array.isArray(classes) ? classes :
|
|
374
|
+
el.classList.add(...(Array.isArray(classes) ? classes : classesToTokens(classes)));
|
|
360
375
|
return el;
|
|
361
376
|
}
|
|
362
377
|
function elementPrevAll(el, selector) {
|
|
@@ -795,24 +810,8 @@ function updateSize() {
|
|
|
795
810
|
|
|
796
811
|
function updateSlides() {
|
|
797
812
|
const swiper = this;
|
|
798
|
-
function getDirectionLabel(property) {
|
|
799
|
-
if (swiper.isHorizontal()) {
|
|
800
|
-
return property;
|
|
801
|
-
}
|
|
802
|
-
// prettier-ignore
|
|
803
|
-
return {
|
|
804
|
-
'width': 'height',
|
|
805
|
-
'margin-top': 'margin-left',
|
|
806
|
-
'margin-bottom ': 'margin-right',
|
|
807
|
-
'margin-left': 'margin-top',
|
|
808
|
-
'margin-right': 'margin-bottom',
|
|
809
|
-
'padding-left': 'padding-top',
|
|
810
|
-
'padding-right': 'padding-bottom',
|
|
811
|
-
'marginRight': 'marginBottom'
|
|
812
|
-
}[property];
|
|
813
|
-
}
|
|
814
813
|
function getDirectionPropertyValue(node, label) {
|
|
815
|
-
return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
|
|
814
|
+
return parseFloat(node.getPropertyValue(swiper.getDirectionLabel(label)) || 0);
|
|
816
815
|
}
|
|
817
816
|
const params = swiper.params;
|
|
818
817
|
const {
|
|
@@ -871,7 +870,9 @@ function updateSlides() {
|
|
|
871
870
|
}
|
|
872
871
|
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
|
873
872
|
if (gridEnabled) {
|
|
874
|
-
swiper.grid.initSlides(
|
|
873
|
+
swiper.grid.initSlides(slides);
|
|
874
|
+
} else if (swiper.grid) {
|
|
875
|
+
swiper.grid.unsetSlides();
|
|
875
876
|
}
|
|
876
877
|
|
|
877
878
|
// Calc slides
|
|
@@ -884,13 +885,13 @@ function updateSlides() {
|
|
|
884
885
|
let slide;
|
|
885
886
|
if (slides[i]) slide = slides[i];
|
|
886
887
|
if (gridEnabled) {
|
|
887
|
-
swiper.grid.updateSlide(i, slide,
|
|
888
|
+
swiper.grid.updateSlide(i, slide, slides);
|
|
888
889
|
}
|
|
889
890
|
if (slides[i] && elementStyle(slide, 'display') === 'none') continue; // eslint-disable-line
|
|
890
891
|
|
|
891
892
|
if (params.slidesPerView === 'auto') {
|
|
892
893
|
if (shouldResetSlideSize) {
|
|
893
|
-
slides[i].style[getDirectionLabel('width')] = ``;
|
|
894
|
+
slides[i].style[swiper.getDirectionLabel('width')] = ``;
|
|
894
895
|
}
|
|
895
896
|
const slideStyles = getComputedStyle(slide);
|
|
896
897
|
const currentTransform = slide.style.transform;
|
|
@@ -932,7 +933,7 @@ function updateSlides() {
|
|
|
932
933
|
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
|
933
934
|
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
|
934
935
|
if (slides[i]) {
|
|
935
|
-
slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
|
|
936
|
+
slides[i].style[swiper.getDirectionLabel('width')] = `${slideSize}px`;
|
|
936
937
|
}
|
|
937
938
|
}
|
|
938
939
|
if (slides[i]) {
|
|
@@ -962,10 +963,10 @@ function updateSlides() {
|
|
|
962
963
|
wrapperEl.style.width = `${swiper.virtualSize + spaceBetween}px`;
|
|
963
964
|
}
|
|
964
965
|
if (params.setWrapperSize) {
|
|
965
|
-
wrapperEl.style[getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
|
|
966
|
+
wrapperEl.style[swiper.getDirectionLabel('width')] = `${swiper.virtualSize + spaceBetween}px`;
|
|
966
967
|
}
|
|
967
968
|
if (gridEnabled) {
|
|
968
|
-
swiper.grid.updateWrapperSize(slideSize, snapGrid
|
|
969
|
+
swiper.grid.updateWrapperSize(slideSize, snapGrid);
|
|
969
970
|
}
|
|
970
971
|
|
|
971
972
|
// Remove last grid elements depending on width
|
|
@@ -1002,7 +1003,7 @@ function updateSlides() {
|
|
|
1002
1003
|
}
|
|
1003
1004
|
if (snapGrid.length === 0) snapGrid = [0];
|
|
1004
1005
|
if (spaceBetween !== 0) {
|
|
1005
|
-
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
|
|
1006
|
+
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : swiper.getDirectionLabel('marginRight');
|
|
1006
1007
|
slides.filter((_, slideIndex) => {
|
|
1007
1008
|
if (!params.cssMode || params.loop) return true;
|
|
1008
1009
|
if (slideIndex === slides.length - 1) {
|
|
@@ -1154,7 +1155,7 @@ function updateSlidesProgress(translate) {
|
|
|
1154
1155
|
|
|
1155
1156
|
// Visible Slides
|
|
1156
1157
|
slides.forEach(slideEl => {
|
|
1157
|
-
slideEl.classList.remove(params.slideVisibleClass);
|
|
1158
|
+
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass);
|
|
1158
1159
|
});
|
|
1159
1160
|
swiper.visibleSlidesIndexes = [];
|
|
1160
1161
|
swiper.visibleSlides = [];
|
|
@@ -1174,12 +1175,16 @@ function updateSlidesProgress(translate) {
|
|
|
1174
1175
|
const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + spaceBetween);
|
|
1175
1176
|
const slideBefore = -(offsetCenter - slideOffset);
|
|
1176
1177
|
const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
|
1178
|
+
const isFullyVisible = slideBefore >= 0 && slideBefore <= swiper.size - swiper.slidesSizesGrid[i];
|
|
1177
1179
|
const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
|
1178
1180
|
if (isVisible) {
|
|
1179
1181
|
swiper.visibleSlides.push(slide);
|
|
1180
1182
|
swiper.visibleSlidesIndexes.push(i);
|
|
1181
1183
|
slides[i].classList.add(params.slideVisibleClass);
|
|
1182
1184
|
}
|
|
1185
|
+
if (isFullyVisible) {
|
|
1186
|
+
slides[i].classList.add(params.slideFullyVisibleClass);
|
|
1187
|
+
}
|
|
1183
1188
|
slide.progress = rtl ? -slideProgress : slideProgress;
|
|
1184
1189
|
slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
|
1185
1190
|
}
|
|
@@ -1257,6 +1262,7 @@ function updateSlidesClasses() {
|
|
|
1257
1262
|
activeIndex
|
|
1258
1263
|
} = swiper;
|
|
1259
1264
|
const isVirtual = swiper.virtual && params.virtual.enabled;
|
|
1265
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1260
1266
|
const getFilteredSlide = selector => {
|
|
1261
1267
|
return elementChildren(slidesEl, `.${params.slideClass}${selector}, swiper-slide${selector}`)[0];
|
|
1262
1268
|
};
|
|
@@ -1264,6 +1270,8 @@ function updateSlidesClasses() {
|
|
|
1264
1270
|
slideEl.classList.remove(params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
1265
1271
|
});
|
|
1266
1272
|
let activeSlide;
|
|
1273
|
+
let prevSlide;
|
|
1274
|
+
let nextSlide;
|
|
1267
1275
|
if (isVirtual) {
|
|
1268
1276
|
if (params.loop) {
|
|
1269
1277
|
let slideIndex = activeIndex - swiper.virtual.slidesBefore;
|
|
@@ -1274,27 +1282,42 @@ function updateSlidesClasses() {
|
|
|
1274
1282
|
activeSlide = getFilteredSlide(`[data-swiper-slide-index="${activeIndex}"]`);
|
|
1275
1283
|
}
|
|
1276
1284
|
} else {
|
|
1277
|
-
|
|
1285
|
+
if (gridEnabled) {
|
|
1286
|
+
activeSlide = slides.filter(slideEl => slideEl.column === activeIndex)[0];
|
|
1287
|
+
nextSlide = slides.filter(slideEl => slideEl.column === activeIndex + 1)[0];
|
|
1288
|
+
prevSlide = slides.filter(slideEl => slideEl.column === activeIndex - 1)[0];
|
|
1289
|
+
} else {
|
|
1290
|
+
activeSlide = slides[activeIndex];
|
|
1291
|
+
}
|
|
1278
1292
|
}
|
|
1279
1293
|
if (activeSlide) {
|
|
1280
1294
|
// Active classes
|
|
1281
1295
|
activeSlide.classList.add(params.slideActiveClass);
|
|
1296
|
+
if (gridEnabled) {
|
|
1297
|
+
if (nextSlide) {
|
|
1298
|
+
nextSlide.classList.add(params.slideNextClass);
|
|
1299
|
+
}
|
|
1300
|
+
if (prevSlide) {
|
|
1301
|
+
prevSlide.classList.add(params.slidePrevClass);
|
|
1302
|
+
}
|
|
1303
|
+
} else {
|
|
1304
|
+
// Next Slide
|
|
1305
|
+
nextSlide = elementNextAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1306
|
+
if (params.loop && !nextSlide) {
|
|
1307
|
+
nextSlide = slides[0];
|
|
1308
|
+
}
|
|
1309
|
+
if (nextSlide) {
|
|
1310
|
+
nextSlide.classList.add(params.slideNextClass);
|
|
1311
|
+
}
|
|
1282
1312
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
// Prev Slide
|
|
1292
|
-
let prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1293
|
-
if (params.loop && !prevSlide === 0) {
|
|
1294
|
-
prevSlide = slides[slides.length - 1];
|
|
1295
|
-
}
|
|
1296
|
-
if (prevSlide) {
|
|
1297
|
-
prevSlide.classList.add(params.slidePrevClass);
|
|
1313
|
+
// Prev Slide
|
|
1314
|
+
prevSlide = elementPrevAll(activeSlide, `.${params.slideClass}, swiper-slide`)[0];
|
|
1315
|
+
if (params.loop && !prevSlide === 0) {
|
|
1316
|
+
prevSlide = slides[slides.length - 1];
|
|
1317
|
+
}
|
|
1318
|
+
if (prevSlide) {
|
|
1319
|
+
prevSlide.classList.add(params.slidePrevClass);
|
|
1320
|
+
}
|
|
1298
1321
|
}
|
|
1299
1322
|
}
|
|
1300
1323
|
swiper.emitSlidesClasses();
|
|
@@ -1419,22 +1442,37 @@ function updateActiveIndex(newActiveIndex) {
|
|
|
1419
1442
|
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
|
1420
1443
|
}
|
|
1421
1444
|
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
|
1422
|
-
if (activeIndex === previousIndex) {
|
|
1445
|
+
if (activeIndex === previousIndex && !swiper.params.loop) {
|
|
1423
1446
|
if (snapIndex !== previousSnapIndex) {
|
|
1424
1447
|
swiper.snapIndex = snapIndex;
|
|
1425
1448
|
swiper.emit('snapIndexChange');
|
|
1426
1449
|
}
|
|
1427
|
-
if (swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
|
1428
|
-
swiper.realIndex = getVirtualRealIndex(activeIndex);
|
|
1429
|
-
}
|
|
1430
1450
|
return;
|
|
1431
1451
|
}
|
|
1452
|
+
if (activeIndex === previousIndex && swiper.params.loop && swiper.virtual && swiper.params.virtual.enabled) {
|
|
1453
|
+
swiper.realIndex = getVirtualRealIndex(activeIndex);
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
1457
|
+
|
|
1432
1458
|
// Get real index
|
|
1433
1459
|
let realIndex;
|
|
1434
1460
|
if (swiper.virtual && params.virtual.enabled && params.loop) {
|
|
1435
1461
|
realIndex = getVirtualRealIndex(activeIndex);
|
|
1462
|
+
} else if (gridEnabled) {
|
|
1463
|
+
const firstSlideInColumn = swiper.slides.filter(slideEl => slideEl.column === activeIndex)[0];
|
|
1464
|
+
let activeSlideIndex = parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'), 10);
|
|
1465
|
+
if (Number.isNaN(activeSlideIndex)) {
|
|
1466
|
+
activeSlideIndex = Math.max(swiper.slides.indexOf(firstSlideInColumn), 0);
|
|
1467
|
+
}
|
|
1468
|
+
realIndex = Math.floor(activeSlideIndex / params.grid.rows);
|
|
1436
1469
|
} else if (swiper.slides[activeIndex]) {
|
|
1437
|
-
|
|
1470
|
+
const slideIndex = swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');
|
|
1471
|
+
if (slideIndex) {
|
|
1472
|
+
realIndex = parseInt(slideIndex, 10);
|
|
1473
|
+
} else {
|
|
1474
|
+
realIndex = activeIndex;
|
|
1475
|
+
}
|
|
1438
1476
|
} else {
|
|
1439
1477
|
realIndex = activeIndex;
|
|
1440
1478
|
}
|
|
@@ -1928,16 +1966,58 @@ function slideToLoop(index, speed, runCallbacks, internal) {
|
|
|
1928
1966
|
index = indexAsNumber;
|
|
1929
1967
|
}
|
|
1930
1968
|
const swiper = this;
|
|
1969
|
+
const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
1931
1970
|
let newIndex = index;
|
|
1932
1971
|
if (swiper.params.loop) {
|
|
1933
1972
|
if (swiper.virtual && swiper.params.virtual.enabled) {
|
|
1934
1973
|
// eslint-disable-next-line
|
|
1935
1974
|
newIndex = newIndex + swiper.virtual.slidesBefore;
|
|
1936
1975
|
} else {
|
|
1937
|
-
|
|
1976
|
+
let targetSlideIndex;
|
|
1977
|
+
if (gridEnabled) {
|
|
1978
|
+
const slideIndex = newIndex * swiper.params.grid.rows;
|
|
1979
|
+
targetSlideIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
|
|
1980
|
+
} else {
|
|
1981
|
+
targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
|
1982
|
+
}
|
|
1983
|
+
const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
|
|
1984
|
+
const {
|
|
1985
|
+
centeredSlides
|
|
1986
|
+
} = swiper.params;
|
|
1987
|
+
let slidesPerView = swiper.params.slidesPerView;
|
|
1988
|
+
if (slidesPerView === 'auto') {
|
|
1989
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
1990
|
+
} else {
|
|
1991
|
+
slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1992
|
+
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
1993
|
+
slidesPerView = slidesPerView + 1;
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
let needLoopFix = cols - targetSlideIndex < slidesPerView;
|
|
1997
|
+
if (centeredSlides) {
|
|
1998
|
+
needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
|
|
1999
|
+
}
|
|
2000
|
+
if (needLoopFix) {
|
|
2001
|
+
const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
|
|
2002
|
+
swiper.loopFix({
|
|
2003
|
+
direction,
|
|
2004
|
+
slideTo: true,
|
|
2005
|
+
activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
2006
|
+
slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
if (gridEnabled) {
|
|
2010
|
+
const slideIndex = newIndex * swiper.params.grid.rows;
|
|
2011
|
+
newIndex = swiper.slides.filter(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex)[0].column;
|
|
2012
|
+
} else {
|
|
2013
|
+
newIndex = swiper.getSlideIndexByData(newIndex);
|
|
2014
|
+
}
|
|
1938
2015
|
}
|
|
1939
2016
|
}
|
|
1940
|
-
|
|
2017
|
+
requestAnimationFrame(() => {
|
|
2018
|
+
swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
|
2019
|
+
});
|
|
2020
|
+
return swiper;
|
|
1941
2021
|
}
|
|
1942
2022
|
|
|
1943
2023
|
/* eslint no-unused-vars: "off" */
|
|
@@ -2153,10 +2233,45 @@ function loopCreate(slideRealIndex) {
|
|
|
2153
2233
|
slidesEl
|
|
2154
2234
|
} = swiper;
|
|
2155
2235
|
if (!params.loop || swiper.virtual && swiper.params.virtual.enabled) return;
|
|
2156
|
-
const
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2236
|
+
const initSlides = () => {
|
|
2237
|
+
const slides = elementChildren(slidesEl, `.${params.slideClass}, swiper-slide`);
|
|
2238
|
+
slides.forEach((el, index) => {
|
|
2239
|
+
el.setAttribute('data-swiper-slide-index', index);
|
|
2240
|
+
});
|
|
2241
|
+
};
|
|
2242
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
2243
|
+
const slidesPerGroup = params.slidesPerGroup * (gridEnabled ? params.grid.rows : 1);
|
|
2244
|
+
const shouldFillGroup = swiper.slides.length % slidesPerGroup !== 0;
|
|
2245
|
+
const shouldFillGrid = gridEnabled && swiper.slides.length % params.grid.rows !== 0;
|
|
2246
|
+
const addBlankSlides = amountOfSlides => {
|
|
2247
|
+
for (let i = 0; i < amountOfSlides; i += 1) {
|
|
2248
|
+
const slideEl = swiper.isElement ? createElement('swiper-slide', [params.slideBlankClass]) : createElement('div', [params.slideClass, params.slideBlankClass]);
|
|
2249
|
+
swiper.slidesEl.append(slideEl);
|
|
2250
|
+
}
|
|
2251
|
+
};
|
|
2252
|
+
if (shouldFillGroup) {
|
|
2253
|
+
if (params.loopAddBlankSlides) {
|
|
2254
|
+
const slidesToAdd = slidesPerGroup - swiper.slides.length % slidesPerGroup;
|
|
2255
|
+
addBlankSlides(slidesToAdd);
|
|
2256
|
+
swiper.recalcSlides();
|
|
2257
|
+
swiper.updateSlides();
|
|
2258
|
+
} else {
|
|
2259
|
+
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)');
|
|
2260
|
+
}
|
|
2261
|
+
initSlides();
|
|
2262
|
+
} else if (shouldFillGrid) {
|
|
2263
|
+
if (params.loopAddBlankSlides) {
|
|
2264
|
+
const slidesToAdd = params.grid.rows - swiper.slides.length % params.grid.rows;
|
|
2265
|
+
addBlankSlides(slidesToAdd);
|
|
2266
|
+
swiper.recalcSlides();
|
|
2267
|
+
swiper.updateSlides();
|
|
2268
|
+
} else {
|
|
2269
|
+
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)');
|
|
2270
|
+
}
|
|
2271
|
+
initSlides();
|
|
2272
|
+
} else {
|
|
2273
|
+
initSlides();
|
|
2274
|
+
}
|
|
2160
2275
|
swiper.loopFix({
|
|
2161
2276
|
slideRealIndex,
|
|
2162
2277
|
direction: params.centeredSlides ? undefined : 'next'
|
|
@@ -2183,6 +2298,9 @@ function loopFix(_temp) {
|
|
|
2183
2298
|
slidesEl,
|
|
2184
2299
|
params
|
|
2185
2300
|
} = swiper;
|
|
2301
|
+
const {
|
|
2302
|
+
centeredSlides
|
|
2303
|
+
} = params;
|
|
2186
2304
|
swiper.allowSlidePrev = true;
|
|
2187
2305
|
swiper.allowSlideNext = true;
|
|
2188
2306
|
if (swiper.virtual && params.virtual.enabled) {
|
|
@@ -2200,17 +2318,33 @@ function loopFix(_temp) {
|
|
|
2200
2318
|
swiper.emit('loopFix');
|
|
2201
2319
|
return;
|
|
2202
2320
|
}
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2321
|
+
let slidesPerView = params.slidesPerView;
|
|
2322
|
+
if (slidesPerView === 'auto') {
|
|
2323
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
2324
|
+
} else {
|
|
2325
|
+
slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2326
|
+
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
2327
|
+
slidesPerView = slidesPerView + 1;
|
|
2328
|
+
}
|
|
2207
2329
|
}
|
|
2330
|
+
const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
|
|
2331
|
+
let loopedSlides = slidesPerGroup;
|
|
2332
|
+
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2333
|
+
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2334
|
+
}
|
|
2335
|
+
loopedSlides += params.loopAdditionalSlides;
|
|
2208
2336
|
swiper.loopedSlides = loopedSlides;
|
|
2337
|
+
const gridEnabled = swiper.grid && params.grid && params.grid.rows > 1;
|
|
2338
|
+
if (slides.length < slidesPerView + loopedSlides) {
|
|
2339
|
+
showWarning('Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters');
|
|
2340
|
+
} else if (gridEnabled && params.grid.fill === 'row') {
|
|
2341
|
+
showWarning('Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`');
|
|
2342
|
+
}
|
|
2209
2343
|
const prependSlidesIndexes = [];
|
|
2210
2344
|
const appendSlidesIndexes = [];
|
|
2211
2345
|
let activeIndex = swiper.activeIndex;
|
|
2212
2346
|
if (typeof activeSlideIndex === 'undefined') {
|
|
2213
|
-
activeSlideIndex = swiper.getSlideIndex(
|
|
2347
|
+
activeSlideIndex = swiper.getSlideIndex(slides.filter(el => el.classList.contains(params.slideActiveClass))[0]);
|
|
2214
2348
|
} else {
|
|
2215
2349
|
activeIndex = activeSlideIndex;
|
|
2216
2350
|
}
|
|
@@ -2218,37 +2352,64 @@ function loopFix(_temp) {
|
|
|
2218
2352
|
const isPrev = direction === 'prev' || !direction;
|
|
2219
2353
|
let slidesPrepended = 0;
|
|
2220
2354
|
let slidesAppended = 0;
|
|
2355
|
+
const cols = gridEnabled ? Math.ceil(slides.length / params.grid.rows) : slides.length;
|
|
2356
|
+
const activeColIndex = gridEnabled ? slides[activeSlideIndex].column : activeSlideIndex;
|
|
2357
|
+
const activeColIndexWithShift = activeColIndex + (centeredSlides && typeof setTranslate === 'undefined' ? -slidesPerView / 2 + 0.5 : 0);
|
|
2221
2358
|
// prepend last slides before start
|
|
2222
|
-
if (
|
|
2223
|
-
slidesPrepended = Math.max(loopedSlides -
|
|
2224
|
-
for (let i = 0; i < loopedSlides -
|
|
2225
|
-
const index = i - Math.floor(i /
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2359
|
+
if (activeColIndexWithShift < loopedSlides) {
|
|
2360
|
+
slidesPrepended = Math.max(loopedSlides - activeColIndexWithShift, slidesPerGroup);
|
|
2361
|
+
for (let i = 0; i < loopedSlides - activeColIndexWithShift; i += 1) {
|
|
2362
|
+
const index = i - Math.floor(i / cols) * cols;
|
|
2363
|
+
if (gridEnabled) {
|
|
2364
|
+
const colIndexToPrepend = cols - index - 1;
|
|
2365
|
+
for (let i = slides.length - 1; i >= 0; i -= 1) {
|
|
2366
|
+
if (slides[i].column === colIndexToPrepend) prependSlidesIndexes.push(i);
|
|
2367
|
+
}
|
|
2368
|
+
// slides.forEach((slide, slideIndex) => {
|
|
2369
|
+
// if (slide.column === colIndexToPrepend) prependSlidesIndexes.push(slideIndex);
|
|
2370
|
+
// });
|
|
2371
|
+
} else {
|
|
2372
|
+
prependSlidesIndexes.push(cols - index - 1);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
} else if (activeColIndexWithShift + slidesPerView > cols - loopedSlides) {
|
|
2376
|
+
slidesAppended = Math.max(activeColIndexWithShift - (cols - loopedSlides * 2), slidesPerGroup);
|
|
2230
2377
|
for (let i = 0; i < slidesAppended; i += 1) {
|
|
2231
|
-
const index = i - Math.floor(i /
|
|
2232
|
-
|
|
2378
|
+
const index = i - Math.floor(i / cols) * cols;
|
|
2379
|
+
if (gridEnabled) {
|
|
2380
|
+
slides.forEach((slide, slideIndex) => {
|
|
2381
|
+
if (slide.column === index) appendSlidesIndexes.push(slideIndex);
|
|
2382
|
+
});
|
|
2383
|
+
} else {
|
|
2384
|
+
appendSlidesIndexes.push(index);
|
|
2385
|
+
}
|
|
2233
2386
|
}
|
|
2234
2387
|
}
|
|
2388
|
+
swiper.__preventObserver__ = true;
|
|
2389
|
+
requestAnimationFrame(() => {
|
|
2390
|
+
swiper.__preventObserver__ = false;
|
|
2391
|
+
});
|
|
2235
2392
|
if (isPrev) {
|
|
2236
2393
|
prependSlidesIndexes.forEach(index => {
|
|
2237
|
-
|
|
2238
|
-
slidesEl.prepend(
|
|
2239
|
-
|
|
2394
|
+
slides[index].swiperLoopMoveDOM = true;
|
|
2395
|
+
slidesEl.prepend(slides[index]);
|
|
2396
|
+
slides[index].swiperLoopMoveDOM = false;
|
|
2240
2397
|
});
|
|
2241
2398
|
}
|
|
2242
2399
|
if (isNext) {
|
|
2243
2400
|
appendSlidesIndexes.forEach(index => {
|
|
2244
|
-
|
|
2245
|
-
slidesEl.append(
|
|
2246
|
-
|
|
2401
|
+
slides[index].swiperLoopMoveDOM = true;
|
|
2402
|
+
slidesEl.append(slides[index]);
|
|
2403
|
+
slides[index].swiperLoopMoveDOM = false;
|
|
2247
2404
|
});
|
|
2248
2405
|
}
|
|
2249
2406
|
swiper.recalcSlides();
|
|
2250
2407
|
if (params.slidesPerView === 'auto') {
|
|
2251
2408
|
swiper.updateSlides();
|
|
2409
|
+
} else if (gridEnabled && (prependSlidesIndexes.length > 0 && isPrev || appendSlidesIndexes.length > 0 && isNext)) {
|
|
2410
|
+
swiper.slides.forEach((slide, slideIndex) => {
|
|
2411
|
+
swiper.grid.updateSlide(slideIndex, slide, swiper.slides);
|
|
2412
|
+
});
|
|
2252
2413
|
}
|
|
2253
2414
|
if (params.watchSlidesProgress) {
|
|
2254
2415
|
swiper.updateSlidesOffset();
|
|
@@ -2264,13 +2425,14 @@ function loopFix(_temp) {
|
|
|
2264
2425
|
} else {
|
|
2265
2426
|
swiper.slideTo(activeIndex + slidesPrepended, 0, false, true);
|
|
2266
2427
|
if (setTranslate) {
|
|
2267
|
-
swiper.
|
|
2268
|
-
swiper.touchEventsData.currentTranslate = swiper.
|
|
2428
|
+
swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
|
2429
|
+
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2269
2430
|
}
|
|
2270
2431
|
}
|
|
2271
2432
|
} else {
|
|
2272
2433
|
if (setTranslate) {
|
|
2273
|
-
|
|
2434
|
+
const shift = gridEnabled ? prependSlidesIndexes.length / params.grid.rows : prependSlidesIndexes.length;
|
|
2435
|
+
swiper.slideTo(swiper.activeIndex + shift, 0, false, true);
|
|
2274
2436
|
swiper.touchEventsData.currentTranslate = swiper.translate;
|
|
2275
2437
|
}
|
|
2276
2438
|
}
|
|
@@ -2284,12 +2446,13 @@ function loopFix(_temp) {
|
|
|
2284
2446
|
} else {
|
|
2285
2447
|
swiper.slideTo(activeIndex - slidesAppended, 0, false, true);
|
|
2286
2448
|
if (setTranslate) {
|
|
2287
|
-
swiper.
|
|
2288
|
-
swiper.touchEventsData.currentTranslate = swiper.
|
|
2449
|
+
swiper.touchEventsData.startTranslate = swiper.touchEventsData.startTranslate - diff;
|
|
2450
|
+
swiper.touchEventsData.currentTranslate = swiper.touchEventsData.currentTranslate - diff;
|
|
2289
2451
|
}
|
|
2290
2452
|
}
|
|
2291
2453
|
} else {
|
|
2292
|
-
|
|
2454
|
+
const shift = gridEnabled ? appendSlidesIndexes.length / params.grid.rows : appendSlidesIndexes.length;
|
|
2455
|
+
swiper.slideTo(swiper.activeIndex - shift, 0, false, true);
|
|
2293
2456
|
}
|
|
2294
2457
|
}
|
|
2295
2458
|
}
|
|
@@ -2402,27 +2565,54 @@ function closestElement(selector, base) {
|
|
|
2402
2565
|
}
|
|
2403
2566
|
return __closestFrom(base);
|
|
2404
2567
|
}
|
|
2568
|
+
function preventEdgeSwipe(swiper, event, startX) {
|
|
2569
|
+
const window = getWindow();
|
|
2570
|
+
const {
|
|
2571
|
+
params
|
|
2572
|
+
} = swiper;
|
|
2573
|
+
const edgeSwipeDetection = params.edgeSwipeDetection;
|
|
2574
|
+
const edgeSwipeThreshold = params.edgeSwipeThreshold;
|
|
2575
|
+
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
|
2576
|
+
if (edgeSwipeDetection === 'prevent') {
|
|
2577
|
+
event.preventDefault();
|
|
2578
|
+
return true;
|
|
2579
|
+
}
|
|
2580
|
+
return false;
|
|
2581
|
+
}
|
|
2582
|
+
return true;
|
|
2583
|
+
}
|
|
2405
2584
|
function onTouchStart(event) {
|
|
2406
2585
|
const swiper = this;
|
|
2407
2586
|
const document = getDocument();
|
|
2408
|
-
|
|
2587
|
+
let e = event;
|
|
2588
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
2409
2589
|
const data = swiper.touchEventsData;
|
|
2410
|
-
|
|
2590
|
+
if (e.type === 'pointerdown') {
|
|
2591
|
+
if (data.pointerId !== null && data.pointerId !== e.pointerId) {
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
data.pointerId = e.pointerId;
|
|
2595
|
+
} else if (e.type === 'touchstart' && e.targetTouches.length === 1) {
|
|
2596
|
+
data.touchId = e.targetTouches[0].identifier;
|
|
2597
|
+
}
|
|
2598
|
+
if (e.type === 'touchstart') {
|
|
2599
|
+
// don't proceed touch event
|
|
2600
|
+
preventEdgeSwipe(swiper, e, e.targetTouches[0].pageX);
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2411
2603
|
const {
|
|
2412
2604
|
params,
|
|
2413
2605
|
touches,
|
|
2414
2606
|
enabled
|
|
2415
2607
|
} = swiper;
|
|
2416
2608
|
if (!enabled) return;
|
|
2417
|
-
if (!params.simulateTouch &&
|
|
2609
|
+
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
2418
2610
|
if (swiper.animating && params.preventInteractionOnTransition) {
|
|
2419
2611
|
return;
|
|
2420
2612
|
}
|
|
2421
2613
|
if (!swiper.animating && params.cssMode && params.loop) {
|
|
2422
2614
|
swiper.loopFix();
|
|
2423
2615
|
}
|
|
2424
|
-
let e = event;
|
|
2425
|
-
if (e.originalEvent) e = e.originalEvent;
|
|
2426
2616
|
let targetEl = e.target;
|
|
2427
2617
|
if (params.touchEventsTarget === 'wrapper') {
|
|
2428
2618
|
if (!swiper.wrapperEl.contains(targetEl)) return;
|
|
@@ -2434,7 +2624,7 @@ function onTouchStart(event) {
|
|
|
2434
2624
|
// change target el for shadow root component
|
|
2435
2625
|
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
|
2436
2626
|
// eslint-disable-next-line
|
|
2437
|
-
const eventPath =
|
|
2627
|
+
const eventPath = e.composedPath ? e.composedPath() : e.path;
|
|
2438
2628
|
if (swipingClassHasValue && e.target && e.target.shadowRoot && eventPath) {
|
|
2439
2629
|
targetEl = eventPath[0];
|
|
2440
2630
|
}
|
|
@@ -2456,14 +2646,8 @@ function onTouchStart(event) {
|
|
|
2456
2646
|
|
|
2457
2647
|
// Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
|
|
2458
2648
|
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
|
2462
|
-
if (edgeSwipeDetection === 'prevent') {
|
|
2463
|
-
event.preventDefault();
|
|
2464
|
-
} else {
|
|
2465
|
-
return;
|
|
2466
|
-
}
|
|
2649
|
+
if (!preventEdgeSwipe(swiper, e, startX)) {
|
|
2650
|
+
return;
|
|
2467
2651
|
}
|
|
2468
2652
|
Object.assign(data, {
|
|
2469
2653
|
isTouched: true,
|
|
@@ -2513,15 +2697,24 @@ function onTouchMove(event) {
|
|
|
2513
2697
|
if (!params.simulateTouch && event.pointerType === 'mouse') return;
|
|
2514
2698
|
let e = event;
|
|
2515
2699
|
if (e.originalEvent) e = e.originalEvent;
|
|
2700
|
+
if (e.type === 'pointermove') {
|
|
2701
|
+
if (data.touchId !== null) return; // return from pointer if we use touch
|
|
2702
|
+
const id = e.pointerId;
|
|
2703
|
+
if (id !== data.pointerId) return;
|
|
2704
|
+
}
|
|
2705
|
+
let targetTouch;
|
|
2706
|
+
if (e.type === 'touchmove') {
|
|
2707
|
+
targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
|
|
2708
|
+
if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
|
2709
|
+
} else {
|
|
2710
|
+
targetTouch = e;
|
|
2711
|
+
}
|
|
2516
2712
|
if (!data.isTouched) {
|
|
2517
2713
|
if (data.startMoving && data.isScrolling) {
|
|
2518
2714
|
swiper.emit('touchMoveOpposite', e);
|
|
2519
2715
|
}
|
|
2520
2716
|
return;
|
|
2521
2717
|
}
|
|
2522
|
-
const pointerIndex = data.evCache.findIndex(cachedEv => cachedEv.pointerId === e.pointerId);
|
|
2523
|
-
if (pointerIndex >= 0) data.evCache[pointerIndex] = e;
|
|
2524
|
-
const targetTouch = data.evCache.length > 1 ? data.evCache[0] : e;
|
|
2525
2718
|
const pageX = targetTouch.pageX;
|
|
2526
2719
|
const pageY = targetTouch.pageY;
|
|
2527
2720
|
if (e.preventedByNestedSwiper) {
|
|
@@ -2537,8 +2730,6 @@ function onTouchMove(event) {
|
|
|
2537
2730
|
Object.assign(touches, {
|
|
2538
2731
|
startX: pageX,
|
|
2539
2732
|
startY: pageY,
|
|
2540
|
-
prevX: swiper.touches.currentX,
|
|
2541
|
-
prevY: swiper.touches.currentY,
|
|
2542
2733
|
currentX: pageX,
|
|
2543
2734
|
currentY: pageY
|
|
2544
2735
|
});
|
|
@@ -2568,7 +2759,8 @@ function onTouchMove(event) {
|
|
|
2568
2759
|
if (data.allowTouchCallbacks) {
|
|
2569
2760
|
swiper.emit('touchMove', e);
|
|
2570
2761
|
}
|
|
2571
|
-
|
|
2762
|
+
touches.previousX = touches.currentX;
|
|
2763
|
+
touches.previousY = touches.currentY;
|
|
2572
2764
|
touches.currentX = pageX;
|
|
2573
2765
|
touches.currentY = pageY;
|
|
2574
2766
|
const diffX = touches.currentX - touches.startX;
|
|
@@ -2594,7 +2786,7 @@ function onTouchMove(event) {
|
|
|
2594
2786
|
data.startMoving = true;
|
|
2595
2787
|
}
|
|
2596
2788
|
}
|
|
2597
|
-
if (data.isScrolling
|
|
2789
|
+
if (data.isScrolling) {
|
|
2598
2790
|
data.isTouched = false;
|
|
2599
2791
|
return;
|
|
2600
2792
|
}
|
|
@@ -2624,7 +2816,7 @@ function onTouchMove(event) {
|
|
|
2624
2816
|
swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
|
2625
2817
|
swiper.touchesDirection = touchesDiff > 0 ? 'prev' : 'next';
|
|
2626
2818
|
const isLoop = swiper.params.loop && !params.cssMode;
|
|
2627
|
-
const allowLoopFix = swiper.
|
|
2819
|
+
const allowLoopFix = swiper.touchesDirection === 'next' && swiper.allowSlideNext || swiper.touchesDirection === 'prev' && swiper.allowSlidePrev;
|
|
2628
2820
|
if (!data.isMoved) {
|
|
2629
2821
|
if (isLoop && allowLoopFix) {
|
|
2630
2822
|
swiper.loopFix({
|
|
@@ -2648,13 +2840,18 @@ function onTouchMove(event) {
|
|
|
2648
2840
|
swiper.emit('sliderFirstMove', e);
|
|
2649
2841
|
}
|
|
2650
2842
|
let loopFixed;
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2843
|
+
new Date().getTime();
|
|
2844
|
+
if (data.isMoved && data.allowThresholdMove && prevTouchesDirection !== swiper.touchesDirection && isLoop && allowLoopFix && Math.abs(diff) >= 1) {
|
|
2845
|
+
Object.assign(touches, {
|
|
2846
|
+
startX: pageX,
|
|
2847
|
+
startY: pageY,
|
|
2848
|
+
currentX: pageX,
|
|
2849
|
+
currentY: pageY,
|
|
2850
|
+
startTranslate: data.currentTranslate
|
|
2656
2851
|
});
|
|
2657
|
-
|
|
2852
|
+
data.loopSwapReset = true;
|
|
2853
|
+
data.startTranslate = data.currentTranslate;
|
|
2854
|
+
return;
|
|
2658
2855
|
}
|
|
2659
2856
|
swiper.emit('sliderMove', e);
|
|
2660
2857
|
data.isMoved = true;
|
|
@@ -2665,7 +2862,7 @@ function onTouchMove(event) {
|
|
|
2665
2862
|
resistanceRatio = 0;
|
|
2666
2863
|
}
|
|
2667
2864
|
if (diff > 0) {
|
|
2668
|
-
if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.
|
|
2865
|
+
if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate > (params.centeredSlides ? swiper.minTranslate() - swiper.slidesSizesGrid[swiper.activeIndex + 1] : swiper.minTranslate())) {
|
|
2669
2866
|
swiper.loopFix({
|
|
2670
2867
|
direction: 'prev',
|
|
2671
2868
|
setTranslate: true,
|
|
@@ -2679,7 +2876,7 @@ function onTouchMove(event) {
|
|
|
2679
2876
|
}
|
|
2680
2877
|
}
|
|
2681
2878
|
} else if (diff < 0) {
|
|
2682
|
-
if (isLoop && allowLoopFix && !loopFixed && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.
|
|
2879
|
+
if (isLoop && allowLoopFix && !loopFixed && data.allowThresholdMove && data.currentTranslate < (params.centeredSlides ? swiper.maxTranslate() + swiper.slidesSizesGrid[swiper.slidesSizesGrid.length - 1] : swiper.maxTranslate())) {
|
|
2683
2880
|
swiper.loopFix({
|
|
2684
2881
|
direction: 'next',
|
|
2685
2882
|
setTranslate: true,
|
|
@@ -2743,16 +2940,26 @@ function onTouchMove(event) {
|
|
|
2743
2940
|
function onTouchEnd(event) {
|
|
2744
2941
|
const swiper = this;
|
|
2745
2942
|
const data = swiper.touchEventsData;
|
|
2746
|
-
|
|
2747
|
-
if (
|
|
2748
|
-
|
|
2943
|
+
let e = event;
|
|
2944
|
+
if (e.originalEvent) e = e.originalEvent;
|
|
2945
|
+
let targetTouch;
|
|
2946
|
+
const isTouchEvent = e.type === 'touchend' || e.type === 'touchcancel';
|
|
2947
|
+
if (!isTouchEvent) {
|
|
2948
|
+
if (data.touchId !== null) return; // return from pointer if we use touch
|
|
2949
|
+
if (e.pointerId !== data.pointerId) return;
|
|
2950
|
+
targetTouch = e;
|
|
2951
|
+
} else {
|
|
2952
|
+
targetTouch = [...e.changedTouches].filter(t => t.identifier === data.touchId)[0];
|
|
2953
|
+
if (!targetTouch || targetTouch.identifier !== data.touchId) return;
|
|
2749
2954
|
}
|
|
2750
|
-
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(
|
|
2751
|
-
const proceed = ['pointercancel', 'contextmenu'].includes(
|
|
2955
|
+
if (['pointercancel', 'pointerout', 'pointerleave', 'contextmenu'].includes(e.type)) {
|
|
2956
|
+
const proceed = ['pointercancel', 'contextmenu'].includes(e.type) && (swiper.browser.isSafari || swiper.browser.isWebView);
|
|
2752
2957
|
if (!proceed) {
|
|
2753
2958
|
return;
|
|
2754
2959
|
}
|
|
2755
2960
|
}
|
|
2961
|
+
data.pointerId = null;
|
|
2962
|
+
data.touchId = null;
|
|
2756
2963
|
const {
|
|
2757
2964
|
params,
|
|
2758
2965
|
touches,
|
|
@@ -2761,9 +2968,7 @@ function onTouchEnd(event) {
|
|
|
2761
2968
|
enabled
|
|
2762
2969
|
} = swiper;
|
|
2763
2970
|
if (!enabled) return;
|
|
2764
|
-
if (!params.simulateTouch &&
|
|
2765
|
-
let e = event;
|
|
2766
|
-
if (e.originalEvent) e = e.originalEvent;
|
|
2971
|
+
if (!params.simulateTouch && e.pointerType === 'mouse') return;
|
|
2767
2972
|
if (data.allowTouchCallbacks) {
|
|
2768
2973
|
swiper.emit('touchEnd', e);
|
|
2769
2974
|
}
|
|
@@ -2776,6 +2981,7 @@ function onTouchEnd(event) {
|
|
|
2776
2981
|
data.startMoving = false;
|
|
2777
2982
|
return;
|
|
2778
2983
|
}
|
|
2984
|
+
|
|
2779
2985
|
// Return Grab Cursor
|
|
2780
2986
|
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
|
2781
2987
|
swiper.setGrabCursor(false);
|
|
@@ -2798,7 +3004,7 @@ function onTouchEnd(event) {
|
|
|
2798
3004
|
nextTick(() => {
|
|
2799
3005
|
if (!swiper.destroyed) swiper.allowClick = true;
|
|
2800
3006
|
});
|
|
2801
|
-
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
|
|
3007
|
+
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 && !data.loopSwapReset || data.currentTranslate === data.startTranslate && !data.loopSwapReset) {
|
|
2802
3008
|
data.isTouched = false;
|
|
2803
3009
|
data.isMoved = false;
|
|
2804
3010
|
data.startMoving = false;
|
|
@@ -2995,8 +3201,15 @@ function onLoad(e) {
|
|
|
2995
3201
|
swiper.update();
|
|
2996
3202
|
}
|
|
2997
3203
|
|
|
2998
|
-
|
|
2999
|
-
|
|
3204
|
+
function onDocumentTouchStart() {
|
|
3205
|
+
const swiper = this;
|
|
3206
|
+
if (swiper.documentTouchHandlerProceeded) return;
|
|
3207
|
+
swiper.documentTouchHandlerProceeded = true;
|
|
3208
|
+
if (swiper.params.touchReleaseOnEdges) {
|
|
3209
|
+
swiper.el.style.touchAction = 'auto';
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3000
3213
|
const events = (swiper, method) => {
|
|
3001
3214
|
const document = getDocument();
|
|
3002
3215
|
const {
|
|
@@ -3010,19 +3223,36 @@ const events = (swiper, method) => {
|
|
|
3010
3223
|
const swiperMethod = method;
|
|
3011
3224
|
|
|
3012
3225
|
// Touch Events
|
|
3226
|
+
document[domMethod]('touchstart', swiper.onDocumentTouchStart, {
|
|
3227
|
+
passive: false,
|
|
3228
|
+
capture
|
|
3229
|
+
});
|
|
3230
|
+
el[domMethod]('touchstart', swiper.onTouchStart, {
|
|
3231
|
+
passive: false
|
|
3232
|
+
});
|
|
3013
3233
|
el[domMethod]('pointerdown', swiper.onTouchStart, {
|
|
3014
3234
|
passive: false
|
|
3015
3235
|
});
|
|
3236
|
+
document[domMethod]('touchmove', swiper.onTouchMove, {
|
|
3237
|
+
passive: false,
|
|
3238
|
+
capture
|
|
3239
|
+
});
|
|
3016
3240
|
document[domMethod]('pointermove', swiper.onTouchMove, {
|
|
3017
3241
|
passive: false,
|
|
3018
3242
|
capture
|
|
3019
3243
|
});
|
|
3244
|
+
document[domMethod]('touchend', swiper.onTouchEnd, {
|
|
3245
|
+
passive: true
|
|
3246
|
+
});
|
|
3020
3247
|
document[domMethod]('pointerup', swiper.onTouchEnd, {
|
|
3021
3248
|
passive: true
|
|
3022
3249
|
});
|
|
3023
3250
|
document[domMethod]('pointercancel', swiper.onTouchEnd, {
|
|
3024
3251
|
passive: true
|
|
3025
3252
|
});
|
|
3253
|
+
document[domMethod]('touchcancel', swiper.onTouchEnd, {
|
|
3254
|
+
passive: true
|
|
3255
|
+
});
|
|
3026
3256
|
document[domMethod]('pointerout', swiper.onTouchEnd, {
|
|
3027
3257
|
passive: true
|
|
3028
3258
|
});
|
|
@@ -3055,22 +3285,18 @@ const events = (swiper, method) => {
|
|
|
3055
3285
|
};
|
|
3056
3286
|
function attachEvents() {
|
|
3057
3287
|
const swiper = this;
|
|
3058
|
-
const document = getDocument();
|
|
3059
3288
|
const {
|
|
3060
3289
|
params
|
|
3061
3290
|
} = swiper;
|
|
3062
3291
|
swiper.onTouchStart = onTouchStart.bind(swiper);
|
|
3063
3292
|
swiper.onTouchMove = onTouchMove.bind(swiper);
|
|
3064
3293
|
swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
|
3294
|
+
swiper.onDocumentTouchStart = onDocumentTouchStart.bind(swiper);
|
|
3065
3295
|
if (params.cssMode) {
|
|
3066
3296
|
swiper.onScroll = onScroll.bind(swiper);
|
|
3067
3297
|
}
|
|
3068
3298
|
swiper.onClick = onClick.bind(swiper);
|
|
3069
3299
|
swiper.onLoad = onLoad.bind(swiper);
|
|
3070
|
-
if (!dummyEventAttached) {
|
|
3071
|
-
document.addEventListener('touchstart', dummyEventListener);
|
|
3072
|
-
dummyEventAttached = true;
|
|
3073
|
-
}
|
|
3074
3300
|
events(swiper, 'on');
|
|
3075
3301
|
}
|
|
3076
3302
|
function detachEvents() {
|
|
@@ -3318,6 +3544,7 @@ var defaults = {
|
|
|
3318
3544
|
resizeObserver: true,
|
|
3319
3545
|
nested: false,
|
|
3320
3546
|
createElements: false,
|
|
3547
|
+
eventsPrefix: 'swiper',
|
|
3321
3548
|
enabled: true,
|
|
3322
3549
|
focusableElements: 'input, select, option, textarea, button, video, label',
|
|
3323
3550
|
// Overrides
|
|
@@ -3392,7 +3619,8 @@ var defaults = {
|
|
|
3392
3619
|
slideToClickedSlide: false,
|
|
3393
3620
|
// loop
|
|
3394
3621
|
loop: false,
|
|
3395
|
-
|
|
3622
|
+
loopAddBlankSlides: true,
|
|
3623
|
+
loopAdditionalSlides: 0,
|
|
3396
3624
|
loopPreventsSliding: true,
|
|
3397
3625
|
// rewind
|
|
3398
3626
|
rewind: false,
|
|
@@ -3411,8 +3639,10 @@ var defaults = {
|
|
|
3411
3639
|
containerModifierClass: 'swiper-',
|
|
3412
3640
|
// NEW
|
|
3413
3641
|
slideClass: 'swiper-slide',
|
|
3642
|
+
slideBlankClass: 'swiper-slide-blank',
|
|
3414
3643
|
slideActiveClass: 'swiper-slide-active',
|
|
3415
3644
|
slideVisibleClass: 'swiper-slide-visible',
|
|
3645
|
+
slideFullyVisibleClass: 'swiper-slide-fully-visible',
|
|
3416
3646
|
slideNextClass: 'swiper-slide-next',
|
|
3417
3647
|
slidePrevClass: 'swiper-slide-prev',
|
|
3418
3648
|
wrapperClass: 'swiper-wrapper',
|
|
@@ -3605,7 +3835,8 @@ let Swiper$2 = class Swiper {
|
|
|
3605
3835
|
velocities: [],
|
|
3606
3836
|
allowMomentumBounce: undefined,
|
|
3607
3837
|
startMoving: undefined,
|
|
3608
|
-
|
|
3838
|
+
pointerId: null,
|
|
3839
|
+
touchId: null
|
|
3609
3840
|
},
|
|
3610
3841
|
// Clicks
|
|
3611
3842
|
allowClick: true,
|
|
@@ -3633,6 +3864,22 @@ let Swiper$2 = class Swiper {
|
|
|
3633
3864
|
// eslint-disable-next-line no-constructor-return
|
|
3634
3865
|
return swiper;
|
|
3635
3866
|
}
|
|
3867
|
+
getDirectionLabel(property) {
|
|
3868
|
+
if (this.isHorizontal()) {
|
|
3869
|
+
return property;
|
|
3870
|
+
}
|
|
3871
|
+
// prettier-ignore
|
|
3872
|
+
return {
|
|
3873
|
+
'width': 'height',
|
|
3874
|
+
'margin-top': 'margin-left',
|
|
3875
|
+
'margin-bottom ': 'margin-right',
|
|
3876
|
+
'margin-left': 'margin-top',
|
|
3877
|
+
'margin-right': 'margin-bottom',
|
|
3878
|
+
'padding-left': 'padding-top',
|
|
3879
|
+
'padding-right': 'padding-bottom',
|
|
3880
|
+
'marginRight': 'marginBottom'
|
|
3881
|
+
}[property];
|
|
3882
|
+
}
|
|
3636
3883
|
getSlideIndex(slideEl) {
|
|
3637
3884
|
const {
|
|
3638
3885
|
slidesEl,
|
|
@@ -4010,7 +4257,7 @@ let Swiper$2 = class Swiper {
|
|
|
4010
4257
|
wrapperEl.removeAttribute('style');
|
|
4011
4258
|
if (slides && slides.length) {
|
|
4012
4259
|
slides.forEach(slideEl => {
|
|
4013
|
-
slideEl.classList.remove(params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
4260
|
+
slideEl.classList.remove(params.slideVisibleClass, params.slideFullyVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass);
|
|
4014
4261
|
slideEl.removeAttribute('style');
|
|
4015
4262
|
slideEl.removeAttribute('data-swiper-slide-index');
|
|
4016
4263
|
});
|
|
@@ -4062,7 +4309,7 @@ Object.keys(prototypes).forEach(prototypeGroup => {
|
|
|
4062
4309
|
Swiper$2.use([Resize, Observer]);
|
|
4063
4310
|
|
|
4064
4311
|
/* underscore in name -> watch for changes */
|
|
4065
|
-
const paramsList = ['eventsPrefix', 'injectStyles', 'injectStylesUrls', 'modules', 'init', '_direction', 'oneWayMovement', 'touchEventsTarget', 'initialSlide', '_speed', 'cssMode', 'updateOnWindowResize', 'resizeObserver', 'nested', 'focusableElements', '_enabled', '_width', '_height', 'preventInteractionOnTransition', 'userAgent', 'url', '_edgeSwipeDetection', '_edgeSwipeThreshold', '_freeMode', '_autoHeight', 'setWrapperSize', 'virtualTranslate', '_effect', 'breakpoints', 'breakpointsBase', '_spaceBetween', '_slidesPerView', 'maxBackfaceHiddenSlides', '_grid', '_slidesPerGroup', '_slidesPerGroupSkip', '_slidesPerGroupAuto', '_centeredSlides', '_centeredSlidesBounds', '_slidesOffsetBefore', '_slidesOffsetAfter', 'normalizeSlideIndex', '_centerInsufficientSlides', '_watchOverflow', 'roundLengths', 'touchRatio', 'touchAngle', 'simulateTouch', '_shortSwipes', '_longSwipes', 'longSwipesRatio', 'longSwipesMs', '_followFinger', 'allowTouchMove', '_threshold', 'touchMoveStopPropagation', 'touchStartPreventDefault', 'touchStartForcePreventDefault', 'touchReleaseOnEdges', 'uniqueNavElements', '_resistance', '_resistanceRatio', '_watchSlidesProgress', '_grabCursor', 'preventClicks', 'preventClicksPropagation', '_slideToClickedSlide', '_loop', '
|
|
4312
|
+
const paramsList = ['eventsPrefix', 'injectStyles', 'injectStylesUrls', 'modules', 'init', '_direction', 'oneWayMovement', 'touchEventsTarget', 'initialSlide', '_speed', 'cssMode', 'updateOnWindowResize', 'resizeObserver', 'nested', 'focusableElements', '_enabled', '_width', '_height', 'preventInteractionOnTransition', 'userAgent', 'url', '_edgeSwipeDetection', '_edgeSwipeThreshold', '_freeMode', '_autoHeight', 'setWrapperSize', 'virtualTranslate', '_effect', 'breakpoints', 'breakpointsBase', '_spaceBetween', '_slidesPerView', 'maxBackfaceHiddenSlides', '_grid', '_slidesPerGroup', '_slidesPerGroupSkip', '_slidesPerGroupAuto', '_centeredSlides', '_centeredSlidesBounds', '_slidesOffsetBefore', '_slidesOffsetAfter', 'normalizeSlideIndex', '_centerInsufficientSlides', '_watchOverflow', 'roundLengths', 'touchRatio', 'touchAngle', 'simulateTouch', '_shortSwipes', '_longSwipes', 'longSwipesRatio', 'longSwipesMs', '_followFinger', 'allowTouchMove', '_threshold', 'touchMoveStopPropagation', 'touchStartPreventDefault', 'touchStartForcePreventDefault', 'touchReleaseOnEdges', 'uniqueNavElements', '_resistance', '_resistanceRatio', '_watchSlidesProgress', '_grabCursor', 'preventClicks', 'preventClicksPropagation', '_slideToClickedSlide', '_loop', 'loopAdditionalSlides', 'loopAddBlankSlides', 'loopPreventsSliding', '_rewind', '_allowSlidePrev', '_allowSlideNext', '_swipeHandler', '_noSwiping', 'noSwipingClass', 'noSwipingSelector', 'passiveListeners', 'containerModifierClass', 'slideClass', 'slideActiveClass', 'slideVisibleClass', 'slideFullyVisibleClass', 'slideNextClass', 'slidePrevClass', 'slideBlankClass', 'wrapperClass', 'lazyPreloaderClass', 'lazyPreloadPrevNext', 'runCallbacksOnInit', 'observer', 'observeParents', 'observeSlideChildren',
|
|
4066
4313
|
// modules
|
|
4067
4314
|
'a11y', '_autoplay', '_controller', 'coverflowEffect', 'cubeEffect', 'fadeEffect', 'flipEffect', 'creativeEffect', 'cardsEffect', 'hashNavigation', 'history', 'keyboard', 'mousewheel', '_navigation', '_pagination', 'parallax', '_scrollbar', '_thumbs', 'virtual', 'zoom', 'control'];
|
|
4068
4315
|
|
|
@@ -4191,7 +4438,7 @@ function updateSwiper(_ref) {
|
|
|
4191
4438
|
}
|
|
4192
4439
|
updateParams.forEach(key => {
|
|
4193
4440
|
if (isObject(currentParams[key]) && isObject(passedParams[key])) {
|
|
4194
|
-
|
|
4441
|
+
Object.assign(currentParams[key], passedParams[key]);
|
|
4195
4442
|
if ((key === 'navigation' || key === 'pagination' || key === 'scrollbar') && 'enabled' in passedParams[key] && !passedParams[key].enabled) {
|
|
4196
4443
|
destroyModule(key);
|
|
4197
4444
|
}
|
|
@@ -4212,6 +4459,9 @@ function updateSwiper(_ref) {
|
|
|
4212
4459
|
if (changedParams.includes('children') && slides && virtual && currentParams.virtual.enabled) {
|
|
4213
4460
|
virtual.slides = slides;
|
|
4214
4461
|
virtual.update(true);
|
|
4462
|
+
} else if (changedParams.includes('virtual') && virtual && currentParams.virtual.enabled) {
|
|
4463
|
+
if (slides) virtual.slides = slides;
|
|
4464
|
+
virtual.update(true);
|
|
4215
4465
|
}
|
|
4216
4466
|
if (changedParams.includes('children') && slides && currentParams.loop) {
|
|
4217
4467
|
loopNeedReloop = true;
|
|
@@ -4414,7 +4664,7 @@ const updateOnVirtualData = swiper => {
|
|
|
4414
4664
|
};
|
|
4415
4665
|
|
|
4416
4666
|
/**
|
|
4417
|
-
* Swiper React
|
|
4667
|
+
* Swiper React 11.0.3
|
|
4418
4668
|
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
|
4419
4669
|
* https://swiperjs.com
|
|
4420
4670
|
*
|
|
@@ -4422,7 +4672,7 @@ const updateOnVirtualData = swiper => {
|
|
|
4422
4672
|
*
|
|
4423
4673
|
* Released under the MIT License
|
|
4424
4674
|
*
|
|
4425
|
-
* Released on:
|
|
4675
|
+
* Released on: October 26, 2023
|
|
4426
4676
|
*/
|
|
4427
4677
|
|
|
4428
4678
|
|