Save chat scroll position when user input overflows the line

This commit is contained in:
Cohee
2023-09-13 00:51:21 +03:00
parent 66ec17620f
commit c0e5d7efae
3 changed files with 11 additions and 6 deletions

View File

@ -62,11 +62,11 @@ const generateDebounced = debounce(() => generateHypeBot(), 500);
* @param {string} text Text to set
*/
function setHypeBotText(text) {
const blockA = $('#chat');
var originalScrollBottom = blockA[0].scrollHeight - (blockA.scrollTop() + blockA.outerHeight());
const chatBlock = $('#chat');
const originalScrollBottom = chatBlock[0].scrollHeight - (chatBlock.scrollTop() + chatBlock.outerHeight());
hypeBotBar.html(DOMPurify.sanitize(text));
var newScrollTop = blockA[0].scrollHeight - (blockA.outerHeight() + originalScrollBottom);
blockA.scrollTop(newScrollTop);
const newScrollTop = chatBlock[0].scrollHeight - (chatBlock.outerHeight() + originalScrollBottom);
chatBlock.scrollTop(newScrollTop);
}
/**