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

[feat] useAnchorTarget 커스텀 훅 제작, 커스텀 훅으로 등록된 엘리먼트로 스크롤하는 스크롤러 추가 #37

Closed
3 tasks done
lybell-art opened this issue Jul 25, 2024 · 1 comment
Assignees
Labels
feat 기능 구현

Comments

@lybell-art
Copy link
Collaborator

lybell-art commented Jul 25, 2024

어떤 기능인가요?

useAnchorTarget 커스텀 훅을 이용하여 스크롤할 대상을 등록합니다.
어떠한 이벤트에서 스크롤할 대상으로 스크롤하게 하려면, scroller.to(스크롤할 대상의 name) 을 입력하여 자동으로 부드럽게 스크롤하도록 합니다.
리액트 특성상 ID를 사용하여 스크롤하면 id의 잠재적 중복 문제가 발생하며, window.scrollTo를 이용하고자 하면 스크롤할 대상의 절대적 위치를 변경 가능하다는 문제가 생기므로 제작하게 되었습니다.

작업 상세 내용

  • 스크롤 대상이 되는 dom을 관리하는 scroller 객체 추가
  • ref를 scroller에 등록시키는 useAnchorTarget 커스텀 훅 추가
  • 등록된 엘리먼트로 스크롤하는 scroller.to 메소드 추가

참고 이미지 및 자료

https://github.com/fisshy/react-scroll/tree/master

@lybell-art lybell-art added the feat 기능 구현 label Jul 25, 2024
@lybell-art lybell-art self-assigned this Jul 25, 2024
@lybell-art
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 기능 구현
Projects
None yet
Development

No branches or pull requests

1 participant