diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-10-16 22:55:28 +1100 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-10-16 22:55:28 +1100 |
| commit | 5c9771e612105ed85e3318f578b84cfb07b656e8 (patch) | |
| tree | 5e3f4f8fe47666fc165153278de8907e2817b9e7 /src/lib.ts | |
| parent | 8b77a42f313e6514a4634dcad988dd2fea6bdee6 (diff) | |
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.
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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, }; |
