Skip to content

Commit

Permalink
fix: The select box does not follow the mouse as you drag to move it
Browse files Browse the repository at this point in the history
  • Loading branch information
damnright committed Mar 20, 2024
1 parent f4d1412 commit 09265dc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/x6-plugin-selection/src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
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

Expand Down Expand Up @@ -738,7 +740,12 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {

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,
)
}
}

Expand Down Expand Up @@ -807,7 +814,9 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
)
}

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)
Expand Down

0 comments on commit 09265dc

Please sign in to comment.