-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -26,6 +31,8 @@ const NumberKeyboardBottomSheet = ({isOpened, onClose, ...props}: Props) => { | |
gap: 1rem; | ||
bottom: 0; | ||
background-color: ${theme.colors.white}; | ||
z-index: 20; | ||
touch-action: none; | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. touch action을 막아주신 코드인거죠? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
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(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 굳이 싶을 수도 있긴한데요.! usePreventTouchMove라는 유틸함수 또는 훅으로 분리해서 사용할 수도 있을 것 같아요! 😁 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 그것도 좋은 방법이라고 생각합니다. touch를 막는 부분이 또 필요하다면 분리해보도록 할게요! |
||
const bottomSheet = bottomSheetRef.current; | ||
if (!bottomSheet) return; | ||
|
||
const preventScroll = (e: TouchEvent) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passive false는 어떤 의미인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. passive 리스너는 preventDefault를 호출하지 않는 역할을 합니다~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. touchMove라는 이벤트가 있었구뇽..!! 덕분에 알게됐어요 😆👍 |
||
} | ||
|
||
return () => { | ||
document.removeEventListener('touchmove', preventScroll); | ||
}; | ||
}, [isOpened]); | ||
|
||
return {bottomSheetRef}; | ||
}; | ||
|
||
export default useNumberKeyboardBottomSheet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나아..중에,, 제가 만들어 둔 z-index token을 사용해야 겠군여