in public/components/Charts/Highlight/Highlight.js [246:274]
stopBrushing(e) {
const { brushing, dragging, brushArea } = this.state;
// Quickly short-circuit if the user isn't brushing in our component
if (!brushing && !dragging) {
return;
}
const { onBrushEnd, onDragEnd, drag } = this.props;
const noHorizontal = Math.abs(brushArea.right - brushArea.left) < 5;
const noVertical = Math.abs(brushArea.top - brushArea.bottom) < 5;
// Invoke the callback with null if the selected area was < 5px
const isNulled = noVertical || noHorizontal;
// Clear the draw area
this.setState({
brushing: false,
dragging: false,
brushArea: drag ? brushArea : { top: 0, right: 0, bottom: 0, left: 0 },
startLocX: 0,
startLocY: 0,
dragArea: drag && !isNulled && brushArea,
});
if (brushing && onBrushEnd) {
onBrushEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null);
}
if (drag && onDragEnd) {
onDragEnd(!isNulled ? this._convertAreaToCoordinates(brushArea) : null);
}
}