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] feat: 스크롤 기능 구현 #348

Merged
merged 21 commits into from
Aug 10, 2023
Merged

[FE] feat: 스크롤 기능 구현 #348

merged 21 commits into from
Aug 10, 2023

Conversation

hae-on
Copy link
Collaborator

@hae-on hae-on commented Aug 8, 2023

Issue

✨ 구현한 기능

스크롤 버튼을 클릭하면 최상단으로 이동합니다.
리뷰 작성 완료 후 리뷰 위치로 이동합니다.

📢 논의하고 싶은 내용

ref type 제대로 적었는지 확인해주세용~

fixed를 사용했는데요. 이게 개발자 도구를 키면 이동하네요...
좌우 고정하는 방법 아시는분...ㅠ

🎸 기타

x

⏰ 일정

  • 추정 시간 : 2시간
  • 걸린 시간 : 3시간

Copy link
Collaborator

@xodms0309 xodms0309 left a 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>;
Copy link
Collaborator

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 할 수 있습니돠

}
};

const scrollToPosition = (targetRef?: React.RefObject<HTMLElement>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

이것두!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const scrollToPosition = (targetRef?: React.RefObject<HTMLElement>) => {
const scrollToPosition = <T extends HTMLElement>(targetRef?: RefObject<T>) => {

이건 어떤가요?!

@@ -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';
Copy link
Collaborator

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) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기도 forwardRef 쓸 수 있을 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

여기는 useScroll과의 충돌로....슬프지만....🥲

Copy link
Collaborator

Choose a reason for hiding this comment

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

어떤 충돌이 있었나요??

Comment on lines 5 to 7
if (mainElement) {
mainElement.scrollTo(0, 0);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

근데 이 조건은 왜 필요한건가요?!

Copy link
Collaborator Author

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

z-index는 없어도 될 것 같아요!

Copy link
Collaborator

@Leejin-Yang Leejin-Yang left a comment

Choose a reason for hiding this comment

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

해온 수고했어요!
스크롤 버튼을 만들어서 한결 사용자 경험이 좋아졌네요 👍
코멘트 확인해주세요


const useScroll = () => {
const scrollToTop = () => {
const mainElement = document.getElementById('main');
Copy link
Collaborator

Choose a reason for hiding this comment

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

리액트에서 돔 요소에 직접 접근하면 위험해서 수정이 필요해 보여요
리액트 렌더링(가상돔에서 돔으로)이 예측 불가능 할 수 있습니다.!
이 부분도 ref로 수정을 해야할거 같네요

Copy link
Collaborator Author

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) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

어떤 충돌이 있었나요??

@hae-on
Copy link
Collaborator Author

hae-on commented Aug 10, 2023

@xodms0309 @Leejin-Yang 수정 완료했습니당

@github-actions
Copy link

Unit Test Results

2 tests   2 ✔️  5s ⏱️
1 suites  0 💤
1 files    0

Results for commit cf448f4.

Copy link
Collaborator

@Leejin-Yang Leejin-Yang left a 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');
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 친구도 useEffect 안으로 들어가면 되겠네요

Copy link
Collaborator

Choose a reason for hiding this comment

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

어 이거 쓰다 만거다

Copy link
Collaborator

Choose a reason for hiding this comment

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

아침에 말한거입니다~

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

zzzzzzzz 오키

Copy link
Collaborator

@xodms0309 xodms0309 left a comment

Choose a reason for hiding this comment

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

수고했어요 해옹 애증의 스크롤..

@hae-on
Copy link
Collaborator Author

hae-on commented Aug 10, 2023

고마워용 타미...근데 approve는,,,,?ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

export default ScrollButton;

const ScrollButtonWrapper = styled(Button)`
position: fixed;
Copy link
Collaborator

Choose a reason for hiding this comment

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

fixed는 뷰포트 따라가서 absolute로 하면 될듯합니다

Copy link
Collaborator

Choose a reason for hiding this comment

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

@hae-on

이거 이제 봤네

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

에 뭐야 absolute 해도 따라오네요 머쓱

Copy link
Collaborator

@xodms0309 xodms0309 left a comment

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 수고했어요~~~~

@hae-on hae-on merged commit 3951b8a into develop Aug 10, 2023
@hae-on hae-on deleted the feat/issue-325 branch August 10, 2023 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] feat: 스크롤 이벤트 구현
3 participants