Add a typing dots (...) animation to chat tab

This commit is contained in:
oobabooga 2023-08-28 13:50:36 -07:00
parent 57e9ded00c
commit 558e918fd6
3 changed files with 78 additions and 6 deletions

View file

@ -58,6 +58,14 @@ document.addEventListener("keydown", function(event) {
});
//------------------------------------------------
// Position the chat typing dots
//------------------------------------------------
typing = document.getElementById('typing-container');
typingParent = typing.parentNode;
typingSibling = typing.previousElementSibling;
typingSibling.insertBefore(typing, typingSibling.childNodes[2]);
//------------------------------------------------
// Chat scrolling
//------------------------------------------------
@ -81,6 +89,14 @@ const observer = new MutationObserver(function(mutations) {
if(!isScrolled) {
targetElement.scrollTop = targetElement.scrollHeight;
}
const firstChild = targetElement.children[0];
if (firstChild.classList.contains('generating')) {
typing.parentNode.classList.add('visible-dots');
} else {
typing.parentNode.classList.remove('visible-dots');
}
});
});