优化预览变换回退分配
复用空的预览变换映射,避免节点递归渲染重复分配
This commit is contained in:
@@ -71,6 +71,11 @@ const RESIZE_HANDLES: ReadonlyArray<{
|
||||
{ id: 'w', left: '0%', top: '50%', cursor: 'ew-resize' },
|
||||
];
|
||||
|
||||
const EMPTY_PREVIEW_TRANSFORMS: ReadonlyMap<
|
||||
NodeId,
|
||||
UiNode['layout']['transform']
|
||||
> = new Map();
|
||||
|
||||
function RenderNode({
|
||||
node,
|
||||
isRoot,
|
||||
@@ -96,7 +101,7 @@ function RenderNode({
|
||||
isRoot?: boolean;
|
||||
parentContainer?: UiNode['layout']['container'];
|
||||
}) {
|
||||
const activePreviewTransforms = previewTransforms ?? new Map();
|
||||
const activePreviewTransforms = previewTransforms ?? EMPTY_PREVIEW_TRANSFORMS;
|
||||
if (hiddenNodeIds.has(node.id)) return null;
|
||||
const layout = activePreviewTransforms.has(node.id)
|
||||
? { ...node.layout, transform: activePreviewTransforms.get(node.id)! }
|
||||
|
||||
Reference in New Issue
Block a user