Skip to content

Commit

Permalink
refactor: 문제 확인을 위한 스크롤 로직 잠시 보류 (#77)
Browse files Browse the repository at this point in the history
현재 간헐적으로 뷰포트 크기가 줄어들었다 늘어났다를 반복하여 스크롤 조정 로직을 잠시 보류한다.
  • Loading branch information
semnil5202 authored Mar 21, 2024
1 parent 6bdfc6b commit e9657e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/layouts/MobileView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ const MobileView = () => {
};

useEffect(() => {
if (window.visualViewport) {
window.visualViewport.onresize = () => handleVisualViewPortResize(mobileViewRef);
}
if (!window.visualViewport) return;

const windowVisualViewPort = window.visualViewport;
windowVisualViewPort.addEventListener('resize', () => handleVisualViewPortResize(mobileViewRef));

return () => {
windowVisualViewPort.removeEventListener('resize', () => handleVisualViewPortResize(mobileViewRef));
};
}, []);

return (
Expand Down
8 changes: 4 additions & 4 deletions src/pages/FeedDetail/contexts/CommentFocusContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const focusTextareaRef = ({ textareaRef, mobileViewRef, isInComment }: FocusText
const difference = isInComment ? RECOMMENT_DIFF : COMMENT_DIFF;

// MobileView 컴포넌트의 스크롤 Top(가장 상단)을 유저가 선택한 (대)댓글 입력창 위치의 절대값 - 위치 조정값으로 이동
mobileViewRef.current.scroll({
top: mobileViewRef.current.scrollTop + textareaRect.top - difference,
behavior: 'smooth',
});
// mobileViewRef.current.scroll({
// top: mobileViewRef.current.scrollTop + textareaRect.top - difference,
// behavior: 'smooth',
// });
};

const initTextareaRef = (textareaRef: MutableRefObject<HTMLTextAreaElement | null>) => {
Expand Down

0 comments on commit e9657e3

Please sign in to comment.