Skip to content

Commit

Permalink
Refactor getAndApplySidebarWidth to remove async and simplify sidebar…
Browse files Browse the repository at this point in the history
… width calculation
  • Loading branch information
mauro-balades committed Feb 6, 2025
1 parent 8eaceb4 commit 1e624ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/browser/base/zen-components/ZenCompactMode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ var gZenCompactModeManager = {
this.animateCompactMode();
},

async getAndApplySidebarWidth() {
let sidebarWidth = await window.promiseDocumentFlushed(() =>
window.windowUtils.getBoundsWithoutFlushing(this.sidebar).width
);
getAndApplySidebarWidth() {
let sidebarWidth = this.sidebar.getBoundingClientRect().width;
if (sidebarWidth > 1) {
this.sidebar.style.setProperty('--zen-sidebar-width', `${sidebarWidth}px`);
}
Expand All @@ -160,8 +158,8 @@ var gZenCompactModeManager = {
this.sidebar.style.removeProperty('margin-right');
this.sidebar.style.removeProperty('margin-left');
this.sidebar.style.removeProperty('transform');
window.requestAnimationFrame(async () => {
let sidebarWidth = await this.getAndApplySidebarWidth();
window.requestAnimationFrame(() => {
let sidebarWidth = this.getAndApplySidebarWidth();
if (!canAnimate) {
this.sidebar.removeAttribute('animate');
this._animating = false;
Expand Down

0 comments on commit 1e624ae

Please sign in to comment.