Add a typing dots (...) animation to chat tab
This commit is contained in:
parent
57e9ded00c
commit
558e918fd6
3 changed files with 78 additions and 6 deletions
16
js/main.js
16
js/main.js
|
@ -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');
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue