Fix corner resize for multi-point arrows (#1105)
The logic to support it was not implemented. This is not the prettiest way to solve it in the world but it does work. Some more refactoring here is probably warranted. Fixes #1039
This commit is contained in:
parent
24fa657093
commit
8e6d55cf75
@ -1964,15 +1964,26 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
||||||
} else {
|
} else {
|
||||||
|
const width = element.width - deltaX;
|
||||||
|
const height = event.shiftKey
|
||||||
|
? element.width
|
||||||
|
: element.height - deltaY;
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
x: element.x + deltaX,
|
x: element.x + deltaX,
|
||||||
y: event.shiftKey
|
y: event.shiftKey
|
||||||
? element.y + element.height - element.width
|
? element.y + element.height - element.width
|
||||||
: element.y + deltaY,
|
: element.y + deltaY,
|
||||||
width: element.width - deltaX,
|
width,
|
||||||
height: event.shiftKey
|
height,
|
||||||
? element.width
|
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||||
: element.height - deltaY,
|
? {
|
||||||
|
points: rescalePoints(
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
rescalePoints(1, height, element.points),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1988,13 +1999,23 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
||||||
} else {
|
} else {
|
||||||
const nextWidth = element.width + deltaX;
|
const width = element.width + deltaX;
|
||||||
|
const height = event.shiftKey ? width : element.height - deltaY;
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
y: event.shiftKey
|
y: event.shiftKey
|
||||||
? element.y + element.height - nextWidth
|
? element.y + element.height - width
|
||||||
: element.y + deltaY,
|
: element.y + deltaY,
|
||||||
width: nextWidth,
|
width,
|
||||||
height: event.shiftKey ? nextWidth : element.height - deltaY,
|
height,
|
||||||
|
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||||
|
? {
|
||||||
|
points: rescalePoints(
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
rescalePoints(1, height, element.points),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2010,12 +2031,23 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
||||||
} else {
|
} else {
|
||||||
|
const width = element.width - deltaX;
|
||||||
|
const height = event.shiftKey
|
||||||
|
? element.width
|
||||||
|
: element.height + deltaY;
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
x: element.x + deltaX,
|
x: element.x + deltaX,
|
||||||
width: element.width - deltaX,
|
width,
|
||||||
height: event.shiftKey
|
height,
|
||||||
? element.width
|
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||||
: element.height + deltaY,
|
? {
|
||||||
|
points: rescalePoints(
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
rescalePoints(1, height, element.points),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2031,11 +2063,22 @@ export class App extends React.Component<any, AppState> {
|
|||||||
}
|
}
|
||||||
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
resizeArrowFn(element, 1, deltaX, deltaY, x, y, event.shiftKey);
|
||||||
} else {
|
} else {
|
||||||
|
const width = element.width + deltaX;
|
||||||
|
const height = event.shiftKey
|
||||||
|
? element.width
|
||||||
|
: element.height + deltaY;
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
width: element.width + deltaX,
|
width,
|
||||||
height: event.shiftKey
|
height,
|
||||||
? element.width
|
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||||
: element.height + deltaY,
|
? {
|
||||||
|
points: rescalePoints(
|
||||||
|
0,
|
||||||
|
width,
|
||||||
|
rescalePoints(1, height, element.points),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -131,13 +131,6 @@ export function handlerRectangles(
|
|||||||
} as typeof handlers;
|
} as typeof handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
n: handlers.n,
|
|
||||||
s: handlers.s,
|
|
||||||
w: handlers.w,
|
|
||||||
e: handlers.e,
|
|
||||||
} as typeof handlers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return handlers;
|
return handlers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user