fix: image insertion bugs (#7278)
This commit is contained in:
parent
adfd95be33
commit
029c3c48ba
@ -4740,9 +4740,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { x, y } = viewportCoordsToSceneCoords(event, this.state);
|
const { x, y } = viewportCoordsToSceneCoords(event, this.state);
|
||||||
|
|
||||||
|
const frame = this.getTopLayerFrameAtSceneCoords({ x, y });
|
||||||
|
|
||||||
mutateElement(pendingImageElement, {
|
mutateElement(pendingImageElement, {
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
frameId: frame ? frame.id : null,
|
||||||
});
|
});
|
||||||
} else if (this.state.activeTool.type === "freedraw") {
|
} else if (this.state.activeTool.type === "freedraw") {
|
||||||
this.handleFreeDrawElementOnPointerDown(
|
this.handleFreeDrawElementOnPointerDown(
|
||||||
@ -5609,9 +5613,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
private createImageElement = ({
|
private createImageElement = ({
|
||||||
sceneX,
|
sceneX,
|
||||||
sceneY,
|
sceneY,
|
||||||
|
addToFrameUnderCursor = true,
|
||||||
}: {
|
}: {
|
||||||
sceneX: number;
|
sceneX: number;
|
||||||
sceneY: number;
|
sceneY: number;
|
||||||
|
addToFrameUnderCursor?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const [gridX, gridY] = getGridPoint(
|
const [gridX, gridY] = getGridPoint(
|
||||||
sceneX,
|
sceneX,
|
||||||
@ -5621,10 +5627,12 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
: this.state.gridSize,
|
: this.state.gridSize,
|
||||||
);
|
);
|
||||||
|
|
||||||
const topLayerFrame = this.getTopLayerFrameAtSceneCoords({
|
const topLayerFrame = addToFrameUnderCursor
|
||||||
|
? this.getTopLayerFrameAtSceneCoords({
|
||||||
x: gridX,
|
x: gridX,
|
||||||
y: gridY,
|
y: gridY,
|
||||||
});
|
})
|
||||||
|
: null;
|
||||||
|
|
||||||
const element = newImageElement({
|
const element = newImageElement({
|
||||||
type: "image",
|
type: "image",
|
||||||
@ -7554,6 +7562,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
const imageElement = this.createImageElement({
|
const imageElement = this.createImageElement({
|
||||||
sceneX: x,
|
sceneX: x,
|
||||||
sceneY: y,
|
sceneY: y,
|
||||||
|
addToFrameUnderCursor: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (insertOnCanvasDirectly) {
|
if (insertOnCanvasDirectly) {
|
||||||
|
@ -99,7 +99,7 @@ export const setCursorForShape = (
|
|||||||
interactiveCanvas.style.cursor = `url(${url}), auto`;
|
interactiveCanvas.style.cursor = `url(${url}), auto`;
|
||||||
} else if (!["image", "custom"].includes(appState.activeTool.type)) {
|
} else if (!["image", "custom"].includes(appState.activeTool.type)) {
|
||||||
interactiveCanvas.style.cursor = CURSOR_TYPE.CROSSHAIR;
|
interactiveCanvas.style.cursor = CURSOR_TYPE.CROSSHAIR;
|
||||||
} else {
|
} else if (appState.activeTool.type !== "image") {
|
||||||
interactiveCanvas.style.cursor = CURSOR_TYPE.AUTO;
|
interactiveCanvas.style.cursor = CURSOR_TYPE.AUTO;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user