From 83d954246f76b1d7d7e6393ac883b69914dff0d7 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Wed, 5 Jul 2023 00:16:36 +0900 Subject: [PATCH] anti-Tav tactics (MovingUI resets on page zoom) --- public/scripts/power-user.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 640f90700..7b0e3305f 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -27,7 +27,7 @@ import { import { registerSlashCommand } from "./slash-commands.js"; -import { delay } from "./utils.js"; +import { delay, debounce } from "./utils.js"; export { loadPowerUserSettings, @@ -983,7 +983,7 @@ async function saveTheme() { } } -async function resetMovablePanels() { +async function resetMovablePanels(type) { const panelIds = [ 'sheld', 'left-nav-panel', @@ -1025,9 +1025,12 @@ async function resetMovablePanels() { eventSource.once(event_types.SETTINGS_UPDATED, () => { $(".resizing").removeClass('resizing'); - toastr.success('Panel positions reset'); + if (type === 'resize') { + toastr.warning('Panel positions reset due to zoom/resize'); + } else { + toastr.success('Panel positions reset'); + } }); - } function doNewChat() { @@ -1121,6 +1124,18 @@ function doResetPanels() { } $(document).ready(() => { + + $(window).on('resize', async () => { + //console.log('Window resized!'); + const zoomLevel = Number(window.devicePixelRatio).toFixed(2); + const winWidth = window.innerWidth; + const winHeight = window.innerHeight; + console.debug(`Zoom: ${zoomLevel}, X:${winWidth}, Y:${winHeight}`); + + resetMovablePanels('resize'); + // Adjust layout and styling here + }); + // Settings that go to settings.json $("#collapse-newlines-checkbox").change(function () { power_user.collapse_newlines = !!$(this).prop("checked");