From 79202c67b26848f610d90019246d2fc0e90703e9 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Tue, 13 Apr 2021 10:49:59 +0300 Subject: [PATCH] keep window ratio on reducing --- web/share/js/wm.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/share/js/wm.js b/web/share/js/wm.js index b74e2626..aa6beba8 100644 --- a/web/share/js/wm.js +++ b/web/share/js/wm.js @@ -75,7 +75,9 @@ function __WindowManager() { let view = self.getViewGeometry(); let rect = el_window.getBoundingClientRect(); if ((rect.bottom - rect.top) > (view.bottom - view.top)) { + let ratio = (rect.bottom - rect.top) / (view.bottom - view.top); el_window.style.height = view.bottom - view.top + "px"; + el_window.style.width = Math.round((rect.right - rect.left) / ratio) + "px"; } if (el_window.hasAttribute("data-centered")) { @@ -377,7 +379,9 @@ function __WindowManager() { if (el_window.classList.contains("window-resizable")) { // При переполнении рабочей области сократить размер окна if ((rect.bottom - rect.top) > (view.bottom - view.top)) { + let ratio = (rect.bottom - rect.top) / (view.bottom - view.top); el_window.style.height = view.bottom - view.top + "px"; + el_window.style.width = Math.round((rect.right - rect.left) / ratio) + "px"; } if ((rect.right - rect.left) > (view.right - view.left)) { el_window.style.width = view.right - view.left + "px";