Avoid sidebar width re-caclulation when animating compact mode

This commit is contained in:
mr. m
2025-04-11 16:52:29 +02:00
parent 1a04cac47c
commit 589335f665

View File

@@ -159,6 +159,10 @@ var gZenCompactModeManager = {
// NOTE: Dont actually use event, it's just so we make sure // NOTE: Dont actually use event, it's just so we make sure
// the caller is from the ResizeObserver // the caller is from the ResizeObserver
getAndApplySidebarWidth(event = undefined) { getAndApplySidebarWidth(event = undefined) {
if (this._ignoreNextResize) {
this._ignoreNextResize = false;
return;
}
let sidebarWidth = this.sidebar.getBoundingClientRect().width; let sidebarWidth = this.sidebar.getBoundingClientRect().width;
if (sidebarWidth > 1) { if (sidebarWidth > 1) {
gZenUIManager.restoreScrollbarState(); gZenUIManager.restoreScrollbarState();
@@ -235,17 +239,14 @@ var gZenCompactModeManager = {
setTimeout(() => { setTimeout(() => {
this.sidebar.removeAttribute('animate'); this.sidebar.removeAttribute('animate');
document.documentElement.removeAttribute('zen-compact-animating'); document.documentElement.removeAttribute('zen-compact-animating');
this.getAndApplySidebarWidth({});
this._ignoreNextResize = true;
this.sidebar.style.removeProperty('margin-right'); this.sidebar.style.removeProperty('margin-right');
this.sidebar.style.removeProperty('margin-left'); this.sidebar.style.removeProperty('margin-left');
this.sidebar.style.removeProperty('opacity'); this.sidebar.style.removeProperty('opacity');
this.sidebar.style.removeProperty('transition');
setTimeout(() => {
this.sidebar.style.removeProperty('transition');
// Just in case:
this.sidebar.style.removeProperty('margin-right');
this.sidebar.style.removeProperty('margin-left');
}, 200);
resolve(); resolve();
}, 0); }, 0);