forked from Mirrors/bubbletea
Add helper method to paginator for determining if we're on the last page
This commit is contained in:
parent
5a1ee26a6b
commit
149579d584
|
@ -82,11 +82,19 @@ func (m *Model) PrevPage() {
|
||||||
// NextPage is a helper function for navigating one page forward. It will not
|
// NextPage is a helper function for navigating one page forward. It will not
|
||||||
// page beyond the last page (i.e. totalPages - 1).
|
// page beyond the last page (i.e. totalPages - 1).
|
||||||
func (m *Model) NextPage() {
|
func (m *Model) NextPage() {
|
||||||
if m.Page < m.TotalPages-1 {
|
if !m.OnLastPage() {
|
||||||
m.Page++
|
m.Page++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LastPage returns whether or not we're on the last page
|
||||||
|
func (m Model) OnLastPage() bool {
|
||||||
|
if m.Page == m.TotalPages-1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// NewModel creates a new model with defaults
|
// NewModel creates a new model with defaults
|
||||||
func NewModel() Model {
|
func NewModel() Model {
|
||||||
return Model{
|
return Model{
|
||||||
|
|
Loading…
Reference in New Issue