mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: Change object Point type to GenericPoint
Replaced instances of object literal Point types with the `GenericPoint` type.
This commit is contained in:
parent
27ff073d7e
commit
60907a5a0e
2 changed files with 9 additions and 8 deletions
|
@ -6913,13 +6913,14 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
private initialPointerDownState(
|
private initialPointerDownState(
|
||||||
event: React.PointerEvent<HTMLElement>,
|
event: React.PointerEvent<HTMLElement>,
|
||||||
): PointerDownState {
|
): 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 selectedElements = this.scene.getSelectedElements(this.state);
|
||||||
const [minX, minY, maxX, maxY] = getCommonBounds(selectedElements);
|
const [minX, minY, maxX, maxY] = getCommonBounds(selectedElements);
|
||||||
const isElbowArrowOnly = selectedElements.findIndex(isElbowArrow) === 0;
|
const isElbowArrowOnly = selectedElements.findIndex(isElbowArrow) === 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
origin: pointFrom(originX, originY),
|
origin: originCoords,
|
||||||
withCmdOrCtrl: event[KEYS.CTRL_OR_CMD],
|
withCmdOrCtrl: event[KEYS.CTRL_OR_CMD],
|
||||||
originInGrid: tupleToCoors(
|
originInGrid: tupleToCoors(
|
||||||
getGridPoint(
|
getGridPoint(
|
||||||
|
@ -6936,7 +6937,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
event.clientY - this.state.offsetTop,
|
event.clientY - this.state.offsetTop,
|
||||||
),
|
),
|
||||||
// we need to duplicate because we'll be updating this state
|
// we need to duplicate because we'll be updating this state
|
||||||
lastCoords: pointFrom(originX, originY),
|
lastCoords: originCoords,
|
||||||
originalElements: this.scene
|
originalElements: this.scene
|
||||||
.getNonDeletedElements()
|
.getNonDeletedElements()
|
||||||
.reduce((acc, element) => {
|
.reduce((acc, element) => {
|
||||||
|
@ -6957,14 +6958,14 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
hasBeenDuplicated: false,
|
hasBeenDuplicated: false,
|
||||||
hasHitCommonBoundingBoxOfSelectedElements:
|
hasHitCommonBoundingBoxOfSelectedElements:
|
||||||
this.isHittingCommonBoundingBoxOfSelectedElements(
|
this.isHittingCommonBoundingBoxOfSelectedElements(
|
||||||
pointFrom(originX, originY),
|
originCoords,
|
||||||
selectedElements,
|
selectedElements,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
drag: {
|
drag: {
|
||||||
hasOccurred: false,
|
hasOccurred: false,
|
||||||
offset: null,
|
offset: null,
|
||||||
origin: { ...origin },
|
origin: originCoords,
|
||||||
},
|
},
|
||||||
eventListeners: {
|
eventListeners: {
|
||||||
onMove: null,
|
onMove: null,
|
||||||
|
|
|
@ -718,7 +718,7 @@ export type PointerDownState = Readonly<{
|
||||||
// Scrollbar checks
|
// Scrollbar checks
|
||||||
scrollbars: ReturnType<typeof isOverScrollBars>;
|
scrollbars: ReturnType<typeof isOverScrollBars>;
|
||||||
// The previous pointer position
|
// The previous pointer position
|
||||||
lastCoords: { x: number; y: number };
|
lastCoords: GenericPoint;
|
||||||
// original element frozen snapshots so we can access the original
|
// original element frozen snapshots so we can access the original
|
||||||
// element attribute values at time of pointerdown
|
// element attribute values at time of pointerdown
|
||||||
originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
|
originalElements: Map<string, NonDeleted<ExcalidrawElement>>;
|
||||||
|
@ -753,10 +753,10 @@ export type PointerDownState = Readonly<{
|
||||||
// Might change during the pointer interaction
|
// Might change during the pointer interaction
|
||||||
hasOccurred: boolean;
|
hasOccurred: boolean;
|
||||||
// Might change during the pointer interaction
|
// 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
|
// by default same as PointerDownState.origin. On alt-duplication, reset
|
||||||
// to current pointer position at time of duplication.
|
// 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
|
// We need to have these in the state so that we can unsubscribe them
|
||||||
eventListeners: {
|
eventListeners: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue