修复 UI 预览拖拽重置视口
仅在画布尺寸或像素单位变化时重新计算预览尺寸 避免节点拖拽的状态深拷贝触发全画布适配
This commit is contained in:
+14
-5
@@ -47,12 +47,21 @@ export function PreviewWorkspace({
|
||||
useState<UiEditorRenderMode>('editor-overlay');
|
||||
const [showFrame, setShowFrame] = useState(false);
|
||||
const tree = controller.treeForActiveImage ?? null;
|
||||
const activeImagePixelWidth = activeImage?.pixel_size[0];
|
||||
const activeImagePixelHeight = activeImage?.pixel_size[1];
|
||||
const activeImagePixelsPerUnit = activeImage?.pixels_per_unit;
|
||||
const logicalSize = useMemo(() => {
|
||||
if (!activeImage) return null;
|
||||
const ppu = activeImage.pixels_per_unit;
|
||||
if (
|
||||
activeImagePixelWidth === undefined ||
|
||||
activeImagePixelHeight === undefined ||
|
||||
activeImagePixelsPerUnit === undefined
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const ppu = activeImagePixelsPerUnit;
|
||||
if (!Number.isFinite(ppu) || ppu <= 0) return null;
|
||||
const width = activeImage.pixel_size[0] / ppu;
|
||||
const height = activeImage.pixel_size[1] / ppu;
|
||||
const width = activeImagePixelWidth / ppu;
|
||||
const height = activeImagePixelHeight / ppu;
|
||||
if (
|
||||
!Number.isFinite(width) ||
|
||||
!Number.isFinite(height) ||
|
||||
@@ -62,7 +71,7 @@ export function PreviewWorkspace({
|
||||
return null;
|
||||
}
|
||||
return { width, height };
|
||||
}, [activeImage]);
|
||||
}, [activeImagePixelHeight, activeImagePixelsPerUnit, activeImagePixelWidth]);
|
||||
|
||||
const nodeInteractions = useNodeTransformInteraction({
|
||||
activeImageId,
|
||||
|
||||
Reference in New Issue
Block a user