From de73c98f17e5ab5fb83cc3db8af5172c334c2dea Mon Sep 17 00:00:00 2001
From: loudonclear <loudon_cohen@brown.edu>
Date: Mon, 10 Jun 2019 11:23:32 -0400
Subject: selection stuff

---
 src/client/views/nodes/Timeline.tsx | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

(limited to 'src/client/views/nodes/Timeline.tsx')

diff --git a/src/client/views/nodes/Timeline.tsx b/src/client/views/nodes/Timeline.tsx
index 3ffd7b749..6fc40768b 100644
--- a/src/client/views/nodes/Timeline.tsx
+++ b/src/client/views/nodes/Timeline.tsx
@@ -57,6 +57,9 @@ export class Timeline extends CollectionSubView(Document) {
     @observable private _keyframes: Doc[][] = []; //2D list of infos
 
     @observable private TEMPNUM = 0; 
+    @observable private _keyChanged = false; 
+
+
     @action
     onRecord = (e: React.MouseEvent) => {
         if (this._isRecording === true){
@@ -100,6 +103,7 @@ export class Timeline extends CollectionSubView(Document) {
 
 
     storeKeyChange = (node:Doc) =>{
+        this._keyChanged = true; 
         if (this._inner.current) {
             if (!this._barMoved) {
                 if (this._data.indexOf(node) === -1) {
@@ -325,20 +329,27 @@ export class Timeline extends CollectionSubView(Document) {
 
     @action
     displayKeyFrames = async (dv: DocumentView) => {
-        console.log("hi"); 
+        if (this._keyChanged){ //this runs when keyframe has been changed, so it should not delete any bars. 
+            this._keyChanged = false;
+        } else {
+            this.clearBars(); 
+        }
         let doc:Doc = dv.props.Document;
         let inner:HTMLDivElement = (await this._inner.current)!;
         this._data.forEach((node) => {
-            if (node === doc){        
-                this.clearBars(); 
+            console.log(node); 
+            console.log(doc); 
+            if (node === doc){   
+                console.log("hi");     
                 const index = this._data.indexOf(node); 
-                this._keyframes[index].forEach((time) => {
-                    if (time !== undefined){
-                        let timeandpos = TimeAndPosition(time);
-                        let bar: HTMLDivElement = this.createBar(5, this._currentBarX, "yellow");
+                this._keyframes[index].forEach( async (timeandpos) => {
+                    if (timeandpos !== undefined){
+                        timeandpos = TimeAndPosition(timeandpos); 
+                        let time = NumCast(await timeandpos.time); 
+                        let bar: HTMLDivElement = this.createBar(5, time, "yellow");
                         inner.appendChild(bar);
                     }
-                })
+                }); 
             }
         }); 
 
@@ -347,11 +358,14 @@ export class Timeline extends CollectionSubView(Document) {
     @action 
     clearBars = async () => {
         let inner:HTMLDivElement = (await this._inner.current)!;
+        console.log(inner.children); 
         inner.childNodes.forEach((bar) => {
             if (bar !== this._currentBar){
                 inner.removeChild(bar);
             }
+
         }); 
+       
     }
     
 
@@ -364,11 +378,13 @@ export class Timeline extends CollectionSubView(Document) {
                             {
                                 SelectionManager.SelectedDocuments().map((dv) => {
                                     this.displayKeyFrames(dv);
-                                })}
+                            })}
+
+                            
+
                         </div>
                     </div>
                     <button onClick={this.onRecord}>Record</button>
-                    {/* <button onClick={this.onInterpolate}>Inter</button> */}
                     <input placeholder="Time" ref={this._timeInput} onKeyDown={this.onTimeEntered}></input>
                 </div>
             </div>
-- 
cgit v1.2.3-70-g09d2

