mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Improve auto-scroll snapping
This commit is contained in:
@@ -9253,12 +9253,21 @@ jQuery(async function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const chatElementScroll = document.getElementById('chat');
|
const chatElementScroll = document.getElementById('chat');
|
||||||
chatElementScroll.addEventListener('wheel', function () {
|
const chatScrollHandler = function () {
|
||||||
|
const scrollIsAtBottom = Math.abs(chatElementScroll.scrollHeight - chatElementScroll.clientHeight - chatElementScroll.scrollTop) < 1;
|
||||||
|
|
||||||
|
// Cancel autoscroll if the user scrolls up
|
||||||
|
if (scrollLock && scrollIsAtBottom) {
|
||||||
|
scrollLock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resume autoscroll if the user scrolls to the bottom
|
||||||
|
if (!scrollLock && !scrollIsAtBottom) {
|
||||||
scrollLock = true;
|
scrollLock = true;
|
||||||
}, { passive: true });
|
}
|
||||||
chatElementScroll.addEventListener('touchstart', function () {
|
};
|
||||||
scrollLock = true;
|
chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true });
|
||||||
}, { passive: true });
|
chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true });
|
||||||
chatElementScroll.addEventListener('scroll', function () {
|
chatElementScroll.addEventListener('scroll', function () {
|
||||||
if (is_use_scroll_holder) {
|
if (is_use_scroll_holder) {
|
||||||
this.scrollTop = scroll_holder;
|
this.scrollTop = scroll_holder;
|
||||||
|
Reference in New Issue
Block a user