glide-react 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/glide-theme.css +42 -0
- package/dist/glide.css +108 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +241 -102
- package/dist/index.mjs +241 -102
- package/package.json +18 -3
package/dist/index.js
CHANGED
|
@@ -552,10 +552,12 @@ var calculateSlideWidth = (listWidth, slidesToShow, centerMode, centerPadding, v
|
|
|
552
552
|
let centerPaddingAdj = 0;
|
|
553
553
|
if (centerMode) {
|
|
554
554
|
const paddingValue = parseInt(centerPadding, 10) || 0;
|
|
555
|
-
centerPaddingAdj = paddingValue * 2;
|
|
556
555
|
if (centerPadding.endsWith("%")) {
|
|
557
|
-
centerPaddingAdj = listWidth * paddingValue
|
|
556
|
+
centerPaddingAdj = listWidth * paddingValue / 100;
|
|
557
|
+
} else {
|
|
558
|
+
centerPaddingAdj = paddingValue;
|
|
558
559
|
}
|
|
560
|
+
centerPaddingAdj = centerPaddingAdj * 2;
|
|
559
561
|
}
|
|
560
562
|
return Math.ceil((listWidth - centerPaddingAdj) / slidesToShow);
|
|
561
563
|
};
|
|
@@ -640,6 +642,9 @@ var getSlideStyle = (spec) => {
|
|
|
640
642
|
if (!spec.variableWidth) {
|
|
641
643
|
style.width = spec.slideWidth;
|
|
642
644
|
}
|
|
645
|
+
if (spec.vertical && spec.slideHeight) {
|
|
646
|
+
style.height = spec.slideHeight;
|
|
647
|
+
}
|
|
643
648
|
if (spec.fade) {
|
|
644
649
|
style.position = "relative";
|
|
645
650
|
if (spec.vertical) {
|
|
@@ -648,7 +653,7 @@ var getSlideStyle = (spec) => {
|
|
|
648
653
|
style.left = -spec.index * spec.slideWidth;
|
|
649
654
|
}
|
|
650
655
|
style.opacity = spec.currentSlide === spec.index ? 1 : 0;
|
|
651
|
-
style.zIndex = spec.currentSlide === spec.index ?
|
|
656
|
+
style.zIndex = spec.currentSlide === spec.index ? 1 : 0;
|
|
652
657
|
if (spec.useCSS) {
|
|
653
658
|
style.transition = `opacity ${spec.speed}ms ${spec.cssEase}, visibility ${spec.speed}ms ${spec.cssEase}`;
|
|
654
659
|
}
|
|
@@ -904,7 +909,7 @@ var Track = (0, import_react.forwardRef)(function Track2({
|
|
|
904
909
|
const baseTrackStyle = {
|
|
905
910
|
position: "relative",
|
|
906
911
|
display: fade ? "block" : "flex",
|
|
907
|
-
flexDirection: vertical ? "column" : "row",
|
|
912
|
+
...fade ? {} : { flexDirection: vertical ? "column" : "row" },
|
|
908
913
|
...trackStyle
|
|
909
914
|
};
|
|
910
915
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -924,7 +929,7 @@ var Track = (0, import_react.forwardRef)(function Track2({
|
|
|
924
929
|
// src/components/Arrows.tsx
|
|
925
930
|
var import_react2 = require("react");
|
|
926
931
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
927
|
-
var PrevArrowSVG = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
932
|
+
var PrevArrowSVG = ({ className, vertical }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
928
933
|
"svg",
|
|
929
934
|
{
|
|
930
935
|
className,
|
|
@@ -939,7 +944,7 @@ var PrevArrowSVG = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.js
|
|
|
939
944
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", { points: "15 18 9 12 15 6" })
|
|
940
945
|
}
|
|
941
946
|
);
|
|
942
|
-
var NextArrowSVG = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
947
|
+
var NextArrowSVG = ({ className, vertical }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
943
948
|
"svg",
|
|
944
949
|
{
|
|
945
950
|
className,
|
|
@@ -956,9 +961,7 @@ var NextArrowSVG = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.js
|
|
|
956
961
|
);
|
|
957
962
|
var baseArrowStyle = {
|
|
958
963
|
position: "absolute",
|
|
959
|
-
|
|
960
|
-
transform: "translateY(-50%)",
|
|
961
|
-
zIndex: 10,
|
|
964
|
+
zIndex: 100,
|
|
962
965
|
display: "flex",
|
|
963
966
|
alignItems: "center",
|
|
964
967
|
justifyContent: "center",
|
|
@@ -983,6 +986,7 @@ var PrevArrow = ({
|
|
|
983
986
|
slidesToShow,
|
|
984
987
|
infinite,
|
|
985
988
|
centerMode,
|
|
989
|
+
vertical,
|
|
986
990
|
onClick,
|
|
987
991
|
customArrow
|
|
988
992
|
}) => {
|
|
@@ -1014,13 +1018,15 @@ var PrevArrow = ({
|
|
|
1014
1018
|
className: `glide-arrow glide-prev ${!canGo ? "glide-disabled" : ""}`,
|
|
1015
1019
|
style: {
|
|
1016
1020
|
...canGo ? baseArrowStyle : disabledArrowStyle,
|
|
1017
|
-
left: 10
|
|
1021
|
+
left: 10,
|
|
1022
|
+
top: "50%",
|
|
1023
|
+
transform: "translateY(-50%)"
|
|
1018
1024
|
},
|
|
1019
1025
|
onClick: handleClick,
|
|
1020
1026
|
"aria-label": "Previous slide",
|
|
1021
1027
|
"aria-disabled": !canGo,
|
|
1022
1028
|
disabled: !canGo,
|
|
1023
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PrevArrowSVG, {})
|
|
1029
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PrevArrowSVG, { vertical })
|
|
1024
1030
|
}
|
|
1025
1031
|
);
|
|
1026
1032
|
};
|
|
@@ -1030,6 +1036,7 @@ var NextArrow = ({
|
|
|
1030
1036
|
slidesToShow,
|
|
1031
1037
|
infinite,
|
|
1032
1038
|
centerMode,
|
|
1039
|
+
vertical,
|
|
1033
1040
|
onClick,
|
|
1034
1041
|
customArrow
|
|
1035
1042
|
}) => {
|
|
@@ -1064,13 +1071,15 @@ var NextArrow = ({
|
|
|
1064
1071
|
className: `glide-arrow glide-next ${!canGo ? "glide-disabled" : ""}`,
|
|
1065
1072
|
style: {
|
|
1066
1073
|
...canGo ? baseArrowStyle : disabledArrowStyle,
|
|
1067
|
-
right: 10
|
|
1074
|
+
right: 10,
|
|
1075
|
+
top: "50%",
|
|
1076
|
+
transform: "translateY(-50%)"
|
|
1068
1077
|
},
|
|
1069
1078
|
onClick: handleClick,
|
|
1070
1079
|
"aria-label": "Next slide",
|
|
1071
1080
|
"aria-disabled": !canGo,
|
|
1072
1081
|
disabled: !canGo,
|
|
1073
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextArrowSVG, {})
|
|
1082
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextArrowSVG, { vertical })
|
|
1074
1083
|
}
|
|
1075
1084
|
);
|
|
1076
1085
|
};
|
|
@@ -1493,6 +1502,95 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1493
1502
|
scrolling
|
|
1494
1503
|
} = state;
|
|
1495
1504
|
const slideCount = import_react5.Children.count(children);
|
|
1505
|
+
const [breakpoint, setBreakpoint] = import_react5.default.useState(null);
|
|
1506
|
+
(0, import_react5.useEffect)(() => {
|
|
1507
|
+
if (!canUseDOM() || !settings.responsive) return;
|
|
1508
|
+
const responsiveSettings2 = settings.responsive;
|
|
1509
|
+
const breakpoints = responsiveSettings2.map((bp) => bp.breakpoint).sort((a, b) => a - b);
|
|
1510
|
+
const mediaQueryListeners = [];
|
|
1511
|
+
breakpoints.forEach((bp, index) => {
|
|
1512
|
+
let query;
|
|
1513
|
+
if (index === 0) {
|
|
1514
|
+
query = `(max-width: ${bp}px)`;
|
|
1515
|
+
} else {
|
|
1516
|
+
query = `(min-width: ${breakpoints[index - 1] + 1}px) and (max-width: ${bp}px)`;
|
|
1517
|
+
}
|
|
1518
|
+
const mql = window.matchMedia(query);
|
|
1519
|
+
const listener = (e) => {
|
|
1520
|
+
if (e.matches) {
|
|
1521
|
+
setBreakpoint(bp);
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
mql.addEventListener("change", listener);
|
|
1525
|
+
mediaQueryListeners.push({ mql, listener });
|
|
1526
|
+
if (mql.matches) {
|
|
1527
|
+
setBreakpoint(bp);
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
const maxBreakpoint = breakpoints[breakpoints.length - 1];
|
|
1531
|
+
const fullScreenQuery = `(min-width: ${maxBreakpoint + 1}px)`;
|
|
1532
|
+
const fullScreenMql = window.matchMedia(fullScreenQuery);
|
|
1533
|
+
const fullScreenListener = (e) => {
|
|
1534
|
+
if (e.matches) {
|
|
1535
|
+
setBreakpoint(null);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
fullScreenMql.addEventListener("change", fullScreenListener);
|
|
1539
|
+
mediaQueryListeners.push({ mql: fullScreenMql, listener: fullScreenListener });
|
|
1540
|
+
if (fullScreenMql.matches) {
|
|
1541
|
+
setBreakpoint(null);
|
|
1542
|
+
}
|
|
1543
|
+
return () => {
|
|
1544
|
+
mediaQueryListeners.forEach(({ mql, listener }) => {
|
|
1545
|
+
mql.removeEventListener("change", listener);
|
|
1546
|
+
});
|
|
1547
|
+
};
|
|
1548
|
+
}, [settings.responsive]);
|
|
1549
|
+
const responsiveSettings = (0, import_react5.useMemo)(() => {
|
|
1550
|
+
let merged;
|
|
1551
|
+
if (!breakpoint || !settings.responsive) {
|
|
1552
|
+
merged = settings;
|
|
1553
|
+
} else {
|
|
1554
|
+
const matchedBreakpoint = settings.responsive.find((bp) => bp.breakpoint === breakpoint);
|
|
1555
|
+
if (!matchedBreakpoint) {
|
|
1556
|
+
merged = settings;
|
|
1557
|
+
} else if (matchedBreakpoint.settings === "disabled") {
|
|
1558
|
+
merged = { ...settings, slidesToShow: 1, slidesToScroll: 1 };
|
|
1559
|
+
} else {
|
|
1560
|
+
merged = { ...settings, ...matchedBreakpoint.settings };
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
if (merged.centerMode && merged.slidesToScroll > 1) {
|
|
1564
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1565
|
+
console.warn(
|
|
1566
|
+
`slidesToScroll should be equal to 1 in centerMode, you are using ${merged.slidesToScroll}`
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
merged = { ...merged, slidesToScroll: 1 };
|
|
1570
|
+
}
|
|
1571
|
+
if (merged.fade) {
|
|
1572
|
+
if (merged.slidesToShow > 1 && process.env.NODE_ENV !== "production") {
|
|
1573
|
+
console.warn(
|
|
1574
|
+
`slidesToShow should be equal to 1 when fade is true, you're using ${merged.slidesToShow}`
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1577
|
+
if (merged.slidesToScroll > 1 && process.env.NODE_ENV !== "production") {
|
|
1578
|
+
console.warn(
|
|
1579
|
+
`slidesToScroll should be equal to 1 when fade is true, you're using ${merged.slidesToScroll}`
|
|
1580
|
+
);
|
|
1581
|
+
}
|
|
1582
|
+
merged = { ...merged, slidesToShow: 1, slidesToScroll: 1 };
|
|
1583
|
+
}
|
|
1584
|
+
return merged;
|
|
1585
|
+
}, [breakpoint, settings]);
|
|
1586
|
+
const {
|
|
1587
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1588
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
1589
|
+
infinite: responsiveInfinite,
|
|
1590
|
+
centerMode: responsiveCenterMode,
|
|
1591
|
+
dots: responsiveDots,
|
|
1592
|
+
arrows: responsiveArrows
|
|
1593
|
+
} = responsiveSettings;
|
|
1496
1594
|
const {
|
|
1497
1595
|
slideWidth: calculatedSlideWidth,
|
|
1498
1596
|
trackStyle,
|
|
@@ -1504,10 +1602,10 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1504
1602
|
} = useTrack({
|
|
1505
1603
|
currentSlide,
|
|
1506
1604
|
slideCount,
|
|
1507
|
-
slidesToShow,
|
|
1508
|
-
slidesToScroll,
|
|
1509
|
-
infinite,
|
|
1510
|
-
centerMode,
|
|
1605
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1606
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
1607
|
+
infinite: responsiveInfinite,
|
|
1608
|
+
centerMode: responsiveCenterMode,
|
|
1511
1609
|
centerPadding,
|
|
1512
1610
|
listWidth: listWidth || 0,
|
|
1513
1611
|
listHeight: listHeight || 0,
|
|
@@ -1525,47 +1623,53 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1525
1623
|
swipeLeft
|
|
1526
1624
|
});
|
|
1527
1625
|
(0, import_react5.useEffect)(() => {
|
|
1528
|
-
if (!canUseDOM()
|
|
1529
|
-
const
|
|
1626
|
+
if (!canUseDOM()) return;
|
|
1627
|
+
const timeoutId = setTimeout(() => {
|
|
1530
1628
|
if (!listRef.current) return;
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1629
|
+
const updateDimensions = () => {
|
|
1630
|
+
if (!listRef.current) return;
|
|
1631
|
+
const newListWidth = getWidth(listRef.current);
|
|
1632
|
+
const firstSlide = listRef.current.querySelector('[data-index="0"]');
|
|
1633
|
+
const newSlideHeight = firstSlide ? getHeight(firstSlide) : null;
|
|
1634
|
+
const newListHeight = newSlideHeight ? newSlideHeight * responsiveSlidesToShow : null;
|
|
1635
|
+
dispatch({
|
|
1636
|
+
type: "INIT",
|
|
1637
|
+
payload: {
|
|
1638
|
+
listWidth: newListWidth,
|
|
1639
|
+
listHeight: newListHeight,
|
|
1640
|
+
slideHeight: newSlideHeight,
|
|
1641
|
+
slideCount
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
};
|
|
1645
|
+
updateDimensions();
|
|
1646
|
+
if (!resizeObserverRef.current && listRef.current) {
|
|
1647
|
+
resizeObserverRef.current = new ResizeObserver(updateDimensions);
|
|
1648
|
+
resizeObserverRef.current.observe(listRef.current);
|
|
1649
|
+
}
|
|
1650
|
+
if (!initialized) {
|
|
1651
|
+
onInit?.();
|
|
1652
|
+
}
|
|
1653
|
+
}, 0);
|
|
1549
1654
|
return () => {
|
|
1655
|
+
clearTimeout(timeoutId);
|
|
1550
1656
|
resizeObserverRef.current?.disconnect();
|
|
1657
|
+
resizeObserverRef.current = null;
|
|
1551
1658
|
};
|
|
1552
|
-
}, [slideCount, onInit]);
|
|
1553
|
-
const autoplayIterator = (0, import_react5.useCallback)(() => {
|
|
1554
|
-
if (autoplaying !== "playing") return;
|
|
1555
|
-
const nextSlideIndex = currentSlide + slidesToScroll;
|
|
1556
|
-
goToSlide(nextSlideIndex);
|
|
1557
|
-
}, [autoplaying, currentSlide, slidesToScroll]);
|
|
1659
|
+
}, [slideCount, initialized, onInit, responsiveSlidesToShow]);
|
|
1558
1660
|
(0, import_react5.useEffect)(() => {
|
|
1559
|
-
if (!
|
|
1560
|
-
if (
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1661
|
+
if (!initialized || !canUseDOM()) return;
|
|
1662
|
+
if (currentSlide >= slideCount) {
|
|
1663
|
+
const newSlide = Math.max(0, slideCount - responsiveSlidesToShow);
|
|
1664
|
+
if (newSlide !== currentSlide) {
|
|
1665
|
+
dispatch({
|
|
1666
|
+
type: "GO_TO_SLIDE",
|
|
1667
|
+
payload: { slide: newSlide, animated: false }
|
|
1668
|
+
});
|
|
1566
1669
|
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1670
|
+
}
|
|
1671
|
+
onReInit?.();
|
|
1672
|
+
}, [responsiveSlidesToShow, responsiveSlidesToScroll, responsiveInfinite, responsiveCenterMode, initialized, slideCount, currentSlide, onReInit]);
|
|
1569
1673
|
(0, import_react5.useEffect)(() => {
|
|
1570
1674
|
if (animating) {
|
|
1571
1675
|
animationEndTimeoutRef.current = setTimeout(() => {
|
|
@@ -1583,21 +1687,21 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1583
1687
|
(slideIndex, dontAnimate = false) => {
|
|
1584
1688
|
if (waitForAnimate && animating) return;
|
|
1585
1689
|
let targetIndex = slideIndex;
|
|
1586
|
-
if (
|
|
1690
|
+
if (responsiveInfinite) {
|
|
1587
1691
|
if (targetIndex < 0) {
|
|
1588
1692
|
targetIndex = slideCount + targetIndex;
|
|
1589
1693
|
} else if (targetIndex >= slideCount) {
|
|
1590
1694
|
targetIndex = targetIndex - slideCount;
|
|
1591
1695
|
}
|
|
1592
1696
|
} else {
|
|
1593
|
-
targetIndex = clamp(targetIndex, 0, slideCount -
|
|
1697
|
+
targetIndex = clamp(targetIndex, 0, slideCount - responsiveSlidesToShow);
|
|
1594
1698
|
}
|
|
1595
1699
|
beforeChange?.(currentSlide, targetIndex);
|
|
1596
1700
|
if (lazyLoad) {
|
|
1597
1701
|
const slidesToLoad = getOnDemandLazySlides({
|
|
1598
1702
|
currentSlide: targetIndex,
|
|
1599
|
-
centerMode,
|
|
1600
|
-
slidesToShow,
|
|
1703
|
+
centerMode: responsiveCenterMode,
|
|
1704
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1601
1705
|
centerPadding,
|
|
1602
1706
|
lazyLoadedList
|
|
1603
1707
|
});
|
|
@@ -1616,23 +1720,23 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1616
1720
|
[
|
|
1617
1721
|
waitForAnimate,
|
|
1618
1722
|
animating,
|
|
1619
|
-
|
|
1723
|
+
responsiveInfinite,
|
|
1620
1724
|
slideCount,
|
|
1621
|
-
|
|
1725
|
+
responsiveSlidesToShow,
|
|
1622
1726
|
beforeChange,
|
|
1623
1727
|
currentSlide,
|
|
1624
1728
|
lazyLoad,
|
|
1625
|
-
|
|
1729
|
+
responsiveCenterMode,
|
|
1626
1730
|
centerPadding,
|
|
1627
1731
|
lazyLoadedList
|
|
1628
1732
|
]
|
|
1629
1733
|
);
|
|
1630
1734
|
const next = (0, import_react5.useCallback)(() => {
|
|
1631
|
-
goToSlide(currentSlide +
|
|
1632
|
-
}, [currentSlide,
|
|
1735
|
+
goToSlide(currentSlide + responsiveSlidesToScroll);
|
|
1736
|
+
}, [currentSlide, responsiveSlidesToScroll, goToSlide]);
|
|
1633
1737
|
const prev = (0, import_react5.useCallback)(() => {
|
|
1634
|
-
goToSlide(currentSlide -
|
|
1635
|
-
}, [currentSlide,
|
|
1738
|
+
goToSlide(currentSlide - responsiveSlidesToScroll);
|
|
1739
|
+
}, [currentSlide, responsiveSlidesToScroll, goToSlide]);
|
|
1636
1740
|
const goTo = (0, import_react5.useCallback)(
|
|
1637
1741
|
(index, dontAnimate = false) => {
|
|
1638
1742
|
goToSlide(index, dontAnimate);
|
|
@@ -1645,6 +1749,29 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1645
1749
|
const play = (0, import_react5.useCallback)(() => {
|
|
1646
1750
|
dispatch({ type: "SET_AUTOPLAY", payload: "playing" });
|
|
1647
1751
|
}, []);
|
|
1752
|
+
const autoplayTick = (0, import_react5.useCallback)(() => {
|
|
1753
|
+
const nextSlideIndex = currentSlide + responsiveSlidesToScroll;
|
|
1754
|
+
goToSlide(nextSlideIndex);
|
|
1755
|
+
}, [currentSlide, responsiveSlidesToScroll, goToSlide]);
|
|
1756
|
+
(0, import_react5.useEffect)(() => {
|
|
1757
|
+
if (!autoplay || !initialized) return;
|
|
1758
|
+
if (autoplaying === "playing") {
|
|
1759
|
+
if (autoplayTimerRef.current) {
|
|
1760
|
+
clearInterval(autoplayTimerRef.current);
|
|
1761
|
+
}
|
|
1762
|
+
autoplayTimerRef.current = setInterval(autoplayTick, autoplaySpeed + 50);
|
|
1763
|
+
} else {
|
|
1764
|
+
if (autoplayTimerRef.current) {
|
|
1765
|
+
clearInterval(autoplayTimerRef.current);
|
|
1766
|
+
autoplayTimerRef.current = null;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
return () => {
|
|
1770
|
+
if (autoplayTimerRef.current) {
|
|
1771
|
+
clearInterval(autoplayTimerRef.current);
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
}, [autoplay, autoplaying, initialized, autoplayTick, autoplaySpeed]);
|
|
1648
1775
|
(0, import_react5.useImperativeHandle)(
|
|
1649
1776
|
ref,
|
|
1650
1777
|
() => ({
|
|
@@ -1694,16 +1821,16 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1694
1821
|
swiped,
|
|
1695
1822
|
swiping,
|
|
1696
1823
|
slideCount,
|
|
1697
|
-
slidesToScroll,
|
|
1698
|
-
infinite,
|
|
1824
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
1825
|
+
infinite: responsiveInfinite,
|
|
1699
1826
|
touchObject,
|
|
1700
1827
|
swipeEvent,
|
|
1701
1828
|
listHeight: listHeight || 0,
|
|
1702
1829
|
listWidth: listWidth || 0,
|
|
1703
1830
|
slideWidth: calculatedSlideWidth,
|
|
1704
1831
|
slideHeight: slideHeight || 0,
|
|
1705
|
-
centerMode,
|
|
1706
|
-
slidesToShow,
|
|
1832
|
+
centerMode: responsiveCenterMode,
|
|
1833
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1707
1834
|
fade,
|
|
1708
1835
|
disabled,
|
|
1709
1836
|
variableWidth,
|
|
@@ -1730,16 +1857,16 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1730
1857
|
swiped,
|
|
1731
1858
|
swiping,
|
|
1732
1859
|
slideCount,
|
|
1733
|
-
|
|
1734
|
-
|
|
1860
|
+
responsiveSlidesToScroll,
|
|
1861
|
+
responsiveInfinite,
|
|
1735
1862
|
touchObject,
|
|
1736
1863
|
swipeEvent,
|
|
1737
1864
|
listHeight,
|
|
1738
1865
|
listWidth,
|
|
1739
1866
|
calculatedSlideWidth,
|
|
1740
1867
|
slideHeight,
|
|
1741
|
-
|
|
1742
|
-
|
|
1868
|
+
responsiveCenterMode,
|
|
1869
|
+
responsiveSlidesToShow,
|
|
1743
1870
|
fade,
|
|
1744
1871
|
disabled,
|
|
1745
1872
|
variableWidth,
|
|
@@ -1761,13 +1888,13 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1761
1888
|
onSwipe,
|
|
1762
1889
|
targetSlide,
|
|
1763
1890
|
currentSlide,
|
|
1764
|
-
infinite,
|
|
1891
|
+
infinite: responsiveInfinite,
|
|
1765
1892
|
slideCount,
|
|
1766
|
-
slidesToScroll,
|
|
1767
|
-
slidesToShow,
|
|
1893
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
1894
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1768
1895
|
slideWidth: calculatedSlideWidth,
|
|
1769
1896
|
slideHeight: slideHeight || 0,
|
|
1770
|
-
centerMode,
|
|
1897
|
+
centerMode: responsiveCenterMode,
|
|
1771
1898
|
fade,
|
|
1772
1899
|
disabled,
|
|
1773
1900
|
variableWidth,
|
|
@@ -1808,13 +1935,13 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1808
1935
|
onSwipe,
|
|
1809
1936
|
targetSlide,
|
|
1810
1937
|
currentSlide,
|
|
1811
|
-
|
|
1938
|
+
responsiveInfinite,
|
|
1812
1939
|
slideCount,
|
|
1813
|
-
|
|
1814
|
-
|
|
1940
|
+
responsiveSlidesToScroll,
|
|
1941
|
+
responsiveSlidesToShow,
|
|
1815
1942
|
calculatedSlideWidth,
|
|
1816
1943
|
slideHeight,
|
|
1817
|
-
|
|
1944
|
+
responsiveCenterMode,
|
|
1818
1945
|
fade,
|
|
1819
1946
|
disabled,
|
|
1820
1947
|
variableWidth,
|
|
@@ -1881,23 +2008,33 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1881
2008
|
}),
|
|
1882
2009
|
[vertical]
|
|
1883
2010
|
);
|
|
1884
|
-
const listStyle = (0, import_react5.useMemo)(
|
|
1885
|
-
|
|
2011
|
+
const listStyle = (0, import_react5.useMemo)(() => {
|
|
2012
|
+
const style = {
|
|
1886
2013
|
position: "relative",
|
|
1887
2014
|
display: "block",
|
|
1888
2015
|
overflow: "hidden",
|
|
1889
2016
|
margin: 0,
|
|
1890
2017
|
padding: 0
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
|
|
2018
|
+
};
|
|
2019
|
+
if (vertical && listHeight) {
|
|
2020
|
+
style.height = listHeight;
|
|
2021
|
+
}
|
|
2022
|
+
if (responsiveCenterMode) {
|
|
2023
|
+
if (vertical) {
|
|
2024
|
+
style.padding = `${centerPadding} 0px`;
|
|
2025
|
+
} else {
|
|
2026
|
+
style.padding = `0px ${centerPadding}`;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
return style;
|
|
2030
|
+
}, [responsiveCenterMode, vertical, centerPadding, listHeight]);
|
|
1894
2031
|
if (!initialized || !canUseDOM()) {
|
|
1895
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `glide-slider ${className}`.trim(), style: sliderStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "glide-list", style: listStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "glide-track", style: { display: "flex" }, children: import_react5.default.Children.map(children, (child, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `glide-slider ${className}`.trim(), style: sliderStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: listRef, className: "glide-list", style: listStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "glide-track", style: { display: "flex" }, children: import_react5.default.Children.map(children, (child, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1896
2033
|
"div",
|
|
1897
2034
|
{
|
|
1898
2035
|
className: "glide-slide",
|
|
1899
2036
|
style: {
|
|
1900
|
-
width: `${100 /
|
|
2037
|
+
width: `${100 / responsiveSlidesToShow}%`,
|
|
1901
2038
|
flexShrink: 0
|
|
1902
2039
|
},
|
|
1903
2040
|
children: child
|
|
@@ -1915,14 +2052,15 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1915
2052
|
onFocus: handleFocus,
|
|
1916
2053
|
onBlur: handleBlur,
|
|
1917
2054
|
children: [
|
|
1918
|
-
|
|
2055
|
+
responsiveArrows && !disabled && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1919
2056
|
PrevArrow,
|
|
1920
2057
|
{
|
|
1921
2058
|
currentSlide,
|
|
1922
2059
|
slideCount,
|
|
1923
|
-
slidesToShow,
|
|
1924
|
-
infinite,
|
|
1925
|
-
centerMode,
|
|
2060
|
+
slidesToShow: responsiveSlidesToShow,
|
|
2061
|
+
infinite: responsiveInfinite,
|
|
2062
|
+
centerMode: responsiveCenterMode,
|
|
2063
|
+
vertical,
|
|
1926
2064
|
onClick: prev,
|
|
1927
2065
|
customArrow: prevArrow
|
|
1928
2066
|
}
|
|
@@ -1952,10 +2090,10 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1952
2090
|
slideCount,
|
|
1953
2091
|
currentSlide,
|
|
1954
2092
|
targetSlide,
|
|
1955
|
-
slidesToShow,
|
|
1956
|
-
slidesToScroll,
|
|
1957
|
-
infinite,
|
|
1958
|
-
centerMode,
|
|
2093
|
+
slidesToShow: responsiveSlidesToShow,
|
|
2094
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
2095
|
+
infinite: responsiveInfinite,
|
|
2096
|
+
centerMode: responsiveCenterMode,
|
|
1959
2097
|
centerPadding,
|
|
1960
2098
|
fade,
|
|
1961
2099
|
vertical,
|
|
@@ -1974,26 +2112,27 @@ var Glide = (0, import_react5.forwardRef)(function Glide2(props, ref) {
|
|
|
1974
2112
|
)
|
|
1975
2113
|
}
|
|
1976
2114
|
),
|
|
1977
|
-
|
|
2115
|
+
responsiveArrows && !disabled && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1978
2116
|
NextArrow,
|
|
1979
2117
|
{
|
|
1980
2118
|
currentSlide,
|
|
1981
2119
|
slideCount,
|
|
1982
|
-
slidesToShow,
|
|
1983
|
-
infinite,
|
|
1984
|
-
centerMode,
|
|
2120
|
+
slidesToShow: responsiveSlidesToShow,
|
|
2121
|
+
infinite: responsiveInfinite,
|
|
2122
|
+
centerMode: responsiveCenterMode,
|
|
2123
|
+
vertical,
|
|
1985
2124
|
onClick: next,
|
|
1986
2125
|
customArrow: nextArrow
|
|
1987
2126
|
}
|
|
1988
2127
|
),
|
|
1989
|
-
|
|
2128
|
+
responsiveDots && !disabled && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1990
2129
|
Dots,
|
|
1991
2130
|
{
|
|
1992
2131
|
slideCount,
|
|
1993
|
-
slidesToScroll,
|
|
1994
|
-
slidesToShow,
|
|
2132
|
+
slidesToScroll: responsiveSlidesToScroll,
|
|
2133
|
+
slidesToShow: responsiveSlidesToShow,
|
|
1995
2134
|
currentSlide,
|
|
1996
|
-
infinite,
|
|
2135
|
+
infinite: responsiveInfinite,
|
|
1997
2136
|
onDotClick: handleDotClick,
|
|
1998
2137
|
customPaging,
|
|
1999
2138
|
appendDots,
|