diff --git a/src/containers/flight/NewFlightApprovalsContainer.js b/src/containers/flight/NewFlightApprovalsContainer.js index fc07023b..a74e390d 100644 --- a/src/containers/flight/NewFlightApprovalsContainer.js +++ b/src/containers/flight/NewFlightApprovalsContainer.js @@ -33,7 +33,7 @@ export default function NewFlightApprovalsContainer({ mode }) { const [mapObject, setMapObject] = useState(); const { areaCoordList, isOpenModal } = useSelector(state => state.laancState); - + const { user } = useSelector(state => state.authState); // const [startDate, setStartDate] = useState(dayjs().format('YYYY-MM-DD')); const [endDate, setEndDate] = useState(); @@ -48,6 +48,9 @@ export default function NewFlightApprovalsContainer({ mode }) { const [isPopup, setIsPopup] = useState(false); const [popup, setPopup] = useState(null); const popupRef = useRef(null); + const rightMenuRef = useRef(null); + const savedRightMenuRef = useRef(null); + const [clientX, setClientX] = useState(0); const previewGeo2 = { type: 'FeatureCollection', @@ -117,12 +120,38 @@ export default function NewFlightApprovalsContainer({ mode }) { } }; let timer; + if (rightMenuRef.current) { + savedRightMenuRef.current = rightMenuRef.current.getBoundingClientRect(); + } if (popup) { timer = setInterval(() => { if (popup.closed) { setIsPopup(false); clearInterval(timer); } + + if (savedRightMenuRef.current) { + console.log('@?@?@?'); + // 부모 창의 특정 영역 (right-layer)의 위치와 크기 + const specificArea = { + left: window.screenX + window.outerWidth - clientX, // 영역을 넓게 설정 + right: window.screenX + window.outerWidth - clientX + }; + console.log(specificArea); + // 팝업 창의 현재 위치 + const popupRightEdge = popup.screenX + popup.outerWidth; + + // window.screenX + window.outerWidth - e.clientX + console.log(popupRightEdge); + // console.log('Popup Position:', { popupLeft, popupTop }); + if ( + popupRightEdge >= specificArea.left && + popupRightEdge <= specificArea.right + ) { + setIsPopup(false); + clearInterval(timer); + } + } }, 1000); // 1초마다 체크 } window.addEventListener('message', childMessage); @@ -132,7 +161,7 @@ export default function NewFlightApprovalsContainer({ mode }) { window.removeEventListener('message', childMessage); }; }, [popup]); - + console.log(history); useEffect(() => { const handleBeforeUnload = e => { localStorage.removeItem('persist:root'); @@ -155,11 +184,12 @@ export default function NewFlightApprovalsContainer({ mode }) { const popupWidth = el.offsetWidth; // 팝업의 너비 const popupHeight = el.offsetHeight; // 팝업의 너비 + // const popupX = window.screenX + window.outerWidth - e.clientX; // 오른쪽 끝에 띄우기 // const popupY = Math.round( // window.screenY + window.outerHeight / 2 - popupHeight / 2 // ); - + setClientX(window.screenX + window.outerWidth - e.clientX); const popupX = window.screenX + (window.outerWidth - popupWidth) / 2 + @@ -298,7 +328,10 @@ export default function NewFlightApprovalsContainer({ mode }) { {!isPopup && (