Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
65be7973be
commit
8fea75b84f
@ -1864,39 +1864,31 @@ export class App extends React.Component<any, AppState> {
|
|||||||
pointerY: number,
|
pointerY: number,
|
||||||
perfect: boolean,
|
perfect: boolean,
|
||||||
) => {
|
) => {
|
||||||
const p1 = element.points[pointIndex];
|
const [px, py] = element.points[pointIndex];
|
||||||
if (perfect) {
|
let x = element.x + deltaX;
|
||||||
const absPx = p1[0] + element.x;
|
let y = element.y + deltaY;
|
||||||
const absPy = p1[1] + element.y;
|
let pointX = px - deltaX;
|
||||||
|
let pointY = py - deltaY;
|
||||||
|
|
||||||
|
if (perfect) {
|
||||||
const { width, height } = getPerfectElementSize(
|
const { width, height } = getPerfectElementSize(
|
||||||
element.type,
|
element.type,
|
||||||
pointerX - element.x - p1[0],
|
px + element.x - pointerX,
|
||||||
pointerY - element.y - p1[1],
|
py + element.y - pointerY,
|
||||||
);
|
);
|
||||||
|
x = px + element.x - width;
|
||||||
const dx = element.x + width + p1[0];
|
y = py + element.y - height;
|
||||||
const dy = element.y + height + p1[1];
|
pointX = width;
|
||||||
mutateElement(element, {
|
pointY = height;
|
||||||
x: dx,
|
|
||||||
y: dy,
|
|
||||||
points: element.points.map((point, i) =>
|
|
||||||
i === pointIndex
|
|
||||||
? ([absPx - element.x, absPy - element.y] as const)
|
|
||||||
: point,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
mutateElement(element, {
|
|
||||||
x: element.x + deltaX,
|
|
||||||
y: element.y + deltaY,
|
|
||||||
points: element.points.map((point, i) =>
|
|
||||||
i === pointIndex
|
|
||||||
? ([p1[0] - deltaX, p1[1] - deltaY] as const)
|
|
||||||
: point,
|
|
||||||
),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutateElement(element, {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
points: element.points.map((point, i) =>
|
||||||
|
i === pointIndex ? ([pointX, pointY] as const) : point,
|
||||||
|
),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const arrowResizeEnd = (
|
const arrowResizeEnd = (
|
||||||
@ -1908,7 +1900,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
pointerY: number,
|
pointerY: number,
|
||||||
perfect: boolean,
|
perfect: boolean,
|
||||||
) => {
|
) => {
|
||||||
const p1 = element.points[pointIndex];
|
const [px, py] = element.points[pointIndex];
|
||||||
if (perfect) {
|
if (perfect) {
|
||||||
const { width, height } = getPerfectElementSize(
|
const { width, height } = getPerfectElementSize(
|
||||||
element.type,
|
element.type,
|
||||||
@ -1923,9 +1915,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
} else {
|
} else {
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
points: element.points.map((point, i) =>
|
points: element.points.map((point, i) =>
|
||||||
i === pointIndex
|
i === pointIndex ? ([px + deltaX, py + deltaY] as const) : point,
|
||||||
? ([p1[0] + deltaX, p1[1] + deltaY] as const)
|
|
||||||
: point,
|
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user