Skip to content

Commit

Permalink
feat: optimize resize
Browse files Browse the repository at this point in the history
  • Loading branch information
F-star committed Feb 7, 2025
1 parent 0845456 commit afa1d5a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/core/src/tools/tool_select/tool_select_resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ export class SelectResizeTool implements IBaseTool {
originAttrs: ITransformRect,
updatedAttrs: ITransformRect,
) {
if (
const isNoSizeGraphics =
(updatedAttrs.width === 0 || updatedAttrs?.transform?.[0] === 0) &&
(updatedAttrs.height === 0 || updatedAttrs?.transform?.[3] === 0)
) {
(updatedAttrs.height === 0 || updatedAttrs?.transform?.[3] === 0);
if (isNoSizeGraphics) {
return false;
}

Expand Down Expand Up @@ -218,20 +218,20 @@ export class SelectResizeTool implements IBaseTool {
let prependedTransform: Matrix = new Matrix();

const selectedElements = this.editor.selectedElements.getItems();
// 1. single object
if (selectedElements.length === 1) {
const singleGraphics = selectedElements[0];
// 非 resize 操作,比如修改矩形的圆角,修改直线的端点位置
if (!this.isResizeOp() || selectedElements[0].attrs.height === 0) {
this.updateSingleGraphics(selectedElements[0]);
if (!this.isResizeOp() || singleGraphics.attrs.height === 0) {
this.updateSingleGraphics(singleGraphics);
return;
}

const originWorldTf = this.originWorldTransforms.get(
selectedElements[0].attrs.id,
singleGraphics.attrs.id,
)!;

const originAttrs = this.originAttrsMap.get(
selectedElements[0].attrs.id,
)!;
const originAttrs = this.originAttrsMap.get(singleGraphics.attrs.id)!;

const updatedTransformRect = resizeRect(
this.handleName,
Expand Down Expand Up @@ -262,7 +262,9 @@ export class SelectResizeTool implements IBaseTool {
);

this.updateControls(selectedElements[0]);
} else {
}
// 2. multi objects
else {
const startSelectBbox = this.startSelectBRect!;
const startSelectedBoxTf = new Matrix().translate(
startSelectBbox.x,
Expand Down Expand Up @@ -293,7 +295,7 @@ export class SelectResizeTool implements IBaseTool {
if (this.isResizeOp()) {
this.resizeGraphicsArray(prependedTransform.getArray());
} else {
console.error('should reach here, please put a issue');
console.error('should not reach here, please put a issue');
}
}

Expand Down

0 comments on commit afa1d5a

Please sign in to comment.