Skip to content

Commit

Permalink
πŸ› fix: BottomSheet μ™ΈλΆ€μ˜ μ˜μ—­μ€ μƒν˜Έμž‘μš©ν•  수 없도둝 μˆ˜μ •ν•˜κΈ° #50
Browse files Browse the repository at this point in the history
  • Loading branch information
naarang committed Oct 25, 2024
1 parent a3c82f4 commit 1ef3d3d
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions src/components/Common/BottomSheetLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,50 @@ const BottomSheetLayout = ({
}
}, [contentRef]);

useEffect(() => {
if (isShowBottomsheet) document.body.style.overflow = 'hidden';
else document.body.style.overflow = 'auto';

return () => {
document.body.style.overflow = 'auto';
};
}, [isShowBottomsheet]);

return (
<motion.div
drag="y"
initial="hidden"
{...(isAvailableHidden ? { onDragEnd } : {})}
animate={controls}
transition={{
type: 'spring',
damping: 40,
stiffness: 400,
}}
variants={{
visible: { y: 0 },
hidden: { y: '100%' },
}}
dragConstraints={{
top: 0,
bottom: contentHeight,
}} // 상단과 ν•˜λ‹¨ λ“œλž˜κ·Έ μ œν•œ μ„€μ •
dragElastic={0.2}
className={`fixed left-0 bottom-0 w-full h-[90vh] p-[1.5rem] pb-[2.5rem] rounded-t-[2.5rem] bg-white shadow-bottomSheetShadow z-30`}
style={{
top: `${VIEW_HEIGHT - contentHeight - LAYOUT_MARGIN}px`,
}}
>
{hasHandlebar && (
<div className="mx-auto mt-[-0.5rem] mb-[1.5rem] w-[4rem] border-[0.125rem] border-[#F1F2F6]"></div>
<>
{isShowBottomsheet && (
<div className="fixed top-0 bottom-0 left-0 right-0 bg-transparent z-30"></div>
)}
<div ref={contentRef}>{children}</div>
</motion.div>
<motion.div
drag="y"
initial="hidden"
{...(isAvailableHidden ? { onDragEnd } : {})}
animate={controls}
transition={{
type: 'spring',
damping: 40,
stiffness: 400,
}}
variants={{
visible: { y: 0 },
hidden: { y: '100%' },
}}
dragConstraints={{
top: 0,
bottom: contentHeight,
}} // 상단과 ν•˜λ‹¨ λ“œλž˜κ·Έ μ œν•œ μ„€μ •
dragElastic={0.2}
className={`fixed left-0 bottom-0 w-full h-[90vh] p-[1.5rem] pb-[2.5rem] rounded-t-[2.5rem] bg-white shadow-bottomSheetShadow z-30`}
style={{
top: `${VIEW_HEIGHT - contentHeight - LAYOUT_MARGIN}px`,
}}
>
{hasHandlebar && (
<div className="mx-auto mt-[-0.5rem] mb-[1.5rem] w-[4rem] border-[0.125rem] border-[#F1F2F6]"></div>
)}
<div ref={contentRef}>{children}</div>
</motion.div>
</>
);
};

Expand Down

0 comments on commit 1ef3d3d

Please sign in to comment.