Fix autoplay

This commit is contained in:
Nicolas Mowen 2024-02-27 12:55:48 -07:00
parent d93acbc078
commit 535c0ac746

View File

@ -129,10 +129,6 @@ export default function EventView({
const [minimap, setMinimap] = useState<string[]>([]); const [minimap, setMinimap] = useState<string[]>([]);
const minimapObserver = useRef<IntersectionObserver | null>(); const minimapObserver = useRef<IntersectionObserver | null>();
useEffect(() => { useEffect(() => {
if (!contentRef.current) {
return;
}
const visibleTimestamps = new Set<string>(); const visibleTimestamps = new Set<string>();
minimapObserver.current = new IntersectionObserver( minimapObserver.current = new IntersectionObserver(
(entries) => { (entries) => {
@ -152,7 +148,7 @@ export default function EventView({
setMinimap([...visibleTimestamps]); setMinimap([...visibleTimestamps]);
}); });
}, },
{ root: contentRef.current, threshold: 0.1 } { root: contentRef.current, threshold: isDesktop ? 0.1 : 0.5 }
); );
return () => { return () => {
@ -171,12 +167,12 @@ export default function EventView({
// no op // no op
} }
}, },
[minimapObserver.current] [minimapObserver]
); );
const minimapBounds = useMemo(() => { const minimapBounds = useMemo(() => {
const data = { const data = {
start: Math.floor(Date.now() / 1000) - 35 * 60, start: 0,
end: Math.floor(Date.now() / 1000) - 21 * 60, end: 0,
}; };
const list = minimap.sort(); const list = minimap.sort();