Skip to content

Plot outputs incorrectly sized inside scaled outputs - #4139

Merged
jcheng5 merged 7 commits into
mainfrom
plot-size-with-zoom
Dec 8, 2024
Merged

jcheng5 merged 7 commits into
mainfrom
plot-size-with-zoom

Conversation

@jcheng5

@jcheng5 jcheng5 commented Oct 1, 2024 •

Copy link
Copy Markdown
Member

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

@gadenbuie gadenbuie left a comment

Copy link
Copy Markdown
Member

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.

Comment thread srcts/src/utils/index.ts Resolved
@gadenbuie gadenbuie added this to the Next Release milestone Nov 13, 2024
@jcheng5
jcheng5 merged commit 5bf0701 into main Dec 8, 2024
@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