diff --git a/web/src/components/overlay/detail/ObjectLifecycle.tsx b/web/src/components/overlay/detail/ObjectLifecycle.tsx index bb80b5c7f..fee15af4a 100644 --- a/web/src/components/overlay/detail/ObjectLifecycle.tsx +++ b/web/src/components/overlay/detail/ObjectLifecycle.tsx @@ -203,6 +203,20 @@ export default function ObjectLifecycle({ setCurrent(index); }; + const handleThumbnailNavigation = useCallback( + (direction: "next" | "previous") => { + if (!mainApi || !thumbnailApi || !eventSequence) return; + const newIndex = + direction === "next" + ? Math.min(current + 1, eventSequence.length - 1) + : Math.max(current - 1, 0); + mainApi.scrollTo(newIndex); + thumbnailApi.scrollTo(newIndex); + setCurrent(newIndex); + }, + [mainApi, thumbnailApi, current, eventSequence], + ); + useEffect(() => { if (eventSequence && eventSequence.length > 0) { setTimeIndex(eventSequence?.[current].timestamp); @@ -545,8 +559,14 @@ export default function ObjectLifecycle({ ))} - - + handleThumbnailNavigation("previous")} + /> + handleThumbnailNavigation("next")} + />