not use one time binding for slider's callbacks

This commit is contained in:
NikolaBorislavovHristov 2018-12-19 17:25:46 +02:00
parent 623bae4794
commit e7e6732aa3

View file

@ -8,9 +8,6 @@ class Slider extends Component {
super(props);
this.orientation = props.orientation;
this.onSlide = props.onSlide;
this.onComplete = props.onComplete;
this.onCancel = props.onCancel;
}
shouldComponentUpdate(nextProps, nextState) {
@ -20,6 +17,18 @@ class Slider extends Component {
nextProps.className !== this.props.className;
}
onSlide = (value) => {
this.props.onSlide(value);
}
onComplete = (value) => {
this.props.onComplete(value);
}
onCancel = () => {
this.props.onCancel();
}
calculateSlidingValue = ({ mouseX, mouseY, sliderElement }) => {
const { x: sliderX, y: sliderY, width: sliderWidth, height: sliderHeight } = sliderElement.getBoundingClientRect();
const sliderStart = this.orientation === 'horizontal' ? sliderX : sliderY;