Skip to content

Commit

Permalink
fix: extracting function getPointerEventsValue
Browse files Browse the repository at this point in the history
  • Loading branch information
damnright committed Jan 17, 2024
1 parent 98c1ce3 commit 02218b1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/x6-plugin-selection/src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
const { ui, selection, translateBy, snapped } = options

const allowTranslating =
(showNodeSelectionBox !== true ||
(typeof pointerEvents === 'string'
? pointerEvents
: pointerEvents?.(this.cells)) === 'none') &&
(showNodeSelectionBox !== true || (pointerEvents && this.getPointerEventsValue(pointerEvents) === 'none')) &&
!this.translating &&
!selection

Expand Down Expand Up @@ -810,6 +807,12 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
)
}

protected getPointerEventsValue(pointerEvents: 'none' | 'auto' | ((cells: Cell[]) => 'none' | 'auto')) {
return typeof pointerEvents === 'string'
? pointerEvents
: pointerEvents(this.cells)
}

protected createSelectionBox(cell: Cell) {
this.addCellSelectedClassName(cell)

Expand All @@ -833,9 +836,7 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
width: bbox.width,
height: bbox.height,
pointerEvents: pointerEvents
? typeof pointerEvents === 'string'
? pointerEvents
: pointerEvents(this.cells)
? this.getPointerEventsValue(pointerEvents)
: 'auto',
})
Dom.appendTo(box, this.container)
Expand Down

0 comments on commit 02218b1

Please sign in to comment.