From 54707a238d0615f32869d95b5a592e50f7baa291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Mon, 2 Dec 2024 21:43:10 -0800 Subject: [PATCH] minor change --- src/folk-shape.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/folk-shape.ts b/src/folk-shape.ts index 2e118a9..45c7232 100644 --- a/src/folk-shape.ts +++ b/src/folk-shape.ts @@ -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;