P-MSQ-API-PREVIEW / handleAutoScrollChat.js
RomZay's picture
Create handleAutoScrollChat.js
aa6254e verified
raw
history blame
463 Bytes
function Scrolldown() {
let targetNode = document.querySelector('#chatbox-container');
if (!targetNode) {
console.error('Chat container not found');
return;
}
const config = { childList: true, subtree: true };
const callback = (mutationList, observer) => {
targetNode.scrollTop = targetNode.scrollHeight;
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}