@nation-a/ui 0.10.0 → 0.10.2
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/index.cjs +53 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5889,6 +5889,7 @@ const dialogRecipe = sva({
|
|
|
5889
5889
|
left: "0",
|
|
5890
5890
|
width: "100vw",
|
|
5891
5891
|
zIndex: "overlay",
|
|
5892
|
+
pointerEvents: "auto",
|
|
5892
5893
|
_open: {
|
|
5893
5894
|
animation: "backdrop-in"
|
|
5894
5895
|
},
|
|
@@ -9558,7 +9559,8 @@ const useBottomSheet = (props) => {
|
|
|
9558
9559
|
initTransformValue: 0,
|
|
9559
9560
|
canDragRef: true,
|
|
9560
9561
|
maxTransformValue: 0,
|
|
9561
|
-
initialOpenHeightPx: 0
|
|
9562
|
+
initialOpenHeightPx: 0,
|
|
9563
|
+
isBottomSheetOpen: false
|
|
9562
9564
|
});
|
|
9563
9565
|
const [springs, api] = useSpring(() => ({
|
|
9564
9566
|
transform: "translateY(0px)",
|
|
@@ -9570,18 +9572,20 @@ const useBottomSheet = (props) => {
|
|
|
9570
9572
|
transform: `translateY(${maxTransformValue}px)`,
|
|
9571
9573
|
config: SPRING_CONFIG.up
|
|
9572
9574
|
});
|
|
9573
|
-
if (onOpen) onOpen();
|
|
9575
|
+
if (onOpen && !metrics.current.isBottomSheetOpen) onOpen();
|
|
9576
|
+
metrics.current.isBottomSheetOpen = true;
|
|
9574
9577
|
};
|
|
9575
9578
|
const snapToMin = () => {
|
|
9576
9579
|
api.start({
|
|
9577
9580
|
transform: "translateY(0px)",
|
|
9578
9581
|
config: SPRING_CONFIG.down
|
|
9579
9582
|
});
|
|
9580
|
-
if (onClose) onClose();
|
|
9583
|
+
if (onClose && metrics.current.isBottomSheetOpen) onClose();
|
|
9584
|
+
metrics.current.isBottomSheetOpen = false;
|
|
9581
9585
|
};
|
|
9582
9586
|
const handleContentTouch = (e) => {
|
|
9583
9587
|
const target = e.target;
|
|
9584
|
-
if (!target.matches(INTERACTIVE_ELEMENTS) && expendOnContentDrag) {
|
|
9588
|
+
if (!target.matches(INTERACTIVE_ELEMENTS) && expendOnContentDrag || !metrics.current.isBottomSheetOpen) {
|
|
9585
9589
|
metrics.current.canDragRef = true;
|
|
9586
9590
|
} else {
|
|
9587
9591
|
metrics.current.canDragRef = false;
|
|
@@ -9597,9 +9601,7 @@ const useBottomSheet = (props) => {
|
|
|
9597
9601
|
return;
|
|
9598
9602
|
}
|
|
9599
9603
|
const currentTransform = springs.transform.get();
|
|
9600
|
-
const initTransformValue = Number(
|
|
9601
|
-
currentTransform.replace("translateY(", "").replace("px)", "") || 0
|
|
9602
|
-
);
|
|
9604
|
+
const initTransformValue = Number(currentTransform.replace("translateY(", "").replace("px)", "") || 0);
|
|
9603
9605
|
metrics.current.initTransformValue = initTransformValue;
|
|
9604
9606
|
metrics.current.initTouchPosition = clientY;
|
|
9605
9607
|
};
|
|
@@ -9625,9 +9627,7 @@ const useBottomSheet = (props) => {
|
|
|
9625
9627
|
return;
|
|
9626
9628
|
}
|
|
9627
9629
|
const currentTransform = springs.transform.get();
|
|
9628
|
-
const finalTransformValue = Number(
|
|
9629
|
-
currentTransform.replace("translateY(", "").replace("px)", "") || 0
|
|
9630
|
-
);
|
|
9630
|
+
const finalTransformValue = Number(currentTransform.replace("translateY(", "").replace("px)", "") || 0);
|
|
9631
9631
|
const transformedDistance = initTransformValue - finalTransformValue;
|
|
9632
9632
|
if (transformedDistance < 0 && SNAP_TO_MIN_THRESHOLD < Math.abs(transformedDistance)) {
|
|
9633
9633
|
snapToMin();
|
|
@@ -9654,21 +9654,55 @@ const useBottomSheet = (props) => {
|
|
|
9654
9654
|
up: handleEnd,
|
|
9655
9655
|
leave: handleEnd
|
|
9656
9656
|
};
|
|
9657
|
+
const preventScrollOnBackdrop = (e) => {
|
|
9658
|
+
if (bottomSheetRef.current && (bottomSheetRef.current.contains(e.target) || // 최소 높이로 떠 있는 바텀시트의 핸들 영역을 클릭하는 경우 특별 처리
|
|
9659
|
+
e instanceof TouchEvent && isBottomSheetHandleArea(e.touches[0].clientY))) {
|
|
9660
|
+
return;
|
|
9661
|
+
}
|
|
9662
|
+
e.preventDefault();
|
|
9663
|
+
e.stopPropagation();
|
|
9664
|
+
};
|
|
9665
|
+
const isBottomSheetHandleArea = (clientY) => {
|
|
9666
|
+
if (!bottomSheetRef.current) return false;
|
|
9667
|
+
const { initialOpenHeightPx } = metrics.current;
|
|
9668
|
+
const bottomSheetTop = window.innerHeight - initialOpenHeightPx;
|
|
9669
|
+
const handleAreaTop = bottomSheetTop;
|
|
9670
|
+
const handleAreaBottom = bottomSheetTop + BOTTOM_SHEET_HANDLE_HEIGHT;
|
|
9671
|
+
return clientY >= handleAreaTop && clientY <= handleAreaBottom;
|
|
9672
|
+
};
|
|
9673
|
+
const handleTouchStart = (e) => {
|
|
9674
|
+
const clientY = e.touches[0].clientY;
|
|
9675
|
+
if (isBottomSheetHandleArea(clientY)) {
|
|
9676
|
+
e.preventDefault();
|
|
9677
|
+
e.stopPropagation();
|
|
9678
|
+
handleTouch.start(e);
|
|
9679
|
+
}
|
|
9680
|
+
};
|
|
9657
9681
|
React.useEffect(() => {
|
|
9658
9682
|
if (isOpen) snapToMax();
|
|
9659
9683
|
else snapToMin();
|
|
9660
|
-
const handleTouchMove = (e) => {
|
|
9661
|
-
if (bottomSheetRef.current && !bottomSheetRef.current.contains(e.target)) {
|
|
9662
|
-
e.preventDefault();
|
|
9663
|
-
}
|
|
9664
|
-
};
|
|
9665
9684
|
if (isOpen) {
|
|
9666
|
-
document.addEventListener("touchmove",
|
|
9685
|
+
document.addEventListener("touchmove", preventScrollOnBackdrop, { passive: false });
|
|
9686
|
+
document.addEventListener("wheel", preventScrollOnBackdrop, { passive: false });
|
|
9687
|
+
document.addEventListener("mousewheel", preventScrollOnBackdrop, { passive: false });
|
|
9688
|
+
document.addEventListener("touchstart", handleTouchStart, { passive: false });
|
|
9689
|
+
document.body.style.overflow = "hidden";
|
|
9690
|
+
document.body.style.touchAction = "none";
|
|
9667
9691
|
} else {
|
|
9668
|
-
document.removeEventListener("touchmove",
|
|
9692
|
+
document.removeEventListener("touchmove", preventScrollOnBackdrop);
|
|
9693
|
+
document.removeEventListener("wheel", preventScrollOnBackdrop);
|
|
9694
|
+
document.removeEventListener("mousewheel", preventScrollOnBackdrop);
|
|
9695
|
+
document.removeEventListener("touchstart", handleTouchStart);
|
|
9696
|
+
document.body.style.overflow = "";
|
|
9697
|
+
document.body.style.touchAction = "";
|
|
9669
9698
|
}
|
|
9670
9699
|
return () => {
|
|
9671
|
-
document.removeEventListener("touchmove",
|
|
9700
|
+
document.removeEventListener("touchmove", preventScrollOnBackdrop);
|
|
9701
|
+
document.removeEventListener("wheel", preventScrollOnBackdrop);
|
|
9702
|
+
document.removeEventListener("mousewheel", preventScrollOnBackdrop);
|
|
9703
|
+
document.removeEventListener("touchstart", handleTouchStart);
|
|
9704
|
+
document.body.style.overflow = "";
|
|
9705
|
+
document.body.style.touchAction = "";
|
|
9672
9706
|
};
|
|
9673
9707
|
}, [isOpen]);
|
|
9674
9708
|
React.useEffect(() => {
|
|
@@ -9676,7 +9710,7 @@ const useBottomSheet = (props) => {
|
|
|
9676
9710
|
const contentElement = contentRef.current;
|
|
9677
9711
|
metrics.current.initialOpenHeightPx = window.innerHeight * (snapPercent.min > 1 ? 1 : snapPercent.min);
|
|
9678
9712
|
if (snapPercent.max === "INNER_HEIGHT" && contentElement) {
|
|
9679
|
-
metrics.current.maxTransformValue = (contentElement.clientHeight
|
|
9713
|
+
metrics.current.maxTransformValue = (contentElement.clientHeight + BOTTOM_SHEET_HANDLE_HEIGHT) * -1;
|
|
9680
9714
|
} else if (typeof snapPercent.max === "number") {
|
|
9681
9715
|
metrics.current.maxTransformValue = (window.innerHeight - metrics.current.initialOpenHeightPx) * (snapPercent.max > 1 ? 1 : snapPercent.max) * -1;
|
|
9682
9716
|
}
|