时间轴。

This commit is contained in:
tengge1 2019-06-07 21:02:30 +08:00
parent f03d6673c1
commit 99241ac780
3 changed files with 26 additions and 9 deletions

View File

@ -79,7 +79,7 @@ class EWorkspace extends React.Component {
</Toolbar>
</Panel>
<Panel title={'South'} region={'south'} split={true} style={{ height: '120px', border: 'none' }}>
<Timeline></Timeline>
<Timeline style={{ width: 0, flex: 1, }}></Timeline>
</Panel>
<Panel title={'West'} region={'west'} split={true} style={{ width: '200px', border: 'none' }}>
<Toolbar direction={'vertical'}>

View File

@ -9,32 +9,36 @@ import PropTypes from 'prop-types';
class Timeline extends React.Component {
constructor(props) {
super(props);
this.canvas = React.createRef();
}
render() {
const { className, style } = this.props;
return <div className={classNames('Timeline', className)} style={style}>
<canvas></canvas>
<canvas className={'time'} ref={this.canvas}></canvas>
</div>;
}
componentDidMount() {
return;
var duration = this.duration; //
var scale = this.scale; // 1
var duration = 120; // ()
var scale = 30; // 1=30
var width = duration * scale; //
var scale5 = scale / 5; // 0.2
var margin = 0; //
this.dom.style.width = (width + margin * 2) + 'px';
this.dom.width = this.dom.clientWidth;
var canvas = this.canvas.current;
canvas.style.width = (width + margin * 2) + 'px';
canvas.width = canvas.clientWidth;
canvas.height = 32;
var context = this.dom.getContext('2d');
var context = canvas.getContext('2d');
//
context.fillStyle = '#eee';
context.fillRect(0, 0, this.dom.width, this.dom.height);
context.fillRect(0, 0, canvas.width, canvas.height);
//
context.strokeStyle = '#555';
@ -86,4 +90,9 @@ Timeline.propTypes = {
style: PropTypes.object,
};
Timeline.defaultProps = {
className: null,
style: null,
};
export default Timeline;

View File

@ -0,0 +1,8 @@
.Timeline {
width: 100%;
}
.Timeline .time {
width: 100%;
height: 32px;
}