aboutsummaryrefslogtreecommitdiff
path: root/src/lib.ts
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-10-16 22:55:28 +1100
committerTerry Truong <terry06890@gmail.com>2022-10-16 22:55:28 +1100
commit5c9771e612105ed85e3318f578b84cfb07b656e8 (patch)
tree5e3f4f8fe47666fc165153278de8907e2817b9e7 /src/lib.ts
parent8b77a42f313e6514a4634dcad988dd2fea6bdee6 (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.ts14
1 files changed, 12 insertions, 2 deletions
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,
};