From e9bfaa865a5f0908fd0a4d5fd71353d750080a32 Mon Sep 17 00:00:00 2001 From: JIeunhuh Date: Fri, 25 Jul 2025 11:12:07 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EB=8F=84=20=ED=8C=9D=EC=97=85=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=A6=88=20=EC=A1=B0=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=ED=81=B4=EB=A6=AD=EC=8B=9C=EC=97=90=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EA=B0=80=EC=9A=B4=EB=8D=B0=EB=A1=9C=20?= =?UTF-8?q?=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/map/newWindowPopup.tsx | 5 ++--- apps/wr/app/map/newWindowPortal.tsx | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/wr/app/map/newWindowPopup.tsx b/apps/wr/app/map/newWindowPopup.tsx index 403401714..e0e43931c 100644 --- a/apps/wr/app/map/newWindowPopup.tsx +++ b/apps/wr/app/map/newWindowPopup.tsx @@ -671,9 +671,8 @@ const NewWindowPopup: React.FC = ({ {/* 체크된 레이어에 따른 조건부 렌더링 */} {renderConditionalContent()} diff --git a/apps/wr/app/map/newWindowPortal.tsx b/apps/wr/app/map/newWindowPortal.tsx index 6d650e3b7..b8da17d7b 100644 --- a/apps/wr/app/map/newWindowPortal.tsx +++ b/apps/wr/app/map/newWindowPortal.tsx @@ -33,7 +33,7 @@ interface NewWindowPortalProps { scrollbars?: string; } -const NewWindowPortal: React.FC = ({ children, onClose, title = "", width = 900, height = 800, resizable = "yes", scrollbars= "yes" }) => { +const NewWindowPortal: React.FC = ({ children, onClose, title = "", width = 900, height = 800, resizable = "yes", scrollbars = "yes" }) => { const [container, setContainer] = useState(null); const newWindowRef = useRef(null); const onCloseRef = useRef(onClose); @@ -50,14 +50,23 @@ const NewWindowPortal: React.FC = ({ children, onClose, ti useEffect(() => { // 이미 창이 열려있으면 새로 열지 않음 if (newWindowRef.current && !newWindowRef.current.closed) return; + // 브라우저 화면 정보 + const screenLeft = window.screenLeft ?? window.screenX; + const screenTop = window.screenTop ?? window.screenY; + const screenWidth = window.innerWidth ?? document.documentElement.clientWidth; + const screenHeight = window.innerHeight ?? document.documentElement.clientHeight; + + // 중앙 위치 계산 + const left = screenLeft + (screenWidth - width) / 2; + const top = screenTop + (screenHeight - height) / 2; // 1. 새 창을 열고 참조를 저장합니다. - const popupOptions = `width=${width},height=${height},resizable=${resizable},scrollbars=${scrollbars}`; + const popupOptions = `width=${width},height=${height},left=${left}, top=${top}, resizable=${resizable},scrollbars=${scrollbars}`; newWindowRef.current = window.open('', title, popupOptions); - + if (newWindowRef.current) { newWindowRef.current.document.title = title; - + // 2. React 컴포넌트를 마운트할 컨테이너 div를 생성하여 새 창의 body에 추가합니다. const div = newWindowRef.current.document.createElement('div'); newWindowRef.current.document.body.appendChild(div); @@ -65,7 +74,6 @@ const NewWindowPortal: React.FC = ({ children, onClose, ti // 3. 메인 창의 스타일을 새 창으로 복사합니다. (매우 중요) copyStyles(document, newWindowRef.current.document); - // 4. 사용자가 창을 닫을 때 부모에게 알리기 위한 이벤트 리스너를 설정합니다. // const handleUnload = () => { // onClose();