Skip to content

[URH-25] useMousePosition 신규 #24

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

Merged
merged 11 commits into from
Jul 31, 2024
Merged

[URH-25] useMousePosition 신규 #24

merged 11 commits into from
Jul 31, 2024

Conversation

foresec
Copy link
Collaborator

@foresec foresec commented Jul 21, 2024

👾 Pull Request

  • 상태: 신규

1️⃣ Spec

  • 마우스의 현재 위치를 감지하여 반환하는 훅
  • 컴포넌트와의 상호작용 등에 쓰일 수 있음

2️⃣ 변경 사항

  • 해당 사항 없음

3️⃣ 예시 코드

1. MouseEvent 기본 속성

  const { viewX, viewY, pageX, pageY, screenX, screenY } = useMousePosition();
  • viewX : 뷰포트에서의 마우스 x 좌표
  • viewY : 뷰포트에서의 마우스 y 좌표
  • pageX : 페이지에서의 마우스 x 좌표
  • pageY : 페이지에서의 마우스 y 좌표
  • screenX : 화면에서의 마우스 x 좌표
  • screenY : 화면에서의 마우스 y 좌표

2. Element를 지정하여 상대 좌표 및 Element 크기

  const { elementX, elementY, refW, refH, targetRef } = useMousePosition();
  • elementX : 지정된 Element left 기준의 마우스 x 좌표
  • elementY : 지정된 Element top 기준의 마우스 y 좌표-
  • refW : 지정된 Element의 너비
  • refH : 지정된 Element의 높이

3. 이벤트핸들링 빈도 및 애니메이션 옵션

  const { viewX, ...} = useMousePosition({delayTime : 100});
  const { viewX, ...} = useMousePosition({animationMode: true});
  • delayTime : 이벤트 핸들링을 throttling할 시간 간격 (ms 단위, default=1000/60 ms)
  • animationMode : 부드러운 이동 혹은 애니메이션 효과를 위해 애니메이션 모드를 활성화할지 여부

4️⃣ 관련 문서 (선택 사항)

@foresec foresec changed the title [URH-25] /useMousePosition 신규 [URH-25] useMousePosition 신규 Jul 21, 2024
@Choozii Choozii requested a review from bicochan July 21, 2024 11:44
Copy link
Member

@jeongbaebang jeongbaebang left a comment

Choose a reason for hiding this comment

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

작성해주신 코드 잘 보았습니다.
옵션을 통해 개발자가 유연하게 사용할 수 있는 부분과, delayTime 옵션 값을 지정하고 animationMode를 활성화하면 에러 문구를 보여주는 로직이 인상적입니다.
고생하셨습니다👍

Copy link
Member

@bicochan bicochan left a comment

Choose a reason for hiding this comment

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

@foresec jsdoc 작성하신 이후에 머지 부탁드려요🙌🏻🙌🏻

@foresec foresec merged commit 4904f5c into master Jul 31, 2024
@foresec foresec deleted the URH-25/use-mouse-position branch July 31, 2024 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants