mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
Ensure we don't render off screen if we are in a hidden iframe when we load
This commit is contained in:
parent
0efd902e3c
commit
f17d88053c
1 changed files with 4 additions and 2 deletions
|
|
@ -63,11 +63,13 @@ class WindowManager extends React.Component {
|
|||
const windowPositions = {};
|
||||
const keys = this.windowKeys();
|
||||
const totalHeight = keys.length * WINDOW_HEIGHT;
|
||||
const globalOffsetLeft = Math.max(0, width / 2 - WINDOW_WIDTH / 2);
|
||||
const globalOffsetTop = Math.max(0, height / 2 - totalHeight / 2);
|
||||
keys.forEach((key, i) => {
|
||||
const offset = WINDOW_HEIGHT * i;
|
||||
windowPositions[key] = {
|
||||
x: Math.ceil(offsetLeft + (width / 2 - WINDOW_WIDTH / 2)),
|
||||
y: Math.ceil(offsetTop + (height / 2 - totalHeight / 2 + offset))
|
||||
x: Math.ceil(offsetLeft + globalOffsetLeft),
|
||||
y: Math.ceil(offsetTop + (globalOffsetTop + offset))
|
||||
};
|
||||
});
|
||||
this.props.updateWindowPositions(windowPositions);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue