From d96f081a4456e821d289ae9b87a2c8b2ae0b17fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Wed, 19 Aug 2026 14:38:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DUI=E9=94=9A=E7=82=B9=E6=BA=A2?= =?UTF-8?q?=E5=87=BA=E9=94=99=E8=AF=AF=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 先校验锚点能否转换为 CSS 百分比,再校验 min/max 排序。 保留极端有限锚点的具体溢出错误,避免被通用排序错误覆盖。 --- .../ui-editor/utils/transform/tf2css.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/ai-game-creator-shell/src/features/ui-editor/utils/transform/tf2css.ts b/apps/ai-game-creator-shell/src/features/ui-editor/utils/transform/tf2css.ts index adee581a1..82b51c221 100644 --- a/apps/ai-game-creator-shell/src/features/ui-editor/utils/transform/tf2css.ts +++ b/apps/ai-game-creator-shell/src/features/ui-editor/utils/transform/tf2css.ts @@ -69,6 +69,18 @@ function toCssLength(percentage: number, pixelOffset: number): string { */ export function tf2css(transform: Transform): CSSProperties { assertFiniteTransform(transform); + // Keep conversion errors specific even when an extreme anchor also happens + // to violate the min/max ordering constraint. + const left = toPercentage(transform.anchor_min[0], 'Transform.anchor_min[0]'); + const top = toPercentage(transform.anchor_min[1], 'Transform.anchor_min[1]'); + const right = toRemainingPercentage( + transform.anchor_max[0], + 'Transform.anchor_max[0]', + ); + const bottom = toRemainingPercentage( + transform.anchor_max[1], + 'Transform.anchor_max[1]', + ); if ( transform.anchor_min[0] > transform.anchor_max[0] || transform.anchor_min[1] > transform.anchor_max[1] @@ -78,21 +90,9 @@ export function tf2css(transform: Transform): CSSProperties { return { position: 'absolute', - left: toCssLength( - toPercentage(transform.anchor_min[0], 'Transform.anchor_min[0]'), - transform.offset_min[0], - ), - top: toCssLength( - toPercentage(transform.anchor_min[1], 'Transform.anchor_min[1]'), - transform.offset_min[1], - ), - right: toCssLength( - toRemainingPercentage(transform.anchor_max[0], 'Transform.anchor_max[0]'), - -transform.offset_max[0], - ), - bottom: toCssLength( - toRemainingPercentage(transform.anchor_max[1], 'Transform.anchor_max[1]'), - -transform.offset_max[1], - ), + left: toCssLength(left, transform.offset_min[0]), + top: toCssLength(top, transform.offset_min[1]), + right: toCssLength(right, -transform.offset_max[0]), + bottom: toCssLength(bottom, -transform.offset_max[1]), }; }