RomZay commited on
Commit
3d49e62
·
verified ·
1 Parent(s): c162705

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -128,11 +128,24 @@ def render_message(history):
128
  return messages_html
129
 
130
  js = """
131
- function scrollToBottom() {
132
- const chatboxContainer = document.getElementById('chatbox-container');
133
- chatboxContainer.scrollTop = chatboxContainer.scrollHeight; // Scroll to the bottom
134
- }
 
 
 
 
 
 
 
 
135
 
 
 
 
 
 
136
  """
137
 
138
 
 
128
  return messages_html
129
 
130
  js = """
131
+ function Scrolldown() {
132
+
133
+ const messagesContainer = document.getElementById('messages');
134
+
135
+ const observer = new MutationObserver((mutationsList, observer) => {
136
+ for (const mutation of mutationsList) {
137
+ if (mutation.type === 'childList') {
138
+ const chatboxContainer = document.getElementById('chatbox-container');
139
+ chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
140
+ }
141
+ }
142
+ });
143
 
144
+ const config = { childList: true };
145
+
146
+ observer.observe(messagesContainer, config);
147
+ console.log('Observing')
148
+ }
149
  """
150
 
151