minor change

This commit is contained in:
“chrisshank” 2024-12-02 21:43:10 -08:00
parent d52f569110
commit 54707a238d
1 changed files with 10 additions and 7 deletions

View File

@ -417,25 +417,28 @@ export class FolkShape extends HTMLElement {
if (handle.includes('resize')) {
const { clientX, clientY } = event;
const [topLeft, topRight, bottomRight, bottomLeft] = this.getClientRect().corners();
const [topLeft] = this.getClientRect().corners();
const newCenter: Point = {
x: (topLeft.x + clientX) / 2,
y: (topLeft.y + clientY) / 2,
};
const newTopLeft = Vector.rotateAround(topLeft, newCenter, -this.rotation);
let bottomRightAdjusted: Point;
let bottomRight: Point;
if (handle.endsWith('nw')) {
bottomRightAdjusted = { x: clientX, y: clientY };
bottomRight = { x: clientX, y: clientY };
} else if (handle.endsWith('ne')) {
bottomRightAdjusted = { x: clientX, y: clientY };
bottomRight = { x: clientX, y: clientY };
} else if (handle.endsWith('se')) {
bottomRightAdjusted = { x: clientX, y: clientY };
bottomRight = { x: clientX, y: clientY };
} else {
bottomRightAdjusted = { x: clientX, y: clientY };
bottomRight = { x: clientX, y: clientY };
}
const newBottomRight = Vector.rotateAround(bottomRightAdjusted, newCenter, -this.rotation);
const newBottomRight = Vector.rotateAround(bottomRight, newCenter, -this.rotation);
this.x = newTopLeft.x;
this.y = newTopLeft.y;