fix image hit and increase mini size to 10
This commit is contained in:
parent
8701a5f843
commit
4f82c32861
@ -4943,7 +4943,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
const selectionShape = getSelectionBoxShape(
|
const selectionShape = getSelectionBoxShape(
|
||||||
element,
|
element,
|
||||||
this.scene.getNonDeletedElementsMap(),
|
this.scene.getNonDeletedElementsMap(),
|
||||||
this.getElementHitThreshold(),
|
isImageElement(element) ? 0 : this.getElementHitThreshold(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return isPointInShape(pointFrom(x, y), selectionShape);
|
return isPointInShape(pointFrom(x, y), selectionShape);
|
||||||
|
@ -26,6 +26,8 @@ import {
|
|||||||
getResizedElementAbsoluteCoords,
|
getResizedElementAbsoluteCoords,
|
||||||
} from "./bounds";
|
} from "./bounds";
|
||||||
|
|
||||||
|
const MINIMAL_CROP_SIZE = 10;
|
||||||
|
|
||||||
export const cropElement = (
|
export const cropElement = (
|
||||||
element: ExcalidrawImageElement,
|
element: ExcalidrawImageElement,
|
||||||
transformHandle: TransformHandleType,
|
transformHandle: TransformHandleType,
|
||||||
@ -85,7 +87,7 @@ export const cropElement = (
|
|||||||
const pointerDeltaY = pointerY - element.y;
|
const pointerDeltaY = pointerY - element.y;
|
||||||
nextHeight = clamp(
|
nextHeight = clamp(
|
||||||
element.height - pointerDeltaY,
|
element.height - pointerDeltaY,
|
||||||
1,
|
MINIMAL_CROP_SIZE,
|
||||||
isFlippedByY ? uncroppedHeight - croppedTop : element.height + croppedTop,
|
isFlippedByY ? uncroppedHeight - croppedTop : element.height + croppedTop,
|
||||||
);
|
);
|
||||||
crop.height = (nextHeight / uncroppedHeight) * naturalHeight;
|
crop.height = (nextHeight / uncroppedHeight) * naturalHeight;
|
||||||
@ -96,7 +98,7 @@ export const cropElement = (
|
|||||||
} else if (transformHandle.includes("s")) {
|
} else if (transformHandle.includes("s")) {
|
||||||
nextHeight = clamp(
|
nextHeight = clamp(
|
||||||
pointerY - element.y,
|
pointerY - element.y,
|
||||||
1,
|
MINIMAL_CROP_SIZE,
|
||||||
isFlippedByY ? element.height + croppedTop : uncroppedHeight - croppedTop,
|
isFlippedByY ? element.height + croppedTop : uncroppedHeight - croppedTop,
|
||||||
);
|
);
|
||||||
crop.height = (nextHeight / uncroppedHeight) * naturalHeight;
|
crop.height = (nextHeight / uncroppedHeight) * naturalHeight;
|
||||||
@ -112,7 +114,7 @@ export const cropElement = (
|
|||||||
|
|
||||||
nextWidth = clamp(
|
nextWidth = clamp(
|
||||||
element.width - pointerDeltaX,
|
element.width - pointerDeltaX,
|
||||||
1,
|
MINIMAL_CROP_SIZE,
|
||||||
isFlippedByX ? uncroppedWidth - croppedLeft : element.width + croppedLeft,
|
isFlippedByX ? uncroppedWidth - croppedLeft : element.width + croppedLeft,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ export const cropElement = (
|
|||||||
} else if (transformHandle.includes("e")) {
|
} else if (transformHandle.includes("e")) {
|
||||||
nextWidth = clamp(
|
nextWidth = clamp(
|
||||||
pointerX - element.x,
|
pointerX - element.x,
|
||||||
1,
|
MINIMAL_CROP_SIZE,
|
||||||
isFlippedByX ? element.width + croppedLeft : uncroppedWidth - croppedLeft,
|
isFlippedByX ? element.width + croppedLeft : uncroppedWidth - croppedLeft,
|
||||||
);
|
);
|
||||||
crop.width = nextWidth * naturalWidthToUncropped;
|
crop.width = nextWidth * naturalWidthToUncropped;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user