diff --git a/web/src/components/IdeContainer/IdeContainer.js b/web/src/components/IdeContainer/IdeContainer.js index 7a8a45d..1f6a79c 100644 --- a/web/src/components/IdeContainer/IdeContainer.js +++ b/web/src/components/IdeContainer/IdeContainer.js @@ -1,4 +1,4 @@ -import { useContext } from 'react' +import { useContext, useRef, useEffect } from 'react' import { Mosaic, MosaicWindow } from 'react-mosaic-component' import { IdeContext } from 'src/components/IdeToolbarNew' import IdeEditor from 'src/components/IdeEditor' @@ -14,16 +14,31 @@ const ELEMENT_MAP = { const IdeContainer = () => { const { state, dispatch } = useContext(IdeContext) + const viewerDOM = useRef(null) + + useEffect(handleViewerSizeUpdate, [viewerDOM]) + + function handleViewerSizeUpdate() { + if (viewerDOM !== null && viewerDOM.current) { + const { width, height } = viewerDOM.current.getBoundingClientRect() + console.log({width, height}) + dispatch({ type: 'setViewerSize', payload: { message: { width, height } }}) + } + } return (