Muhammad Abdiel Al Hafiz commited on
Commit
e68c247
·
1 Parent(s): 795d4e9

try adding js

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -64,14 +64,31 @@ example_images = [
64
  # Custom CSS for HTML height
65
  css = """
66
  .scrollable-html {
67
- height: 210px;
68
  overflow-y: auto;
69
  border: 1px solid #ccc;
70
  padding: 10px;
71
  box-sizing: border-box;
 
72
  }
73
  """
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  # Gradio Interface
76
  interface = gr.Interface(
77
  fn=predict_image,
@@ -90,4 +107,5 @@ interface = gr.Interface(
90
  css=css
91
  )
92
 
93
- interface.launch(share=True)
 
 
64
  # Custom CSS for HTML height
65
  css = """
66
  .scrollable-html {
67
+ height: 207px;
68
  overflow-y: auto;
69
  border: 1px solid #ccc;
70
  padding: 10px;
71
  box-sizing: border-box;
72
+ transition: height 0.3s ease;
73
  }
74
  """
75
 
76
+ # Custom JavaScript to dynamically adjust height
77
+ js = """
78
+ <script>
79
+ function adjustHeight() {
80
+ const outputElement = document.querySelector('.scrollable-html');
81
+ if (outputElement && outputElement.innerHTML.trim() !== '') {
82
+ outputElement.style.height = '250px';
83
+ } else {
84
+ outputElement.style.height = '207px';
85
+ }
86
+ }
87
+ document.addEventListener('DOMContentLoaded', adjustHeight);
88
+ setInterval(adjustHeight, 1000); // Check every second to adjust height
89
+ </script>
90
+ """
91
+
92
  # Gradio Interface
93
  interface = gr.Interface(
94
  fn=predict_image,
 
107
  css=css
108
  )
109
 
110
+ # Inject the custom JavaScript for dynamic height
111
+ interface.launch(share=True, inline=False, scripts=js)