From 94059af89c35c65daf38493736108072e42b69ae Mon Sep 17 00:00:00 2001 From: He4eT Date: Sun, 28 Feb 2021 21:34:45 +0500 Subject: [PATCH] Add smart scrolling --- src/components/player/TextBuffer.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/player/TextBuffer.jsx b/src/components/player/TextBuffer.jsx index 46541c2..b79ab67 100644 --- a/src/components/player/TextBuffer.jsx +++ b/src/components/player/TextBuffer.jsx @@ -54,8 +54,15 @@ export default function ({ inbox, currentWindow }) { : messages.concat(incoming)) setTimeout(() => { + const inputs = + textBufferEl.current.querySelectorAll('.message.input') + const lastInput = + inputs[inputs.length- 1] + textBufferEl.current.scrollTop = - textBufferEl.current.scrollHeight * 2 + lastInput + ? lastInput.offsetTop + : textBufferEl.current.scrollHeight * 2 }, 0) }, [inbox])