refactor(react): use node.width/height for resizer changes
This commit is contained in:
@@ -74,7 +74,6 @@ function ResizeControl({
|
|||||||
const dimensionChange: NodeDimensionChange = {
|
const dimensionChange: NodeDimensionChange = {
|
||||||
id,
|
id,
|
||||||
type: 'dimensions',
|
type: 'dimensions',
|
||||||
updateStyle: true,
|
|
||||||
resizing: true,
|
resizing: true,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
width: change.width,
|
width: change.width,
|
||||||
|
|||||||
@@ -219,9 +219,9 @@ export function NodeWrapper({
|
|||||||
transform: `translate(${positionAbsoluteOrigin.x}px,${positionAbsoluteOrigin.y}px)`,
|
transform: `translate(${positionAbsoluteOrigin.x}px,${positionAbsoluteOrigin.y}px)`,
|
||||||
pointerEvents: hasPointerEvents ? 'all' : 'none',
|
pointerEvents: hasPointerEvents ? 'all' : 'none',
|
||||||
visibility: initialized ? 'visible' : 'hidden',
|
visibility: initialized ? 'visible' : 'hidden',
|
||||||
width,
|
|
||||||
height,
|
|
||||||
...node.style,
|
...node.style,
|
||||||
|
width: width ?? node.style?.width,
|
||||||
|
height: height ?? node.style?.height,
|
||||||
}}
|
}}
|
||||||
data-id={id}
|
data-id={id}
|
||||||
data-testid={`rf__node-${id}`}
|
data-testid={`rf__node-${id}`}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ export type NodeDimensionChange = {
|
|||||||
id: string;
|
id: string;
|
||||||
type: 'dimensions';
|
type: 'dimensions';
|
||||||
dimensions?: Dimensions;
|
dimensions?: Dimensions;
|
||||||
updateStyle?: boolean;
|
|
||||||
resizing?: boolean;
|
resizing?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -121,10 +121,12 @@ function applyChanges(changes: any[], elements: any[]): any[] {
|
|||||||
}
|
}
|
||||||
updateItem.computed.width = currentChange.dimensions.width;
|
updateItem.computed.width = currentChange.dimensions.width;
|
||||||
updateItem.computed.height = currentChange.dimensions.height;
|
updateItem.computed.height = currentChange.dimensions.height;
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof currentChange.updateStyle !== 'undefined') {
|
// this is needed for the node resizer to work
|
||||||
updateItem.style = { ...(updateItem.style || {}), ...currentChange.dimensions };
|
if (currentChange.resizing) {
|
||||||
|
updateItem.width = currentChange.dimensions.width;
|
||||||
|
updateItem.height = currentChange.dimensions.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof currentChange.resizing === 'boolean') {
|
if (typeof currentChange.resizing === 'boolean') {
|
||||||
|
|||||||
Reference in New Issue
Block a user