mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
Remove scroll looping
This commit is contained in:
parent
81018c2da7
commit
03f8db40a0
1 changed files with 3 additions and 11 deletions
|
@ -141,10 +141,10 @@ func (rstr *RosterView) Last() *rooms.Room {
|
|||
}
|
||||
|
||||
func (rstr *RosterView) ScrollNext() {
|
||||
if index := rstr.index(rstr.selected); index == -1 || index == len(rstr.rooms)-1 {
|
||||
if index := rstr.index(rstr.selected); index == -1 {
|
||||
rstr.selected = rstr.First()
|
||||
rstr.scrollOffset = 0
|
||||
} else {
|
||||
} else if index < len(rstr.rooms)-1 {
|
||||
rstr.Lock()
|
||||
defer rstr.Unlock()
|
||||
rstr.selected = rstr.rooms[index+1]
|
||||
|
@ -155,15 +155,7 @@ func (rstr *RosterView) ScrollNext() {
|
|||
}
|
||||
|
||||
func (rstr *RosterView) ScrollPrev() {
|
||||
if index := rstr.index(rstr.selected); index < 1 {
|
||||
rstr.selected = rstr.Last()
|
||||
|
||||
if i := len(rstr.rooms) - rstr.RoomsOnScreen(); i < 0 {
|
||||
rstr.scrollOffset = 0
|
||||
} else {
|
||||
rstr.scrollOffset = i
|
||||
}
|
||||
} else {
|
||||
if index := rstr.index(rstr.selected); index > 0 {
|
||||
rstr.Lock()
|
||||
defer rstr.Unlock()
|
||||
rstr.selected = rstr.rooms[index-1]
|
||||
|
|
Loading…
Add table
Reference in a new issue