mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-24 00:14:25 +02:00
fix: Increase transform handle offset (#10180)
* fix: Increase transform handle offset Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Temporarily disable transform handles for linear elements on mobile and tablets Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Linear hidden resize Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * disable mobielOrTablet linear element bbox completely * fix: Test Signed-off-by: Mark Tolmacs <mark@lazycat.hu> * fix: Lint Signed-off-by: Mark Tolmacs <mark@lazycat.hu> --------- Signed-off-by: Mark Tolmacs <mark@lazycat.hu> Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
committed by
Mark Tolmacs
parent
b228d92e9b
commit
0fc5b31008
@@ -2,6 +2,7 @@ import {
|
||||
DEFAULT_TRANSFORM_HANDLE_SPACING,
|
||||
isAndroid,
|
||||
isIOS,
|
||||
isMobileOrTablet,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import { pointFrom, pointRotateRads } from "@excalidraw/math";
|
||||
@@ -326,7 +327,7 @@ export const getTransformHandles = (
|
||||
);
|
||||
};
|
||||
|
||||
export const shouldShowBoundingBox = (
|
||||
export const hasBoundingBox = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: InteractiveCanvasAppState,
|
||||
) => {
|
||||
@@ -345,5 +346,7 @@ export const shouldShowBoundingBox = (
|
||||
return true;
|
||||
}
|
||||
|
||||
return element.points.length > 2;
|
||||
// on mobile/tablet we currently don't show bbox because of resize issues
|
||||
// (also prob best for simplicity's sake)
|
||||
return element.points.length > 2 && !isMobileOrTablet();
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ import {
|
||||
getContainerElement,
|
||||
isValidTextContainer,
|
||||
redrawTextBoundingBox,
|
||||
shouldShowBoundingBox,
|
||||
hasBoundingBox,
|
||||
getFrameChildren,
|
||||
isCursorInFrame,
|
||||
addElementsToFrame,
|
||||
@@ -5678,7 +5678,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
if (
|
||||
considerBoundingBox &&
|
||||
this.state.selectedElementIds[element.id] &&
|
||||
shouldShowBoundingBox([element], this.state)
|
||||
hasBoundingBox([element], this.state)
|
||||
) {
|
||||
// if hitting the bounding box, return early
|
||||
// but if not, we should check for other cases as well (e.g. frame name)
|
||||
@@ -6597,7 +6597,13 @@ class App extends React.Component<AppProps, AppState> {
|
||||
(!this.state.selectedLinearElement ||
|
||||
this.state.selectedLinearElement.hoverPointIndex === -1) &&
|
||||
this.state.openDialog?.name !== "elementLinkSelector" &&
|
||||
!(selectedElements.length === 1 && isElbowArrow(selectedElements[0]))
|
||||
!(selectedElements.length === 1 && isElbowArrow(selectedElements[0])) &&
|
||||
// HACK: Disable transform handles for linear elements on mobile until a
|
||||
// better way of showing them is found
|
||||
!(
|
||||
isLinearElement(selectedElements[0]) &&
|
||||
(isMobileOrTablet() || selectedElements[0].points.length === 2)
|
||||
)
|
||||
) {
|
||||
const elementWithTransformHandleType =
|
||||
getElementWithTransformHandleType(
|
||||
@@ -7730,14 +7736,8 @@ class App extends React.Component<AppProps, AppState> {
|
||||
!this.state.selectedLinearElement?.isEditing &&
|
||||
!isElbowArrow(selectedElements[0]) &&
|
||||
!(
|
||||
isLineElement(selectedElements[0]) &&
|
||||
LinearElementEditor.getPointIndexUnderCursor(
|
||||
selectedElements[0],
|
||||
elementsMap,
|
||||
this.state.zoom,
|
||||
pointerDownState.origin.x,
|
||||
pointerDownState.origin.y,
|
||||
) !== -1
|
||||
isLinearElement(selectedElements[0]) &&
|
||||
(isMobileOrTablet() || selectedElements[0].points.length === 2)
|
||||
) &&
|
||||
!(
|
||||
this.state.selectedLinearElement &&
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
getOmitSidesForDevice,
|
||||
getTransformHandles,
|
||||
getTransformHandlesFromCoords,
|
||||
shouldShowBoundingBox,
|
||||
hasBoundingBox,
|
||||
} from "@excalidraw/element";
|
||||
import {
|
||||
isElbowArrow,
|
||||
@@ -1086,7 +1086,7 @@ const _renderInteractiveScene = ({
|
||||
!appState.newElement &&
|
||||
!appState.selectedLinearElement?.isEditing
|
||||
) {
|
||||
const showBoundingBox = shouldShowBoundingBox(selectedElements, appState);
|
||||
const showBoundingBox = hasBoundingBox(selectedElements, appState);
|
||||
|
||||
const isSingleLinearElementSelected =
|
||||
selectedElements.length === 1 && isLinearElement(selectedElements[0]);
|
||||
|
||||
Reference in New Issue
Block a user