mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
improve initial scroll to active item in detail stream
This commit is contained in:
parent
865ca80608
commit
774e567317
@ -100,7 +100,25 @@ export default function DetailStream({
|
|||||||
}
|
}
|
||||||
}, [reviewItems, activeReviewId, effectiveTime]);
|
}, [reviewItems, activeReviewId, effectiveTime]);
|
||||||
|
|
||||||
// Auto-scroll to current time
|
// Initial scroll to active review (runs immediately when user selects, not during playback)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!scrollRef.current || !activeReviewId || userInteracting || isPlaying)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const element = scrollRef.current.querySelector(
|
||||||
|
`[data-review-id="${activeReviewId}"]`,
|
||||||
|
) as HTMLElement;
|
||||||
|
|
||||||
|
if (element) {
|
||||||
|
setProgrammaticScroll();
|
||||||
|
scrollIntoView(element, {
|
||||||
|
scrollMode: "if-needed",
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [activeReviewId, setProgrammaticScroll, userInteracting, isPlaying]);
|
||||||
|
|
||||||
|
// Auto-scroll to current time during playback
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!scrollRef.current || userInteracting || !isPlaying) return;
|
if (!scrollRef.current || userInteracting || !isPlaying) return;
|
||||||
// Prefer the review whose range contains the effectiveTime. If none
|
// Prefer the review whose range contains the effectiveTime. If none
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user