diff options
-rw-r--r-- | src/client/apis/recording/recordingApi.ts | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/src/client/apis/recording/recordingApi.ts b/src/client/apis/recording/recordingApi.ts index 50d6f8038..3e9f030ab 100644 --- a/src/client/apis/recording/recordingApi.ts +++ b/src/client/apis/recording/recordingApi.ts @@ -43,6 +43,9 @@ export class RecordingApi { // used for tracking movements in the view frame this.disposeFunc = null; + + // for now, set playFFView + this.playFFView = null; } // little helper :) @@ -127,7 +130,7 @@ export class RecordingApi { private trackMovements = (panX: number, panY: number): Error | undefined => { // ensure we are recording if (!this.isRecording) { - console.error('[recordingApi.ts] pause() failed: recording is paused()') + console.error('[recordingApi.ts] pause() failed: recording is paused()') return new Error('[recordingApi.ts] pause()') } @@ -142,22 +145,6 @@ export class RecordingApi { this.currentPresentation.movements.push(movement) } - // TOOD: need to pause all intervals if possible lol - // TODO: extract this into different class with pause and resume recording - public followMovements = (presentation: Presentation, docView: CollectionFreeFormView): void => { - const document = docView.Document - - const { movements } = presentation - movements.forEach(movement => { - const { panX, panY, time } = movement - // set the pan to what was stored - setTimeout(() => { - document._panX = panX; - document._panY = panY; - }, time) - }) - } - // instance variable for the FFView private disposeFunc: IReactionDisposer | null; @@ -172,6 +159,9 @@ export class RecordingApi { () => ({ x: NumCast(view.Document.panX, -1), y: NumCast(view.Document.panY, -1) }), (res) => (res.x !== -1 && res.y !== -1) && this.trackMovements(res.x, res.y) ) + + // for now, set the most recent recordingFFView to the playFFView + this.playFFView = view; } // call on dispose function to stop tracking movements @@ -180,7 +170,27 @@ export class RecordingApi { this.disposeFunc = null; } + // TODO: extract this into different class with pause and resume recording + private playFFView: CollectionFreeFormView | null; + + public followMovements = (presentation: Presentation, docView: CollectionFreeFormView): undefined | Error => { + if (presentation.startDate === null || this.playFFView === null) { + return new Error('[recordingApi.ts] followMovements() failed: no presentation data or no view') + } + const document = this.playFFView.Document + const { movements } = presentation + movements.forEach(movement => { + const { panX, panY, time } = movement + // set the pan to what was stored + setTimeout(() => { + document._panX = panX; + document._panY = panY; + }, time) + }) + } + + // Unfinished code for tracing multiple free form views // export let pres: Map<CollectionFreeFormView, IReactionDisposer> = new Map() // export function AddRecordingFFView(ffView: CollectionFreeFormView): void { @@ -195,5 +205,4 @@ export class RecordingApi { // disposer?.(); // pres.delete(ffView) // } - }
\ No newline at end of file |