Allow zooming on very thin selection boxes #1482
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #1407
I've changed the selection validation logic in
SelectToZoom
to compute the manahattan distance. I'm no longer converting the selection to aBox
and calling#hasMinSize
, sinceVector3
already provides a method for computing the manhattan distance.Of course there are always edge cases to deal with and unforeseen consequences...
The edge case is zooming on a 0-width or 0-height box. To deal with this, I had a few options:
hasMinSize(1)
check in thevalidate
prop.transform
prop.computeZoomSelection
a bit messy.The unforeseen consequence had to do with
SvgRect
:We work around the fact that SVG doesn't support drawing
inside
strokes by drawing a slightly smaller and slightly offset rectangle. The problem is that empty rectangles are simply hidden by browsers, so anySvgRect
with a width or height lower than or equal to their stroke width would simply vanish.This behaviour wasn't too problematic when we couldn't zoom on a very thin box, since at the point the selection box disappeared, the zoom box was invalid — so releasing the mouse did nothing. So I had to find a fix.
I decided to replace
rect
withpath
, which seems to work great, fortunately.