Skip to content

Commit

Permalink
Merge pull request #1589 from KapJI/slider-minvalue
Browse files Browse the repository at this point in the history
[Slider] Remove redundant 'defaultValue'. Fix bug when 'min' is greater than zero.
  • Loading branch information
shaurya947 committed Oct 30, 2015
2 parents 9be7261 + a3e9cad commit fd346dd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ const Slider = React.createClass({

getDefaultProps() {
return {
defaultValue: 0,
disabled: false,
max: 1,
min: 0,
Expand All @@ -93,7 +92,7 @@ const Slider = React.createClass({
getInitialState() {
let value = this.props.value;
if (value === undefined) {
value = this.props.defaultValue;
value = this.props.defaultValue !== undefined ? this.props.defaultValue : this.props.min;
}
let percent = (value - this.props.min) / (this.props.max - this.props.min);
if (isNaN(percent)) percent = 0;
Expand All @@ -113,7 +112,7 @@ const Slider = React.createClass({
let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({muiTheme: newMuiTheme});

if (nextProps.value !== undefined) {
if (nextProps.value !== undefined && !this.state.dragging) {
this.setValue(nextProps.value);
}
},
Expand Down

0 comments on commit fd346dd

Please sign in to comment.