mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 00:20:05 +01:00
This commit is contained in:
parent
4e344e7be2
commit
a878c530c6
|
|
@ -67,7 +67,7 @@ const useRnd = (id: string): Props => {
|
||||||
) => {
|
) => {
|
||||||
const [, x, y] =
|
const [, x, y] =
|
||||||
/translate\((-?\d+)px, (-?\d+)px\)/.exec(transform) || [];
|
/translate\((-?\d+)px, (-?\d+)px\)/.exec(transform) || [];
|
||||||
const newPositon =
|
const newPosition =
|
||||||
typeof x === "string" && typeof y === "string"
|
typeof x === "string" && typeof y === "string"
|
||||||
? { x: pxToNum(x), y: pxToNum(y) }
|
? { x: pxToNum(x), y: pxToNum(y) }
|
||||||
: resizePosition;
|
: resizePosition;
|
||||||
|
|
@ -76,21 +76,29 @@ const useRnd = (id: string): Props => {
|
||||||
|
|
||||||
const newSize = { height: pxToNum(height), width: pxToNum(width) };
|
const newSize = { height: pxToNum(height), width: pxToNum(width) };
|
||||||
|
|
||||||
if (newPositon.y < 0) {
|
if (newPosition.y < 0) {
|
||||||
newSize.height += newPositon.y;
|
newSize.height += newPosition.y;
|
||||||
newPositon.y = 0;
|
newPosition.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSize(newSize);
|
if (
|
||||||
setPosition(newPositon);
|
!isWindowOutsideBounds(
|
||||||
setWindowStates((currentWindowStates) => ({
|
{ position: newPosition, size: newSize },
|
||||||
...currentWindowStates,
|
getWindowViewport(),
|
||||||
[id]: {
|
true
|
||||||
...currentWindowStates[id],
|
)
|
||||||
position: newPositon,
|
) {
|
||||||
size: newSize,
|
setSize(newSize);
|
||||||
},
|
setPosition(newPosition);
|
||||||
}));
|
setWindowStates((currentWindowStates) => ({
|
||||||
|
...currentWindowStates,
|
||||||
|
[id]: {
|
||||||
|
...currentWindowStates[id],
|
||||||
|
position: newPosition,
|
||||||
|
size: newSize,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[id, setPosition, setSize, setWindowStates]
|
[id, setPosition, setSize, setWindowStates]
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user