From c242b58e9f2c0bce2ca596b6f276604aa82473e1 Mon Sep 17 00:00:00 2001 From: Eleanor Eng Date: Mon, 10 Jun 2019 11:21:23 -0400 Subject: IT WORKS --- src/client/views/nodes/KeyFrame.tsx | 16 ------------ src/client/views/nodes/Timeline.tsx | 51 ++++++++----------------------------- 2 files changed, 10 insertions(+), 57 deletions(-) delete mode 100644 src/client/views/nodes/KeyFrame.tsx (limited to 'src') diff --git a/src/client/views/nodes/KeyFrame.tsx b/src/client/views/nodes/KeyFrame.tsx deleted file mode 100644 index fb072f4d6..000000000 --- a/src/client/views/nodes/KeyFrame.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { Doc } from '../../../new_fields/Doc'; - -export class KeyFrame { - private _document: Doc; - constructor() { - this._document = new Doc(); - - - } - - get doc():Doc { - return this._document; - } - - -} \ No newline at end of file diff --git a/src/client/views/nodes/Timeline.tsx b/src/client/views/nodes/Timeline.tsx index cc3945f0a..56976670f 100644 --- a/src/client/views/nodes/Timeline.tsx +++ b/src/client/views/nodes/Timeline.tsx @@ -3,7 +3,6 @@ import * as ReactDOM from "react-dom"; import { observer } from "mobx-react"; import { observable, reaction, action, IReactionDisposer, observe, IObservableArray } from "mobx"; import "./Timeline.scss"; -import { KeyFrame } from "./KeyFrame"; import { CollectionViewProps } from "../collections/CollectionBaseView"; import { CollectionSubView, SubCollectionViewProps } from "../collections/CollectionSubView"; import { DocumentViewProps, DocumentView } from "./DocumentView"; @@ -76,26 +75,18 @@ export class Timeline extends CollectionSubView(Document) { }, async data => { if (this._inner.current) { if (!this._barMoved) { - console.log("running"); if (this._data.indexOf(node) === -1) { - - const kf = new List(); this._data.push(node); let index = this._data.indexOf(node); let timeandpos = this.setTimeAndPos(node); - - let info: Doc[] = new Array(1000); //////////////////////////////////////////////////// do something + let info: Doc[] = new Array(1000); //kinda weird info[this._currentBarX] = timeandpos; - this._keyframes[index] = info; //graphical yellow bar let bar: HTMLDivElement = this.createBar(5, this._currentBarX, "yellow"); this._inner.current.appendChild(bar); - this._keys.forEach((key, index) => { - - }); } else { let index = this._data.indexOf(node); if (this._keyframes[index][this._currentBarX] !== undefined) { //when node is in data, but doesn't have data for this specific time. @@ -139,17 +130,11 @@ export class Timeline extends CollectionSubView(Document) { @action timeChange = async (time: number) => { - //const docs = (await DocListCastAsync(this.props.Document[this.props.fieldKey]))!; - //const kfList:Doc[][] = Cast(this._keyframes, listSpec(Doc), []) as any; const docs = this._data; - const kfList: Doc[][] = this._keyframes; - - const list = await Promise.all(kfList.map(l => Promise.all(l))); - let isFrame: boolean = false; - docs.forEach(async (oneDoc, i) => { let leftKf!: TimeAndPosition; let rightKf!: TimeAndPosition; + let singleFrame: Doc | undefined = undefined; let oneKf = this._keyframes[i]; oneKf.forEach((singleKf) => { if (singleKf !== undefined) { @@ -165,32 +150,17 @@ export class Timeline extends CollectionSubView(Document) { rightKf = TimeAndPosition(this._keyframes[i][rightMin]); } } else { - isFrame = true; + singleFrame = singleKf; } } }); - if (leftKf && rightKf) { - this.interpolate(oneDoc, leftKf, rightKf, this._currentBarX); - } - if (isFrame) { - if (oneKf[i] !== undefined) { - // console.log(isFrame); - // //@ts-ignore - // oneDoc.x = this._keyframes[i].position.x; - // //@ts-ignore - // oneDoc.y = this._keyframes[i].position.y; - - //maybe???? - let pos: Position = Position(oneDoc); - let timeandpos = new Doc; - const newPos = new Doc; - this._keys.forEach(key => newPos[key] = pos[key]); - timeandpos.position = newPos; - timeandpos.time = this._currentBarX; - this._keyframes[i][this._currentBarX] = timeandpos; + if (singleFrame) { + if (true || oneKf[i] !== undefined) { + this._keys.map(key => FieldValue(oneDoc[key])); } + } else if (leftKf && rightKf) { + this.interpolate(oneDoc, leftKf, rightKf, this._currentBarX); } - isFrame = false; }); } @@ -198,7 +168,7 @@ export class Timeline extends CollectionSubView(Document) { let counter: number = Infinity; let leftMin: number = Infinity; kfList.forEach((kf) => { - if (kf !== undefined && NumCast(kf.time) < time) { //ERROR: "cannot read property time of undefined" + if (kf !== undefined && NumCast(kf.time) < time) { let diff: number = Math.abs(NumCast(kf.time) - time); if (diff < counter) { counter = diff; @@ -245,7 +215,6 @@ export class Timeline extends CollectionSubView(Document) { }); } - private _barMoved: boolean = false; @action onInnerPointerUp = (e: React.PointerEvent) => { @@ -323,7 +292,7 @@ export class Timeline extends CollectionSubView(Document) { @action displayKeyFrames = (dv: DocumentView) => { - console.log(dv); + // console.log(dv); dv.props.Document; } -- cgit v1.2.3-70-g09d2