mirror of
https://github.com/wassname/slider.git
synced 2026-09-12 12:50:45 +08:00
docs: update demo
This commit is contained in:
+25
-1
@@ -14,17 +14,41 @@ function log(value) {
|
|||||||
const CustomizedRange = React.createClass({
|
const CustomizedRange = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
|
lowerBound: 20,
|
||||||
|
upperBound: 40,
|
||||||
value: [20, 40],
|
value: [20, 40],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
onLowerBoundChange: function(e) {
|
||||||
|
this.setState({ lowerBound: +e.target.value });
|
||||||
|
},
|
||||||
|
onUpperBoundChange: function(e) {
|
||||||
|
this.setState({ upperBound: +e.target.value });
|
||||||
|
},
|
||||||
onSliderChange: function(value) {
|
onSliderChange: function(value) {
|
||||||
log(value);
|
log(value);
|
||||||
this.setState({
|
this.setState({
|
||||||
value: value,
|
value: value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleApply: function() {
|
||||||
|
const { lowerBound, upperBound } = this.state;
|
||||||
|
this.setState({ value: [lowerBound, upperBound]});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
return <Slider range value={this.state.value} onChange={this.onSliderChange} />;
|
return (
|
||||||
|
<div>
|
||||||
|
<label>LowerBound: </label>
|
||||||
|
<input type="number" value={this.state.lowerBound} onChange={this.onLowerBoundChange} />
|
||||||
|
<br />
|
||||||
|
<label>UpperBound: </label>
|
||||||
|
<input type="number" value={this.state.upperBound} onChange={this.onUpperBoundChange} />
|
||||||
|
<br />
|
||||||
|
<button onClick={this.handleApply}>Apply</button>
|
||||||
|
<br /><br />
|
||||||
|
<Slider range allowCross={false} value={this.state.value} onChange={this.onSliderChange} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user