mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: cursor alignment when creating linear elements with shift pressed (#5518)
* feat: cursor alignment when creating linear elements * feat: apply cursor alignment to multi-point linear elements * refactor: rename size helper function
This commit is contained in:
parent
54c7ec416a
commit
865d29388c
3 changed files with 54 additions and 9 deletions
|
@ -87,9 +87,9 @@ import {
|
|||
getDragOffsetXY,
|
||||
getElementWithTransformHandleType,
|
||||
getNormalizedDimensions,
|
||||
getPerfectElementSize,
|
||||
getResizeArrowDirection,
|
||||
getResizeOffsetXY,
|
||||
getLockedLinearCursorAlignSize,
|
||||
getTransformHandleTypeFromCoords,
|
||||
hitTest,
|
||||
isHittingElementBoundingBoxWithoutHittingElement,
|
||||
|
@ -2768,10 +2768,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
if (shouldRotateWithDiscreteAngle(event)) {
|
||||
({ width: dxFromLastCommitted, height: dyFromLastCommitted } =
|
||||
getPerfectElementSize(
|
||||
this.state.activeTool.type,
|
||||
dxFromLastCommitted,
|
||||
dyFromLastCommitted,
|
||||
getLockedLinearCursorAlignSize(
|
||||
// actual coordinate of the last committed point
|
||||
lastCommittedX + rx,
|
||||
lastCommittedY + ry,
|
||||
// cursor-grid coordinate
|
||||
gridX,
|
||||
gridY,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -4241,10 +4244,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||
let dy = gridY - draggingElement.y;
|
||||
|
||||
if (shouldRotateWithDiscreteAngle(event) && points.length === 2) {
|
||||
({ width: dx, height: dy } = getPerfectElementSize(
|
||||
this.state.activeTool.type,
|
||||
dx,
|
||||
dy,
|
||||
({ width: dx, height: dy } = getLockedLinearCursorAlignSize(
|
||||
draggingElement.x,
|
||||
draggingElement.y,
|
||||
pointerCoords.x,
|
||||
pointerCoords.y,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue