* various tweaks

* update debounce time

* scroll to top with new events
This commit is contained in:
Josh Hawkins
2024-02-23 07:52:54 -06:00
committed by GitHub
parent fc94fcb2ac
commit 7d18c2c03d
5 changed files with 91 additions and 64 deletions

View File

@@ -187,14 +187,7 @@ export function EventReviewTimeline({
setCurrentTimeSegment(alignedHandlebarTime);
}
}, [
handlebarTime,
segmentDuration,
showHandlebar,
timelineDuration,
timelineStart,
alignDateToTimeline,
]);
}, []);
useEffect(() => {
generateSegments();

View File

@@ -186,14 +186,20 @@ export function EventSegment({
const firstMinimapSegmentRef = useRef<HTMLDivElement>(null);
let debounceTimer: ReturnType<typeof setTimeout>;
function debounceScrollIntoView(element: HTMLElement) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
element.scrollIntoView({ behavior: "smooth", block: "center" });
}, 100);
}
useEffect(() => {
// Check if the first segment is out of view
const firstSegment = firstMinimapSegmentRef.current;
if (firstSegment && showMinimap && isFirstSegmentInMinimap) {
firstSegment.scrollIntoView({
behavior: "smooth",
block: "center",
});
debounceScrollIntoView(firstSegment);
}
}, [showMinimap, isFirstSegmentInMinimap, events, segmentDuration]);