tori29umai commited on
Commit
08e50da
·
verified ·
1 Parent(s): d4bcb04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -202,7 +202,7 @@ def clear_chat():
202
  # カスタムCSS
203
  custom_css = """
204
  #chatbot {
205
- height: 50vh !important;
206
  overflow-y: auto;
207
  }
208
  """
@@ -213,12 +213,29 @@ custom_js = """
213
  function adjustChatbotHeight() {
214
  var chatbot = document.querySelector('#chatbot');
215
  if (chatbot) {
216
- chatbot.style.height = '50vh';
 
 
217
  }
218
  }
219
  // ページ読み込み時と画面サイズ変更時にチャットボットの高さを調整
220
  window.addEventListener('load', adjustChatbotHeight);
221
  window.addEventListener('resize', adjustChatbotHeight);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  </script>
223
  """
224
 
 
202
  # カスタムCSS
203
  custom_css = """
204
  #chatbot {
205
+ min-height: 300px;
206
  overflow-y: auto;
207
  }
208
  """
 
213
  function adjustChatbotHeight() {
214
  var chatbot = document.querySelector('#chatbot');
215
  if (chatbot) {
216
+ var windowHeight = window.innerHeight;
217
+ var newHeight = Math.max(300, windowHeight * 0.5);
218
+ chatbot.style.height = newHeight + 'px';
219
  }
220
  }
221
  // ページ読み込み時と画面サイズ変更時にチャットボットの高さを調整
222
  window.addEventListener('load', adjustChatbotHeight);
223
  window.addEventListener('resize', adjustChatbotHeight);
224
+
225
+ // Mutation Observerを使用してDOMの変更を監視し、チャットボットが表示されたときに高さを調整
226
+ var observer = new MutationObserver(function(mutations) {
227
+ mutations.forEach(function(mutation) {
228
+ if (mutation.type === 'childList') {
229
+ var chatbot = document.querySelector('#chatbot');
230
+ if (chatbot) {
231
+ adjustChatbotHeight();
232
+ observer.disconnect();
233
+ }
234
+ }
235
+ });
236
+ });
237
+
238
+ observer.observe(document.body, { childList: true, subtree: true });
239
  </script>
240
  """
241