fix: stabilize psd template preview size
This commit is contained in:
parent
dceebf0652
commit
89dfc39284
@ -54,6 +54,8 @@ import { resolveTextLayout } from "@/lib/agents/psd-text-layout";
|
||||
const fetcher = (url: string) => fetch(url, { cache: "no-store" }).then((res) => res.json());
|
||||
const PREVIEW_VIEWPORT_PADDING = 56;
|
||||
const PREVIEW_STAGE_MAX_SCALE = 0.82;
|
||||
const PREVIEW_STAGE_TARGET_WIDTH = 760;
|
||||
const PREVIEW_STAGE_TARGET_HEIGHT = 760;
|
||||
|
||||
function createInitialState(template: AgentPsdTemplate | null, sourceImageUrl: string) {
|
||||
const imageAssignments: Record<string, string> = {};
|
||||
@ -477,8 +479,14 @@ export function AgentPsdTemplateEditorDialog({
|
||||
|
||||
const updateScale = () => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
const availableWidth = Math.max(240, rect.width - PREVIEW_VIEWPORT_PADDING);
|
||||
const availableHeight = Math.max(240, rect.height - PREVIEW_VIEWPORT_PADDING);
|
||||
const availableWidth = Math.max(
|
||||
240,
|
||||
Math.min(PREVIEW_STAGE_TARGET_WIDTH, rect.width - PREVIEW_VIEWPORT_PADDING)
|
||||
);
|
||||
const availableHeight = Math.max(
|
||||
240,
|
||||
Math.min(PREVIEW_STAGE_TARGET_HEIGHT, rect.height - PREVIEW_VIEWPORT_PADDING)
|
||||
);
|
||||
const nextScale = Math.min(
|
||||
availableWidth / Math.max(1, selectedTemplate.width),
|
||||
availableHeight / Math.max(1, selectedTemplate.height),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user