diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 11:48:04 +0100 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2026-10-27 11:48:04 +0100 |
| commit | 9e1d138a29aafc52d2da68b66f7d6ea00081134f (patch) | |
| tree | d1a11cc2c192b2418560a61b9bb42fca035d2e4b /crates/gipfel-web/src/app.rs | |
| parent | 21487476293a77518e81c91ecdc0fbd4c4b74a25 (diff) | |
web: visible guide dots with hover peak identification
- guide dots: dark outline ring + bright core, readable on any photo
- hover over a dot shows 'NAME · height m' in the sidebar (same info
the desktop hover status line gives)
- pointermove doubles as hover report when not dragging
Diffstat (limited to 'crates/gipfel-web/src/app.rs')
| -rw-r--r-- | crates/gipfel-web/src/app.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/crates/gipfel-web/src/app.rs b/crates/gipfel-web/src/app.rs index 8512d6a..f152dcc 100644 --- a/crates/gipfel-web/src/app.rs +++ b/crates/gipfel-web/src/app.rs @@ -38,6 +38,7 @@ pub fn app() -> Html { let pan = use_mut_ref(Panorama::new); let markers = use_state(Vec::<Marker>::new); let fit_distortion = use_state(|| false); + let hover = use_state(|| Option::<String>::None); // force a redraw when the window is resized so the canvas backing // store tracks its CSS size (listener lives as long as the app) @@ -309,6 +310,23 @@ pub fn app() -> Html { } }) }, + hover: { + let pan = pan.clone(); + let view = view.clone(); + let hover = hover.clone(); + Callback::from(move |(ix, iy): (f64, f64)| { + let p = pan.borrow(); + let name = markers::nearest_hill(&p, ix, iy, 20.0 / view.scale).map(|i| { + let h = &p.hills[i]; + format!("{} · {:.0} m", h.name, h.height) + }); + hover.set(name); + }) + }, + hover_end: { + let hover = hover.clone(); + Callback::from(move |_: ()| hover.set(None)) + }, }; // overlay data for the canvas @@ -356,9 +374,12 @@ pub fn app() -> Html { if !fit_info.is_empty() { <p class="fitinfo">{ (*fit_info).clone() }</p> } + if let Some(h) = hover.as_ref() { + <p class="hover">{ h.clone() }</p> + } } <p class="hint"> - { "Click a green dot to mark that peak · drag markers to adjust · right-click a marker to remove." } + { "Hover a green dot to see the peak · click to mark it · drag to adjust · right-click to remove." } </p> <p class="hint dim"> { "The view is fitted automatically once 4+ markers are placed." } |
