@gem-sdk/swiper 0.0.7 → 0.0.9
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/modules/a11y.min.mjs +1 -1
- package/modules/a11y.mjs +1 -1
- package/modules/pagination.min.mjs +1 -1
- package/modules/pagination.min.mjs.map +1 -1
- package/modules/pagination.mjs +20 -16
- package/package.json +3 -3
- package/shared/swiper-core.min.mjs +1 -1
- package/shared/swiper-core.min.mjs.map +1 -1
- package/shared/swiper-core.mjs +425 -52
- package/shared/update-swiper.min.mjs +1 -1
- package/shared/update-swiper.min.mjs.map +1 -1
- package/shared/update-swiper.mjs +1 -1
- package/shared/utils.min.mjs +1 -1
- package/shared/utils.min.mjs.map +1 -1
- package/shared/utils.mjs +1 -1
- package/swiper-bundle.css +2 -2
- package/swiper-bundle.js +448 -71
- 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 +451 -74
- 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.d.ts +5 -0
- package/swiper-element.js +429 -56
- 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.d.ts +5 -0
- package/swiper-react.mjs +2 -2
- package/swiper-vue.d.ts +9 -0
- package/swiper-vue.mjs +7 -3
- package/swiper.css +2 -2
- package/swiper.js +426 -53
- 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-class.d.ts +10 -0
- package/types/swiper-events.d.ts +5 -0
- package/types/swiper-options.d.ts +7 -0
package/shared/swiper-core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as getWindow, g as getDocument } from './ssr-window.esm.mjs';
|
|
2
|
-
import { b as elementParents, q as elementStyle, e as elementChildren, a as setCSSProperty,
|
|
2
|
+
import { b as elementParents, q as elementStyle, e as elementChildren, a as setCSSProperty, i as elementOuterSize, r as elementNextAll, t as elementPrevAll, k as getTranslate, u as animateCSSModeScroll, n as nextTick, v as showWarning, c as createElement, w as elementIsChildOf, f as now, x as extend, h as elementIndex, y as deleteProps } from './utils.mjs';
|
|
3
3
|
|
|
4
4
|
let support;
|
|
5
5
|
function calcSupport() {
|
|
@@ -1541,56 +1541,63 @@ function slideToLoop(index, speed, runCallbacks, internal) {
|
|
|
1541
1541
|
if (typeof speed === 'undefined') {
|
|
1542
1542
|
speed = swiper.params.speed;
|
|
1543
1543
|
}
|
|
1544
|
-
const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1;
|
|
1545
1544
|
let newIndex = index;
|
|
1546
1545
|
if (swiper.params.loop) {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1546
|
+
swiper.slides;
|
|
1547
|
+
const totalSlides = swiper.slides.length;
|
|
1548
|
+
let targetSlideIndex;
|
|
1549
|
+
targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
|
1550
|
+
const cols = swiper.slides.length;
|
|
1551
|
+
const {
|
|
1552
|
+
centeredSlides
|
|
1553
|
+
} = swiper.params;
|
|
1554
|
+
let slidesPerView = swiper.params.slidesPerView;
|
|
1555
|
+
if (slidesPerView === 'auto') {
|
|
1556
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
1550
1557
|
} else {
|
|
1551
|
-
|
|
1552
|
-
if (
|
|
1553
|
-
|
|
1554
|
-
targetSlideIndex = swiper.slides.find(slideEl => slideEl.getAttribute('data-swiper-slide-index') * 1 === slideIndex).column;
|
|
1555
|
-
} else {
|
|
1556
|
-
targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
|
1557
|
-
}
|
|
1558
|
-
const cols = gridEnabled ? Math.ceil(swiper.slides.length / swiper.params.grid.rows) : swiper.slides.length;
|
|
1559
|
-
const {
|
|
1560
|
-
centeredSlides
|
|
1561
|
-
} = swiper.params;
|
|
1562
|
-
let slidesPerView = swiper.params.slidesPerView;
|
|
1563
|
-
if (slidesPerView === 'auto') {
|
|
1564
|
-
slidesPerView = swiper.slidesPerViewDynamic();
|
|
1565
|
-
} else {
|
|
1566
|
-
slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1567
|
-
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
1568
|
-
slidesPerView = slidesPerView + 1;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
let needLoopFix = cols - targetSlideIndex < slidesPerView;
|
|
1572
|
-
if (centeredSlides) {
|
|
1573
|
-
needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
|
|
1574
|
-
}
|
|
1575
|
-
if (internal && centeredSlides && swiper.params.slidesPerView !== 'auto' && !gridEnabled) {
|
|
1576
|
-
needLoopFix = false;
|
|
1577
|
-
}
|
|
1578
|
-
if (needLoopFix) {
|
|
1579
|
-
const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
|
|
1580
|
-
swiper.loopFix({
|
|
1581
|
-
direction,
|
|
1582
|
-
slideTo: true,
|
|
1583
|
-
activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
1584
|
-
slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
|
|
1585
|
-
});
|
|
1558
|
+
slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1559
|
+
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
1560
|
+
slidesPerView = slidesPerView + 1;
|
|
1586
1561
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1562
|
+
}
|
|
1563
|
+
let needLoopFix = cols - targetSlideIndex < slidesPerView;
|
|
1564
|
+
if (centeredSlides) {
|
|
1565
|
+
needLoopFix = needLoopFix || targetSlideIndex < Math.ceil(slidesPerView / 2);
|
|
1566
|
+
}
|
|
1567
|
+
if (internal && centeredSlides && swiper.params.slidesPerView !== 'auto') {
|
|
1568
|
+
needLoopFix = false;
|
|
1569
|
+
}
|
|
1570
|
+
if (centeredSlides && needLoopFix) {
|
|
1571
|
+
const direction = centeredSlides ? targetSlideIndex < swiper.activeIndex ? 'prev' : 'next' : targetSlideIndex - swiper.activeIndex - 1 < swiper.params.slidesPerView ? 'next' : 'prev';
|
|
1572
|
+
swiper.loopFix({
|
|
1573
|
+
direction,
|
|
1574
|
+
slideTo: true,
|
|
1575
|
+
activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
1576
|
+
slideRealIndex: direction === 'next' ? swiper.realIndex : undefined
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
if (!centeredSlides && needLoopFix) {
|
|
1580
|
+
let direction;
|
|
1581
|
+
let nextSteps;
|
|
1582
|
+
let prevSteps;
|
|
1583
|
+
if (swiper.activeIndex < targetSlideIndex) {
|
|
1584
|
+
nextSteps = targetSlideIndex - swiper.activeIndex;
|
|
1585
|
+
prevSteps = swiper.activeIndex - (targetSlideIndex - totalSlides);
|
|
1590
1586
|
} else {
|
|
1591
|
-
|
|
1587
|
+
prevSteps = swiper.activeIndex - targetSlideIndex;
|
|
1588
|
+
nextSteps = targetSlideIndex + totalSlides - swiper.activeIndex;
|
|
1592
1589
|
}
|
|
1590
|
+
direction = nextSteps > prevSteps ? 'prev' : 'next';
|
|
1591
|
+
swiper.loopFixDot({
|
|
1592
|
+
direction,
|
|
1593
|
+
slideTo: true,
|
|
1594
|
+
activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
1595
|
+
slideRealIndex: direction === 'next' ? swiper.realIndex : undefined,
|
|
1596
|
+
targetSlideIndex,
|
|
1597
|
+
newIndex: swiper.getSlideIndexByData(newIndex)
|
|
1598
|
+
});
|
|
1593
1599
|
}
|
|
1600
|
+
newIndex = swiper.getSlideIndexByData(newIndex);
|
|
1594
1601
|
}
|
|
1595
1602
|
requestAnimationFrame(() => {
|
|
1596
1603
|
swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
|
@@ -1598,6 +1605,87 @@ function slideToLoop(index, speed, runCallbacks, internal) {
|
|
|
1598
1605
|
return swiper;
|
|
1599
1606
|
}
|
|
1600
1607
|
|
|
1608
|
+
function slideToLoopCenterSneakPeek(index, speed, runCallbacks, internal) {
|
|
1609
|
+
if (index === void 0) {
|
|
1610
|
+
index = 0;
|
|
1611
|
+
}
|
|
1612
|
+
if (runCallbacks === void 0) {
|
|
1613
|
+
runCallbacks = true;
|
|
1614
|
+
}
|
|
1615
|
+
if (typeof index === 'string') {
|
|
1616
|
+
const indexAsNumber = parseInt(index, 10);
|
|
1617
|
+
index = indexAsNumber;
|
|
1618
|
+
}
|
|
1619
|
+
const swiper = this;
|
|
1620
|
+
if (swiper.destroyed) return;
|
|
1621
|
+
if (typeof speed === 'undefined') {
|
|
1622
|
+
speed = swiper.params.speed;
|
|
1623
|
+
}
|
|
1624
|
+
let newIndex = index;
|
|
1625
|
+
if (swiper.params.loop) {
|
|
1626
|
+
swiper.slides;
|
|
1627
|
+
const totalSlides = swiper.slides.length;
|
|
1628
|
+
let targetSlideIndex;
|
|
1629
|
+
targetSlideIndex = swiper.getSlideIndexByData(newIndex);
|
|
1630
|
+
const cols = swiper.slides.length;
|
|
1631
|
+
const {
|
|
1632
|
+
centeredSlides
|
|
1633
|
+
} = swiper.params;
|
|
1634
|
+
let slidesPerView = swiper.params.slidesPerView;
|
|
1635
|
+
if (slidesPerView === 'auto') {
|
|
1636
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
1637
|
+
} else {
|
|
1638
|
+
slidesPerView = Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1639
|
+
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
1640
|
+
slidesPerView = slidesPerView + 1;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
if (internal && centeredSlides && swiper.params.slidesPerView !== 'auto') ;
|
|
1644
|
+
const isSneakPeekCenter = swiper.params?.isSneakPeekCenter;
|
|
1645
|
+
if (isSneakPeekCenter) {
|
|
1646
|
+
let direction;
|
|
1647
|
+
let nextSteps;
|
|
1648
|
+
let prevSteps;
|
|
1649
|
+
if (swiper.activeIndex < targetSlideIndex) {
|
|
1650
|
+
nextSteps = targetSlideIndex - swiper.activeIndex;
|
|
1651
|
+
prevSteps = swiper.activeIndex - (targetSlideIndex - totalSlides);
|
|
1652
|
+
} else {
|
|
1653
|
+
prevSteps = swiper.activeIndex - targetSlideIndex;
|
|
1654
|
+
nextSteps = targetSlideIndex + totalSlides - swiper.activeIndex;
|
|
1655
|
+
}
|
|
1656
|
+
direction = nextSteps > prevSteps ? 'prev' : 'next';
|
|
1657
|
+
swiper.loopFixDot({
|
|
1658
|
+
direction,
|
|
1659
|
+
slideTo: true,
|
|
1660
|
+
activeSlideIndex: direction === 'next' ? targetSlideIndex + 1 : targetSlideIndex - cols + 1,
|
|
1661
|
+
slideRealIndex: direction === 'next' ? swiper.realIndex : undefined,
|
|
1662
|
+
targetSlideIndex,
|
|
1663
|
+
newIndex: swiper.getSlideIndexByData(newIndex)
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
newIndex = swiper.getSlideIndexByData(newIndex);
|
|
1667
|
+
}
|
|
1668
|
+
swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
|
1669
|
+
const slides = swiper.slides;
|
|
1670
|
+
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
1671
|
+
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
1672
|
+
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
1673
|
+
|
|
1674
|
+
// Move last item to first position only if active slide is the first slide
|
|
1675
|
+
const lastSlide = slides[slides.length - 1];
|
|
1676
|
+
lastSlide.swiperLoopMoveDOM = true;
|
|
1677
|
+
swiper.slidesEl.prepend(lastSlide);
|
|
1678
|
+
lastSlide.swiperLoopMoveDOM = false;
|
|
1679
|
+
swiper.setTransition(0);
|
|
1680
|
+
swiper.setTranslate(-(swiperTranslate + gap));
|
|
1681
|
+
swiper.recalcSlides();
|
|
1682
|
+
swiper.updateSlides();
|
|
1683
|
+
swiper.setTransition(swiper.params.speed);
|
|
1684
|
+
swiper.setTranslate(-swiperTranslate);
|
|
1685
|
+
}
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1601
1689
|
/* eslint no-unused-vars: "off" */
|
|
1602
1690
|
function slideNext(speed, runCallbacks, internal) {
|
|
1603
1691
|
if (runCallbacks === void 0) {
|
|
@@ -1622,7 +1710,7 @@ function slideNext(speed, runCallbacks, internal) {
|
|
|
1622
1710
|
if (params.loop) {
|
|
1623
1711
|
if (animating && !isVirtual && params.loopPreventsSliding) return false;
|
|
1624
1712
|
|
|
1625
|
-
//
|
|
1713
|
+
// Kiểm tra xem loop có bị disable không
|
|
1626
1714
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
1627
1715
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
1628
1716
|
swiper.loopFix({
|
|
@@ -1641,7 +1729,27 @@ function slideNext(speed, runCallbacks, internal) {
|
|
|
1641
1729
|
if (params.rewind && swiper.isEnd) {
|
|
1642
1730
|
return swiper.slideTo(0, speed, runCallbacks, internal);
|
|
1643
1731
|
}
|
|
1644
|
-
|
|
1732
|
+
requestAnimationFrame(() => {
|
|
1733
|
+
swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
|
1734
|
+
const slides = swiper.slides;
|
|
1735
|
+
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && (swiper.activeIndex === slides.length - 1 || swiper.isEnd)) {
|
|
1736
|
+
const lastSnapGridIndex = swiper.snapGrid.length - 1;
|
|
1737
|
+
const gap = Math.abs(swiper.snapGrid[lastSnapGridIndex] - swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
1738
|
+
const swiperTranslate = structuredClone(swiper.snapGrid[lastSnapGridIndex - 1]);
|
|
1739
|
+
|
|
1740
|
+
// Move first item to last position only if active slide is the last slide
|
|
1741
|
+
const firstSlide = slides[0];
|
|
1742
|
+
firstSlide.swiperLoopMoveDOM = true;
|
|
1743
|
+
swiper.slidesEl.append(firstSlide);
|
|
1744
|
+
firstSlide.swiperLoopMoveDOM = false;
|
|
1745
|
+
swiper.setTransition(0);
|
|
1746
|
+
swiper.setTranslate(-(swiperTranslate - gap));
|
|
1747
|
+
swiper.recalcSlides();
|
|
1748
|
+
swiper.updateSlides();
|
|
1749
|
+
swiper.setTransition(swiper.params.speed);
|
|
1750
|
+
swiper.setTranslate(-swiperTranslate);
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1645
1753
|
}
|
|
1646
1754
|
|
|
1647
1755
|
/* eslint no-unused-vars: "off" */
|
|
@@ -1662,11 +1770,9 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1662
1770
|
if (typeof speed === 'undefined') {
|
|
1663
1771
|
speed = swiper.params.speed;
|
|
1664
1772
|
}
|
|
1665
|
-
|
|
1773
|
+
swiper.virtual && params.virtual.enabled;
|
|
1666
1774
|
if (params.loop) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
// Check if loop is disabled
|
|
1775
|
+
// Kiểm tra xem loop có bị disable không
|
|
1670
1776
|
const currentSlidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
1671
1777
|
if (swiper.slides.length >= currentSlidesPerView) {
|
|
1672
1778
|
swiper.loopFix({
|
|
@@ -1715,7 +1821,27 @@ function slidePrev(speed, runCallbacks, internal) {
|
|
|
1715
1821
|
});
|
|
1716
1822
|
return true;
|
|
1717
1823
|
}
|
|
1718
|
-
|
|
1824
|
+
requestAnimationFrame(() => {
|
|
1825
|
+
swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
|
1826
|
+
const slides = swiper.slides;
|
|
1827
|
+
if (swiper.params?.isSneakPeekCenter && slides.length > 1 && swiper.activeIndex === 0) {
|
|
1828
|
+
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
1829
|
+
const swiperTranslate = JSON.parse(JSON.stringify(swiper.snapGrid[1]));
|
|
1830
|
+
|
|
1831
|
+
// Move last item to first position only if active slide is the first slide
|
|
1832
|
+
const lastSlide = slides[slides.length - 1];
|
|
1833
|
+
lastSlide.swiperLoopMoveDOM = true;
|
|
1834
|
+
swiper.slidesEl.prepend(lastSlide);
|
|
1835
|
+
lastSlide.swiperLoopMoveDOM = false;
|
|
1836
|
+
swiper.setTransition(0);
|
|
1837
|
+
swiper.setTranslate(-(swiperTranslate + gap));
|
|
1838
|
+
swiper.recalcSlides();
|
|
1839
|
+
swiper.updateSlides();
|
|
1840
|
+
swiper.setTransition(swiper.params.speed);
|
|
1841
|
+
swiper.setTranslate(-swiperTranslate);
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
return;
|
|
1719
1845
|
}
|
|
1720
1846
|
|
|
1721
1847
|
/* eslint no-unused-vars: "off" */
|
|
@@ -1804,6 +1930,7 @@ function slideToClickedSlide() {
|
|
|
1804
1930
|
var slide = {
|
|
1805
1931
|
slideTo,
|
|
1806
1932
|
slideToLoop,
|
|
1933
|
+
slideToLoopCenterSneakPeek,
|
|
1807
1934
|
slideNext,
|
|
1808
1935
|
slidePrev,
|
|
1809
1936
|
slideReset,
|
|
@@ -1891,7 +2018,7 @@ function loopFix(_temp) {
|
|
|
1891
2018
|
const swiper = this;
|
|
1892
2019
|
if (!swiper.params.loop) return;
|
|
1893
2020
|
|
|
1894
|
-
// Disable loop mode
|
|
2021
|
+
// Disable loop mode nếu số slides ít hơn slidesPerView
|
|
1895
2022
|
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
1896
2023
|
if (swiper.slides.length < currentSlidesPerView) {
|
|
1897
2024
|
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
@@ -2103,6 +2230,206 @@ function loopFix(_temp) {
|
|
|
2103
2230
|
swiper.emit('loopFix');
|
|
2104
2231
|
}
|
|
2105
2232
|
|
|
2233
|
+
function loopFixDot(_temp) {
|
|
2234
|
+
let {
|
|
2235
|
+
slideRealIndex,
|
|
2236
|
+
slideTo = true,
|
|
2237
|
+
direction,
|
|
2238
|
+
activeSlideIndex,
|
|
2239
|
+
initial,
|
|
2240
|
+
targetSlideIndex,
|
|
2241
|
+
newIndex
|
|
2242
|
+
} = _temp === void 0 ? {} : _temp;
|
|
2243
|
+
const swiper = this;
|
|
2244
|
+
if (!swiper.params.loop) return;
|
|
2245
|
+
|
|
2246
|
+
// Disable loop mode nếu số slides ít hơn slidesPerView
|
|
2247
|
+
const currentSlidesPerView = swiper.params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
|
|
2248
|
+
if (swiper.slides.length < currentSlidesPerView) {
|
|
2249
|
+
console.warn('Swiper: Loop mode disabled - slides.length < slidesPerView');
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
swiper.emit('beforeLoopFix');
|
|
2253
|
+
const {
|
|
2254
|
+
slides,
|
|
2255
|
+
allowSlidePrev,
|
|
2256
|
+
allowSlideNext,
|
|
2257
|
+
slidesEl,
|
|
2258
|
+
params
|
|
2259
|
+
} = swiper;
|
|
2260
|
+
const targetData = slidesEl.children[targetSlideIndex].getAttribute('data-swiper-slide-index');
|
|
2261
|
+
const oldActiveData = Array.from(slidesEl.children).find(el => el.classList.contains(params.slideActiveClass)).getAttribute('data-swiper-slide-index');
|
|
2262
|
+
const {
|
|
2263
|
+
centeredSlides,
|
|
2264
|
+
initialSlide
|
|
2265
|
+
} = params;
|
|
2266
|
+
const swiperDataOldActiveIndex = slidesEl.children[swiper.activeIndex].getAttribute('data-swiper-slide-index');
|
|
2267
|
+
swiper.allowSlidePrev = true;
|
|
2268
|
+
swiper.allowSlideNext = true;
|
|
2269
|
+
let slidesPerView = params.slidesPerView;
|
|
2270
|
+
if (slidesPerView === 'auto') {
|
|
2271
|
+
slidesPerView = swiper.slidesPerViewDynamic();
|
|
2272
|
+
} else {
|
|
2273
|
+
slidesPerView = Math.ceil(parseFloat(params.slidesPerView, 10));
|
|
2274
|
+
if (centeredSlides && slidesPerView % 2 === 0) {
|
|
2275
|
+
slidesPerView = slidesPerView + 1;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
const slidesPerGroup = params.slidesPerGroupAuto ? slidesPerView : params.slidesPerGroup;
|
|
2279
|
+
let loopedSlides = centeredSlides ? Math.max(slidesPerGroup, Math.ceil(slidesPerView / 2)) : slidesPerGroup;
|
|
2280
|
+
if (loopedSlides % slidesPerGroup !== 0) {
|
|
2281
|
+
loopedSlides += slidesPerGroup - loopedSlides % slidesPerGroup;
|
|
2282
|
+
}
|
|
2283
|
+
loopedSlides += params.loopAdditionalSlides;
|
|
2284
|
+
swiper.loopedSlides = loopedSlides;
|
|
2285
|
+
if (slides.length < slidesPerView + loopedSlides || swiper.params.effect === 'cards' && slides.length < slidesPerView + loopedSlides * 2) {
|
|
2286
|
+
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');
|
|
2287
|
+
}
|
|
2288
|
+
const isNext = direction === 'next' || !direction;
|
|
2289
|
+
const isPrev = direction === 'prev' || !direction;
|
|
2290
|
+
let numberOfSlidesNeedClone = [];
|
|
2291
|
+
let slidesIndex = [];
|
|
2292
|
+
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2293
|
+
slidesIndex.push(slidesEl.children[i].getAttribute('data-swiper-slide-index'));
|
|
2294
|
+
}
|
|
2295
|
+
if (isPrev) {
|
|
2296
|
+
for (let i = targetSlideIndex; i < slidesEl.children.length; i++) {
|
|
2297
|
+
numberOfSlidesNeedClone.push(i);
|
|
2298
|
+
}
|
|
2299
|
+
} else if (isNext) {
|
|
2300
|
+
for (let i = 0; i < slidesPerView - (slidesEl.children.length - targetSlideIndex); i++) {
|
|
2301
|
+
numberOfSlidesNeedClone.push(i);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
const cols = slides.length;
|
|
2305
|
+
const isInitialOverflow = initial && cols - initialSlide < slidesPerView && !centeredSlides;
|
|
2306
|
+
isInitialOverflow ? initialSlide : swiper.activeIndex;
|
|
2307
|
+
if (typeof activeSlideIndex === 'undefined') {
|
|
2308
|
+
activeSlideIndex = swiper.getSlideIndex(slides.find(el => el.classList.contains(params.slideActiveClass)));
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// Tạo DocumentFragment để chứa các slide clone
|
|
2312
|
+
const cloneFragment = document.createDocumentFragment();
|
|
2313
|
+
|
|
2314
|
+
// Clone các slide theo numberOfSlidesNeedClone (đã đảo ngược) và thêm vào fragment
|
|
2315
|
+
(isNext ? numberOfSlidesNeedClone : numberOfSlidesNeedClone.reverse()).forEach(index => {
|
|
2316
|
+
if (slides[index]) {
|
|
2317
|
+
const originalSlide = slides[index];
|
|
2318
|
+
const clonedSlide = originalSlide.cloneNode(true);
|
|
2319
|
+
|
|
2320
|
+
// Đánh dấu slide clone
|
|
2321
|
+
clonedSlide.setAttribute('data-swiper-clone', 'true');
|
|
2322
|
+
clonedSlide.classList.add('swiper-slide-clone');
|
|
2323
|
+
|
|
2324
|
+
// Thêm clone vào fragment
|
|
2325
|
+
cloneFragment.appendChild(clonedSlide);
|
|
2326
|
+
}
|
|
2327
|
+
});
|
|
2328
|
+
if (isPrev) {
|
|
2329
|
+
numberOfSlidesNeedClone.forEach(index => {
|
|
2330
|
+
const originalSlide = slides[index];
|
|
2331
|
+
originalSlide.swiperLoopMoveDOM = true;
|
|
2332
|
+
slidesEl.prepend(originalSlide);
|
|
2333
|
+
originalSlide.swiperLoopMoveDOM = false;
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
if (isNext) {
|
|
2337
|
+
numberOfSlidesNeedClone.forEach(index => {
|
|
2338
|
+
const originalSlide = slides[index];
|
|
2339
|
+
originalSlide.swiperLoopMoveDOM = true;
|
|
2340
|
+
slidesEl.append(originalSlide);
|
|
2341
|
+
originalSlide.swiperLoopMoveDOM = false;
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
// Sắp xếp cloneFragment theo data-swiper-slide-index tăng dần
|
|
2346
|
+
const clonedSlides = Array.from(cloneFragment.children);
|
|
2347
|
+
clonedSlides.sort((a, b) => {
|
|
2348
|
+
const indexA = parseInt(a.getAttribute('data-swiper-slide-index')) || 0;
|
|
2349
|
+
const indexB = parseInt(b.getAttribute('data-swiper-slide-index')) || 0;
|
|
2350
|
+
return indexA - indexB;
|
|
2351
|
+
});
|
|
2352
|
+
|
|
2353
|
+
// Xóa tất cả children cũ và thêm lại theo thứ tự đã sắp xếp
|
|
2354
|
+
cloneFragment.innerHTML = '';
|
|
2355
|
+
clonedSlides.forEach(slide => {
|
|
2356
|
+
cloneFragment.appendChild(slide);
|
|
2357
|
+
});
|
|
2358
|
+
|
|
2359
|
+
// Thêm fragment vào vị trí phù hợp
|
|
2360
|
+
if (isPrev) {
|
|
2361
|
+
// Nếu là prev, thêm fragment vào cuối slidesEl
|
|
2362
|
+
slidesEl.appendChild(cloneFragment);
|
|
2363
|
+
} else if (isNext) {
|
|
2364
|
+
// Nếu là next, thêm fragment vào đầu slidesEl
|
|
2365
|
+
slidesEl.insertBefore(cloneFragment, slidesEl.firstChild);
|
|
2366
|
+
}
|
|
2367
|
+
swiper.recalcSlides();
|
|
2368
|
+
swiper.updateSlides();
|
|
2369
|
+
|
|
2370
|
+
// Tìm slide có data-swiper-slide-index tương ứng
|
|
2371
|
+
let oldActiveIndex = null;
|
|
2372
|
+
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2373
|
+
const child = slidesEl.children[i];
|
|
2374
|
+
if (child.getAttribute('data-swiper-slide-index') === swiperDataOldActiveIndex) {
|
|
2375
|
+
oldActiveIndex = i;
|
|
2376
|
+
break;
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
if (slideTo && oldActiveIndex !== swiper.activeIndex) {
|
|
2380
|
+
swiper.slideTo(oldActiveIndex, 0);
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
// Tìm vị trí slide cũ sau khi remove clone để set lại translate tạo hiệu ứng animate
|
|
2384
|
+
const skip = Math.min(swiper.params.slidesPerGroupSkip, newIndex);
|
|
2385
|
+
let snapIndex = skip + Math.floor((newIndex - skip) / swiper.params.slidesPerGroup);
|
|
2386
|
+
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
2387
|
+
const translate = -swiper.snapGrid[snapIndex];
|
|
2388
|
+
if (translate === swiper.translate) {
|
|
2389
|
+
let oldActiveIndexAfterRemoveClone;
|
|
2390
|
+
for (let i = 0; i < slidesEl.children.length; i++) {
|
|
2391
|
+
const child = slidesEl.children[i];
|
|
2392
|
+
if (child.getAttribute('data-swiper-slide-index') === swiperDataOldActiveIndex) {
|
|
2393
|
+
oldActiveIndexAfterRemoveClone = i;
|
|
2394
|
+
break;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
const skip = Math.min(swiper.params.slidesPerGroupSkip, oldActiveIndexAfterRemoveClone);
|
|
2398
|
+
let snapIndex = skip + Math.floor((oldActiveIndexAfterRemoveClone - skip) / swiper.params.slidesPerGroup);
|
|
2399
|
+
if (snapIndex >= swiper.snapGrid.length) snapIndex = swiper.snapGrid.length - 1;
|
|
2400
|
+
const oldTranslate = -swiper.snapGrid[snapIndex];
|
|
2401
|
+
let updateTranslate;
|
|
2402
|
+
if (oldTranslate === swiper.translate) {
|
|
2403
|
+
updateTranslate = swiper.snapGrid[snapIndex > 0 ? snapIndex - 1 : swiper.snapGrid.length - 1];
|
|
2404
|
+
} else {
|
|
2405
|
+
updateTranslate = oldTranslate;
|
|
2406
|
+
}
|
|
2407
|
+
swiper.setTranslate(updateTranslate);
|
|
2408
|
+
}
|
|
2409
|
+
// Remove slide clone ra khỏi slidesEl sau khi slideTo hoàn thành
|
|
2410
|
+
const cloneSlides = slidesEl.querySelectorAll('[data-swiper-clone="true"]');
|
|
2411
|
+
cloneSlides.forEach(cloneSlide => {
|
|
2412
|
+
if (cloneSlide.parentNode) {
|
|
2413
|
+
cloneSlide.parentNode.removeChild(cloneSlide);
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
swiper.recalcSlides();
|
|
2417
|
+
swiper.updateSlides();
|
|
2418
|
+
const targetDataIndex = Array.from(slidesEl.children).findIndex(el => el.getAttribute('data-swiper-slide-index') * 1 === targetData * 1);
|
|
2419
|
+
const oldDataIndex = Array.from(slidesEl.children).findIndex(el => el.getAttribute('data-swiper-slide-index') * 1 === oldActiveData * 1);
|
|
2420
|
+
const snapIndexNew = skip + Math.floor((targetDataIndex - skip) / swiper.params.slidesPerGroup);
|
|
2421
|
+
const snapIndexOld = skip + Math.floor((oldDataIndex - skip) / swiper.params.slidesPerGroup);
|
|
2422
|
+
if (slideTo && snapIndexNew === targetDataIndex) {
|
|
2423
|
+
const translateOld = -swiper.snapGrid[snapIndexOld > swiper.snapGrid.length - 1 ? snapIndexNew - 1 > swiper.snapGrid.length - 1 ? 0 : snapIndexNew - 1 : snapIndexOld];
|
|
2424
|
+
swiper.setTranslate(translateOld);
|
|
2425
|
+
}
|
|
2426
|
+
swiper.recalcSlides();
|
|
2427
|
+
swiper.updateSlides();
|
|
2428
|
+
swiper.allowSlidePrev = allowSlidePrev;
|
|
2429
|
+
swiper.allowSlideNext = allowSlideNext;
|
|
2430
|
+
swiper.emit('loopFixDot');
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2106
2433
|
function loopDestroy() {
|
|
2107
2434
|
const swiper = this;
|
|
2108
2435
|
const {
|
|
@@ -2129,6 +2456,7 @@ function loopDestroy() {
|
|
|
2129
2456
|
var loop = {
|
|
2130
2457
|
loopCreate,
|
|
2131
2458
|
loopFix,
|
|
2459
|
+
loopFixDot,
|
|
2132
2460
|
loopDestroy
|
|
2133
2461
|
};
|
|
2134
2462
|
|
|
@@ -2723,6 +3051,9 @@ function onTouchEnd(event) {
|
|
|
2723
3051
|
swiper.slideTo(stopIndex);
|
|
2724
3052
|
}
|
|
2725
3053
|
}
|
|
3054
|
+
swiper.syncSneakPeekCenter({
|
|
3055
|
+
speed: swiper.params.speed
|
|
3056
|
+
});
|
|
2726
3057
|
}
|
|
2727
3058
|
|
|
2728
3059
|
function onResize() {
|
|
@@ -3264,6 +3595,7 @@ var defaults = {
|
|
|
3264
3595
|
loopAddBlankSlides: true,
|
|
3265
3596
|
loopAdditionalSlides: 0,
|
|
3266
3597
|
loopPreventsSliding: true,
|
|
3598
|
+
isSneakPeekCenter: false,
|
|
3267
3599
|
// rewind
|
|
3268
3600
|
rewind: false,
|
|
3269
3601
|
// Swiping/no swiping
|
|
@@ -3805,6 +4137,46 @@ class Swiper {
|
|
|
3805
4137
|
});
|
|
3806
4138
|
return true;
|
|
3807
4139
|
}
|
|
4140
|
+
syncSneakPeekCenter(_temp) {
|
|
4141
|
+
let {
|
|
4142
|
+
speed = 0
|
|
4143
|
+
} = _temp === void 0 ? {} : _temp;
|
|
4144
|
+
const swiper = this;
|
|
4145
|
+
requestAnimationFrame(() => {
|
|
4146
|
+
const slides = swiper.slides;
|
|
4147
|
+
if (swiper.params?.isSneakPeekCenter && slides.length > 1) {
|
|
4148
|
+
const isFirstSlide = swiper.activeIndex === 0;
|
|
4149
|
+
const isLastSlide = swiper.activeIndex === slides.length - 1 || swiper.isEnd;
|
|
4150
|
+
const gap = Math.abs(swiper.snapGrid[1] - swiper.snapGrid[0]);
|
|
4151
|
+
const swiperTranslate = structuredClone(swiper.snapGrid[1]);
|
|
4152
|
+
if (isFirstSlide) {
|
|
4153
|
+
// Move last item to first position when at first slide
|
|
4154
|
+
const lastSlide = slides.at(-1);
|
|
4155
|
+
lastSlide.swiperLoopMoveDOM = true;
|
|
4156
|
+
swiper.slidesEl.prepend(lastSlide);
|
|
4157
|
+
lastSlide.swiperLoopMoveDOM = false;
|
|
4158
|
+
swiper.setTransition(0);
|
|
4159
|
+
swiper.setTranslate(-(swiperTranslate + gap));
|
|
4160
|
+
swiper.recalcSlides();
|
|
4161
|
+
swiper.updateSlides();
|
|
4162
|
+
swiper.setTransition(speed);
|
|
4163
|
+
swiper.setTranslate(-swiperTranslate);
|
|
4164
|
+
} else if (isLastSlide) {
|
|
4165
|
+
// Move first item to last position when at last slide
|
|
4166
|
+
const firstSlide = slides[0];
|
|
4167
|
+
firstSlide.swiperLoopMoveDOM = true;
|
|
4168
|
+
swiper.slidesEl.append(firstSlide);
|
|
4169
|
+
firstSlide.swiperLoopMoveDOM = false;
|
|
4170
|
+
swiper.setTransition(0);
|
|
4171
|
+
swiper.setTranslate(-(swiperTranslate - gap));
|
|
4172
|
+
swiper.recalcSlides();
|
|
4173
|
+
swiper.updateSlides();
|
|
4174
|
+
swiper.setTransition(speed);
|
|
4175
|
+
swiper.setTranslate(-swiperTranslate);
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
});
|
|
4179
|
+
}
|
|
3808
4180
|
init(el) {
|
|
3809
4181
|
const swiper = this;
|
|
3810
4182
|
if (swiper.initialized) return swiper;
|
|
@@ -3866,6 +4238,7 @@ class Swiper {
|
|
|
3866
4238
|
// Init Flag
|
|
3867
4239
|
swiper.initialized = true;
|
|
3868
4240
|
preload(swiper);
|
|
4241
|
+
swiper.syncSneakPeekCenter();
|
|
3869
4242
|
|
|
3870
4243
|
// Emit
|
|
3871
4244
|
swiper.emit('init');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as setInnerHTML}from"./utils.min.mjs";const paramsList=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","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","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function isObject(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function extend(e,t){const i=["__proto__","constructor","prototype"];Object.keys(t).filter((e=>i.indexOf(e)<0)).forEach((i=>{void 0===e[i]?e[i]=t[i]:isObject(t[i])&&isObject(e[i])&&Object.keys(t[i]).length>0?t[i].__swiper__?e[i]=t[i]:extend(e[i],t[i]):e[i]=t[i]}))}function needsNavigation(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function needsPagination(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function needsScrollbar(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function uniqueClasses(e){void 0===e&&(e="");const t=e.split(" ").map((e=>e.trim())).filter((e=>!!e)),i=[];return t.forEach((e=>{i.indexOf(e)<0&&i.push(e)})),i.join(" ")}function attrToProp(e){return void 0===e&&(e=""),e.replace(/-[a-z]/g,(e=>e.toUpperCase().replace("-","")))}function wrapperClass(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function updateSwiper(e){let{swiper:t,slides:i,passedParams:l,changedParams:n,nextEl:o,prevEl:r,scrollbarEl:s,paginationEl:a}=e;const d=n.filter((e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e)),{params:c,pagination:p,navigation:u,scrollbar:v,virtual:g,thumbs:b}=t;let f,w,
|
|
1
|
+
import{s as setInnerHTML}from"./utils.min.mjs";const paramsList=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_isSneakPeekCenter","_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","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function isObject(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function extend(e,t){const i=["__proto__","constructor","prototype"];Object.keys(t).filter((e=>i.indexOf(e)<0)).forEach((i=>{void 0===e[i]?e[i]=t[i]:isObject(t[i])&&isObject(e[i])&&Object.keys(t[i]).length>0?t[i].__swiper__?e[i]=t[i]:extend(e[i],t[i]):e[i]=t[i]}))}function needsNavigation(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function needsPagination(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function needsScrollbar(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function uniqueClasses(e){void 0===e&&(e="");const t=e.split(" ").map((e=>e.trim())).filter((e=>!!e)),i=[];return t.forEach((e=>{i.indexOf(e)<0&&i.push(e)})),i.join(" ")}function attrToProp(e){return void 0===e&&(e=""),e.replace(/-[a-z]/g,(e=>e.toUpperCase().replace("-","")))}function wrapperClass(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function updateSwiper(e){let{swiper:t,slides:i,passedParams:l,changedParams:n,nextEl:o,prevEl:r,scrollbarEl:s,paginationEl:a}=e;const d=n.filter((e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e)),{params:c,pagination:p,navigation:u,scrollbar:v,virtual:g,thumbs:b}=t;let f,_,w,h,m,S,E,C;n.includes("thumbs")&&l.thumbs&&l.thumbs.swiper&&!l.thumbs.swiper.destroyed&&c.thumbs&&(!c.thumbs.swiper||c.thumbs.swiper.destroyed)&&(f=!0),n.includes("controller")&&l.controller&&l.controller.control&&c.controller&&!c.controller.control&&(_=!0),n.includes("pagination")&&l.pagination&&(l.pagination.el||a)&&(c.pagination||!1===c.pagination)&&p&&!p.el&&(w=!0),n.includes("scrollbar")&&l.scrollbar&&(l.scrollbar.el||s)&&(c.scrollbar||!1===c.scrollbar)&&v&&!v.el&&(h=!0),n.includes("navigation")&&l.navigation&&(l.navigation.prevEl||r)&&(l.navigation.nextEl||o)&&(c.navigation||!1===c.navigation)&&u&&!u.prevEl&&!u.nextEl&&(m=!0);const x=e=>{t[e]&&(t[e].destroy(),"navigation"===e?(t.isElement&&(t[e].prevEl.remove(),t[e].nextEl.remove()),c[e].prevEl=void 0,c[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),c[e].el=void 0,t[e].el=void 0))};if(n.includes("loop")&&t.isElement&&(c.loop&&!l.loop?S=!0:!c.loop&&l.loop?E=!0:C=!0),d.forEach((e=>{if(isObject(c[e])&&isObject(l[e]))Object.assign(c[e],l[e]),"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e||!("enabled"in l[e])||l[e].enabled||x(e);else{const t=l[e];!0!==t&&!1!==t||"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e?c[e]=l[e]:!1===t&&x(e)}})),d.includes("controller")&&!_&&t.controller&&t.controller.control&&c.controller&&c.controller.control&&(t.controller.control=c.controller.control),n.includes("children")&&i&&g&&c.virtual.enabled?(g.slides=i,g.update(!0)):n.includes("virtual")&&g&&c.virtual.enabled&&(i&&(g.slides=i),g.update(!0)),n.includes("children")&&i&&c.loop&&(C=!0),f){b.init()&&b.update(!0)}_&&(t.controller.control=c.controller.control),w&&(!t.isElement||a&&"string"!=typeof a||(a=document.createElement("div"),a.classList.add("swiper-pagination"),a.part.add("pagination"),t.el.appendChild(a)),a&&(c.pagination.el=a),p.init(),p.render(),p.update()),h&&(!t.isElement||s&&"string"!=typeof s||(s=document.createElement("div"),s.classList.add("swiper-scrollbar"),s.part.add("scrollbar"),t.el.appendChild(s)),s&&(c.scrollbar.el=s),v.init(),v.updateSize(),v.setTranslate()),m&&(t.isElement&&(o&&"string"!=typeof o||(o=document.createElement("div"),o.classList.add("swiper-button-next"),setInnerHTML(o,t.hostEl.constructor.nextButtonSvg),o.part.add("button-next"),t.el.appendChild(o)),r&&"string"!=typeof r||(r=document.createElement("div"),r.classList.add("swiper-button-prev"),setInnerHTML(r,t.hostEl.constructor.prevButtonSvg),r.part.add("button-prev"),t.el.appendChild(r))),o&&(c.navigation.nextEl=o),r&&(c.navigation.prevEl=r),u.init(),u.update()),n.includes("allowSlideNext")&&(t.allowSlideNext=l.allowSlideNext),n.includes("allowSlidePrev")&&(t.allowSlidePrev=l.allowSlidePrev),n.includes("direction")&&t.changeDirection(l.direction,!1),(S||C)&&t.loopDestroy(),(E||C)&&t.loopCreate(),t.update()}export{needsPagination as a,needsScrollbar as b,attrToProp as c,uniqueClasses as d,extend as e,isObject as i,needsNavigation as n,paramsList as p,updateSwiper as u,wrapperClass as w};
|
|
2
2
|
//# sourceMappingURL=update-swiper.min.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-swiper.mjs.mjs","names":["setInnerHTML","paramsList","isObject","o","constructor","Object","prototype","toString","call","slice","__swiper__","extend","target","src","noExtend","keys","filter","key","indexOf","forEach","length","needsNavigation","params","navigation","nextEl","prevEl","needsPagination","pagination","el","needsScrollbar","scrollbar","uniqueClasses","classNames","classes","split","map","c","trim","unique","push","join","attrToProp","attrName","replace","l","toUpperCase","wrapperClass","className","includes","updateSwiper","_ref","swiper","slides","passedParams","changedParams","scrollbarEl","paginationEl","updateParams","currentParams","virtual","thumbs","needThumbsInit","needControllerInit","needPaginationInit","needScrollbarInit","needNavigationInit","loopNeedDestroy","loopNeedEnable","loopNeedReloop","destroyed","controller","control","destroyModule","mod","destroy","isElement","remove","undefined","loop","assign","enabled","newValue","update","init","document","createElement","classList","add","part","appendChild","render","updateSize","setTranslate","hostEl","nextButtonSvg","prevButtonSvg","allowSlideNext","allowSlidePrev","changeDirection","direction","loopDestroy","loopCreate"],"sources":["0"],"mappings":"YAAcA,iBAAoB,kBAGlC,MAAMC,WAAa,CAAC,eAAgB,eAAgB,mBAAoB,UAAW,OAAQ,aAAc,iBAAkB,wBAAyB,oBAAqB,eAAgB,SAAU,UAAW,uBAAwB,iBAAkB,SAAU,oBAAqB,WAAY,SAAU,UAAW,iCAAkC,YAAa,MAAO,sBAAuB,sBAAuB,YAAa,cAAe,iBAAkB,mBAAoB,UAAW,cAAe,kBAAmB,gBAAiB,iBAAkB,0BAA2B,QAAS,kBAAmB,sBAAuB,sBAAuB,kBAAmB,wBAAyB,sBAAuB,qBAAsB,sBAAuB,4BAA6B,iBAAkB,eAAgB,aAAc,aAAc,gBAAiB,eAAgB,cAAe,kBAAmB,eAAgB,gBAAiB,iBAAkB,aAAc,2BAA4B,2BAA4B,gCAAiC,sBAAuB,oBAAqB,cAAe,mBAAoB,uBAAwB,cAAe,gBAAiB,2BAA4B,uBAAwB,QAAS,uBAAwB,qBAAsB,sBAAuB,UAAW,kBAAmB,kBAAmB,gBAAiB,aAAc,iBAAkB,oBAAqB,mBAAoB,yBAA0B,aAAc,mBAAoB,oBAAqB,yBAA0B,iBAAkB,iBAAkB,kBAAmB,eAAgB,qBAAsB,sBAAuB,qBAAsB,WAAY,iBAAkB,
|
|
1
|
+
{"version":3,"file":"update-swiper.mjs.mjs","names":["setInnerHTML","paramsList","isObject","o","constructor","Object","prototype","toString","call","slice","__swiper__","extend","target","src","noExtend","keys","filter","key","indexOf","forEach","length","needsNavigation","params","navigation","nextEl","prevEl","needsPagination","pagination","el","needsScrollbar","scrollbar","uniqueClasses","classNames","classes","split","map","c","trim","unique","push","join","attrToProp","attrName","replace","l","toUpperCase","wrapperClass","className","includes","updateSwiper","_ref","swiper","slides","passedParams","changedParams","scrollbarEl","paginationEl","updateParams","currentParams","virtual","thumbs","needThumbsInit","needControllerInit","needPaginationInit","needScrollbarInit","needNavigationInit","loopNeedDestroy","loopNeedEnable","loopNeedReloop","destroyed","controller","control","destroyModule","mod","destroy","isElement","remove","undefined","loop","assign","enabled","newValue","update","init","document","createElement","classList","add","part","appendChild","render","updateSize","setTranslate","hostEl","nextButtonSvg","prevButtonSvg","allowSlideNext","allowSlidePrev","changeDirection","direction","loopDestroy","loopCreate"],"sources":["0"],"mappings":"YAAcA,iBAAoB,kBAGlC,MAAMC,WAAa,CAAC,eAAgB,eAAgB,mBAAoB,UAAW,OAAQ,aAAc,iBAAkB,wBAAyB,oBAAqB,eAAgB,SAAU,UAAW,uBAAwB,iBAAkB,SAAU,oBAAqB,WAAY,SAAU,UAAW,iCAAkC,YAAa,MAAO,sBAAuB,sBAAuB,YAAa,cAAe,iBAAkB,mBAA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