Skip to content

Commit 21956dc

Browse files
committed
Fix: scale ratio calculation
1 parent cdf3fe6 commit 21956dc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/store/reducers/editor/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Reducer, createSelector, createSlice } from "@reduxjs/toolkit";
22
import { v4 as uuidv4 } from "uuid";
3+
import { ids } from "@/constants";
34
import type { ISTKData } from "@/types";
4-
import booths from "./booths";
5-
import seats from "./seats";
6-
import shapes from "./shapes";
7-
import text from "./text";
5+
import { default as booths } from "./booths";
6+
import { default as seats } from "./seats";
7+
import { default as shapes } from "./shapes";
8+
import { default as text } from "./text";
89

910
export const locationPlaceholder = "Type your location here";
1011

@@ -248,7 +249,7 @@ export const slice = createSlice({
248249
},
249250
setInitialViewBoxScale: (state, action) => {
250251
state.initialViewBoxScale = action.payload;
251-
state.initialViewBoxScaleForWidth = document.documentElement.clientWidth;
252+
state.initialViewBoxScaleForWidth = document.getElementById(ids.workspace).clientWidth;
252253
},
253254
setVisibilityOffset: (state, action) => {
254255
state.visibilityOffset = action.payload;

src/utils/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const getWorkspaceCenterY = () => {
2424

2525
export const getScaleFactorAccountingForViewBoxWidth = (scaleFactor: number, initialViewBoxScaleForWidth?: number) => {
2626
if (initialViewBoxScaleForWidth) {
27-
const currentWidth = document.documentElement.clientWidth;
27+
const currentWidth = document.getElementById(ids.workspace).clientWidth;
2828
const ratio = currentWidth / initialViewBoxScaleForWidth;
2929
scaleFactor *= ratio >= 1 ? ratio : ratio * 1.25;
3030
}

0 commit comments

Comments
 (0)