chore: Refactor doBoundsIntersect (#9657)

This commit is contained in:
Márk Tolmács
2025-06-16 12:30:42 +02:00
committed by GitHub
parent 058918f8e5
commit 958597dfaa
8 changed files with 172 additions and 105 deletions

View File

@@ -1,5 +1,3 @@
import { type Bounds } from "@excalidraw/element";
export const PRECISION = 10e-5;
export const clamp = (value: number, min: number, max: number) => {
@@ -33,17 +31,3 @@ export const isFiniteNumber = (value: any): value is number => {
export const isCloseTo = (a: number, b: number, precision = PRECISION) =>
Math.abs(a - b) < precision;
export const doBoundsIntersect = (
bounds1: Bounds | null,
bounds2: Bounds | null,
): boolean => {
if (bounds1 == null || bounds2 == null) {
return false;
}
const [minX1, minY1, maxX1, maxY1] = bounds1;
const [minX2, minY2, maxX2, maxY2] = bounds2;
return minX1 < maxX2 && maxX1 > minX2 && minY1 < maxY2 && maxY1 > minY2;
};