mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-15 02:04:21 +01:00
fix: Random projection
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
debugDrawLine,
|
||||||
DEFAULT_ADAPTIVE_RADIUS,
|
DEFAULT_ADAPTIVE_RADIUS,
|
||||||
DEFAULT_PROPORTIONAL_RADIUS,
|
DEFAULT_PROPORTIONAL_RADIUS,
|
||||||
invariant,
|
invariant,
|
||||||
@@ -31,9 +32,9 @@ import { elementCenterPoint, getDiamondPoints } from "./bounds";
|
|||||||
|
|
||||||
import { generateLinearCollisionShape } from "./shape";
|
import { generateLinearCollisionShape } from "./shape";
|
||||||
|
|
||||||
import { isPointInElement } from "./collision";
|
|
||||||
import { LinearElementEditor } from "./linearElementEditor";
|
import { LinearElementEditor } from "./linearElementEditor";
|
||||||
import { isRectangularElement } from "./typeChecks";
|
import { isRectangularElement } from "./typeChecks";
|
||||||
|
import { isPointInElement } from "./collision";
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ElementsMap,
|
ElementsMap,
|
||||||
@@ -560,7 +561,7 @@ export const projectFixedPointOntoDiagonal = (
|
|||||||
elementsMap: ElementsMap,
|
elementsMap: ElementsMap,
|
||||||
): GlobalPoint | null => {
|
): GlobalPoint | null => {
|
||||||
invariant(arrow.points.length >= 2, "Arrow must have at least two points");
|
invariant(arrow.points.length >= 2, "Arrow must have at least two points");
|
||||||
if (arrow.width < 1 && arrow.height < 1) {
|
if (arrow.width < 3 && arrow.height < 3) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,5 +599,9 @@ export const projectFixedPointOntoDiagonal = (
|
|||||||
p = p1 || p2 || null;
|
p = p1 || p2 || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugDrawLine(diagonalOne, { color: "purple", permanent: true });
|
||||||
|
debugDrawLine(diagonalTwo, { color: "purple", permanent: true });
|
||||||
|
debugDrawLine(intersector, { color: "orange", permanent: true });
|
||||||
|
|
||||||
return p && isPointInElement(p, element, elementsMap) ? p : null;
|
return p && isPointInElement(p, element, elementsMap) ? p : null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user