Skip to content

fix: positioning element inside viewbox - #2758

Merged
kacperzolkiewski merged 2 commits into
software-mansion:mainfrom
kacperzolkiewski:fixPreserveAspectRatio
Oct 8, 2025
Merged

kacperzolkiewski merged 2 commits into
software-mansion:mainfrom
kacperzolkiewski:fixPreserveAspectRatio

Conversation

@kacperzolkiewski

@kacperzolkiewski kacperzolkiewski commented Sep 2, 2025 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes: #2078
Fixes: #1343

When preserveAspectRatio !== "none", the initial translateX and translateY values should be calculated after adjusting scaleX and scaleY with Math.min or Math.max (depending on the meetOrSlice value).
Previously translateX and translateY were computed before applying this adjustment using the raw scaleX and scaleY. This caused incorrect positioning of the content.

Test Plan

Run examples from issues: #2078 and #1343

Compatibility

OS Implemented
iOS ✅
MacOS ✅
Android ✅
Web ❌

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)
  • I added a test for the API in the __tests__ folder

@kacperzolkiewski
kacperzolkiewski merged commit 11209a0 into software-mansion:main Oct 8, 2025
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.

content is not center if the viewbox origin is not (0,0) Unexpected preserveAspectRatio results

2 participants