aboutsummaryrefslogtreecommitdiff
path: root/src/components/TimeLine.vue
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2023-01-24 21:03:32 +1100
committerTerry Truong <terry06890@gmail.com>2023-01-24 21:03:32 +1100
commit547237277d3c9f2d7932a3d8d5cc284590132d19 (patch)
tree3221eb73ea375636e26adf68bf1e2037ce91c6f0 /src/components/TimeLine.vue
parent0f74c8bad0b176f808cdf53911f70d5d791823fe (diff)
For search, jump to 'appropriate' scale
Diffstat (limited to 'src/components/TimeLine.vue')
-rw-r--r--src/components/TimeLine.vue11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/components/TimeLine.vue b/src/components/TimeLine.vue
index 373439a..18ae107 100644
--- a/src/components/TimeLine.vue
+++ b/src/components/TimeLine.vue
@@ -88,7 +88,8 @@ import {moduloPositive, animateWithClass, getTextWidth} from '../util';
import {
getDaysInMonth, MIN_CAL_DATE, MONTH_NAMES, HistDate, HistEvent, getImagePath, dateToYearStr, dateToTickStr,
MIN_DATE, MAX_DATE, MONTH_SCALE, DAY_SCALE, SCALES,
- stepDate, getScaleRatio, getNumSubUnits, getUnitDiff, getEventPrecision, dateToUnit, dateToScaleDate,
+ stepDate, getScaleRatio, getNumSubUnits, getUnitDiff, getEventPrecision, getScaleForJump,
+ dateToUnit, dateToScaleDate,
TimelineState,
} from '../lib';
import {useStore} from '../store';
@@ -1332,12 +1333,8 @@ watch(() => props.searchTarget, () => {
if (!idToPos.value.has(event.id)){ // If not already visible
// Determine new time range
- let tempScale = scale.value;
- let targetDate = event.start;
- if (targetDate.isEarlier(MIN_CAL_DATE) && tempScale < 1){ // Account for jumping out of calendar limits
- tempScale = getEventPrecision(event);
- }
- targetDate = dateToScaleDate(targetDate, tempScale);
+ let tempScale = getScaleForJump(event);
+ let targetDate = dateToScaleDate(event.start, tempScale);
const startEndDiff = getUnitDiff(startDate.value, endDate.value, scale.value);
let targetStart = stepDate(targetDate, tempScale, {forward: false, count: Math.floor(startEndDiff / 2)});
if (targetStart.isEarlier(MIN_DATE)){