diff options
author | crupest <crupest@outlook.com> | 2023-08-31 18:33:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-08-31 18:33:29 +0800 |
commit | 1a543da5a018d1a99b51bfe5d7d90edff0502a11 (patch) | |
tree | 3169fae9a4b9a6229566bb3243b61d3d9fa78395 /FrontEnd/src/utilities/geometry.ts | |
parent | 4a6d8c606fab0215065ce65d2f105fafd8db7169 (diff) | |
download | timeline-1a543da5a018d1a99b51bfe5d7d90edff0502a11.tar.gz timeline-1a543da5a018d1a99b51bfe5d7d90edff0502a11.tar.bz2 timeline-1a543da5a018d1a99b51bfe5d7d90edff0502a11.zip |
Fix a fatal bug in geometry.
Diffstat (limited to 'FrontEnd/src/utilities/geometry.ts')
-rw-r--r-- | FrontEnd/src/utilities/geometry.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/FrontEnd/src/utilities/geometry.ts b/FrontEnd/src/utilities/geometry.ts index 12dd4bbb..60a8d3d4 100644 --- a/FrontEnd/src/utilities/geometry.ts +++ b/FrontEnd/src/utilities/geometry.ts @@ -49,7 +49,7 @@ export class Rect { } set right(value: number) { - this.width = this.left + value; + this.width = value - this.left; } get bottom(): number { @@ -57,7 +57,7 @@ export class Rect { } set bottom(value: number) { - this.height = this.top + value; + this.height = value - this.top; } get ratio(): number { @@ -218,15 +218,16 @@ export function adjustRectToContainer( : clamp(rect.top, container.top - rect.height, container.bottom); } else if (mode === "resize") { const noFlip = options?.resizeNoFlip; - rect.right = clamp( + const newRight = clamp( rect.right, - noFlip ? 0 : container.left, - container.right, + rect.width > 0 && noFlip ? rect.left : container.left, + rect.width < 0 && noFlip ? rect.left : container.right, ); + rect.right = newRight; rect.bottom = clamp( rect.bottom, - noFlip ? 0 : container.top, - container.bottom, + rect.height > 0 && noFlip ? rect.top : container.top, + rect.height < 0 && noFlip ? rect.top : container.bottom, ); } else { rect.left = clamp(rect.left, container.left, container.right); |