Skip to content
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

Plot outputs incorrectly sized inside scaled outputs #4139

Merged
merged 7 commits into from
Dec 8, 2024

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Oct 1, 2024

Fixes #4135.

CSS zoom property affects el.getBoundingClientRect() but not el.offsetWidth/Height. When reporting sizes of outputs from client to server, we need to back out the CSS zoom because those sizes are used as CSS width/height, which will be affected by zoom.

(Note that something similar happens with CSS transforms but we don't have a good way to deal with them)

Safari doesn't support el.currentCSSZoom, but it also doesn't have the problem of el.getBoundingClientRect() and offset size not matching when zoom is applied. We're hoping that these two facts are not a coincidence and that any browser that treats those sizes as different also gives us el.currentCSSZoom.

getBoundingClientRect is also used in the coordmap for plots. @gadenbuie and I verified that coordmaps already work well even when zoom is applied. The coords_css uses el.getBoundingClientRect() without backing out the zoom; I'm convinced this is correct/how it has to be.

@jcheng5 jcheng5 requested a review from gadenbuie October 1, 2024 20:17
CSS zoom property affects el.getBoundingClientRect() but not
el.offsetWidth/Height. When reporting sizes of outputs from
client to server, we need to back out the CSS zoom because
those sizes are used as CSS width/height, which will be
affected by zoom.

(Note that something similar happens with CSS transforms but
we don't have a good way to deal with them)
@jcheng5 jcheng5 force-pushed the plot-size-with-zoom branch from 5eb3171 to 7cadc7a Compare October 1, 2024 20:22
Copy link
Member

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

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

LGTM! It seems that currentCSSZoom will be available when we update typescript to >= 5.5.2.

srcts/src/utils/index.ts Outdated Show resolved Hide resolved
@gadenbuie gadenbuie added this to the Next Release milestone Nov 13, 2024
@jcheng5 jcheng5 merged commit 5bf0701 into main Dec 8, 2024
11 checks passed
@jcheng5 jcheng5 deleted the plot-size-with-zoom branch December 8, 2024 09:25
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.

Plot outputs incorrectly sized inside scaled outputs
2 participants