diff --git a/src/store/reducers/editor/index.ts b/src/store/reducers/editor/index.ts index 8fae73b..18361ac 100644 --- a/src/store/reducers/editor/index.ts +++ b/src/store/reducers/editor/index.ts @@ -268,7 +268,7 @@ export const slice = createSlice({ }, setInitialViewBoxScale: (state, action) => { state.initialViewBoxScale = action.payload; - state.initialViewBoxScaleForWidth = document.getElementById(ids.workspace).clientWidth; + state.initialViewBoxScaleForWidth = document.getElementById(ids.workspace)?.clientWidth; }, setVisibilityOffset: (state, action) => { state.visibilityOffset = action.payload; diff --git a/src/utils/workspace.ts b/src/utils/workspace.ts index 5a99d4d..952d5b8 100644 --- a/src/utils/workspace.ts +++ b/src/utils/workspace.ts @@ -24,7 +24,7 @@ export const getWorkspaceCenterY = () => { export const getScaleFactorAccountingForViewBoxWidth = (scaleFactor: number, initialViewBoxScaleForWidth?: number) => { if (initialViewBoxScaleForWidth) { - const currentWidth = document.getElementById(ids.workspace).clientWidth; + const currentWidth = document.getElementById(ids.workspace)?.clientWidth; const ratio = currentWidth / initialViewBoxScaleForWidth; scaleFactor *= ratio >= 1 ? ratio : ratio * 1.25; }