From dd469b4ff7f9945864aa2da0e23fd466334884aa Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 21 May 2018 19:27:23 +0200 Subject: onchange --- app/client/common/slider.component.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/client/common') diff --git a/app/client/common/slider.component.js b/app/client/common/slider.component.js index fe27c84..174877d 100644 --- a/app/client/common/slider.component.js +++ b/app/client/common/slider.component.js @@ -16,7 +16,7 @@ class Slider extends Component { this.handleRange = this.handleRange.bind(this) } componentWillReceiveProps(nextProps) { - const next_value = nextProps.opt[nextProps.name] + const next_value = nextProps.value || nextProps.opt[nextProps.name] if (next_value !== this.state.value) { this.setState({ value: next_value }); } @@ -34,7 +34,7 @@ class Slider extends Component { if (old_value !== new_value) { this.setState({ value: new_value }) this.props.actions.set_param(this.props.name, new_value) - this.props.onChange(new_value) + this.props.onChange && this.props.onChange(new_value) } clearTimeout(this.timeout) } @@ -50,7 +50,7 @@ class Slider extends Component { this.setState({ value: new_value }) this.timeout = setTimeout(() => { this.props.actions.set_param(this.props.name, new_value) - this.props.onChange(new_value) + this.props.onChange && this.props.onChange(new_value) }, SLIDER_THROTTLE_TIME) } render(){ -- cgit v1.2.3-70-g09d2