From 5c9771e612105ed85e3318f578b84cfb07b656e8 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sun, 16 Oct 2022 22:55:28 +1100 Subject: Add basic display of placeholder events Make App hold an event map, passing it to TimeLine children, which use it to display events. A TimeLine emits an 'events-req' if more events in their range could be displayed, which may cause App to add placeholder events to the map. --- src/lib.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/lib.ts') diff --git a/src/lib.ts b/src/lib.ts index 54dffc5..ad3686d 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -266,6 +266,15 @@ export function getScaleRatio(scale: number, scale2: number){ } return scale2 / scale; } +export function getUnitDiff(date: HistDate, date2: HistDate, scale: number): number { + if (scale == DAY_SCALE){ + return date.getDayDiff(date2); + } else if (scale == MONTH_SCALE){ + return date.getMonthDiff(date2); + } else { + return date.getYearDiff(date2) / scale; + } +} // For sending timeline-bound data to BaseLine export class TimelineState { @@ -284,12 +293,13 @@ export class TimelineState { this.endOffset = endOffset; this.scaleIdx = scaleIdx; } -}; +} export type HistEvent = { + id: number, title: string, start: HistDate, startUpper: HistDate | null, - end: HistDate, + end: HistDate | null, endUpper: HistDate | null, }; -- cgit v1.2.3