mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
Focus timeline zoom on narrative
This commit is contained in:
committed by
Lachlan Kermode
parent
ebceb6a36f
commit
8d36671a48
@@ -36,11 +36,29 @@ function updateSelected(appState, action) {
|
||||
}
|
||||
|
||||
function updateNarrative(appState, action) {
|
||||
let minTime = appState.filters.timerange[0];
|
||||
let maxTime = appState.filters.timerange[1];
|
||||
|
||||
if (!!action.narrative) {
|
||||
minTime = parseDate('2100-01-01T00:00:00');
|
||||
maxTime = parseDate('1900-01-01T00:00:00');
|
||||
|
||||
action.narrative.steps.forEach(step => {
|
||||
const stepTime = parseDate(step.timestamp);
|
||||
if (stepTime < minTime) minTime = stepTime;
|
||||
if (stepTime > maxTime) maxTime = stepTime;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
...appState,
|
||||
narrative: action.narrative,
|
||||
narrativeState: {
|
||||
current: !!action.narrative ? 0 : null
|
||||
},
|
||||
filters: {
|
||||
...appState.filters,
|
||||
timerange: [minTime, maxTime]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user