refactor(react): use node.width/height for resizer changes

This commit is contained in:
moklick
2024-01-09 16:20:47 +01:00
parent 8487cb10e0
commit b18ef10e43
4 changed files with 7 additions and 7 deletions
@@ -74,7 +74,6 @@ function ResizeControl({
const dimensionChange: NodeDimensionChange = {
id,
type: 'dimensions',
updateStyle: true,
resizing: true,
dimensions: {
width: change.width,
@@ -219,9 +219,9 @@ export function NodeWrapper({
transform: `translate(${positionAbsoluteOrigin.x}px,${positionAbsoluteOrigin.y}px)`,
pointerEvents: hasPointerEvents ? 'all' : 'none',
visibility: initialized ? 'visible' : 'hidden',
width,
height,
...node.style,
width: width ?? node.style?.width,
height: height ?? node.style?.height,
}}
data-id={id}
data-testid={`rf__node-${id}`}
-1
View File
@@ -7,7 +7,6 @@ export type NodeDimensionChange = {
id: string;
type: 'dimensions';
dimensions?: Dimensions;
updateStyle?: boolean;
resizing?: boolean;
};
+5 -3
View File
@@ -121,10 +121,12 @@ function applyChanges(changes: any[], elements: any[]): any[] {
}
updateItem.computed.width = currentChange.dimensions.width;
updateItem.computed.height = currentChange.dimensions.height;
}
if (typeof currentChange.updateStyle !== 'undefined') {
updateItem.style = { ...(updateItem.style || {}), ...currentChange.dimensions };
// this is needed for the node resizer to work
if (currentChange.resizing) {
updateItem.width = currentChange.dimensions.width;
updateItem.height = currentChange.dimensions.height;
}
}
if (typeof currentChange.resizing === 'boolean') {