mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Move path related function into the math package
This commit is contained in:
parent
1b56cf90fb
commit
9eb08df3ea
9 changed files with 72 additions and 46 deletions
|
@ -15,9 +15,10 @@ import {
|
|||
isImageElement,
|
||||
isTextElement,
|
||||
} from "./typeChecks";
|
||||
import { getBoundTextShape, isPathALoop } from "../shapes";
|
||||
import { getBoundTextShape } from "../shapes";
|
||||
import type { GlobalPoint, LocalPoint, Polygon } from "../../math";
|
||||
import { isPointWithinBounds, point } from "../../math";
|
||||
import { pathIsALoop, isPointWithinBounds, point } from "../../math";
|
||||
import { LINE_CONFIRM_THRESHOLD } from "../constants";
|
||||
|
||||
export const shouldTestInside = (element: ExcalidrawElement) => {
|
||||
if (element.type === "arrow") {
|
||||
|
@ -31,11 +32,17 @@ export const shouldTestInside = (element: ExcalidrawElement) => {
|
|||
isTextElement(element);
|
||||
|
||||
if (element.type === "line") {
|
||||
return isDraggableFromInside && isPathALoop(element.points);
|
||||
return (
|
||||
isDraggableFromInside &&
|
||||
pathIsALoop(element.points, LINE_CONFIRM_THRESHOLD)
|
||||
);
|
||||
}
|
||||
|
||||
if (element.type === "freedraw") {
|
||||
return isDraggableFromInside && isPathALoop(element.points);
|
||||
return (
|
||||
isDraggableFromInside &&
|
||||
pathIsALoop(element.points, LINE_CONFIRM_THRESHOLD)
|
||||
);
|
||||
}
|
||||
|
||||
return isDraggableFromInside || isImageElement(element);
|
||||
|
|
|
@ -39,7 +39,7 @@ import {
|
|||
} from "./typeChecks";
|
||||
import { KEYS, shouldRotateWithDiscreteAngle } from "../keys";
|
||||
import { getBoundTextElement, handleBindTextResize } from "./textElement";
|
||||
import { DRAGGING_THRESHOLD } from "../constants";
|
||||
import { DRAGGING_THRESHOLD, LINE_CONFIRM_THRESHOLD } from "../constants";
|
||||
import type { Mutable } from "../utility-types";
|
||||
import { ShapeCache } from "../scene/ShapeCache";
|
||||
import type { Store } from "../store";
|
||||
|
@ -57,12 +57,12 @@ import {
|
|||
pointDistance,
|
||||
pointSubtract,
|
||||
pointFromPair,
|
||||
pathIsALoop,
|
||||
} from "../../math";
|
||||
import {
|
||||
getBezierCurveLength,
|
||||
getBezierXY,
|
||||
getControlPointsForBezierCurve,
|
||||
isPathALoop,
|
||||
mapIntervalToBezierT,
|
||||
} from "../shapes";
|
||||
import { getGridPoint } from "../snapping";
|
||||
|
@ -418,7 +418,12 @@ export class LinearElementEditor {
|
|||
selectedPoint === 0 ||
|
||||
selectedPoint === element.points.length - 1
|
||||
) {
|
||||
if (isPathALoop(element.points, appState.zoom.value)) {
|
||||
if (
|
||||
pathIsALoop(
|
||||
element.points,
|
||||
LINE_CONFIRM_THRESHOLD / appState.zoom.value,
|
||||
)
|
||||
) {
|
||||
LinearElementEditor.movePoints(
|
||||
element,
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue