From 09265dc8f4dbb2170203c307564f5a55cfdef65b Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 20 Mar 2024 16:43:55 +0800 Subject: [PATCH] fix: The select box does not follow the mouse as you drag to move it --- packages/x6-plugin-selection/src/selection.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/x6-plugin-selection/src/selection.ts b/packages/x6-plugin-selection/src/selection.ts index 349e846509a..52d57426d21 100644 --- a/packages/x6-plugin-selection/src/selection.ts +++ b/packages/x6-plugin-selection/src/selection.ts @@ -126,7 +126,9 @@ export class SelectionImpl extends View { const { ui, selection, translateBy, snapped } = options const allowTranslating = - (showNodeSelectionBox !== true || (pointerEvents && this.getPointerEventsValue(pointerEvents) === 'none')) && + (showNodeSelectionBox !== true || + (pointerEvents && + this.getPointerEventsValue(pointerEvents) === 'none')) && !this.translating && !selection @@ -738,7 +740,12 @@ export class SelectionImpl extends View { protected updateContainerPosition(offset: { dx: number; dy: number }) { if (offset.dx || offset.dy) { - this.updateElementPosition(this.selectionContainer, offset.dx, offset.dy) + const scale = this.graph.transform.getScale() + this.updateElementPosition( + this.selectionContainer, + offset.dx * scale.sx, + offset.dy * scale.sy, + ) } } @@ -807,7 +814,9 @@ export class SelectionImpl extends View { ) } - protected getPointerEventsValue(pointerEvents: 'none' | 'auto' | ((cells: Cell[]) => 'none' | 'auto')) { + protected getPointerEventsValue( + pointerEvents: 'none' | 'auto' | ((cells: Cell[]) => 'none' | 'auto'), + ) { return typeof pointerEvents === 'string' ? pointerEvents : pointerEvents(this.cells)