mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-12-23 19:11:14 +01:00
Add ability to use carousel buttons to scroll through object lifecycle elements (#14662)
This commit is contained in:
parent
4e25bebdd0
commit
e67b7a6d5e
@ -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({
|
||||
</CarouselItem>
|
||||
))}
|
||||
</CarouselContent>
|
||||
<CarouselPrevious />
|
||||
<CarouselNext />
|
||||
<CarouselPrevious
|
||||
disabled={current === 0}
|
||||
onClick={() => handleThumbnailNavigation("previous")}
|
||||
/>
|
||||
<CarouselNext
|
||||
disabled={current === eventSequence.length - 1}
|
||||
onClick={() => handleThumbnailNavigation("next")}
|
||||
/>
|
||||
</Carousel>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user