feat: shift-clamp when creating multi-point lines/arrows (#5500)
Co-authored-by: Ryan <diweihao@bytedance.com>
This commit is contained in:
parent
426b5d9537
commit
2820cd112e
@ -2754,6 +2754,27 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
points: points.slice(0, -1),
|
points: points.slice(0, -1),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
const [gridX, gridY] = getGridPoint(
|
||||||
|
scenePointerX,
|
||||||
|
scenePointerY,
|
||||||
|
this.state.gridSize,
|
||||||
|
);
|
||||||
|
|
||||||
|
const [lastCommittedX, lastCommittedY] =
|
||||||
|
multiElement?.lastCommittedPoint ?? [0, 0];
|
||||||
|
|
||||||
|
let dxFromLastCommitted = gridX - rx - lastCommittedX;
|
||||||
|
let dyFromLastCommitted = gridY - ry - lastCommittedY;
|
||||||
|
|
||||||
|
if (shouldRotateWithDiscreteAngle(event)) {
|
||||||
|
({ width: dxFromLastCommitted, height: dyFromLastCommitted } =
|
||||||
|
getPerfectElementSize(
|
||||||
|
this.state.activeTool.type,
|
||||||
|
dxFromLastCommitted,
|
||||||
|
dyFromLastCommitted,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (isPathALoop(points, this.state.zoom.value)) {
|
if (isPathALoop(points, this.state.zoom.value)) {
|
||||||
setCursor(this.canvas, CURSOR_TYPE.POINTER);
|
setCursor(this.canvas, CURSOR_TYPE.POINTER);
|
||||||
}
|
}
|
||||||
@ -2761,7 +2782,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
mutateElement(multiElement, {
|
mutateElement(multiElement, {
|
||||||
points: [
|
points: [
|
||||||
...points.slice(0, -1),
|
...points.slice(0, -1),
|
||||||
[scenePointerX - rx, scenePointerY - ry],
|
[
|
||||||
|
lastCommittedX + dxFromLastCommitted,
|
||||||
|
lastCommittedY + dyFromLastCommitted,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -80,5 +80,5 @@ export const shouldMaintainAspectRatio = (event: MouseEvent | KeyboardEvent) =>
|
|||||||
event.shiftKey;
|
event.shiftKey;
|
||||||
|
|
||||||
export const shouldRotateWithDiscreteAngle = (
|
export const shouldRotateWithDiscreteAngle = (
|
||||||
event: MouseEvent | KeyboardEvent,
|
event: MouseEvent | KeyboardEvent | React.PointerEvent<HTMLCanvasElement>,
|
||||||
) => event.shiftKey;
|
) => event.shiftKey;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user