Fix overly sticky auto-scroll behavior (#4382) The problem: Auto-scroll is overly sticky. While a generated message is streaming in, it is almost impossible to cancel the auto-scroll behavior by scrolling up, it just snaps back down. The reason is that the 'wheel' and 'touchmove' events trigger before the scroll position is updated. So the scrollIsAtBottom value never becomes false. That is, unless the user manages to scroll up quick enough to beat the call to scrollChatToBottom() in onProgressStreaming(). The 'scroll' event is better because it fires slightly later in the scroll behavior. This makes canceling auto-scroll by scrolling up much more reliable. Making auto-scroll cancelling more reliable has the side effect that resuming auto-scroll becomes harder. To even this out, this change slightly increases the tolerance for resuming auto-scroll to 5 pixels. This is small enough to be generally unnoticeable but significantly easier to hit than the previous 1 pixel. I tested this change in * Firefox on Linux * Chrome on Linux * Firefox on Android * Chrome on Android In all cases, the auto-scroll behavior is greatly improved: * While auto-scrolling, scrolling a little bit up immediately cancels the auto-scroll behavior. * Scrolling all the way down resumes the auto-scroll behavior.

667116f4ffd9b731682611a68fc22feb7731bb12

Christoph <github@yozora.eu>

Signed
1 files changed, +2 -3Ignore whitespace
public/script.js+2 -3
@@ -9549,7 +9549,7 @@ jQuery(async function () {
95499549 return;
95509550 }
95519551
95529552 const scrollIsAtBottom = Math.abs(chatElementScroll.scrollHeight - chatElementScroll.clientHeight - chatElementScroll.scrollTop) < 15;
95539553
95549554 // Resume autoscroll if the user scrolls to the bottom
95559555 if (scrollLock && scrollIsAtBottom) {
@@ -9561,8 +9561,7 @@ jQuery(async function () {
95619561 scrollLock = true;
95629562 }
95639563 };
95649564 chatElementScroll.addEventListener('wheelscroll', chatScrollHandler, { passive: true });
9565- chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true });
95669565
95679566 $(document).on('click', '.mes', function () {
95689567 //when a 'delete message' parent div is clicked