termkit / skeleton

The Multi-tab framework of Bubbletea programs!
GNU General Public License v3.0
38 stars 2 forks source link

way to set individual page position #6

Open qwertypoluyt opened 2 months ago

qwertypoluyt commented 2 months ago

how can one set the page position of a single page?

here is what i currently use atm s.SetPagePosition(lipgloss.Center) <-- sets all page position

canack commented 2 months ago

Hi, sorry for late answer. I didn't get notified.

Skeleton sends IAMActivePage message every page switch. You should add your Update method this code:

// Psuedo code
func (a *agents) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    var cmds []tea.Cmd
    var cmd tea.Cmd

    switch msg := msg.(type) {
    case skeleton.IAMActivePage: // It means, you switched this page
        a.skeleton.SetPagePosition(lipgloss.Center)
    }

    return a, tea.Batch(cmds...)
}

You can solve like this currently. @qwertypoluyt