georad commited on
Commit
698bb86
·
verified ·
1 Parent(s): 45d1ec2

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +34 -1
pages/type_text.py CHANGED
@@ -19,7 +19,41 @@ def on_click():
19
  def make_spinner(text = "In progress..."):
20
  with st.spinner(text):
21
  yield
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
 
 
 
 
23
  #@st.cache
24
  def convert_df(df:pd.DataFrame):
25
  return df.to_csv(index=False).encode('utf-8')
@@ -32,7 +66,6 @@ def convert_json(df:pd.DataFrame):
32
  #st.json(json_string, expanded=True)
33
  return json_string
34
 
35
-
36
  #df_chapters = pd.read_csv("SBS_V2_0/Chapter_Index_Rows.csv")
37
  df_chapters = pd.read_csv("SBS_V2_0/Chapter_Index_Rows_with_total.csv")
38
 
 
19
  def make_spinner(text = "In progress..."):
20
  with st.spinner(text):
21
  yield
22
+
23
+ def auto_scroll_to_bottom():
24
+ # JavaScript to scroll to bottom
25
+ js_code = """
26
+ <script>
27
+ // Wait for the page to fully render
28
+ const scrollToBottom = () => {
29
+ // Get the main Streamlit iframe
30
+ const streamlitDoc = window.parent.document;
31
+ // Get the app container
32
+ const appContainer = streamlitDoc.querySelector('.main');
33
+ if (appContainer) {
34
+ // Scroll the app container to the bottom
35
+ appContainer.scrollTop = appContainer.scrollHeight;
36
+ } else {
37
+ // Fallback to scrolling the entire page
38
+ window.parent.scrollTo(0, streamlitDoc.body.scrollHeight);
39
+ }
40
+ };
41
+
42
+ // Try immediately
43
+ scrollToBottom();
44
+
45
+ // Also try after a short delay to ensure content is rendered
46
+ setTimeout(scrollToBottom, 200);
47
+
48
+ // And after a longer delay just to be safe
49
+ setTimeout(scrollToBottom, 500);
50
+ </script>
51
+ """
52
 
53
+ # Render the JavaScript code
54
+ html = f'<div style="display:none">{js_code}</div>'
55
+ st.components.v1.html(html, height=0)
56
+
57
  #@st.cache
58
  def convert_df(df:pd.DataFrame):
59
  return df.to_csv(index=False).encode('utf-8')
 
66
  #st.json(json_string, expanded=True)
67
  return json_string
68
 
 
69
  #df_chapters = pd.read_csv("SBS_V2_0/Chapter_Index_Rows.csv")
70
  df_chapters = pd.read_csv("SBS_V2_0/Chapter_Index_Rows_with_total.csv")
71