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:
@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user