aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-01-28 13:38:41 -0500
committerbobzel <zzzman@gmail.com>2021-01-28 13:38:41 -0500
commit663f888a8948cd4081ed5bc5b00c1c51e3db83a5 (patch)
treea6df50284e2a497c8e574445322382f4512c57c4 /src/client/views/collections
parent61fcef6b466c40f5b5d9c5831f25d3df240dbdf3 (diff)
parameterized StackedTimeline with tag names for starting/ending an anchor
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionStackedTimeline.tsx16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index 21fbef1ac..801433151 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -29,6 +29,8 @@ export type CollectionStackedTimelineProps = {
playing: () => boolean;
setTime: (time: number) => void;
isChildActive: () => boolean;
+ startTag: string;
+ endTag: string;
};
@observer
@@ -85,13 +87,13 @@ export class CollectionStackedTimeline extends CollectionSubView<PanZoomDocument
}
}
- anchorStart = (anchor: Doc) => NumCast(anchor.anchorStartTime, NumCast(anchor._timecodeToShow, NumCast(anchor.videoStart, NumCast(anchor.audioStart))));
- anchorEnd = (anchor: Doc, val: any = null) => NumCast(anchor.anchorEndTime, NumCast(anchor._timecodeToHide, NumCast(anchor.videoEnd, NumCast(anchor.audioEnd, val))));
+ anchorStart = (anchor: Doc) => NumCast(anchor._timecodeToShow, NumCast(anchor[this.props.startTag]));
+ anchorEnd = (anchor: Doc, val: any = null) => NumCast(anchor._timecodeToHide, NumCast(anchor[this.props.endTag]));
getLinkData(l: Doc) {
let la1 = l.anchor1 as Doc;
let la2 = l.anchor2 as Doc;
- const linkTime = NumCast(la2.anchorStartTime, NumCast(la1.anchorStartTime));
+ const linkTime = NumCast(la2[this.props.startTag], NumCast(la1[this.props.startTag]));
if (Doc.AreProtosEqual(la1, this.dataDoc)) {
la1 = l.anchor2 as Doc;
la2 = l.anchor1 as Doc;
@@ -108,8 +110,8 @@ export class CollectionStackedTimeline extends CollectionSubView<PanZoomDocument
@action
changeAnchor = (anchor: Opt<Doc>, time: number) => {
if (anchor) {
- const timelineOnly = Cast(anchor.anchorStartTime, "number", null) !== undefined;
- if (timelineOnly) this._left ? anchor.anchorStartTime = time : anchor.anchorEndTime = time;
+ const timelineOnly = Cast(anchor[this.props.startTag], "number", null) !== undefined;
+ if (timelineOnly) this._left ? anchor[this.props.startTag] = time : anchor[this.props.endTag] = time;
else this._left ? anchor._timecodeToShow = time : anchor._timecodeToHide = time;
}
}
@@ -173,10 +175,10 @@ export class CollectionStackedTimeline extends CollectionSubView<PanZoomDocument
title: ComputedField.MakeFunction(`"#" + formatToTime(self.anchorStartTime) + "-" + formatToTime(self.anchorEndTime)`) as any,
useLinkSmallAnchor: true,
hideLinkButton: true,
- anchorStartTime,
- anchorEndTime,
annotationOn: this.props.Document
});
+ anchor[this.props.startTag] = anchorStartTime;
+ anchor[this.props.endTag] = anchorEndTime;
if (Cast(this.dataDoc[this.props.fieldKey], listSpec(Doc), null) !== undefined) {
Cast(this.dataDoc[this.props.fieldKey], listSpec(Doc), []).push(anchor);
} else {