Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Fixed use case when the window start small
Browse files Browse the repository at this point in the history
  • Loading branch information
lvcabral committed Dec 18, 2023
1 parent 7348ea6 commit 6595431
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/titlebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ export class CustomTitlebar extends ThemeBar {
}
}

private canCenterTitle() {
const menuBarContainerMargin = 20
const menuSpaceLimit = window.innerWidth / 2 - this.menuBarContainer.getBoundingClientRect().right - menuBarContainerMargin
return (this.title.getBoundingClientRect().width / 2 <= menuSpaceLimit)
}

/// Public methods

/**
Expand Down Expand Up @@ -540,15 +546,15 @@ export class CustomTitlebar extends ThemeBar {

if (menuPosition !== 'bottom') {
addDisposableListener(window, 'resize', () => {
const menuBarContainerMargin = 20
const menuSpaceLimit = window.innerWidth / 2 - this.menuBarContainer.getBoundingClientRect().right - menuBarContainerMargin
if (this.title.getBoundingClientRect().width / 2 <= menuSpaceLimit) {
if (this.canCenterTitle()) {
addClass(this.title, 'cet-title-center')
} else {
removeClass(this.title, 'cet-title-center')
}
})
addClass(this.title, 'cet-title-center')
if (this.canCenterTitle()) {
addClass(this.title, 'cet-title-center')
}
}

if (!isMacintosh && order === 'first-buttons') {
Expand Down

0 comments on commit 6595431

Please sign in to comment.