This commit is contained in:
2026-06-09 23:00:09 +02:00
parent 6542504a4b
commit 42b5c6247d
8 changed files with 217 additions and 88 deletions
+14
View File
@@ -299,6 +299,20 @@ export function BandMap({ band, spots, spotStatus, currentFreqHz, onSpotClick, o
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [band, containerH, currentFreqHz, range, lo, hi]);
// Re-centre on the rig frequency whenever the zoom level changes — zooming
// would otherwise drift away from where you're operating. Skips the initial
// mount (the band-centre effect above handles that).
const firstZoomRef = useRef(true);
useEffect(() => {
if (firstZoomRef.current) { firstZoomRef.current = false; return; }
const el = scrollerRef.current;
if (!el || !range || containerH <= 0) return;
const kHz = currentFreqHz && currentFreqHz / 1000 >= lo && currentFreqHz / 1000 <= hi
? currentFreqHz / 1000 : (lo + hi) / 2;
el.scrollTop = Math.max(0, freqToY(kHz) - containerH / 2);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [zoomIdx]);
useEffect(() => {
const el = scrollerRef.current;
if (!el) return;