From 663f888a8948cd4081ed5bc5b00c1c51e3db83a5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 28 Jan 2021 13:38:41 -0500 Subject: parameterized StackedTimeline with tag names for starting/ending an anchor --- .../views/collections/CollectionStackedTimeline.tsx | 16 +++++++++------- src/client/views/nodes/AudioBox.tsx | 10 +++++----- src/client/views/nodes/VideoBox.tsx | 9 ++++----- 3 files changed, 18 insertions(+), 17 deletions(-) (limited to 'src') 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 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, 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; -const AudioDocument = makeInterface(documentSchema, audioSchema); +type AudioDocument = makeInterface<[typeof documentSchema]>; +const AudioDocument = makeInterface(documentSchema); @observer export class AudioBox extends ViewBoxAnnotatableComponent(AudioDocument) { @@ -352,6 +350,8 @@ export class AudioBox extends ViewBoxAnnotatableComponent; -const VideoDocument = makeInterface(documentSchema, timeSchema); +type VideoDocument = makeInterface<[typeof documentSchema]>; +const VideoDocument = makeInterface(documentSchema); @observer export class VideoBox extends ViewBoxAnnotatableComponent(VideoDocument) { @@ -499,6 +496,8 @@ export class VideoBox extends ViewBoxAnnotatableComponent