Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/SelectableGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type TSelectableGroupProps = {
* @type boolean
*/
fixedPosition?: boolean
minSelectSize?: number
}

export class SelectableGroup extends Component<TSelectableGroupProps> {
Expand All @@ -110,6 +111,7 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
allowMetaClick: false,
allowShiftClick: false,
selectOnClick: true,
minSelectSize: 0
}

state = { selectionMode: false }
Expand Down Expand Up @@ -347,7 +349,6 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
return
}
this.mouseMoveStarted = true
this.mouseMoved = true

const { mouseDownData } = this
const { clientX, clientY } = evt
Expand Down Expand Up @@ -376,8 +377,17 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
offsetHeight: selectboxState.height || 1,
}

this.selectItems(selectboxBounds)
this.props.duringSelection!([...this.selectingItems])
if (
!this.props.minSelectSize ||
this.props.minSelectSize < selectboxBounds.width ||
this.props.minSelectSize < selectboxBounds.height
)
{
this.mouseMoved = true
this.selectItems(selectboxBounds)
this.props.duringSelection!([...this.selectingItems])
}

this.mouseMoveStarted = false
}

Expand Down Expand Up @@ -612,15 +622,16 @@ export class SelectableGroup extends Component<TSelectableGroupProps> {
this.preventEvent(evt.target, 'click')
}

this.setSelectboxState!({
x: 0,
y: 0,
width: 0,
height: 0,
})
this.props.onSelectionFinish!([...this.selectedItems])
}

this.setSelectboxState!({
x: 0,
y: 0,
width: 0,
height: 0,
})

this.toggleSelectionMode()
this.cleanUp()
this.mouseMoved = false
Expand Down