up
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user