[codex] Keep canvas size stable across rerenders - #89
Conversation
545327b to
39294a0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39294a0e69
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| var width = canvas.width, | ||
| height = canvas.height; | ||
| var width = parseFloat(canvas.style.width) || canvas.width, |
There was a problem hiding this comment.
Avoid parsing non-pixel CSS widths as raw numbers
Reading canvas.style.width with parseFloat(...) treats values like "100%" or "12em" as pixel counts (100, 12), so render() can immediately shrink the logical canvas and then overwrite the style to that incorrect px value. This is a regression from using canvas.width directly and breaks canvases sized via non-px CSS units when this path runs in Kothic.render.
Useful? React with 👍 / 👎.
Signed-off-by: Darafei Praliaskouski <me@komzpa.net>
39294a0 to
b28a5c5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b28a5c5934
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (pixelMatch) { | ||
| return parseFloat(pixelMatch[1]); | ||
| } |
There was a problem hiding this comment.
Respect updated canvas width/height attributes on rerender
Reading pixel style.width/style.height first makes rerenders ignore caller-driven size changes via canvas.width/canvas.height. After the first HiDPI render, the code stores inline "...px" styles; on later renders this branch returns the old style value and overwrites the backing store back to the previous size, so programmatic canvas resize no longer works. In practice, setting canvas.width = 300 between renders is discarded and the canvas snaps back to the old dimensions.
Useful? React with 👍 / 👎.
Summary
Kothic.render(...)calls on the same canvasFixes #51.
Validation