From 02218b115530959c19e922161bee885049973245 Mon Sep 17 00:00:00 2001 From: yuyang Date: Wed, 17 Jan 2024 14:47:25 +0800 Subject: [PATCH] fix: extracting function getPointerEventsValue --- packages/x6-plugin-selection/src/selection.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/x6-plugin-selection/src/selection.ts b/packages/x6-plugin-selection/src/selection.ts index 0b6bf8a7f6a..349e846509a 100644 --- a/packages/x6-plugin-selection/src/selection.ts +++ b/packages/x6-plugin-selection/src/selection.ts @@ -126,10 +126,7 @@ export class SelectionImpl extends View { 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 @@ -810,6 +807,12 @@ export class SelectionImpl extends View { ) } + protected getPointerEventsValue(pointerEvents: 'none' | 'auto' | ((cells: Cell[]) => 'none' | 'auto')) { + return typeof pointerEvents === 'string' + ? pointerEvents + : pointerEvents(this.cells) + } + protected createSelectionBox(cell: Cell) { this.addCellSelectedClassName(cell) @@ -833,9 +836,7 @@ export class SelectionImpl extends View { width: bbox.width, height: bbox.height, pointerEvents: pointerEvents - ? typeof pointerEvents === 'string' - ? pointerEvents - : pointerEvents(this.cells) + ? this.getPointerEventsValue(pointerEvents) : 'auto', }) Dom.appendTo(box, this.container)