Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
# At the top of file with imports
|
4 |
def add_sticky_header_css():
|
@@ -29,47 +30,39 @@ def add_sticky_header_css():
|
|
29 |
</style>
|
30 |
""", unsafe_allow_html=True)
|
31 |
|
32 |
-
def
|
33 |
-
#
|
34 |
js_code = """
|
35 |
<script>
|
36 |
-
//
|
37 |
-
|
38 |
-
//
|
39 |
-
const
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
45 |
}
|
46 |
-
}
|
47 |
|
48 |
-
//
|
49 |
-
|
50 |
-
scrollToBottom();
|
51 |
-
});
|
52 |
|
53 |
-
//
|
54 |
-
|
55 |
-
observer.observe(streamlitDoc.body, {
|
56 |
-
childList: true,
|
57 |
-
subtree: true
|
58 |
-
});
|
59 |
|
60 |
-
//
|
61 |
-
scrollToBottom
|
62 |
-
setTimeout(() => {
|
63 |
-
observer.disconnect();
|
64 |
-
// One final scroll
|
65 |
-
scrollToBottom();
|
66 |
-
}, 1000);
|
67 |
</script>
|
68 |
"""
|
69 |
|
70 |
-
#
|
71 |
-
|
72 |
-
|
73 |
|
74 |
# At the start of main function or execution flow
|
75 |
add_sticky_header_css()
|
|
|
1 |
import streamlit as st
|
2 |
+
import base64
|
3 |
|
4 |
# At the top of file with imports
|
5 |
def add_sticky_header_css():
|
|
|
30 |
</style>
|
31 |
""", unsafe_allow_html=True)
|
32 |
|
33 |
+
def auto_scroll_to_bottom():
|
34 |
+
# JavaScript to scroll to bottom
|
35 |
js_code = """
|
36 |
<script>
|
37 |
+
// Wait for the page to fully render
|
38 |
+
const scrollToBottom = () => {
|
39 |
+
// Get the main Streamlit iframe
|
40 |
+
const streamlitDoc = window.parent.document;
|
41 |
+
// Get the app container
|
42 |
+
const appContainer = streamlitDoc.querySelector('.main');
|
43 |
+
if (appContainer) {
|
44 |
+
// Scroll the app container to the bottom
|
45 |
+
appContainer.scrollTop = appContainer.scrollHeight;
|
46 |
+
} else {
|
47 |
+
// Fallback to scrolling the entire page
|
48 |
+
window.parent.scrollTo(0, streamlitDoc.body.scrollHeight);
|
49 |
}
|
50 |
+
};
|
51 |
|
52 |
+
// Try immediately
|
53 |
+
scrollToBottom();
|
|
|
|
|
54 |
|
55 |
+
// Also try after a short delay to ensure content is rendered
|
56 |
+
setTimeout(scrollToBottom, 200);
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
// And after a longer delay just to be safe
|
59 |
+
setTimeout(scrollToBottom, 500);
|
|
|
|
|
|
|
|
|
|
|
60 |
</script>
|
61 |
"""
|
62 |
|
63 |
+
# Render the JavaScript code
|
64 |
+
html = f'<div style="display:none">{js_code}</div>'
|
65 |
+
st.components.v1.html(html, height=0)
|
66 |
|
67 |
# At the start of main function or execution flow
|
68 |
add_sticky_header_css()
|