Mercurial > hg > orthanc-wsi
changeset 595:ea5cfc37aac7 annotations
fix menu layout at startup
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Mon, 07 Sep 2026 11:02:04 +0200 |
| parents | be8f2691d1f0 |
| children | 0b282bf7ff63 |
| files | ViewerPlugin/WebApplication/viewer.js |
| diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ViewerPlugin/WebApplication/viewer.js Mon Sep 07 10:51:52 2026 +0200 +++ b/ViewerPlugin/WebApplication/viewer.js Mon Sep 07 11:02:04 2026 +0200 @@ -44,7 +44,7 @@ // UI state toolbarsVisible: false, - panelOpen: true, + panelOpen: false, mapBackground: '', rotationDeg: 0, activeDrawTool: null, @@ -604,8 +604,23 @@ var toggle = document.getElementById('right-panel-toggle'); var isResizing = false; + // Ensure the initial chevron direction matches the real offcanvas state. + that.panelOpen = panel.classList.contains('show'); + function ResizingLoop() { - toggle.style.right = (window.innerWidth - panel.getBoundingClientRect().left) + 'px'; + // If the offcanvas is hidden (e.g. before workspace load), its left edge can be 0, + // which would incorrectly move the toggle off-screen. Clamp to [0, panelWidth]. + var panelRect = panel.getBoundingClientRect(); + var panelWidth = Math.max(0, panelRect.width || 0); + var right = window.innerWidth - panelRect.left; + + if (!isFinite(right)) { + right = 0; + } + + right = Math.max(0, Math.min(right, panelWidth)); + toggle.style.right = right + 'px'; + if (isResizing) { requestAnimationFrame(ResizingLoop); } @@ -634,6 +649,9 @@ StartResizing(); }); panel.addEventListener('shown.bs.offcanvas', StopResizing); + + // Keep the toggle aligned if viewport size changes. + window.addEventListener('resize', StopResizing); }, // -----------------------------------------------------------------------
