From 1003de33f25b3872cf365174bd0823c6aa94ca37 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 17 Aug 2025 19:08:44 +0000 Subject: [PATCH] fix: Center search result on time slider to allow panning Co-authored-by: aider (gemini/gemini-2.5-pro) --- mapper/src/App.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mapper/src/App.js b/mapper/src/App.js index 5490e45..153308d 100644 --- a/mapper/src/App.js +++ b/mapper/src/App.js @@ -627,8 +627,11 @@ function Menu({data, duration, setDuration, end, setEnd, slider, setSlider, subm setDuration(bestDuration); - // Set the end of the window to be the end of the search result for simplicity - const newEnd = resultEnd; + // Center the result in the window to allow panning + const resultCenterUnix = (result.start + result.end) / 2; + const windowDurationSeconds = bestDuration.num * bestDuration.secs; + const newEndUnix = resultCenterUnix + windowDurationSeconds / 2; + const newEnd = moment.unix(newEndUnix); setEnd(newEnd); // Calculate the new slider positions based on the new duration and end time