Skip to content

Fix SVG alignment and click box #273

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

Merged
merged 2 commits into from
Sep 11, 2021

Conversation

pokey
Copy link
Member

@pokey pokey commented Sep 11, 2021

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

image

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

Comment on lines +166 to +167
margin: `-${svgHeightPx}px -${svgWidthPx}px 0 0`,
width: `${svgWidthPx}px`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're left-aligned, we basically need to shift right by (characterWidth - hatWidthPx) / 2, translated to svg view box space (newViewBoxWidth / svgWidthPx)

@pokey pokey marked this pull request as ready for review September 11, 2021 17:02
@AndreasArvidsson AndreasArvidsson merged commit 1848837 into main Sep 11, 2021
@AndreasArvidsson AndreasArvidsson deleted the fix-svg-alignment-and-click-box branch September 11, 2021 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SVG hat obstructs click target area Fix decoration appearing after GitLens Current Line Blame
2 participants