diff --git a/src/components/slider/Slider.js b/src/components/slider/Slider.js index 67ba761dab..d5d664b700 100644 --- a/src/components/slider/Slider.js +++ b/src/components/slider/Slider.js @@ -104,7 +104,11 @@ export class Slider extends Component { if (!this.sliderHandleClick) { this.updateDomData(); - this.setValue(event); + const value = this.setValue(event); + + if (this.props.onSlideEnd) { + this.props.onSlideEnd({ originalEvent: event, value }); + } } this.sliderHandleClick = false; @@ -211,41 +215,44 @@ export class Slider extends Component { newValue = Math.floor(newValue); } - this.updateValue(event, newValue); + return this.updateValue(event, newValue); } updateValue(event, value) { - let newValue = parseFloat(value.toFixed(10)); + let parsedValue = parseFloat(value.toFixed(10)); + let newValue = parsedValue; if (this.props.range) { if (this.handleIndex === 0) { - if (newValue < this.props.min) - newValue = this.props.min; - else if (newValue > this.value[1]) - newValue = this.value[1]; + if (parsedValue < this.props.min) + parsedValue = this.props.min; + else if (parsedValue > this.value[1]) + parsedValue = this.value[1]; } else { - if (newValue > this.props.max) - newValue = this.props.max; - else if (newValue < this.value[0]) - newValue = this.value[0]; + if (parsedValue > this.props.max) + parsedValue = this.props.max; + else if (parsedValue < this.value[0]) + parsedValue = this.value[0]; } - let newValues = [...this.value]; - newValues[this.handleIndex] = newValue; + newValue = [...this.value]; + newValue[this.handleIndex] = parsedValue; if (this.props.onChange) { this.props.onChange({ originalEvent: event, - value: newValues + value: newValue }); } } else { - if (newValue < this.props.min) - newValue = this.props.min; - else if (newValue > this.props.max) - newValue = this.props.max; + if (parsedValue < this.props.min) + parsedValue = this.props.min; + else if (parsedValue > this.props.max) + parsedValue = this.props.max; + + newValue = parsedValue; if (this.props.onChange) { this.props.onChange({ @@ -254,6 +261,8 @@ export class Slider extends Component { }); } } + + return newValue; } componentWillUnmount() {