From 678883fb5481388acbaea72480bf1e8ce461e03d Mon Sep 17 00:00:00 2001 From: cyrilluce Date: Tue, 19 Sep 2023 14:34:35 +0800 Subject: [PATCH] fix: plugin-selection unmatch after scale graph (#3907) (#3918) Co-authored-by: cluezhang --- packages/x6-plugin-selection/src/selection.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/x6-plugin-selection/src/selection.ts b/packages/x6-plugin-selection/src/selection.ts index 90dd609ee7c..ea7b53fe350 100644 --- a/packages/x6-plugin-selection/src/selection.ts +++ b/packages/x6-plugin-selection/src/selection.ts @@ -468,12 +468,12 @@ export class SelectionImpl extends View { } } else { const scale = this.graph.transform.getScale() - for (let i = 0, len = this.$boxes.length; i < len; i += 1) { - this.updateElementPosition( - this.$boxes[i], - dx * scale.sx, - dy * scale.sy, - ) + for ( + let i = 0, $boxes = this.$boxes, len = $boxes.length; + i < len; + i += 1 + ) { + this.updateElementPosition($boxes[i], dx * scale.sx, dy * scale.sy) } this.updateElementPosition( this.selectionContainer, @@ -848,10 +848,15 @@ export class SelectionImpl extends View { confirmUpdate() { if (this.boxCount) { this.hide() - for (let i = 0, len = this.$boxes.length; i < len; i += 1) { - const box = this.$boxes[i] + for ( + let i = 0, $boxes = this.$boxes, len = $boxes.length; + i < len; + i += 1 + ) { + const box = $boxes[i] const cellId = Dom.attr(box, 'data-cell-id') Dom.remove(box) + this.boxCount -= 1 const cell = this.collection.get(cellId) if (cell) { this.createSelectionBox(cell)