mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: Replace { x: number, y: number } type declarations with Point type
- Updated type declarations written as { x: number, y: number } to use the Point type as per requirements. - Explicit names were used for variables by destructuring previously used object types. - For example, scenePointer.x, scenePointer.y are now destructured as scenePointerX and scenePointerY. - When a Point type was required as an argument, the `pointFrom` helper function was used to convert and pass the value.
This commit is contained in:
parent
85cb973936
commit
899c652147
21 changed files with 210 additions and 188 deletions
|
@ -1,5 +1,9 @@
|
|||
import { arrayToMap } from "@excalidraw/common";
|
||||
import { isPointWithinBounds, pointFrom } from "@excalidraw/math";
|
||||
import {
|
||||
type GenericPoint,
|
||||
isPointWithinBounds,
|
||||
pointFrom,
|
||||
} from "@excalidraw/math";
|
||||
import { doLineSegmentsIntersect } from "@excalidraw/utils/bbox";
|
||||
import { elementsOverlappingBBox } from "@excalidraw/utils/withinBounds";
|
||||
|
||||
|
@ -154,11 +158,8 @@ export const elementOverlapsWithFrame = (
|
|||
);
|
||||
};
|
||||
|
||||
export const isCursorInFrame = (
|
||||
cursorCoords: {
|
||||
x: number;
|
||||
y: number;
|
||||
},
|
||||
export const isCursorInFrame = <Point extends GenericPoint>(
|
||||
cursorCoords: Point,
|
||||
frame: NonDeleted<ExcalidrawFrameLikeElement>,
|
||||
elementsMap: ElementsMap,
|
||||
) => {
|
||||
|
@ -166,7 +167,7 @@ export const isCursorInFrame = (
|
|||
|
||||
return isPointWithinBounds(
|
||||
pointFrom(fx1, fy1),
|
||||
pointFrom(cursorCoords.x, cursorCoords.y),
|
||||
cursorCoords,
|
||||
pointFrom(fx2, fy2),
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue