-
First Check
Example Code# Works in Nicegui 2.x
def scroll_log(top: bool = True) -> None:
element_type = "first" if top else "last"
ui.run_javascript(f"""
const logElement = document.querySelector('.nicegui-log');
if (logElement && logElement.{element_type}ElementChild) {{
logElement.{element_type}ElementChild.scrollIntoView();
}}
""") DescriptionIn NiceGUI 2.x I could use ui.run_javascript to scroll a ui.log to the top or bottom by setting As a suggestion, it would be nice to have the ui.scroll_area NiceGUI Version3.0.4 Python Version3.13 BrowserFirefox Operating SystemWindows Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Update: OK, I figured it out, it was simpler than I thought - the same Javascript can be used, except this time target the q-scrollarea__content instead of .nicegui-log: def scroll_log(top: bool = True) -> None:
element_type = "first" if top else "last"
ui.run_javascript(f"""
const logElement = document.querySelector('.q-scrollarea__content');
if (logElement && logElement.{element_type}ElementChild) {{
logElement.{element_type}ElementChild.scrollIntoView();
}}
""") |
Beta Was this translation helpful? Give feedback.
Update: OK, I figured it out, it was simpler than I thought - the same Javascript can be used, except this time target the q-scrollarea__content instead of .nicegui-log: