Skip to content

Commit

Permalink
Fix canvas size relative to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-drozd-it committed Sep 18, 2024
1 parent 52d23c9 commit e0c9e76
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/drawing/DrawingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const DrawingBoard = ({ width, height }: DrawingBoardProps): JSX.Element => {
const zoom = useAppSelector((state) => state.room.drawing.zoom);

// tools
const menuRef = useRef<HTMLDivElement>(null);
const tool = useAppSelector((state) => state.room.drawing.tool);

// size
Expand Down Expand Up @@ -110,8 +111,10 @@ const DrawingBoard = ({ width, height }: DrawingBoardProps): JSX.Element => {
const resizeCanvas = () => {

const currWidth = width;
const currHeight = height - (menuRef.current?.clientHeight ?? 0);

// const currHeight = (height / aspectRatio);
const currHeight = (height);

const currScaleFactor = Math.min(currWidth / 1920, currHeight / 1080);

setCanvas((prevState) => {
Expand Down Expand Up @@ -488,6 +491,7 @@ const DrawingBoard = ({ width, height }: DrawingBoardProps): JSX.Element => {
borderTop: '1px solid gray',
backgroundColor: 'lightgray',
}}
ref={menuRef}
justifyContent='center'
direction='row'
wrap='nowrap'
Expand Down

0 comments on commit e0c9e76

Please sign in to comment.