-
Notifications
You must be signed in to change notification settings - Fork 0
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] feat: 스크롤 기능 구현 #348
[FE] feat: 스크롤 기능 구현 #348
Conversation
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.
수고했어요 해옹~ 코멘트 확인해주세옹
@@ -30,10 +31,11 @@ const MIN_CONTENT_LENGTH = 0; | |||
|
|||
interface ReviewRegisterFormProps { | |||
product: ProductDetail; | |||
targetRef: React.RefObject<HTMLElement>; |
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.
이거 위에서
import type { RefObject } from 'react';
이렇게 import 할 수 있습니돠
frontend/src/hooks/useScroll.ts
Outdated
} | ||
}; | ||
|
||
const scrollToPosition = (targetRef?: React.RefObject<HTMLElement>) => { |
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.
이것두!
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.
const scrollToPosition = (targetRef?: React.RefObject<HTMLElement>) => { | |
const scrollToPosition = <T extends HTMLElement>(targetRef?: RefObject<T>) => { |
이건 어떤가요?!
frontend/src/pages/HomePage.tsx
Outdated
@@ -3,6 +3,7 @@ import { Link as RouterLink } from 'react-router-dom'; | |||
import styled from 'styled-components'; | |||
|
|||
import { CategoryMenu, SvgIcon } from '@/components/Common'; | |||
import ScrollButton from '@/components/Common/ScrollButton/ScrollButton'; |
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.
잊지말자
index.ts
closeReviewDialog: () => void; | ||
} | ||
|
||
const ReviewRegisterForm = ({ product, closeReviewDialog }: ReviewRegisterFormProps) => { | ||
const ReviewRegisterForm = ({ product, targetRef, closeReviewDialog }: ReviewRegisterFormProps) => { |
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.
여기도 forwardRef 쓸 수 있을 것 같아요
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.
여기는 useScroll과의 충돌로....슬프지만....🥲
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.
어떤 충돌이 있었나요??
frontend/src/hooks/useScroll.ts
Outdated
if (mainElement) { | ||
mainElement.scrollTo(0, 0); | ||
} |
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.
근데 이 조건은 왜 필요한건가요?!
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.
id가 main인 곳에만 scroll 0이 적용되어 사용하였습니다~
bottom: 90px; | ||
right: 32%; | ||
border-radius: 50%; | ||
z-index: 1; |
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는 없어도 될 것 같아요!
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.
해온 수고했어요!
스크롤 버튼을 만들어서 한결 사용자 경험이 좋아졌네요 👍
코멘트 확인해주세요
frontend/src/hooks/useScroll.ts
Outdated
|
||
const useScroll = () => { | ||
const scrollToTop = () => { | ||
const mainElement = document.getElementById('main'); |
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.
리액트에서 돔 요소에 직접 접근하면 위험해서 수정이 필요해 보여요
리액트 렌더링(가상돔에서 돔으로)이 예측 불가능 할 수 있습니다.!
이 부분도 ref로 수정을 해야할거 같네요
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.
수정 완~~~
closeReviewDialog: () => void; | ||
} | ||
|
||
const ReviewRegisterForm = ({ product, closeReviewDialog }: ReviewRegisterFormProps) => { | ||
const ReviewRegisterForm = ({ product, targetRef, closeReviewDialog }: ReviewRegisterFormProps) => { |
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.
어떤 충돌이 있었나요??
@xodms0309 @Leejin-Yang 수정 완료했습니당 |
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.
해온 짱입니다 🐼
@@ -7,9 +8,22 @@ import useScroll from '@/hooks/useScroll'; | |||
|
|||
const ScrollButton = () => { | |||
const { scrollToTop } = useScroll(); | |||
const [scrollTop, setScrollTop] = useState(false); | |||
const mainElement = document.getElementById('main'); |
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.
이 친구도 useEffect 안으로 들어가면 되겠네요
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.
어 이거 쓰다 만거다
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.
아침에 말한거입니다~
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.
zzzzzzzz 오키
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.
수고했어요 해옹 애증의 스크롤..
고마워용 타미...근데 approve는,,,,?ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ |
export default ScrollButton; | ||
|
||
const ScrollButtonWrapper = styled(Button)` | ||
position: fixed; |
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.
fixed는 뷰포트 따라가서 absolute로 하면 될듯합니다
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.
이거 이제 봤네
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.
에 뭐야 absolute 해도 따라오네요 머쓱
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.
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 수고했어요~~~~
Issue
✨ 구현한 기능
스크롤 버튼을 클릭하면 최상단으로 이동합니다.
리뷰 작성 완료 후 리뷰 위치로 이동합니다.
📢 논의하고 싶은 내용
ref type 제대로 적었는지 확인해주세용~
fixed를 사용했는데요. 이게 개발자 도구를 키면 이동하네요...
좌우 고정하는 방법 아시는분...ㅠ
🎸 기타
x
⏰ 일정