From ab9c2004e0c69dd64ce391f0ac10cd484ed476b8 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 21 Mar 2024 08:45:29 -0600 Subject: [PATCH] Don't show minimap when minimap bounds exceed timeline area --- web/src/views/events/EventView.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/src/views/events/EventView.tsx b/web/src/views/events/EventView.tsx index ed2216722..67a833102 100644 --- a/web/src/views/events/EventView.tsx +++ b/web/src/views/events/EventView.tsx @@ -384,11 +384,8 @@ function DetectionReview({ [timeRange], ); - const { alignStartDateToTimeline } = useTimelineUtils( - segmentDuration, - timelineDuration, - reviewTimelineRef, - ); + const { alignStartDateToTimeline, getVisibleTimelineDuration } = + useTimelineUtils(segmentDuration, timelineDuration, reviewTimelineRef); const scrollLock = useScrollLockout(contentRef); @@ -457,10 +454,21 @@ function DetectionReview({ return false; } - return contentRef.current.scrollHeight > contentRef.current.clientHeight; + // don't show minimap if the view is not scrollable + if (contentRef.current.scrollHeight < contentRef.current.clientHeight) { + return false; + } + + const visibleTime = getVisibleTimelineDuration(); + const minimapTime = minimapBounds.end - minimapBounds.start; + if (visibleTime && minimapTime >= visibleTime * 0.75) { + return false; + } + + return true; // we know that these deps are correct // eslint-disable-next-line react-hooks/exhaustive-deps - }, [contentRef.current?.scrollHeight, severity]); + }, [contentRef.current?.scrollHeight, minimapBounds]); return ( <>