diff --git a/src/globals.js b/src/globals.js index f5ff998a..3c443394 100644 --- a/src/globals.js +++ b/src/globals.js @@ -141,12 +141,6 @@ if (window.location !== window.parent.location) { window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height; window.desktop_width = window.innerWidth; -// recalculate desktop height and width on window resize -$( window ).on( "resize", function() { - window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height; - window.desktop_width = window.innerWidth; -}); - // for now `active_element` is basically the last element that was clicked, // later on though (todo) `active_element` will also be set by keyboard movements // such as arrow keys, tab key, ... and when creating new windows... diff --git a/src/initgui.js b/src/initgui.js index 097dd037..121594f4 100644 --- a/src/initgui.js +++ b/src/initgui.js @@ -1976,4 +1976,32 @@ function requestOpenerOrigin() { $(document).on('click', '.generic-close-window-button', function(e){ $(this).closest('.window').close(); +}); + +// Re-calculate desktop height and width on window resize and re-position the login and signup windows +$(window).on("resize", function () { + // If host env is popup, don't continue because the popup window has its own resize requirements. + if (window.embedded_in_popup) + return; + + const ratio = window.desktop_width / window.innerWidth; + + window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height; + window.desktop_width = window.innerWidth; + + // Re-center the login window + const top = $(".window-login").position()?.top; + const width = $(".window-login").width(); + $(".window-login").css({ + left: (window.desktop_width - width) / 2, + top: top / ratio, + }); + + // Re-center the create account window + const top2 = $(".window-signup").position()?.top; + const width2 = $(".window-signup").width(); + $(".window-signup").css({ + left: (window.desktop_width - width2) / 2, + top: top2 / ratio, + }); }); \ No newline at end of file