Skip to content

Commit

Permalink
feat: #27 useBottomSheet Hook event type 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
imb96 committed Oct 29, 2023
1 parent dc4fd68 commit 80faa86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/components/shared/ModalBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from '@emotion/styled';

import { useBottomSheet } from '@hooks/useBottomSheet';

type ModalBottomProps = {
type ModalBottomSheetProps = {
children: React.ReactNode;
setShowModal: React.Dispatch<React.SetStateAction<boolean>>;
};
Expand All @@ -25,7 +25,7 @@ const StyledBottomSheet = styled.div`
left: 0;
width: 100%;
height: 75%;
${({ theme }) => theme.STYLES.FLEX_CENTER}
${({ theme }) => theme.STYLES.FLEX_CENTER};
flex-direction: column;
background-color: white;
border-top-left-radius: 0.75rem;
Expand Down Expand Up @@ -65,7 +65,7 @@ const BottomSheet = ({ children }: { children: React.ReactNode }) => (
<StyledBottomSheet>{children}</StyledBottomSheet>
);

export const ModalBottomSheet = (props: ModalBottomProps) => {
export const ModalBottomSheet = (props: ModalBottomSheetProps) => {
const [isModalVisible, setIsModalVisible] = useState(true);
const modalRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -115,22 +115,24 @@ export const ModalBottomSheet = (props: ModalBottomProps) => {
}
);

const BottomSheetContainer = styled.div``;

return (
<StyledModalBottom>
{isModalVisible && (
<>
<StyledDeemBackground />
<div
<BottomSheetContainer
ref={modalRef}
onTouchStart={() => handleTouchStart}
onTouchMove={() => handleTouchMove}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
<BottomSheet {...props}>
<StyledModalHeader />
{props.children}
</BottomSheet>
</div>
</BottomSheetContainer>
</>
)}
</StyledModalBottom>
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useBottomSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const useBottomSheet = (closeModal: () => void) => {
move: 0,
});

const handleTouchStart = (event: TouchEvent) => {
const handleTouchStart = (event: React.TouchEvent) => {
record.current.first = event.touches[0].screenY;
};

const handleTouchMove = useCallback((event: TouchEvent) => {
const handleTouchMove = useCallback((event: React.TouchEvent) => {
if (!record.current.move) {
record.current.move = event.touches[0].screenY;
}
Expand Down

0 comments on commit 80faa86

Please sign in to comment.