2015-06-30 22:58:32 +03:00
|
|
|
###
|
|
|
|
@todo
|
|
|
|
###
|
|
|
|
|
|
|
|
ProgressBar = require '../../components/progress_bar'
|
|
|
|
|
|
|
|
module.exports = React.createClass
|
|
|
|
|
|
|
|
# -- States & Properties
|
|
|
|
getInitialState: ->
|
|
|
|
progress: 0
|
|
|
|
buffer: 10
|
|
|
|
|
|
|
|
# -- Lifecycle
|
|
|
|
componentWillMount: ->
|
|
|
|
@simulateProgress()
|
|
|
|
|
|
|
|
# -- Simulate kind of a progress async function
|
|
|
|
simulateProgress: ->
|
|
|
|
setTimeout =>
|
|
|
|
if @state.progress < 100
|
|
|
|
@increaseProgress()
|
|
|
|
@increaseBuffer() if @state.progress > @state.buffer
|
|
|
|
else
|
|
|
|
@replaceState @getInitialState()
|
|
|
|
@simulateProgress()
|
|
|
|
, (Math.random() * 1 + 1) * 1000
|
|
|
|
|
|
|
|
increaseProgress: ->
|
|
|
|
@setState progress: Math.random() * 30 + @state.progress
|
|
|
|
|
|
|
|
increaseBuffer: ->
|
|
|
|
@setState buffer: Math.random() * (100 - @state.progress) + @state.progress
|
|
|
|
|
|
|
|
# -- Render
|
|
|
|
render: ->
|
|
|
|
<section>
|
|
|
|
<h2>Progress bars</h2>
|
|
|
|
|
|
|
|
<p>Determinate</p>
|
2015-07-04 21:09:16 +03:00
|
|
|
<ProgressBar mode="determinate" value={@state.progress} buffer={@state.buffer}/>
|
2015-06-30 22:58:32 +03:00
|
|
|
|
|
|
|
<p>Indeterminate...</p>
|
2015-07-04 21:09:16 +03:00
|
|
|
<ProgressBar mode="indeterminate"/>
|
|
|
|
|
|
|
|
<p>Circular</p>
|
|
|
|
<ProgressBar type="circular" mode="indeterminate"/>
|
2015-06-30 22:58:32 +03:00
|
|
|
</section>
|