Don't treat slider handles as background clicks

This commit is contained in:
adroitwhiz 2020-09-30 20:03:02 -04:00
parent a436c6f3a8
commit 1d5b032c3d

View file

@ -47,6 +47,9 @@ class SliderComponent extends React.Component {
} }
handleClickBackground (event) { handleClickBackground (event) {
// Because the slider handle is a child of the "background" element this handler is registered to, it calls this
// when clicked as well. We only want to change the slider value if the user clicked on the background itself.
if (event.target !== this.background) return;
// Move slider handle's center to the cursor // Move slider handle's center to the cursor
this.handleClickOffset = HANDLE_WIDTH / 2; this.handleClickOffset = HANDLE_WIDTH / 2;
this.props.onChange(this.scaleMouseToSliderPosition(event)); this.props.onChange(this.scaleMouseToSliderPosition(event));