refactor: Change object Point type to GenericPoint

Replaced instances of object literal Point types with the `GenericPoint` type.
This commit is contained in:
sunub 2025-04-19 17:06:20 +09:00
parent 27ff073d7e
commit 60907a5a0e
2 changed files with 9 additions and 8 deletions

View file

@ -6913,13 +6913,14 @@ class App extends React.Component<AppProps, AppState> {
private initialPointerDownState(
event: React.PointerEvent<HTMLElement>,
): PointerDownState {
const [originX, originY] = viewportCoordsToSceneCoords(event, this.state);
const originCoords = viewportCoordsToSceneCoords(event, this.state);
const [originX, originY] = originCoords;
const selectedElements = this.scene.getSelectedElements(this.state);
const [minX, minY, maxX, maxY] = getCommonBounds(selectedElements);
const isElbowArrowOnly = selectedElements.findIndex(isElbowArrow) === 0;
return {
origin: pointFrom(originX, originY),
origin: originCoords,
withCmdOrCtrl: event[KEYS.CTRL_OR_CMD],
originInGrid: tupleToCoors(
getGridPoint(
@ -6936,7 +6937,7 @@ class App extends React.Component<AppProps, AppState> {
event.clientY - this.state.offsetTop,
),
// we need to duplicate because we'll be updating this state
lastCoords: pointFrom(originX, originY),
lastCoords: originCoords,
originalElements: this.scene
.getNonDeletedElements()
.reduce((acc, element) => {
@ -6957,14 +6958,14 @@ class App extends React.Component<AppProps, AppState> {
hasBeenDuplicated: false,
hasHitCommonBoundingBoxOfSelectedElements:
this.isHittingCommonBoundingBoxOfSelectedElements(
pointFrom(originX, originY),
originCoords,
selectedElements,
),
},
drag: {
hasOccurred: false,
offset: null,
origin: { ...origin },
origin: originCoords,
},
eventListeners: {
onMove: null,

View file

@ -718,7 +718,7 @@ export type PointerDownState = Readonly<{
// Scrollbar checks
scrollbars: ReturnType<typeof isOverScrollBars>;
// The previous pointer position
lastCoords: { x: number; y: number };
lastCoords: GenericPoint;
// original element frozen snapshots so we can access the original
// element attribute values at time of pointerdown
originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
@ -753,10 +753,10 @@ export type PointerDownState = Readonly<{
// Might change during the pointer interaction
hasOccurred: boolean;
// Might change during the pointer interaction
offset: { x: number; y: number } | null;
offset: GenericPoint | null;
// by default same as PointerDownState.origin. On alt-duplication, reset
// to current pointer position at time of duplication.
origin: { x: number; y: number };
origin: GenericPoint;
};
// We need to have these in the state so that we can unsubscribe them
eventListeners: {