Skip to content

Commit b83c3e3

Browse files
committed
fix smooth scrolling going to negative chat messages sometimes
1 parent f51848d commit b83c3e3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/main/kotlin/org/polyfrost/chatting/chat/ChatScrolling.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ object ChatScrolling {
5454

5555
fun shift(delta: Int) {
5656
if (!ChattingConfig.smoothScrolling || !initialized) return
57-
from += delta
58-
to += delta
59-
current += delta
57+
from = (from + delta).coerceAtLeast(0f)
58+
to = (to + delta).coerceAtLeast(0f)
59+
current = (current + delta).coerceAtLeast(0f)
6060
frozen = current.roundToInt()
6161
}
6262

63-
fun pos(): Int = frozen
63+
fun pos(): Int = frozen.coerceAtLeast(0)
6464
}

0 commit comments

Comments
 (0)