Update app.py
Browse files
app.py
CHANGED
@@ -31,24 +31,34 @@ about_page = st.Page(
|
|
31 |
icon=":material/info:",
|
32 |
default=False)
|
33 |
|
|
|
|
|
|
|
34 |
|
35 |
# Create scrollable content
|
36 |
for i in range(100):
|
37 |
st.write(f"This is scrollable content line {i}")
|
38 |
|
39 |
-
#
|
40 |
-
st.
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
|
54 |
# --- NAVIGATION SETUP ---
|
|
|
31 |
icon=":material/info:",
|
32 |
default=False)
|
33 |
|
34 |
+
# --- Automatic Scrolling Approach ---
|
35 |
+
# Add a checkbox to control auto-scrolling
|
36 |
+
auto_scroll = st.sidebar.checkbox("Auto-scroll to bottom", value=True)
|
37 |
|
38 |
# Create scrollable content
|
39 |
for i in range(100):
|
40 |
st.write(f"This is scrollable content line {i}")
|
41 |
|
42 |
+
# Add a manual scroll button at both top and bottom for convenience
|
43 |
+
if st.button("Scroll to Bottom") or auto_scroll:
|
44 |
+
# Create a link target
|
45 |
+
st.markdown('''
|
46 |
+
<a name="bottom"></a>
|
47 |
+
''', unsafe_allow_html=True)
|
48 |
+
|
49 |
+
# Use Streamlit's HTML component to execute the scroll
|
50 |
+
st.components.v1.html('''
|
51 |
+
<script>
|
52 |
+
// Use the iframe parent to scroll the main content area
|
53 |
+
window.parent.document.querySelector('section.main').scrollTo({
|
54 |
+
top: window.parent.document.querySelector('section.main').scrollHeight,
|
55 |
+
behavior: 'smooth'
|
56 |
+
});
|
57 |
+
</script>
|
58 |
+
''', height=0)
|
59 |
+
|
60 |
+
# Add some text at the bottom as a visual indicator
|
61 |
+
st.write("You've reached the bottom!")
|
62 |
|
63 |
|
64 |
# --- NAVIGATION SETUP ---
|