Skip to content

Commit

Permalink
Allow reading variable tab height for tab bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
willhansen committed Oct 12, 2024
1 parent d74c2f7 commit 368817a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/services/sidebar.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,14 +602,9 @@ export function updateBounds(): void {
function calcTabsBounds(panel: TabsPanel): ItemBounds[] {
// Logs.info('Sidebar.calcTabsBounds', panel.id)
const result: ItemBounds[] = []
const th = Sidebar.tabHeight
const tm = Sidebar.tabMargin
if (th === 0) return result
const half = th >> 1
const marginA = Math.floor(tm / 2)
const marginB = Math.ceil(tm / 2)
const insideA = (half >> 1) + marginB + 2
const insideB = (half >> 1) + marginB - 2

let overallHeight = -marginA
let tabs = Tabs.list
Expand All @@ -624,6 +619,14 @@ function calcTabsBounds(panel: TabsPanel): ItemBounds[] {
if (tab.invisible || tab.pinned) continue
if (tab.panelId !== panel.id) continue

// This method to get tab element taken from: https://github.com/mbnuqw/sidebery/blob/d74c2f70bcd9a980dcec02738a5260b171f5ecc1/src/services/tabs.fg.scroll.ts#L25
const elId = 'tab' + tab.id.toString()
const el = document.getElementById(elId)
let th = el.offsetHeight - tm
const half = th >> 1
const insideA = (half >> 1) + marginB + 2
const insideB = (half >> 1) + marginB - 2

result.push({
type: ItemBoundsType.Tab,
id: tab.id,
Expand Down

0 comments on commit 368817a

Please sign in to comment.