georad commited on
Commit
b60388c
·
verified ·
1 Parent(s): 9a10dbf

Update pages/home.py

Browse files
Files changed (1) hide show
  1. pages/home.py +23 -10
pages/home.py CHANGED
@@ -48,18 +48,31 @@ st.header("Tags the below 41 medical entities")
48
  'VOLUME'
49
  'WEIGHT'
50
 
 
 
 
51
 
52
  # Create scrollable content
53
  for i in range(100):
54
  st.write(f"This is scrollable content line {i}")
55
 
56
- # Add JavaScript to automatically scroll to the bottom
57
- st.markdown("""
58
- <script>
59
- // Set a timeout to ensure the page has loaded
60
- setTimeout(function() {
61
- // Get the window object and scroll to the bottom
62
- window.scrollTo(0, document.body.scrollHeight);
63
- }, 500);
64
- </script>
65
- """, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
48
  'VOLUME'
49
  'WEIGHT'
50
 
51
+ # --- Automatic Scrolling Approach ---
52
+ # Add a checkbox to control auto-scrolling
53
+ auto_scroll = st.sidebar.checkbox("Auto-scroll to bottom", value=True)
54
 
55
  # Create scrollable content
56
  for i in range(100):
57
  st.write(f"This is scrollable content line {i}")
58
 
59
+ # Add a manual scroll button at both top and bottom for convenience
60
+ if st.button("Scroll to Bottom") or auto_scroll:
61
+ # Create a link target
62
+ st.markdown('''
63
+ <a name="bottom"></a>
64
+ ''', unsafe_allow_html=True)
65
+
66
+ # Use Streamlit's HTML component to execute the scroll
67
+ st.components.v1.html('''
68
+ <script>
69
+ // Use the iframe parent to scroll the main content area
70
+ window.parent.document.querySelector('section.main').scrollTo({
71
+ top: window.parent.document.querySelector('section.main').scrollHeight,
72
+ behavior: 'smooth'
73
+ });
74
+ </script>
75
+ ''', height=0)
76
+
77
+ # Add some text at the bottom as a visual indicator
78
+ st.write("You've reached the bottom!")