fix more rect selection bugs
This commit is contained in:
@@ -8,6 +8,10 @@ const width = computed(() => Math.abs(rect.a.x - rect.b.x));
|
||||
const height = computed(() => Math.abs(rect.a.y - rect.b.y));
|
||||
|
||||
function onDocumentPointerDown(e: MouseEvent) {
|
||||
if (e.button !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const point = { x: e.x, y: e.y };
|
||||
rect.set(
|
||||
point,
|
||||
@@ -17,12 +21,16 @@ function onDocumentPointerDown(e: MouseEvent) {
|
||||
}
|
||||
|
||||
function onDocumentPointerMove(e: MouseEvent) {
|
||||
if (!rect.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
rect.updateB(e.x, e.y);
|
||||
|
||||
if (
|
||||
rect.mode !== 'set' ||
|
||||
!rect.enabled ||
|
||||
warrenStore.selection.size === 0
|
||||
warrenStore.selection.size === 0 ||
|
||||
!rect.isMinSize()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -30,22 +38,24 @@ function onDocumentPointerMove(e: MouseEvent) {
|
||||
warrenStore.clearSelection();
|
||||
}
|
||||
|
||||
function onDocumentPointerUp() {
|
||||
function onDocumentPointerUp(e: MouseEvent) {
|
||||
if (e.button !== 0 || !rect.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
rect.disable();
|
||||
|
||||
if (warrenStore.current == null || warrenStore.current.dir == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = rect.a;
|
||||
const end = rect.b;
|
||||
|
||||
const left = Math.min(start.x, end.x);
|
||||
const top = Math.min(start.y, end.y);
|
||||
const width = Math.abs(start.x - end.x);
|
||||
const height = Math.abs(start.y - end.y);
|
||||
const left = Math.min(rect.a.x, rect.b.x);
|
||||
const top = Math.min(rect.a.y, rect.b.y);
|
||||
const width = Math.abs(rect.a.x - rect.b.x);
|
||||
const height = Math.abs(rect.a.y - rect.b.y);
|
||||
|
||||
if (!rect.isMinSize()) {
|
||||
warrenStore.clearSelection();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,8 +82,6 @@ function onDocumentPointerUp() {
|
||||
}
|
||||
}
|
||||
|
||||
rect.dirty = true;
|
||||
|
||||
if (rect.mode === 'set') {
|
||||
warrenStore.setSelection(targetEntries);
|
||||
} else if (rect.mode === 'add') {
|
||||
|
||||
Reference in New Issue
Block a user