From 393d15a64f818c0c8aba76090ed0f9ab4c5b43a4 Mon Sep 17 00:00:00 2001 From: He4eT Date: Wed, 24 May 2023 01:21:30 +0300 Subject: [PATCH] TextBuffer: smooth scrolling --- src/components/Player/TextBuffer.jsx | 8 +++++--- src/components/Player/player.css | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Player/TextBuffer.jsx b/src/components/Player/TextBuffer.jsx index 9de6074..eaa149a 100644 --- a/src/components/Player/TextBuffer.jsx +++ b/src/components/Player/TextBuffer.jsx @@ -67,10 +67,12 @@ export default function TextBuffer ({ inbox, currentWindow }) { const lastInput = inputs[inputs.length - 1] - textBufferEl.current.scrollTop = - lastInput + textBufferEl.current.scrollTo({ + top: lastInput ? lastInput.offsetTop - : textBufferEl.current.scrollHeight * 2 + : textBufferEl.current.scrollHeight, + behavior: 'smooth', + }) }, 0) }, [currentWindow, inbox]) diff --git a/src/components/Player/player.css b/src/components/Player/player.css index 9c3671a..dff5873 100644 --- a/src/components/Player/player.css +++ b/src/components/Player/player.css @@ -78,6 +78,7 @@ .ifplayer .output .textBuffer { flex: 2 1; outline: none; + scroll-behavior: smooth; } .ifplayer .output .textBuffer > br:first-child,