Improved chat scrolling (#3601)
This commit is contained in:
parent
300219b081
commit
46408465ce
2 changed files with 29 additions and 2 deletions
23
js/main.js
23
js/main.js
|
@ -48,3 +48,26 @@ document.addEventListener("keydown", function(event) {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Chat scrolling
|
||||
const targetElement = document.getElementById('chat').parentNode.parentNode.parentNode;
|
||||
|
||||
// Create a MutationObserver instance
|
||||
const observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
let childElement = targetElement.childNodes[2].childNodes[0].childNodes[1];
|
||||
childElement.scrollTop = childElement.scrollHeight;
|
||||
});
|
||||
});
|
||||
|
||||
// Configure the observer to watch for changes in the subtree and attributes
|
||||
const config = {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
attributeOldValue: true,
|
||||
characterDataOldValue: true
|
||||
};
|
||||
|
||||
// Start observing the target element
|
||||
observer.observe(targetElement, config);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue