Skip to content

Commit

Permalink
Trigger onChange with current value instead of previous
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepb committed Dec 15, 2014
1 parent 6471c48 commit ef7adeb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/js/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ var Slider = React.createClass({
},

setPercent: function (percent) {
var value = percent * (this.props.max - this.props.min) + this.props.min;
var value = this._percentToValue(percent);
this.setState({value: value, percent: percent});
},

Expand Down Expand Up @@ -162,7 +162,12 @@ var Slider = React.createClass({
_updateWithChangeEvent: function(e, percent) {
if (this.state.percent === percent) return;
this.setPercent(percent);
if (this.props.onChange) this.props.onChange(e, this.state.value);
var value = this._percentToValue(percent);
if (this.props.onChange) this.props.onChange(e, value);
},

_percentToValue: function(percent) {
return percent * (this.props.max - this.props.min) + this.props.min;
}

});
Expand Down

0 comments on commit ef7adeb

Please sign in to comment.