diff options
Diffstat (limited to 'apps/web/src/lib/selection/hit-testing.ts')
| -rw-r--r-- | apps/web/src/lib/selection/hit-testing.ts | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/apps/web/src/lib/selection/hit-testing.ts b/apps/web/src/lib/selection/hit-testing.ts deleted file mode 100644 index d8186238..00000000 --- a/apps/web/src/lib/selection/hit-testing.ts +++ /dev/null @@ -1,50 +0,0 @@ -function isIntersecting({
- selectionRect,
- itemRect,
-}: {
- selectionRect: DOMRect;
- itemRect: DOMRect;
-}) {
- return !(
- itemRect.right < selectionRect.left ||
- itemRect.left > selectionRect.right ||
- itemRect.bottom < selectionRect.top ||
- itemRect.top > selectionRect.bottom
- );
-}
-
-function createSelectionRect({
- startPos,
- currentPos,
-}: {
- startPos: { x: number; y: number };
- currentPos: { x: number; y: number };
-}) {
- return new DOMRect(
- Math.min(startPos.x, currentPos.x),
- Math.min(startPos.y, currentPos.y),
- Math.abs(currentPos.x - startPos.x),
- Math.abs(currentPos.y - startPos.y),
- );
-}
-
-export function resolveElementIntersections({
- startPos,
- currentPos,
- elements,
-}: {
- startPos: { x: number; y: number };
- currentPos: { x: number; y: number };
- elements: Map<string, HTMLElement>;
-}) {
- const selectionRect = createSelectionRect({ startPos, currentPos });
-
- return [...elements.entries()]
- .filter(([, element]) =>
- isIntersecting({
- selectionRect,
- itemRect: element.getBoundingClientRect(),
- }),
- )
- .map(([id]) => id);
-}
|
