Fix SVG alignment and click box#273
Merged
AndreasArvidsson merged 2 commits intomainfrom Sep 11, 2021
Merged
Conversation
pokey
commented
Sep 11, 2021
Comment on lines
+166
to
+167
| margin: `-${svgHeightPx}px -${svgWidthPx}px 0 0`, | ||
| width: `${svgWidthPx}px`, |
Member
Author
There was a problem hiding this comment.
No need to play games with span width anymore because we now align to the left side of the char
Comment on lines
-278
to
-280
| ((originalViewBoxWidth / hatWidthToCharacterWidthRatio) * | ||
| fontMeasurements.characterWidth) / | ||
| svgWidthPx; |
Member
Author
There was a problem hiding this comment.
This was the dumb mistake. We need to adjust from char width to svg width, not the other way around 😅
Comment on lines
+277
to
+278
| const newViewBoxX = | ||
| (-(characterWidth - hatWidthPx) * (newViewBoxWidth / svgWidthPx)) / 2; |
Member
Author
There was a problem hiding this comment.
Since we're left-aligned, we basically need to shift right by (characterWidth - hatWidthPx) / 2, translated to svg view box space (newViewBoxWidth / svgWidthPx)
AndreasArvidsson
approved these changes
Sep 11, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I adjusted the measurements to fix the math bug for my setup, but unfortunately different users will be affected proportional to the square of the ratio of their character width to the ceiling of the width, so they'll unfortunately need to do their own tweaking if they've adjusted their defaults
Note that the hats have moved up very slightly, but it is minor, and we will tweak these heights in #269 anyway
Fixes #110
Fixes #92
And possibly #78