@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.js
CHANGED
|
@@ -5871,6 +5871,7 @@ const dialogRecipe = sva({
|
|
|
5871
5871
|
left: "0",
|
|
5872
5872
|
width: "100vw",
|
|
5873
5873
|
zIndex: "overlay",
|
|
5874
|
+
pointerEvents: "auto",
|
|
5874
5875
|
_open: {
|
|
5875
5876
|
animation: "backdrop-in"
|
|
5876
5877
|
},
|
|
@@ -9540,7 +9541,8 @@ const useBottomSheet = (props) => {
|
|
|
9540
9541
|
initTransformValue: 0,
|
|
9541
9542
|
canDragRef: true,
|
|
9542
9543
|
maxTransformValue: 0,
|
|
9543
|
-
initialOpenHeightPx: 0
|
|
9544
|
+
initialOpenHeightPx: 0,
|
|
9545
|
+
isBottomSheetOpen: false
|
|
9544
9546
|
});
|
|
9545
9547
|
const [springs, api] = useSpring(() => ({
|
|
9546
9548
|
transform: "translateY(0px)",
|
|
@@ -9552,18 +9554,20 @@ const useBottomSheet = (props) => {
|
|
|
9552
9554
|
transform: `translateY(${maxTransformValue}px)`,
|
|
9553
9555
|
config: SPRING_CONFIG.up
|
|
9554
9556
|
});
|
|
9555
|
-
if (onOpen) onOpen();
|
|
9557
|
+
if (onOpen && !metrics.current.isBottomSheetOpen) onOpen();
|
|
9558
|
+
metrics.current.isBottomSheetOpen = true;
|
|
9556
9559
|
};
|
|
9557
9560
|
const snapToMin = () => {
|
|
9558
9561
|
api.start({
|
|
9559
9562
|
transform: "translateY(0px)",
|
|
9560
9563
|
config: SPRING_CONFIG.down
|
|
9561
9564
|
});
|
|
9562
|
-
if (onClose) onClose();
|
|
9565
|
+
if (onClose && metrics.current.isBottomSheetOpen) onClose();
|
|
9566
|
+
metrics.current.isBottomSheetOpen = false;
|
|
9563
9567
|
};
|
|
9564
9568
|
const handleContentTouch = (e) => {
|
|
9565
9569
|
const target = e.target;
|
|
9566
|
-
if (!target.matches(INTERACTIVE_ELEMENTS) && expendOnContentDrag) {
|
|
9570
|
+
if (!target.matches(INTERACTIVE_ELEMENTS) && expendOnContentDrag || !metrics.current.isBottomSheetOpen) {
|
|
9567
9571
|
metrics.current.canDragRef = true;
|
|
9568
9572
|
} else {
|
|
9569
9573
|
metrics.current.canDragRef = false;
|
|
@@ -9579,9 +9583,7 @@ const useBottomSheet = (props) => {
|
|
|
9579
9583
|
return;
|
|
9580
9584
|
}
|
|
9581
9585
|
const currentTransform = springs.transform.get();
|
|
9582
|
-
const initTransformValue = Number(
|
|
9583
|
-
currentTransform.replace("translateY(", "").replace("px)", "") || 0
|
|
9584
|
-
);
|
|
9586
|
+
const initTransformValue = Number(currentTransform.replace("translateY(", "").replace("px)", "") || 0);
|
|
9585
9587
|
metrics.current.initTransformValue = initTransformValue;
|
|
9586
9588
|
metrics.current.initTouchPosition = clientY;
|
|
9587
9589
|
};
|
|
@@ -9607,9 +9609,7 @@ const useBottomSheet = (props) => {
|
|
|
9607
9609
|
return;
|
|
9608
9610
|
}
|
|
9609
9611
|
const currentTransform = springs.transform.get();
|
|
9610
|
-
const finalTransformValue = Number(
|
|
9611
|
-
currentTransform.replace("translateY(", "").replace("px)", "") || 0
|
|
9612
|
-
);
|
|
9612
|
+
const finalTransformValue = Number(currentTransform.replace("translateY(", "").replace("px)", "") || 0);
|
|
9613
9613
|
const transformedDistance = initTransformValue - finalTransformValue;
|
|
9614
9614
|
if (transformedDistance < 0 && SNAP_TO_MIN_THRESHOLD < Math.abs(transformedDistance)) {
|
|
9615
9615
|
snapToMin();
|
|
@@ -9636,21 +9636,55 @@ const useBottomSheet = (props) => {
|
|
|
9636
9636
|
up: handleEnd,
|
|
9637
9637
|
leave: handleEnd
|
|
9638
9638
|
};
|
|
9639
|
+
const preventScrollOnBackdrop = (e) => {
|
|
9640
|
+
if (bottomSheetRef.current && (bottomSheetRef.current.contains(e.target) || // 최소 높이로 떠 있는 바텀시트의 핸들 영역을 클릭하는 경우 특별 처리
|
|
9641
|
+
e instanceof TouchEvent && isBottomSheetHandleArea(e.touches[0].clientY))) {
|
|
9642
|
+
return;
|
|
9643
|
+
}
|
|
9644
|
+
e.preventDefault();
|
|
9645
|
+
e.stopPropagation();
|
|
9646
|
+
};
|
|
9647
|
+
const isBottomSheetHandleArea = (clientY) => {
|
|
9648
|
+
if (!bottomSheetRef.current) return false;
|
|
9649
|
+
const { initialOpenHeightPx } = metrics.current;
|
|
9650
|
+
const bottomSheetTop = window.innerHeight - initialOpenHeightPx;
|
|
9651
|
+
const handleAreaTop = bottomSheetTop;
|
|
9652
|
+
const handleAreaBottom = bottomSheetTop + BOTTOM_SHEET_HANDLE_HEIGHT;
|
|
9653
|
+
return clientY >= handleAreaTop && clientY <= handleAreaBottom;
|
|
9654
|
+
};
|
|
9655
|
+
const handleTouchStart = (e) => {
|
|
9656
|
+
const clientY = e.touches[0].clientY;
|
|
9657
|
+
if (isBottomSheetHandleArea(clientY)) {
|
|
9658
|
+
e.preventDefault();
|
|
9659
|
+
e.stopPropagation();
|
|
9660
|
+
handleTouch.start(e);
|
|
9661
|
+
}
|
|
9662
|
+
};
|
|
9639
9663
|
useEffect(() => {
|
|
9640
9664
|
if (isOpen) snapToMax();
|
|
9641
9665
|
else snapToMin();
|
|
9642
|
-
const handleTouchMove = (e) => {
|
|
9643
|
-
if (bottomSheetRef.current && !bottomSheetRef.current.contains(e.target)) {
|
|
9644
|
-
e.preventDefault();
|
|
9645
|
-
}
|
|
9646
|
-
};
|
|
9647
9666
|
if (isOpen) {
|
|
9648
|
-
document.addEventListener("touchmove",
|
|
9667
|
+
document.addEventListener("touchmove", preventScrollOnBackdrop, { passive: false });
|
|
9668
|
+
document.addEventListener("wheel", preventScrollOnBackdrop, { passive: false });
|
|
9669
|
+
document.addEventListener("mousewheel", preventScrollOnBackdrop, { passive: false });
|
|
9670
|
+
document.addEventListener("touchstart", handleTouchStart, { passive: false });
|
|
9671
|
+
document.body.style.overflow = "hidden";
|
|
9672
|
+
document.body.style.touchAction = "none";
|
|
9649
9673
|
} else {
|
|
9650
|
-
document.removeEventListener("touchmove",
|
|
9674
|
+
document.removeEventListener("touchmove", preventScrollOnBackdrop);
|
|
9675
|
+
document.removeEventListener("wheel", preventScrollOnBackdrop);
|
|
9676
|
+
document.removeEventListener("mousewheel", preventScrollOnBackdrop);
|
|
9677
|
+
document.removeEventListener("touchstart", handleTouchStart);
|
|
9678
|
+
document.body.style.overflow = "";
|
|
9679
|
+
document.body.style.touchAction = "";
|
|
9651
9680
|
}
|
|
9652
9681
|
return () => {
|
|
9653
|
-
document.removeEventListener("touchmove",
|
|
9682
|
+
document.removeEventListener("touchmove", preventScrollOnBackdrop);
|
|
9683
|
+
document.removeEventListener("wheel", preventScrollOnBackdrop);
|
|
9684
|
+
document.removeEventListener("mousewheel", preventScrollOnBackdrop);
|
|
9685
|
+
document.removeEventListener("touchstart", handleTouchStart);
|
|
9686
|
+
document.body.style.overflow = "";
|
|
9687
|
+
document.body.style.touchAction = "";
|
|
9654
9688
|
};
|
|
9655
9689
|
}, [isOpen]);
|
|
9656
9690
|
useEffect(() => {
|
|
@@ -9658,7 +9692,7 @@ const useBottomSheet = (props) => {
|
|
|
9658
9692
|
const contentElement = contentRef.current;
|
|
9659
9693
|
metrics.current.initialOpenHeightPx = window.innerHeight * (snapPercent.min > 1 ? 1 : snapPercent.min);
|
|
9660
9694
|
if (snapPercent.max === "INNER_HEIGHT" && contentElement) {
|
|
9661
|
-
metrics.current.maxTransformValue = (contentElement.clientHeight
|
|
9695
|
+
metrics.current.maxTransformValue = (contentElement.clientHeight + BOTTOM_SHEET_HANDLE_HEIGHT) * -1;
|
|
9662
9696
|
} else if (typeof snapPercent.max === "number") {
|
|
9663
9697
|
metrics.current.maxTransformValue = (window.innerHeight - metrics.current.initialOpenHeightPx) * (snapPercent.max > 1 ? 1 : snapPercent.max) * -1;
|
|
9664
9698
|
}
|