feat: 모바일 하단 내비게이션·설정 패널 도입
This commit is contained in:
1 parent
bb0ab91bcc
commit
54e5d14127
11 files changed
+613
-375
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import React, { useRef } from 'react';
|
||||
|
||||
/**
|
||||
* 모달 오버레이(배경) 클릭 시에만 닫히도록 하는 핸들러 쌍.
|
||||
* 모달 내부에서 텍스트를 드래그 선택하다가 마우스가 오버레이 위에서 놓이면
|
||||
* click 이벤트의 타겟이 오버레이가 되어 의도치 않게 닫히는 문제를 막기 위해,
|
||||
* mousedown과 click(mouseup) 타겟이 모두 오버레이 자신일 때만 닫는다.
|
||||
*/
|
||||
export function useOverlayClose(onClose: () => void) {
|
||||
const mouseDownOnSelfRef = useRef(false);
|
||||
|
||||
const onMouseDown = (e: React.MouseEvent<HTMLElement>) => {
|
||||
mouseDownOnSelfRef.current = e.target === e.currentTarget;
|
||||
};
|
||||
|
||||
const onClick = (e: React.MouseEvent<HTMLElement>) => {
|
||||
if (mouseDownOnSelfRef.current && e.target === e.currentTarget) {
|
||||
onClose();
|
||||
}
|
||||
mouseDownOnSelfRef.current = false;
|
||||
};
|
||||
|
||||
return { onMouseDown, onClick };
|
||||
}
|
||||
Reference in new issue
Block a user