Repository navigation
fix: Correct native matrix translation indices - #529
Open
ZainnQureshii wants to merge 1 commit into
Open
ZainnQureshii wants to merge 1 commit into
ZainnQureshii wants to merge 1 commit into
Conversation
parseTransform expanded the CSS 2D matrix(a, b, c, d, tx, ty) into a 4x4 matrix with tx and ty at indices 8 and 9. React Native reads the 16 values column-major, with translation at indices 12 and 13 (Transform.cpp sets them there for translate), so the translation was dropped. Place tx and ty at 12 and 13 and keep index 10 as 1.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseTransformexpands CSSmatrix(a, b, c, d, tx, ty)into the 16-value native matrix, but it puttxandtyat indices 8 and 9 (packages/react-strict-dom/src/native/css/parseTransform.js). React Native reads that array column-major with translation at indices 12 and 13 (thetranslatecase inReactCommon/react/renderer/graphics/Transform.cppsetsmatrix[12]andmatrix[13]), and the CSS Transforms spec mapsmatrix(a, b, c, d, e, f)tomatrix3d(a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, e, f, 0, 1). So on native any translation inside a 2Dmatrix()was dropped.For
matrix(1, 0, 0, 1, 12, -34)the output goes from[1, 0, 0, 0, 0, 1, 0, 0, 12, -34, 1, 0, 0, 0, 0, 1]to[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 12, -34, 0, 1].The existing
matrixparser expectation is updated, and there are two new regression tests: one on the parser and one throughcss.create()on anhtml.div.Test plan
With the fix reverted and the tests kept: 3 failed, 108 passed. With the fix: 111 passed.
19 suites, 899 tests passed. Prettier and ESLint are clean on the changed files. Not run: device rendering and Flow.
Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code