Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] NumberKeyboardBottomSheet 영역에서 스크롤이 가능한 문제 #633

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import {css} from '@emotion/react';
import {createPortal} from 'react-dom';
import {useEffect, useRef} from 'react';

import {useTheme} from '@components/Design/theme/HDesignProvider';

import FixedButton from '../FixedButton/FixedButton';

import NumberKeyboard, {NumberKeyboardProps} from './NumberKeyboard';
import useNumberKeyboardBottomSheet from './useNumberKeyboardBottomSheet';

interface Props extends NumberKeyboardProps {
isOpened?: boolean;
isOpened: boolean;
onClose: () => void;
}

const NumberKeyboardBottomSheet = ({isOpened, onClose, ...props}: Props) => {
const {theme} = useTheme();
const {bottomSheetRef} = useNumberKeyboardBottomSheet({isOpened});

return createPortal(
<div
ref={bottomSheetRef}
css={css`
position: fixed;
padding-bottom: 6.25rem;
Expand All @@ -26,6 +31,8 @@ const NumberKeyboardBottomSheet = ({isOpened, onClose, ...props}: Props) => {
gap: 1rem;
bottom: 0;
background-color: ${theme.colors.white};
z-index: 20;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나아..중에,, 제가 만들어 둔 z-index token을 사용해야 겠군여

touch-action: none;
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

touch action을 막아주신 코드인거죠?

Copy link
Contributor Author

@Todari Todari Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞숨당~


transform: ${isOpened ? 'translate3d(0, 0, 0)' : 'translate3d(0, 100%, 0)'};
transition: 0.2s ease-in-out;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {useEffect, useRef} from 'react';

interface Props {
isOpened: boolean;
}

const useNumberKeyboardBottomSheet = ({isOpened}: Props) => {
const bottomSheetRef = useRef<HTMLDivElement>(null);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 굳이 싶을 수도 있긴한데요.! usePreventTouchMove라는 유틸함수 또는 훅으로 분리해서 사용할 수도 있을 것 같아요! 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 그것도 좋은 방법이라고 생각합니다. touch를 막는 부분이 또 필요하다면 분리해보도록 할게요!

const bottomSheet = bottomSheetRef.current;
if (!bottomSheet) return;

const preventScroll = (e: TouchEvent) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳굳쓰 ~

if (bottomSheet.contains(e.target as Node)) {
e.preventDefault();
}
};

if (isOpened) {
document.addEventListener('touchmove', preventScroll, {passive: false});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passive false는 어떤 의미인가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passive 리스너는 preventDefault를 호출하지 않는 역할을 합니다~
touchMove event는 기본적으로 passive event 인데,
우리는 preventDefault를 호출하기 때문에 passive:false 를 통해서 preventDefault를 사용한다고 알려줘야합니당~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

touchMove라는 이벤트가 있었구뇽..!! 덕분에 알게됐어요 😆👍

}

return () => {
document.removeEventListener('touchmove', preventScroll);
};
}, [isOpened]);

return {bottomSheetRef};
};

export default useNumberKeyboardBottomSheet;
Loading