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:
parent
1b2fbe27ed
commit
b4f3c7db4d
1 changed files with 20 additions and 1 deletions
|
|
@ -163,17 +163,36 @@ export default function RadioTab({ data }: { data: any }) {
|
||||||
}
|
}
|
||||||
}, [theme]);
|
}, [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 pauseRotation = useCallback(() => {
|
||||||
const controls = globeRef.current?.controls() as any;
|
const controls = globeRef.current?.controls() as any;
|
||||||
if (controls) controls.autoRotate = false;
|
if (controls) controls.autoRotate = false;
|
||||||
if (rotationResumeRef.current) clearTimeout(rotationResumeRef.current);
|
if (rotationResumeRef.current) clearTimeout(rotationResumeRef.current);
|
||||||
rotationResumeRef.current = setTimeout(() => {
|
rotationResumeRef.current = setTimeout(() => {
|
||||||
|
// Only resume if no sidebar is open
|
||||||
|
if (selectedPlaceRef.current || showFavoritesRef.current) return;
|
||||||
const c = globeRef.current?.controls() as any;
|
const c = globeRef.current?.controls() as any;
|
||||||
if (c) c.autoRotate = true;
|
if (c) c.autoRotate = true;
|
||||||
}, 5000);
|
}, 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) ──
|
// ── Point click handler (stable ref) ──
|
||||||
const handlePointClickRef = useRef<(point: any) => void>(undefined);
|
const handlePointClickRef = useRef<(point: any) => void>(undefined);
|
||||||
handlePointClickRef.current = (point: any) => {
|
handlePointClickRef.current = (point: any) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue