refactor(react): add setAttributes for dimension changes
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
# @xyflow/react
|
# @xyflow/react
|
||||||
|
|
||||||
## 12.0.0-next.xx
|
## 12.0.0-next.15
|
||||||
|
|
||||||
## Patch changes
|
## Patch changes
|
||||||
|
|
||||||
|
- re-observe nodes when using `onlyRenderVisibleElements={true}`
|
||||||
- use correct positions for intersection helpers
|
- use correct positions for intersection helpers
|
||||||
- fix minimap interaction for touch devices
|
- 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
|
## 12.0.0-next.14
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ function ResizeControl({
|
|||||||
id,
|
id,
|
||||||
type: 'dimensions',
|
type: 'dimensions',
|
||||||
resizing: true,
|
resizing: true,
|
||||||
|
setAttributes: true,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
width: change.width,
|
width: change.width,
|
||||||
height: change.height,
|
height: change.height,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ function applyChange(change: any, element: any): any {
|
|||||||
element.measured.width = change.dimensions.width;
|
element.measured.width = change.dimensions.width;
|
||||||
element.measured.height = change.dimensions.height;
|
element.measured.height = change.dimensions.height;
|
||||||
|
|
||||||
if (change.resizing) {
|
if (change.setAttributes) {
|
||||||
element.width = change.dimensions.width;
|
element.width = change.dimensions.width;
|
||||||
element.height = change.dimensions.height;
|
element.height = change.dimensions.height;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ export type NodeDimensionChange = {
|
|||||||
id: string;
|
id: string;
|
||||||
type: 'dimensions';
|
type: 'dimensions';
|
||||||
dimensions?: Dimensions;
|
dimensions?: Dimensions;
|
||||||
|
/* if this is true, the node is currently being resized via the NodeResizer */
|
||||||
resizing?: boolean;
|
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 = {
|
export type NodePositionChange = {
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ export function handleExpandParent(
|
|||||||
changes.push({
|
changes.push({
|
||||||
id: parentId,
|
id: parentId,
|
||||||
type: 'dimensions',
|
type: 'dimensions',
|
||||||
resizing: true,
|
setAttributes: true,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
width: Math.max(dimensions.width, Math.round(expandedRect.width)),
|
width: Math.max(dimensions.width, Math.round(expandedRect.width)),
|
||||||
height: Math.max(dimensions.height, Math.round(expandedRect.height)),
|
height: Math.max(dimensions.height, Math.round(expandedRect.height)),
|
||||||
|
|||||||
Reference in New Issue
Block a user