refactor(changes): allow set attributes to be width or height
This commit is contained in:
@@ -118,11 +118,12 @@ function ResizeControl({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (change.width !== undefined && change.height !== undefined) {
|
if (change.width !== undefined && change.height !== undefined) {
|
||||||
|
const setAttributes = !resizeDirection ? true : resizeDirection === 'horizontal' ? 'width' : 'height';
|
||||||
const dimensionChange: NodeDimensionChange = {
|
const dimensionChange: NodeDimensionChange = {
|
||||||
id,
|
id,
|
||||||
type: 'dimensions',
|
type: 'dimensions',
|
||||||
resizing: true,
|
resizing: true,
|
||||||
setAttributes: true,
|
setAttributes,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
width: change.width,
|
width: change.width,
|
||||||
height: change.height,
|
height: change.height,
|
||||||
|
|||||||
@@ -130,8 +130,12 @@ function applyChange(change: any, element: any): any {
|
|||||||
element.measured.height = change.dimensions.height;
|
element.measured.height = change.dimensions.height;
|
||||||
|
|
||||||
if (change.setAttributes) {
|
if (change.setAttributes) {
|
||||||
element.width = change.dimensions.width;
|
if (change.setAttributes === true || change.setAttributes === 'width') {
|
||||||
element.height = change.dimensions.height;
|
element.width = change.dimensions.width;
|
||||||
|
}
|
||||||
|
if (change.setAttributes === true || change.setAttributes === 'height') {
|
||||||
|
element.height = change.dimensions.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export type NodeDimensionChange = {
|
|||||||
/* if this is true, the node is currently being resized via the NodeResizer */
|
/* 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 */
|
/* if this is true, we will set width and height of the node and not just the measured dimensions */
|
||||||
setAttributes?: boolean;
|
setAttributes?: boolean | 'width' | 'height';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type NodePositionChange = {
|
export type NodePositionChange = {
|
||||||
|
|||||||
Reference in New Issue
Block a user