web: add scroll to top button and squelch some debug logging

This commit is contained in:
Bill Thiede 2024-09-12 22:37:58 -07:00
parent d4fc2e2ef1
commit bd578191a8
2 changed files with 19 additions and 14 deletions

View File

@ -511,13 +511,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
.value_of();
let r = el.get_bounding_client_rect();
info!(
"window scrolled {}x{}@{},{}",
r.width(),
r.height(),
r.x(),
r.y(),
);
let end = r.height() - ih;
let y = -r.y();
orders.send_msg(Msg::SetProgress((y / end).max(0.)));

View File

@ -869,7 +869,8 @@ fn thread(
],
],
],
div![el_ref(content_el), messages] /* TODO(wathiede): plumb in orignal id
div![el_ref(content_el), messages, click_to_top()],
/* TODO(wathiede): plumb in orignal id
a![
attrs! {At::Href=>api::original(&thread_node.0.as_ref().expect("message missing").id)},
"Original"
@ -1129,7 +1130,7 @@ fn news_post(
"Original"
],
*/
ev(Ev::Scroll, |e| info!("scroll event {e:?}"))
click_to_top(),
]
}
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
@ -1222,3 +1223,14 @@ pub fn versions(versions: &crate::state::Version) -> Node<Msg> {
])
]
}
fn click_to_top() -> Node<Msg> {
button![
C!["button", "is-danger", "is-small"],
span!["Top"],
span![C!["icon"], i![C!["fas", "fa-arrow-turn-up"]]],
ev(Ev::Click, move |_| web_sys::window()
.unwrap()
.scroll_to_with_x_and_y(0., 0.))
]
}