client: chat scrollback: clamp to edges rather than wrapping
This commit is contained in:
parent
afd190b7cc
commit
c619be5917
@ -698,9 +698,16 @@ var scrollback_move = function(delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chat_scrollback_index === -1) {
|
if (chat_scrollback_index === -1) {
|
||||||
chat_scrollback_index = (delta === 1) ? 0 : chat_scrollback.length - 1;
|
chat_scrollback_index = chat_scrollback.length - 1; // always starts at most recent message
|
||||||
} else {
|
} else {
|
||||||
chat_scrollback_index = negmod(chat_scrollback_index + delta, chat_scrollback.length);
|
chat_scrollback_index += delta;
|
||||||
|
|
||||||
|
// clamp
|
||||||
|
if (chat_scrollback_index === -1) {
|
||||||
|
chat_scrollback_index = 0;
|
||||||
|
} else if (chat_scrollback_index === chat_scrollback.length) {
|
||||||
|
chat_scrollback_index = chat_scrollback.length - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#chatbox").value = chat_scrollback[chat_scrollback_index];
|
$("#chatbox").value = chat_scrollback[chat_scrollback_index];
|
||||||
|
Loading…
Reference in New Issue
Block a user