From 12e894b41c09f8339fd2457444a4cb9f4ce16418 Mon Sep 17 00:00:00 2001 From: He4eT Date: Sun, 4 Jun 2023 01:55:31 +0300 Subject: [PATCH] TextBuffer: input text scroll margin --- src/components/Player/OutputBox/TextBuffer.jsx | 12 ++++++------ src/components/Player/player.css | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/Player/OutputBox/TextBuffer.jsx b/src/components/Player/OutputBox/TextBuffer.jsx index eaa149a..4a10266 100644 --- a/src/components/Player/OutputBox/TextBuffer.jsx +++ b/src/components/Player/OutputBox/TextBuffer.jsx @@ -67,12 +67,12 @@ export default function TextBuffer ({ inbox, currentWindow }) { const lastInput = inputs[inputs.length - 1] - textBufferEl.current.scrollTo({ - top: lastInput - ? lastInput.offsetTop - : textBufferEl.current.scrollHeight, - behavior: 'smooth', - }) + lastInput + ? lastInput.scrollIntoView() + : textBufferEl.current.scrollTo({ + top: textBufferEl.current.scrollHeight, + behavior: 'smooth', + }) }, 0) }, [currentWindow, inbox]) diff --git a/src/components/Player/player.css b/src/components/Player/player.css index 7d0f047..c1d5bd3 100644 --- a/src/components/Player/player.css +++ b/src/components/Player/player.css @@ -103,6 +103,7 @@ } .ifplayer .output .textBuffer .message.input { + scroll-margin-top: var(--inner-padding); color: var(--input-color); }