Skip to content

Commit

Permalink
feat: auto scroll to the activated liquid tab when it's out of the vi…
Browse files Browse the repository at this point in the history
…ewport
  • Loading branch information
WhiredPlanck committed Apr 26, 2024
1 parent de3a186 commit 2bb3070
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ class LiquidTabsUi(override val ctx: Context, val theme: Theme) : Ui {
if (selected >= 0) {
tabs[selected].setActive(false)
}
tabs[index].setActive(true)
tabs[index].also { tabUi ->
tabUi.setActive(true)
if (tabUi.root.left !in root.scrollX..root.scrollX + root.width) {
root.run { post { smoothScrollTo(tabUi.root.left, scrollY) } }
}
}
selected = index
}

Expand Down

0 comments on commit 2bb3070

Please sign in to comment.