Skip to content

Commit

Permalink
fix: move eventTypes to Selection.CommonOptions & add into the defaul…
Browse files Browse the repository at this point in the history
…t option
  • Loading branch information
aMoonkin committed Oct 12, 2023
1 parent bfa50bc commit bc1b9d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/x6-plugin-selection/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ModifierKey,
CssLoader,
Dom,
ObjectExt,
Cell,
EventArgs,
Graph,
Expand Down Expand Up @@ -42,15 +41,10 @@ export class Selection

constructor(options: Selection.Options = {}) {
super()
this.options = ObjectExt.merge(
{ enabled: true },
Selection.defaultOptions,
options,
)

if (!Array.isArray(this.options.eventTypes)) {
// a new option, compatible with the behavior of older versions
this.options.eventTypes = ['leftMouseDown', 'mouseWheelDown']
this.options = {
enabled: true,
...Selection.defaultOptions,
...options,
}

CssLoader.ensure(this.name, content)
Expand Down Expand Up @@ -479,11 +473,9 @@ export class Selection
}

export namespace Selection {
type SelectionEventType = 'leftMouseDown' | 'mouseWheelDown'
export interface EventArgs extends SelectionImpl.EventArgs {}
export interface Options extends SelectionImpl.CommonOptions {
enabled?: boolean
eventTypes?: SelectionEventType[]
}

export type Filter = SelectionImpl.Filter
Expand All @@ -507,5 +499,6 @@ export namespace Selection {
selectEdgeOnMoved: false,
following: true,
content: null,
eventTypes: ['leftMouseDown', 'mouseWheelDown'],
}
}
5 changes: 5 additions & 0 deletions packages/x6-plugin-selection/src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ export class SelectionImpl extends View<SelectionImpl.EventArgs> {
}

export namespace SelectionImpl {
type SelectionEventType = 'leftMouseDown' | 'mouseWheelDown'

export interface CommonOptions {
model?: Model
collection?: Collection
Expand Down Expand Up @@ -977,6 +979,9 @@ export namespace SelectionImpl {

// Whether to respond event on the selectionBox
pointerEvents?: 'none' | 'auto'

// with which mouse button the selection can be started
eventTypes?: SelectionEventType[]
}

export interface Options extends CommonOptions {
Expand Down

0 comments on commit bc1b9d3

Please sign in to comment.