Fix: Stop globe rotation while station panel is open

Auto-rotation now stops completely when a station list or
favorites sidebar is visible. Resumes only when all panels
are closed. Interaction-based pause (drag/scroll) also
respects open panels - won't resume after 5s timeout if
a sidebar is still showing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-06 19:40:35 +01:00
parent 1b2fbe27ed
commit b4f3c7db4d

View file

@ -163,17 +163,36 @@ export default function RadioTab({ data }: { data: any }) {
}
}, [theme]);
// ── Helper: pause globe rotation for 5s ──
// ── Helper: pause globe rotation for 5s (only resumes if no panel open) ──
const selectedPlaceRef = useRef(selectedPlace);
selectedPlaceRef.current = selectedPlace;
const showFavoritesRef = useRef(showFavorites);
showFavoritesRef.current = showFavorites;
const pauseRotation = useCallback(() => {
const controls = globeRef.current?.controls() as any;
if (controls) controls.autoRotate = false;
if (rotationResumeRef.current) clearTimeout(rotationResumeRef.current);
rotationResumeRef.current = setTimeout(() => {
// Only resume if no sidebar is open
if (selectedPlaceRef.current || showFavoritesRef.current) return;
const c = globeRef.current?.controls() as any;
if (c) c.autoRotate = true;
}, 5000);
}, []);
// ── Stop/resume rotation when panels open/close ──
useEffect(() => {
const controls = globeRef.current?.controls() as any;
if (!controls) return;
if (selectedPlace || showFavorites) {
controls.autoRotate = false;
if (rotationResumeRef.current) clearTimeout(rotationResumeRef.current);
} else {
controls.autoRotate = true;
}
}, [selectedPlace, showFavorites]);
// ── Point click handler (stable ref) ──
const handlePointClickRef = useRef<(point: any) => void>(undefined);
handlePointClickRef.current = (point: any) => {