mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Support negative resize for multiple points line/arrow (#1237)
* Support negative resize for multiple points line * prettier * Fix an issue with width or height becoming zero
This commit is contained in:
parent
d5899f6ca0
commit
b1ed5b4cdc
3 changed files with 10 additions and 36 deletions
|
@ -144,7 +144,7 @@ export function resizeElements(
|
|||
width,
|
||||
height,
|
||||
...adjustXYWithRotation("nw", element, deltaX, dY, angle),
|
||||
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||
...(isLinearElement(element) && width !== 0 && height !== 0
|
||||
? {
|
||||
points: rescalePoints(
|
||||
0,
|
||||
|
@ -176,7 +176,7 @@ export function resizeElements(
|
|||
width,
|
||||
height,
|
||||
...adjustXYWithRotation("ne", element, deltaX, dY, angle),
|
||||
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||
...(isLinearElement(element) && width !== 0 && height !== 0
|
||||
? {
|
||||
points: rescalePoints(
|
||||
0,
|
||||
|
@ -208,7 +208,7 @@ export function resizeElements(
|
|||
width,
|
||||
height,
|
||||
...adjustXYWithRotation("sw", element, deltaX, dY, angle),
|
||||
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||
...(isLinearElement(element) && width !== 0 && height !== 0
|
||||
? {
|
||||
points: rescalePoints(
|
||||
0,
|
||||
|
@ -240,7 +240,7 @@ export function resizeElements(
|
|||
width,
|
||||
height,
|
||||
...adjustXYWithRotation("se", element, deltaX, dY, angle),
|
||||
...(isLinearElement(element) && width >= 0 && height >= 0
|
||||
...(isLinearElement(element) && width !== 0 && height !== 0
|
||||
? {
|
||||
points: rescalePoints(
|
||||
0,
|
||||
|
@ -255,12 +255,7 @@ export function resizeElements(
|
|||
case "n": {
|
||||
const height = element.height - deltaY;
|
||||
|
||||
if (isLinearElement(element)) {
|
||||
if (element.points.length > 2 && height <= 0) {
|
||||
// Someday we should implement logic to flip the shape.
|
||||
// But for now, just stop.
|
||||
break;
|
||||
}
|
||||
if (isLinearElement(element) && height !== 0) {
|
||||
mutateElement(element, {
|
||||
height,
|
||||
...adjustXYWithRotation("n", element, 0, deltaY, angle),
|
||||
|
@ -278,13 +273,7 @@ export function resizeElements(
|
|||
case "w": {
|
||||
const width = element.width - deltaX;
|
||||
|
||||
if (isLinearElement(element)) {
|
||||
if (element.points.length > 2 && width <= 0) {
|
||||
// Someday we should implement logic to flip the shape.
|
||||
// But for now, just stop.
|
||||
break;
|
||||
}
|
||||
|
||||
if (isLinearElement(element) && width !== 0) {
|
||||
mutateElement(element, {
|
||||
width,
|
||||
...adjustXYWithRotation("w", element, deltaX, 0, angle),
|
||||
|
@ -301,12 +290,7 @@ export function resizeElements(
|
|||
case "s": {
|
||||
const height = element.height + deltaY;
|
||||
|
||||
if (isLinearElement(element)) {
|
||||
if (element.points.length > 2 && height <= 0) {
|
||||
// Someday we should implement logic to flip the shape.
|
||||
// But for now, just stop.
|
||||
break;
|
||||
}
|
||||
if (isLinearElement(element) && height !== 0) {
|
||||
mutateElement(element, {
|
||||
height,
|
||||
...adjustXYWithRotation("s", element, 0, deltaY, angle),
|
||||
|
@ -323,12 +307,7 @@ export function resizeElements(
|
|||
case "e": {
|
||||
const width = element.width + deltaX;
|
||||
|
||||
if (isLinearElement(element)) {
|
||||
if (element.points.length > 2 && width <= 0) {
|
||||
// Someday we should implement logic to flip the shape.
|
||||
// But for now, just stop.
|
||||
break;
|
||||
}
|
||||
if (isLinearElement(element) && width !== 0) {
|
||||
mutateElement(element, {
|
||||
width,
|
||||
...adjustXYWithRotation("e", element, deltaX, 0, angle),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue