|
@@ -14,6 +14,7 @@ interface ITimelineProps {
|
|
|
animationLimit: number;
|
|
animationLimit: number;
|
|
|
fps: number;
|
|
fps: number;
|
|
|
repositionCanvas: (keyframe: IAnimationKey) => void;
|
|
repositionCanvas: (keyframe: IAnimationKey) => void;
|
|
|
|
|
+ resizeWindowProportion: number;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export class Timeline extends React.Component<
|
|
export class Timeline extends React.Component<
|
|
@@ -80,6 +81,11 @@ export class Timeline extends React.Component<
|
|
|
if (prevProps.animationLimit !== this.props.animationLimit) {
|
|
if (prevProps.animationLimit !== this.props.animationLimit) {
|
|
|
this.setState({ limitValue: this.props.animationLimit });
|
|
this.setState({ limitValue: this.props.animationLimit });
|
|
|
}
|
|
}
|
|
|
|
|
+ if (prevProps.resizeWindowProportion !== this.props.resizeWindowProportion) {
|
|
|
|
|
+ if (this.state.scrollWidth !== undefined) {
|
|
|
|
|
+ this.setState({ scrollWidth: this.calculateScrollWidth(this.state.start, this.state.end) });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
@@ -113,7 +119,9 @@ export class Timeline extends React.Component<
|
|
|
scrollWidth: this.calculateScrollWidth(0, newEnd),
|
|
scrollWidth: this.calculateScrollWidth(0, newEnd),
|
|
|
});
|
|
});
|
|
|
if (this._scrollbarHandle.current && this._scrollContainer.current) {
|
|
if (this._scrollbarHandle.current && this._scrollContainer.current) {
|
|
|
- this._scrollbarHandle.current.style.left = `${this._scrollContainer.current.getBoundingClientRect().left + this._marginScrollbar}px`;
|
|
|
|
|
|
|
+ this._scrollbarHandle.current.style.left = `${
|
|
|
|
|
+ this._scrollContainer.current.getBoundingClientRect().left + this._marginScrollbar
|
|
|
|
|
+ }px`;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
@@ -231,12 +239,12 @@ export class Timeline extends React.Component<
|
|
|
|
|
|
|
|
if ((e.target as HTMLDivElement).className === "left-draggable" && this._scrollbarHandle.current) {
|
|
if ((e.target as HTMLDivElement).className === "left-draggable" && this._scrollbarHandle.current) {
|
|
|
this._active = "leftDraggable";
|
|
this._active = "leftDraggable";
|
|
|
- this._shiftX = e.clientX - this._scrollbarHandle.current.getBoundingClientRect().left;
|
|
|
|
|
|
|
+ this._shiftX = e.clientX - this._scrollbarHandle.current.getBoundingClientRect().left - 3;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ((e.target as HTMLDivElement).className === "right-draggable" && this._scrollbarHandle.current) {
|
|
if ((e.target as HTMLDivElement).className === "right-draggable" && this._scrollbarHandle.current) {
|
|
|
this._active = "rightDraggable";
|
|
this._active = "rightDraggable";
|
|
|
- this._shiftX = e.clientX - this._scrollbarHandle.current.getBoundingClientRect().left;
|
|
|
|
|
|
|
+ this._shiftX = e.clientX - this._scrollbarHandle.current.getBoundingClientRect().left + 3;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -332,7 +340,10 @@ export class Timeline extends React.Component<
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!(framesTo >= this.state.end - 20)) {
|
|
if (!(framesTo >= this.state.end - 20)) {
|
|
|
- let toleft = framesTo * unit + this._scrollContainer.current.getBoundingClientRect().left + this._marginScrollbar * 2;
|
|
|
|
|
|
|
+ let toleft =
|
|
|
|
|
+ framesTo * unit +
|
|
|
|
|
+ this._scrollContainer.current.getBoundingClientRect().left +
|
|
|
|
|
+ this._marginScrollbar * 2;
|
|
|
if (this._scrollbarHandle.current) {
|
|
if (this._scrollbarHandle.current) {
|
|
|
this._scrollbarHandle.current.style.left = toleft + "px";
|
|
this._scrollbarHandle.current.style.left = toleft + "px";
|
|
|
}
|
|
}
|
|
@@ -382,7 +393,12 @@ export class Timeline extends React.Component<
|
|
|
scrollable={this._scrollable}
|
|
scrollable={this._scrollable}
|
|
|
/>
|
|
/>
|
|
|
<div className="timeline-wrapper">
|
|
<div className="timeline-wrapper">
|
|
|
- <div ref={this._scrollable} className="display-line" onClick={this.setCurrentFrame} tabIndex={50}>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ ref={this._scrollable}
|
|
|
|
|
+ className="display-line"
|
|
|
|
|
+ onClick={this.setCurrentFrame}
|
|
|
|
|
+ tabIndex={50}
|
|
|
|
|
+ >
|
|
|
<svg
|
|
<svg
|
|
|
style={{
|
|
style={{
|
|
|
width: "100%",
|
|
width: "100%",
|
|
@@ -399,16 +415,35 @@ export class Timeline extends React.Component<
|
|
|
<svg key={`tl_${frame}`}>
|
|
<svg key={`tl_${frame}`}>
|
|
|
{
|
|
{
|
|
|
<>
|
|
<>
|
|
|
- {frame % Math.round(this.state.selectionLength.length / 20) === 0 ? (
|
|
|
|
|
|
|
+ {frame % Math.round(this.state.selectionLength.length / 20) ===
|
|
|
|
|
+ 0 ? (
|
|
|
<>
|
|
<>
|
|
|
- <text x={(i * 100) / this.state.selectionLength.length + "%"} y="18" style={{ fontSize: 10, fill: "#555555" }}>
|
|
|
|
|
|
|
+ <text
|
|
|
|
|
+ x={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
|
|
+ y="18"
|
|
|
|
|
+ style={{ fontSize: 10, fill: "#555555" }}
|
|
|
|
|
+ >
|
|
|
{frame}
|
|
{frame}
|
|
|
</text>
|
|
</text>
|
|
|
- <line x1={(i * 100) / this.state.selectionLength.length + "%"} y1="22" x2={(i * 100) / this.state.selectionLength.length + "%"} y2="40" style={{ stroke: "#555555", strokeWidth: 0.5 }} />
|
|
|
|
|
|
|
+ <line
|
|
|
|
|
+ x1={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
|
|
+ y1="22"
|
|
|
|
|
+ x2={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
|
|
+ y2="40"
|
|
|
|
|
+ style={{ stroke: "#555555", strokeWidth: 0.5 }}
|
|
|
|
|
+ />
|
|
|
</>
|
|
</>
|
|
|
) : null}
|
|
) : null}
|
|
|
{this.getCurrentFrame(frame) ? (
|
|
{this.getCurrentFrame(frame) ? (
|
|
|
- <svg x={this._scrollable.current ? this._scrollable.current.clientWidth / this.state.selectionLength.length / 2 : 1}>
|
|
|
|
|
|
|
+ <svg
|
|
|
|
|
+ x={
|
|
|
|
|
+ this._scrollable.current
|
|
|
|
|
+ ? this._scrollable.current.clientWidth /
|
|
|
|
|
+ this.state.selectionLength.length /
|
|
|
|
|
+ 2
|
|
|
|
|
+ : 1
|
|
|
|
|
+ }
|
|
|
|
|
+ >
|
|
|
<line
|
|
<line
|
|
|
x1={(i * 100) / this.state.selectionLength.length + "%"}
|
|
x1={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
y1="0"
|
|
y1="0"
|
|
@@ -416,7 +451,10 @@ export class Timeline extends React.Component<
|
|
|
y2="40"
|
|
y2="40"
|
|
|
style={{
|
|
style={{
|
|
|
stroke: "rgba(18, 80, 107, 0.26)",
|
|
stroke: "rgba(18, 80, 107, 0.26)",
|
|
|
- strokeWidth: this._scrollable.current ? this._scrollable.current.clientWidth / this.state.selectionLength.length : 1,
|
|
|
|
|
|
|
+ strokeWidth: this._scrollable.current
|
|
|
|
|
+ ? this._scrollable.current.clientWidth /
|
|
|
|
|
+ this.state.selectionLength.length
|
|
|
|
|
+ : 1,
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
</svg>
|
|
</svg>
|
|
@@ -424,7 +462,14 @@ export class Timeline extends React.Component<
|
|
|
|
|
|
|
|
{this.getKeyframe(frame) ? (
|
|
{this.getKeyframe(frame) ? (
|
|
|
<svg key={`kf_${i}`} tabIndex={i + 40}>
|
|
<svg key={`kf_${i}`} tabIndex={i + 40}>
|
|
|
- <line id={`kf_${i.toString()}`} x1={(i * 100) / this.state.selectionLength.length + "%"} y1="0" x2={(i * 100) / this.state.selectionLength.length + "%"} y2="40" style={{ stroke: "#ffc017", strokeWidth: 1 }} />
|
|
|
|
|
|
|
+ <line
|
|
|
|
|
+ id={`kf_${i.toString()}`}
|
|
|
|
|
+ x1={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
|
|
+ y1="0"
|
|
|
|
|
+ x2={(i * 100) / this.state.selectionLength.length + "%"}
|
|
|
|
|
+ y2="40"
|
|
|
|
|
+ style={{ stroke: "#ffc017", strokeWidth: 1 }}
|
|
|
|
|
+ />
|
|
|
</svg>
|
|
</svg>
|
|
|
) : null}
|
|
) : null}
|
|
|
</>
|
|
</>
|
|
@@ -435,9 +480,20 @@ export class Timeline extends React.Component<
|
|
|
</svg>
|
|
</svg>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <div className="timeline-scroll-handle" onMouseMove={this.scrollDrag} onMouseDown={this.scrollDragStart} onMouseUp={this.scrollDragEnd} onMouseLeave={this.scrollDragEnd} onDragStart={this.dragDomFalse}>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ className="timeline-scroll-handle"
|
|
|
|
|
+ onMouseMove={this.scrollDrag}
|
|
|
|
|
+ onMouseDown={this.scrollDragStart}
|
|
|
|
|
+ onMouseUp={this.scrollDragEnd}
|
|
|
|
|
+ onMouseLeave={this.scrollDragEnd}
|
|
|
|
|
+ onDragStart={this.dragDomFalse}
|
|
|
|
|
+ >
|
|
|
<div className="scroll-handle" ref={this._scrollContainer} tabIndex={60}>
|
|
<div className="scroll-handle" ref={this._scrollContainer} tabIndex={60}>
|
|
|
- <div className="handle" ref={this._scrollbarHandle} style={{ width: this.state.scrollWidth }}>
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ className="handle"
|
|
|
|
|
+ ref={this._scrollbarHandle}
|
|
|
|
|
+ style={{ width: this.state.scrollWidth }}
|
|
|
|
|
+ >
|
|
|
<div className="left-grabber">
|
|
<div className="left-grabber">
|
|
|
<div className="left-draggable">
|
|
<div className="left-draggable">
|
|
|
<div className="grabber"></div>
|
|
<div className="grabber"></div>
|
|
@@ -461,7 +517,13 @@ export class Timeline extends React.Component<
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="input-frame">
|
|
<div className="input-frame">
|
|
|
- <input ref={this._inputAnimationLimit} type="number" value={this.state.limitValue} onChange={(e) => this.handleLimitChange(e)} onBlur={(e) => this.onInputBlur(e)}></input>
|
|
|
|
|
|
|
+ <input
|
|
|
|
|
+ ref={this._inputAnimationLimit}
|
|
|
|
|
+ type="number"
|
|
|
|
|
+ value={this.state.limitValue}
|
|
|
|
|
+ onChange={(e) => this.handleLimitChange(e)}
|
|
|
|
|
+ onBlur={(e) => this.onInputBlur(e)}
|
|
|
|
|
+ ></input>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|