Skip to content

Commit

Permalink
Disallow resize above screen
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinBrett committed Jul 14, 2024
1 parent ec84ebe commit e4c9630
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/system/Window/RndWindow/useRnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const useRnd = (id: string): Props => {
_delta,
resizePosition
) => {
const [, x, y] = transform.match(/translate\((\d+)px, (\d+)px\)/) || [];
const [, x, y] =
transform.match(/translate\((-?\d+)px, (-?\d+)px\)/) || [];
const newPositon =
typeof x === "string" && typeof y === "string"
? { x: pxToNum(x), y: pxToNum(y) }
Expand All @@ -75,6 +76,11 @@ const useRnd = (id: string): Props => {

const newSize = { height: pxToNum(height), width: pxToNum(width) };

if (newPositon.y < 0) {
newSize.height += newPositon.y;
newPositon.y = 0;
}

setSize(newSize);
setPosition(newPositon);
setWindowStates((currentWindowStates) => ({
Expand Down

0 comments on commit e4c9630

Please sign in to comment.