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