rect file selection
This commit is contained in:
11
frontend/utils/rect.ts
Normal file
11
frontend/utils/rect.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function intersectRect(
|
||||
a: { x: number; y: number; width: number; height: number },
|
||||
b: { x: number; y: number; width: number; height: number }
|
||||
): boolean {
|
||||
return !(
|
||||
b.x > a.x + a.width ||
|
||||
b.x + b.width < a.x ||
|
||||
b.y > a.y + a.height ||
|
||||
b.y + b.height < a.y
|
||||
);
|
||||
}
|
||||
@@ -7,11 +7,11 @@ import type { DirectoryEntry } from '~/shared/types';
|
||||
*/
|
||||
export function getTargetsFromSelection(
|
||||
targetEntry: DirectoryEntry,
|
||||
selection: Set<DirectoryEntry>
|
||||
selection: Map<string, DirectoryEntry>
|
||||
): DirectoryEntry[] {
|
||||
if (selection.size === 0 || !selection.has(targetEntry)) {
|
||||
if (selection.size === 0 || !selection.has(targetEntry.name)) {
|
||||
return [targetEntry];
|
||||
}
|
||||
|
||||
return Array.from(selection);
|
||||
return Array.from(selection.values());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user