blob: ffdd34b781875840ec1a663b7790a961d67f26de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
import * as React from "react";
import * as ReactDOM from "react-dom";
import { observer } from "mobx-react";
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 {
@observable private _inner = React.createRef<HTMLDivElement>();
@observable private _isRecording: Boolean = false;
@observable private _currentBar: any = null;
@observable private _newBar: any = null;
@action
onRecord = (e: React.MouseEvent) => {
this._isRecording = true;
// console.log("hello");
}
@action
onStop = (e: React.MouseEvent) => {
this._isRecording = false;
if (this._inner.current) { //if you comment this section out it works as before...
this._newBar = document.createElement("div");
this._newBar.style.height = "100%";
this._newBar.style.width = "5px";
this._newBar.style.backgroundColor = "yellow";
this._newBar.style.transform = this._currentBar.style.transform;
this._inner.current.appendChild(this._newBar);
}
this._currentBar.remove();
this._currentBar = null;
}
@action
onInnerPointerDown = (e: React.PointerEvent) => {
if (this._isRecording) {
if (this._inner.current) {
if (this._currentBar === null) {
console.log("rr");
let mouse = e.nativeEvent;
this._currentBar = document.createElement("div");
this._currentBar.style.height = "100%";
this._currentBar.style.width = "5px";
this._currentBar.style.backgroundColor = "white";
this._currentBar.style.transform = `translate(${mouse.offsetX}px)`;
this._inner.current.appendChild(this._currentBar);
} else {
this._currentBar.remove();
this._currentBar = null;
this.onInnerPointerDown(e);
}
}
}
}
createMark = (width: number) => {
}
private _keyFrames: KeyFrame[] = [];
componentDidMount() {
// 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() {
return (
<div>
<div className="timeline-container">
<div className="timeline">
<div className="inner" ref={this._inner} onPointerDown={this.onInnerPointerDown}>
</div>
</div>
<button onClick={this.onRecord}>Record</button>
<button onClick={this.onStop}>Stop</button>
<input placeholder="Time"></input>
</div>
</div>
);
}
}
|