refactor(react): add setAttributes for dimension changes

This commit is contained in:
moklick
2024-04-22 14:51:23 +02:00
parent 973a3ddd35
commit 7e8bcd8825
5 changed files with 12 additions and 4 deletions

View File

@@ -1,12 +1,16 @@
# @xyflow/react
## 12.0.0-next.xx
## 12.0.0-next.15
## Patch changes
- re-observe nodes when using `onlyRenderVisibleElements={true}`
- use correct positions for intersection helpers
- fix minimap interaction for touch devices
- pass user nodes to `onSelectionChange` instead of internal ones
- pass user nodes to `onSelectionChange` instead of internal ones to work with Redux
- call `onEnd` in XYResizer thanks @tonyf
- cleanup `getPositionWithOrigin` usage
- use `setAttributes` flag for dimension change when `width`/`height` should be set
## 12.0.0-next.14

View File

@@ -113,6 +113,7 @@ function ResizeControl({
id,
type: 'dimensions',
resizing: true,
setAttributes: true,
dimensions: {
width: change.width,
height: change.height,

View File

@@ -100,7 +100,7 @@ function applyChange(change: any, element: any): any {
element.measured.width = change.dimensions.width;
element.measured.height = change.dimensions.height;
if (change.resizing) {
if (change.setAttributes) {
element.width = change.dimensions.width;
element.height = change.dimensions.height;
}

View File

@@ -4,7 +4,10 @@ export type NodeDimensionChange = {
id: string;
type: 'dimensions';
dimensions?: Dimensions;
/* if this is true, the node is currently being resized via the NodeResizer */
resizing?: boolean;
/* if this is true, we will set width and height of the node and not just the measured dimensions */
setAttributes?: boolean;
};
export type NodePositionChange = {

View File

@@ -217,7 +217,7 @@ export function handleExpandParent(
changes.push({
id: parentId,
type: 'dimensions',
resizing: true,
setAttributes: true,
dimensions: {
width: Math.max(dimensions.width, Math.round(expandedRect.width)),
height: Math.max(dimensions.height, Math.round(expandedRect.height)),