Skip to content

Commit fdeb5c2

Browse files
committed
Fix page width calculation and enforce scale limit
- Added a check to limit the scale to a maximum of 1.3 if it exceeds 1.4. - Removed redundant condition that checked if the scaled width exceeded a threshold. - Added console logs for debugging page width and offset calculations.
1 parent 4e309c3 commit fdeb5c2

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/assets/lib/kookit.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/common.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ export const getPageWidth = (
208208
isNavLocked: boolean,
209209
isSettingLocked: boolean
210210
) => {
211+
if (Math.abs(parseFloat(scale)) > 1.4) {
212+
scale = "1.3";
213+
}
211214
const findValidMultiple = (limit: number) => {
212215
let multiple = limit - (limit % 12);
213216

@@ -225,18 +228,6 @@ export const getPageWidth = (
225228
document.body.clientWidth * 0.4 >
226229
document.body.clientWidth
227230
) {
228-
if (
229-
document.body.clientWidth * Math.abs(parseFloat(scale)) -
230-
document.body.clientWidth * 0.4 >
231-
document.body.clientWidth
232-
) {
233-
let pageWidth = document.body.clientWidth - 106;
234-
let pageOffset = 50 + "px";
235-
return {
236-
pageOffset,
237-
pageWidth: pageWidth + "px",
238-
};
239-
}
240231
let pageWidth = document.body.clientWidth - 106;
241232
let pageOffset = 50 + "px";
242233
return {
@@ -253,6 +244,7 @@ export const getPageWidth = (
253244
document.body.clientWidth * 0.4 -
254245
(isNavLocked ? 300 : 0) -
255246
(isSettingLocked ? 300 : 0);
247+
console.log(preWidth, "preWidth");
256248
let width = findValidMultiple(preWidth);
257249
pageOffset = `calc(50vw + ${isNavLocked ? 150 : 0}px - ${
258250
isSettingLocked ? 150 : 0
@@ -271,10 +263,12 @@ export const getPageWidth = (
271263
}px - ${width / 2}px)`;
272264
pageWidth = width;
273265
}
266+
console.log(pageWidth, document.body.clientWidth, "pageWidth check");
274267
if (pageWidth > document.body.clientWidth) {
275268
pageWidth = document.body.clientWidth - 106;
276269
pageOffset = 50 + "px";
277270
}
271+
console.log(pageOffset, pageWidth, "pageWidth");
278272
return {
279273
pageOffset,
280274
pageWidth: pageWidth + "px",

0 commit comments

Comments
 (0)