fix: Center search result on time slider to allow panning

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-08-17 19:08:44 +00:00
parent aa40a3b1c1
commit 1003de33f2

View File

@@ -627,8 +627,11 @@ function Menu({data, duration, setDuration, end, setEnd, slider, setSlider, subm
setDuration(bestDuration); setDuration(bestDuration);
// Set the end of the window to be the end of the search result for simplicity // Center the result in the window to allow panning
const newEnd = resultEnd; 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); setEnd(newEnd);
// Calculate the new slider positions based on the new duration and end time // Calculate the new slider positions based on the new duration and end time