Skip to content

Commit

Permalink
Merge branch 'master' of github.com:xinthink/react-native-material-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
xinthink committed Mar 27, 2016
2 parents 94a470e + 019db5b commit b1f8db6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ const SliderWithRange = mdl.RangeSlider.slider()
max: curValue.max,
})
}
onConfirm={(curValue) => {
console.log("Slider drag ended");
console.log(curValue);
}}
/>
```

Expand Down
18 changes: 16 additions & 2 deletions lib/mdl/RangeSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RangeSlider extends Component {
this._onThumbRadiiUpdate(nextProps);
}

// property initializers begin
// region Property initializers
_onTrackLayout = ({ nativeEvent: { layout: { width } } }) => {
if (this._trackTotalLength !== width) {
this._trackTotalLength = width;
Expand All @@ -71,6 +71,8 @@ class RangeSlider extends Component {
ovrRef.confirmMoveTo(this._validateMove(dx, px, width));
this._overriddenThumb = null;
});

this._emitConfirm();
};

// Respond to Grant and Move touch gestures
Expand All @@ -85,7 +87,7 @@ class RangeSlider extends Component {
});
};

// property initializers end
// endregion

// Throw error if preset ranges are invalid
_setRange(range) {
Expand Down Expand Up @@ -144,6 +146,15 @@ class RangeSlider extends Component {
}
}

_emitConfirm() {
if (this.props.onChange) {
this.props.onChange({
min: this._toSliderScale(this._range.min),
max: this._toSliderScale(this._range.max),
});
}
}

// Internal update of ranges. Values should be to "Pixel Scale"
_updateValue(values) {
if (!this._trackTotalLength) {
Expand Down Expand Up @@ -358,6 +369,9 @@ RangeSlider.propTypes = {

// Callback when value changed
onChange: PropTypes.func,

// Callback when the value range is confirmed
onConfirm: PropTypes.func,
};

// ## <section id='defaults'>Defaults</section>
Expand Down

0 comments on commit b1f8db6

Please sign in to comment.