mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 03:22:11 +00:00
Slider's callback props defined optional
This commit is contained in:
parent
f47178f49c
commit
e852ad9ade
1 changed files with 12 additions and 6 deletions
|
|
@ -43,18 +43,24 @@ class Slider extends Component {
|
||||||
|
|
||||||
onBlur = () => {
|
onBlur = () => {
|
||||||
this.releaseThumb();
|
this.releaseThumb();
|
||||||
this.props.onCancel();
|
if (typeof this.props.onCancel === 'function') {
|
||||||
|
this.props.onCancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseUp = ({ clientX: mouseX, clientY: mouseY }) => {
|
onMouseUp = ({ clientX: mouseX, clientY: mouseY }) => {
|
||||||
this.releaseThumb();
|
this.releaseThumb();
|
||||||
const slidingValue = this.calculateSlidingValue({ mouseX, mouseY });
|
const slidingValue = this.calculateSlidingValue({ mouseX, mouseY });
|
||||||
this.props.onComplete(slidingValue);
|
if (typeof this.props.onComplete === 'function') {
|
||||||
|
this.props.onComplete(slidingValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseMove = ({ clientX: mouseX, clientY: mouseY }) => {
|
onMouseMove = ({ clientX: mouseX, clientY: mouseY }) => {
|
||||||
const slidingValue = this.calculateSlidingValue({ mouseX, mouseY });
|
const slidingValue = this.calculateSlidingValue({ mouseX, mouseY });
|
||||||
this.props.onSlide(slidingValue);
|
if (typeof this.props.onSlide === 'function') {
|
||||||
|
this.props.onSlide(slidingValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onStartSliding = ({ clientX: mouseX, clientY: mouseY, button }) => {
|
onStartSliding = ({ clientX: mouseX, clientY: mouseY, button }) => {
|
||||||
|
|
@ -90,9 +96,9 @@ Slider.propTypes = {
|
||||||
minimumValue: PropTypes.number.isRequired,
|
minimumValue: PropTypes.number.isRequired,
|
||||||
maximumValue: PropTypes.number.isRequired,
|
maximumValue: PropTypes.number.isRequired,
|
||||||
orientation: PropTypes.oneOf(['horizontal', 'vertical']).isRequired,
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']).isRequired,
|
||||||
onSlide: PropTypes.func.isRequired,
|
onSlide: PropTypes.func,
|
||||||
onComplete: PropTypes.func.isRequired,
|
onComplete: PropTypes.func,
|
||||||
onCancel: PropTypes.func.isRequired
|
onCancel: PropTypes.func
|
||||||
};
|
};
|
||||||
Slider.defaultProps = {
|
Slider.defaultProps = {
|
||||||
value: 0,
|
value: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue