mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Add method to pager model for getting percent scrolled
This commit is contained in:
@@ -18,6 +18,16 @@ type Model struct {
|
||||
lines []string
|
||||
}
|
||||
|
||||
func (m Model) ScrollPercent() float64 {
|
||||
if m.Height >= len(m.lines) {
|
||||
return 1.0
|
||||
}
|
||||
y := float64(m.Y)
|
||||
h := float64(m.Height)
|
||||
t := float64(len(m.lines))
|
||||
return (y + h) / t
|
||||
}
|
||||
|
||||
// Content set the pager's text content
|
||||
func (m *Model) Content(s string) {
|
||||
s = strings.TrimSpace(s)
|
||||
|
||||
Reference in New Issue
Block a user