From bc398b5e3cd23fd6b9224e98dff8efb7d5eaef79 Mon Sep 17 00:00:00 2001
From: Andrew Kim <andrewdkim@users.noreply.github.com>
Date: Sat, 13 Apr 2019 18:17:18 -0400
Subject: graphics change

---
 src/client/views/nodes/Timeline.tsx | 60 +++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 15 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 45e37dd8a..321f91471 100644
--- a/src/client/views/nodes/Timeline.tsx
+++ b/src/client/views/nodes/Timeline.tsx
@@ -1,35 +1,65 @@
 import * as React from "react"
 import * as ReactDOM from "react-dom"
 import { observer } from "mobx-react"
-import { observable, reaction } from "mobx"
-import { TimelineField } from "../../../fields/TimelineField";
+import { observable, reaction, action} from "mobx"
 import "./Timeline.scss"
 import { KeyStore } from "../../../fields/KeyStore";
 import { Document } from "../../../fields/Document";
+import { KeyFrame } from "./KeyFrame";
 
 @observer
-export class Timeline extends React.Component<TimelineField>{
+export class Timeline extends React.Component{
+    @observable private _inner = React.createRef<HTMLDivElement>(); 
+    @observable private _isRecording:Boolean = false;
+    @observable private _currentBar:any; 
 
-    private _isRecording = false;
+    @action
     onRecord = (e: React.MouseEvent) => {
         this._isRecording = true;
     }
 
+    @action
     onStop = (e: React.MouseEvent) => {
         this._isRecording = false;
     }
 
+    @action
+    onInnerPointerDown = (e:React.PointerEvent) => {
+        if (this._isRecording) {
+            if (this._inner.current){
+                if (this._currentBar == null){
+                    let mouse = e.nativeEvent; 
+                    let _currentBar = document.createElement("div"); 
+                    _currentBar.style.height = "100%"; 
+                    _currentBar.style.width = "5px"
+                    _currentBar.style.left = "mouse.offsetX"; 
+                    _currentBar.style.backgroundColor = "white"
+                    _currentBar.style.transform = `translate(${mouse.offsetX}px)`; 
+                    this._inner.current.appendChild(_currentBar); 
+                } else {
+                    this._currentBar.remove()
+                    this._currentBar = null; 
+                }
+                
+            }
+        }
+    }
+
+
+    private _keyFrames:KeyFrame[] = []; 
+
     componentDidMount() {
-        let doc: Document;
-        let keyFrame: Document;
-        let keys = [KeyStore.X, KeyStore.Y];
-        reaction(() => {
-            return keys.map(key => doc.GetNumber(key, 0));
-        }, data => {
-            keys.forEach((key, index) => {
-                keyFrame.SetNumber(key, data[index]);
-            });
-        });
+        // let doc: Document;
+        // let keyFrame = new KeyFrame(); 
+        // this._keyFrames.push(keyFrame); 
+        // let keys = [KeyStore.X, KeyStore.Y];
+        // reaction(() => {
+        //     return keys.map(key => doc.GetNumber(key, 0));
+        // }, data => {
+        //     keys.forEach((key, index) => {
+        //         keyFrame.document().SetNumber(key, data[index]);
+        //     });
+        // });
     }
 
     render() {
@@ -37,7 +67,7 @@ export class Timeline extends React.Component<TimelineField>{
             <div>
                 <div className="timeline-container">
                     <div className="timeline">
-                        <div className="inner">
+                        <div className="inner" ref = {this._inner} onPointerDown  = {this.onInnerPointerDown}>
                         </div>
                     </div>
                     <button>Record</button>
-- 
cgit v1.2.3-70-g09d2

