diff --git a/src/components/browser/BrowserWindow.tsx b/src/components/browser/BrowserWindow.tsx index 7def2734..61a9aeca 100644 --- a/src/components/browser/BrowserWindow.tsx +++ b/src/components/browser/BrowserWindow.tsx @@ -90,8 +90,28 @@ export const BrowserWindow = () => { const { state } = useContext(AuthContext); const { user } = state; + const [dimensions, setDimensions] = useState({ + width: window.innerWidth * 0.7, + height: window.innerHeight * 0.64 + }); + + const handleResize = useCallback(() => { + setDimensions({ + width: window.innerWidth * 0.7, + height: window.innerHeight * 0.64 + }); + }, []); + useEffect(() => { - coordinateMapper.updateDimensions(window.innerWidth * 0.7, window.innerHeight * 0.64, viewportInfo.width, viewportInfo.height); + window.addEventListener('resize', handleResize); + + return () => { + window.removeEventListener('resize', handleResize); + }; + }, [handleResize]); + + useEffect(() => { + coordinateMapper.updateDimensions(dimensions.width, dimensions.height, viewportInfo.width, viewportInfo.height); }, [viewportInfo]); useEffect(() => { @@ -136,23 +156,6 @@ export const BrowserWindow = () => { } }, [getList, resetListState]); - useEffect(() => { - if (socket) { - socket.on('viewportInfo', (data: { width: number, height: number, userId: string }) => { - if (!data.userId || data.userId === user?.id) { - setViewportInfo({ - width: data.width, - height: data.height - }); - } - }); - - return () => { - socket.off('viewportInfo'); - }; - } - }, [socket, user?.id]); - const screencastHandler = useCallback((data: string | ScreencastData) => { if (typeof data === 'string') { setScreenShot(data); @@ -525,20 +528,20 @@ export const BrowserWindow = () => { ) : null } -
+
{((getText === true || getList === true) && !showAttributeModal && highlighterData?.rect != null && highlighterData?.rect.top != null) && canvasRef?.current ? : null}