web: better progress bar
This commit is contained in:
parent
03f1035e0e
commit
86ee1257fa
@ -332,6 +332,8 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
selected_threads,
|
selected_threads,
|
||||||
};
|
};
|
||||||
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
||||||
|
// Generate signal so progress bar is reset
|
||||||
|
orders.send_msg(Msg::WindowScrolled);
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::ShowThreadRequest { thread_id } => {
|
Msg::ShowThreadRequest { thread_id } => {
|
||||||
@ -382,6 +384,8 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
orders.send_msg(Msg::UpdateServerVersion(data.version));
|
||||||
|
// Generate signal so progress bar is reset
|
||||||
|
orders.send_msg(Msg::WindowScrolled);
|
||||||
}
|
}
|
||||||
Msg::ShowThreadResult(bad) => {
|
Msg::ShowThreadResult(bad) => {
|
||||||
error!("show_thread_query error: {bad:#?}");
|
error!("show_thread_query error: {bad:#?}");
|
||||||
@ -511,9 +515,29 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
.value_of();
|
.value_of();
|
||||||
|
|
||||||
let r = el.get_bounding_client_rect();
|
let r = el.get_bounding_client_rect();
|
||||||
let end = r.height() - ih;
|
if r.height() < ih {
|
||||||
|
// The whole content fits in the window, no scrollbar
|
||||||
|
orders.send_msg(Msg::SetProgress(0.));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let end: f64 = r.height() - ih;
|
||||||
|
if end < 0. {
|
||||||
|
orders.send_msg(Msg::SetProgress(0.));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Flip Y, normally it's 0-point when the top of the content hits the top of the
|
||||||
|
// screen and goes negative from there.
|
||||||
let y = -r.y();
|
let y = -r.y();
|
||||||
orders.send_msg(Msg::SetProgress((y / end).max(0.)));
|
let ratio: f64 = (y / end).max(0.);
|
||||||
|
debug!(
|
||||||
|
"WindowScrolled ih {ih} end {end} ratio {ratio:.02} {}x{} @ {},{}",
|
||||||
|
r.width(),
|
||||||
|
r.height(),
|
||||||
|
r.x(),
|
||||||
|
r.y()
|
||||||
|
);
|
||||||
|
|
||||||
|
orders.send_msg(Msg::SetProgress(ratio));
|
||||||
} else {
|
} else {
|
||||||
orders.send_msg(Msg::SetProgress(0.));
|
orders.send_msg(Msg::SetProgress(0.));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user