forked from yuristrelets/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.js
More file actions
55 lines (47 loc) · 1.33 KB
/
progress.js
File metadata and controls
55 lines (47 loc) · 1.33 KB
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
import React from 'react';
import ProgressBar from '../../components/progress_bar';
const initialState = {
progress: 0,
buffer: 10
};
class ProgressBarTest extends React.Component {
state = initialState;
componentWillMount () {
this.simulateProgress();
}
simulateProgress () {
setTimeout(() => {
if (this.state.progress < 100) {
this.increaseProgress();
if (this.state.progress > this.state.buffer) this.increaseBuffer();
} else {
this.setState(initialState);
}
this.simulateProgress();
}, (Math.random() * 1 + 1) * 1000);
}
increaseProgress () {
this.setState({
progress: Math.random() * 30 + this.state.progress
});
}
increaseBuffer () {
this.setState({
buffer: Math.random() * (100 - this.state.progress) + this.state.progress
});
}
render () {
return (
<section>
<h5>Progress bars</h5>
<p style={{margin: '10px auto'}}>Determinate</p>
<ProgressBar mode='determinate' value={this.state.progress} buffer={this.state.buffer}/>
<p style={{margin: '10px auto'}}>Indeterminate...</p>
<ProgressBar mode='indeterminate'/>
<p style={{margin: '10px auto'}}>Circular</p>
<ProgressBar type='circular' mode='indeterminate'/>
</section>
);
}
}
export default ProgressBarTest;