From a837b1e2fb9fb8ab411616d1c6278d3d58832a3c Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Thu, 3 Aug 2023 21:17:34 +0900 Subject: [PATCH] fix movingUI observer states --- public/scripts/RossAscends-mods.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index cb1188cf3..88090b512 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -534,12 +534,14 @@ export function dragElement(elmnt) { if (elmntHeader.length) { elmntHeader.off('mousedown').on('mousedown', (e) => { - + hasBeenDraggedByUser = true + observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); dragMouseDown(e); }); - $(elmnt).off('mousedown').on('mousedown', () => { isMouseDown = true }) - } else { - elmnt.off('mousedown').on('mousedown', dragMouseDown); + $(elmnt).off('mousedown').on('mousedown', () => { + isMouseDown = true + observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); + }) } const observer = new MutationObserver((mutations) => { @@ -618,7 +620,7 @@ export function dragElement(elmnt) { } //prevent resizing from top left into the top bar - if (top <= 40 && maxX >= topBarFirstX && left <= topBarFirstX + if (top < 40 && maxX >= topBarFirstX && left <= topBarFirstX ) { console.debug('prevent topbar underlap resize') elmnt.css('width', width - 1 + "px"); @@ -674,8 +676,6 @@ export function dragElement(elmnt) { } }); - observer.observe(elmnt.get(0), { attributes: true, attributeFilter: ['style'] }); - function dragMouseDown(e) { if (e) { @@ -745,6 +745,7 @@ export function dragElement(elmnt) { $("body").css("overflow", ""); // Clear the "data-dragged" attribute elmnt.attr('data-dragged', 'false'); + observer.disconnect() console.debug(`Saving ${elmntName} UI position`) saveSettingsDebounced();