Skip to content

Commit 368817a

Browse files
committed
Allow reading variable tab height for tab bounds
1 parent d74c2f7 commit 368817a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/services/sidebar.actions.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,14 +602,9 @@ export function updateBounds(): void {
602602
function calcTabsBounds(panel: TabsPanel): ItemBounds[] {
603603
// Logs.info('Sidebar.calcTabsBounds', panel.id)
604604
const result: ItemBounds[] = []
605-
const th = Sidebar.tabHeight
606605
const tm = Sidebar.tabMargin
607-
if (th === 0) return result
608-
const half = th >> 1
609606
const marginA = Math.floor(tm / 2)
610607
const marginB = Math.ceil(tm / 2)
611-
const insideA = (half >> 1) + marginB + 2
612-
const insideB = (half >> 1) + marginB - 2
613608

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

622+
// This method to get tab element taken from: https://github.com/mbnuqw/sidebery/blob/d74c2f70bcd9a980dcec02738a5260b171f5ecc1/src/services/tabs.fg.scroll.ts#L25
623+
const elId = 'tab' + tab.id.toString()
624+
const el = document.getElementById(elId)
625+
let th = el.offsetHeight - tm
626+
const half = th >> 1
627+
const insideA = (half >> 1) + marginB + 2
628+
const insideB = (half >> 1) + marginB - 2
629+
627630
result.push({
628631
type: ItemBoundsType.Tab,
629632
id: tab.id,

0 commit comments

Comments
 (0)