update progress demo

pull/330/head
afc163 9 years ago
parent 047ab6b099
commit 73c1d3f595

@ -15,24 +15,35 @@ var MyProgress = React.createClass({
percent: 0
};
},
componentDidMount: function() {
var self = this;
setInterval(function() {
if (self.state.percent < 100) {
self.state.percent += 4;
}
self.setState({
percent: self.state.percent
});
}, 200);
increase() {
let percent = this.state.percent + 10;
if (percent > 100) {
percent = 100;
}
this.setState({ percent });
},
decline() {
let percent = this.state.percent - 10;
if (percent < 0) {
percent = 0;
}
this.setState({ percent });
},
render() {
return <ProgressCircle percent={this.state.percent} />;
return <div>
<ProgressCircle percent={this.state.percent} />
<div className="ant-btn-group">
<button className="ant-btn ant-btn-ghost" onClick={this.decline}>
<i className="anticon anticon-minus"></i>
</button>
<button className="ant-btn ant-btn-ghost" onClick={this.increase}>
<i className="anticon anticon-plus"></i>
</button>
</div>
</div>;
}
});
React.render(
<MyProgress />
, document.getElementById('components-progress-demo-circle-dynamic'));
React.render(<MyProgress />, document.getElementById('components-progress-demo-circle-dynamic'));
````

@ -15,24 +15,35 @@ var MyProgress = React.createClass({
percent: 0
};
},
componentDidMount: function() {
var self = this;
setInterval(function() {
if (self.state.percent < 100) {
self.state.percent += 4;
}
self.setState({
percent: self.state.percent
});
}, 200);
increase() {
let percent = this.state.percent + 10;
if (percent > 100) {
percent = 100;
}
this.setState({ percent });
},
decline() {
let percent = this.state.percent - 10;
if (percent < 0) {
percent = 0;
}
this.setState({ percent });
},
render() {
return <Progress percent={this.state.percent} />;
return <div>
<Progress percent={this.state.percent} />
<div className="ant-btn-group">
<button className="ant-btn ant-btn-ghost" onClick={this.decline}>
<i className="anticon anticon-minus"></i>
</button>
<button className="ant-btn ant-btn-ghost" onClick={this.increase}>
<i className="anticon anticon-plus"></i>
</button>
</div>
</div>;
}
});
React.render(
<MyProgress />
, document.getElementById('components-progress-demo-dynamic'));
React.render(<MyProgress />, document.getElementById('components-progress-demo-dynamic'));
````

@ -27,7 +27,7 @@
&-line-bg {
border-radius: 100px;
background-color: @primary-color;
transition: all 0.6s linear 0s;
transition: all 0.3s linear 0s;
}
&-line-text {
position: absolute;

Loading…
Cancel
Save