From c26eccfe28b48a32ac4dacffa45336bb817091c5 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 4 Jul 2024 21:37:51 +0200 Subject: [PATCH] web: Fix canvas to the top left of the screen --- dist/web/source/style.css | 6 ++++++ main/gui/source/window/web_window.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/dist/web/source/style.css b/dist/web/source/style.css index 117f8b7a6837d..dada2c254210c 100644 --- a/dist/web/source/style.css +++ b/dist/web/source/style.css @@ -179,4 +179,10 @@ a:hover { #logo { height: 25%; margin-top: 50px; +} + +.canvas-fixed { + position: absolute; + top: 0; + left: 0; } \ No newline at end of file diff --git a/main/gui/source/window/web_window.cpp b/main/gui/source/window/web_window.cpp index 9f137f8127f30..827cf72f0b17a 100644 --- a/main/gui/source/window/web_window.cpp +++ b/main/gui/source/window/web_window.cpp @@ -25,6 +25,10 @@ EM_JS(void, resizeCanvas, (), { js_resizeCanvas(); }); +EM_JS(void, fixCanvasInPlace, (), { + document.getElementById('canvas').classList.add('canvas-fixed'); +}); + EM_JS(void, setupThemeListener, (), { window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { Module._handleThemeChange(); @@ -88,6 +92,9 @@ namespace hex { return; alert("Failed to load permanent file system: "+err); }); + + // Center splash screen + document.getElementById('canvas').classList.remove('canvas-fixed'); }); } @@ -95,6 +102,7 @@ namespace hex { resizeCanvas(); setupThemeListener(); setupInputModeListener(); + fixCanvasInPlace(); bool themeFollowSystem = ImHexApi::System::usesSystemThemeDetection(); EventOSThemeChanged::subscribe(this, [themeFollowSystem] {