-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VictoryBrushContainer: add a threshold for mouseMove events to avoid accidental minimal draws #1443
VictoryBrushContainer: add a threshold for mouseMove events to avoid accidental minimal draws #1443
Conversation
…accidental minimal draws
if ( | ||
(!allowResize && !allowDrag) || | ||
!this.withinBounds({ x, y }, fullDomainBox) || | ||
!this.hasMoved({ ...targetProps, x2: x, y2: y }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently a check for whether the mouse moved in onMouseUp
. I think the check should stay there, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do it there initialy, but the drawing happens even before the mouseup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you mean. Since this has to run on every mouse move, it would be great to be able to short circuit it for users who don't have a mouseMoveThreshold
defined. Like (targetProps.mouseMoveThreshold && !this.hasMoved({ ...targetProps, x2: x, y2: y }))
It might also be nice to reuse this logic in onMouseUp
instead of the more naive check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reuse this logic in
onMouseUp
Why? x2
won't be different from x1
unless onMouseMove
handling actually happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General preference for a named function like hasMoved
, but I guess (x1 === x2 || y1 === y2)
is already pretty concise and clear.
@@ -45,7 +45,8 @@ export const brushContainerMixin = (base) => | |||
stroke: "transparent", | |||
fill: "transparent" | |||
}, | |||
handleWidth: 8 | |||
handleWidth: 8, | |||
mouseMoveThreshold: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value for mouseMoveThreshold
should be 0
@Hypnosphi Thanks! I'll get a patch out for you tonight :) |
When using
defaultBrushArea: 'move'
, it's too easy to accidentally draw a minimal selection when in fact you just click the empty area. I've added a customisable threshold for handling mouseMove with default of 2pxProbably related: #1058