-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
feat: Use animation matrix For Skew prop #38494
Conversation
Hi @xxrlzzz! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Original Effect: original.mp4Fixed Effect: fixed.mp4 |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Base commit: 8ff05b5 |
...es/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
for (int transformIdx = 0, size = transforms.size(); transformIdx < size; transformIdx++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to process all transforms in order, you can't have separate loops for translate and other properties, as it may cause the resulting matrix to be incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't sure disorder of properties will leds a incorrect result matrix, since every property are handled by matrix multiply rather direct set matrix element.
The reason for separate translate
and other properties is we need to know the real center of the view to set origin of rotate and scale (default origin is the top-left point of the view, rather center of the view like it used to be)
e2eeaaf
to
14e6815
Compare
14e6815
to
87482db
Compare
I note there is already has We can use implementation form AdnroidX transition library to access this api saftly. |
Compatibility test (device with api before android Q) 2023-07-26.19.38.56.mov2023-07-26.19.18.00.mov |
87482db
to
5ba54ff
Compare
This pr is current depend on #38558 to solve unable to get view width, height problem |
@xxrlzzz Is this PR still relevant? As I understand it, the PR on which this one depends was merged. |
ok, I will continue this PR ASAP. |
5ba54ff
to
faa408e
Compare
without with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Sorry for the delay on reviewing this, we should try to get this imported.
float[] offsets = getTranslateForTransformOrigin(viewWidth, viewHeight, transformOrigin); | ||
float originX = viewWidth / 2, originY = viewHeight / 2; | ||
if (offsets != null) { | ||
originX += offsets[0]; | ||
originY += offsets[1]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should account for this by doing a transform as a first step and then the reverse transform as the last step, similar to processTransform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
fe24a84
to
74cc237
Compare
While the implementation seems right here, I'm a bit concerned about adopting this given the Android SDK docs
There's also significant complexity being introduced here in terms of what code paths can potentially triggered. Adding a different transform property to the array can significantly change how the transform is set. |
Summary:
This PR intent to solve Skew property on Android: #27649.
After android Q, we can use
setAnimationMatrix
to implement cssTransform
. (This api can also be accessed before android Q)Old method for implement
Transform
is maintain a local 4*4 matrix, after finish handle all properties decompose back to a 3*3 matrix, and set back to android view use apisetTranslation
,setRotation
,setScale
. There is no such a api to direct setskew
property. But the native layer of android is using a 3*3 skia matrix to handle all those transform properties.So we could handle those
Transform
on our side and callsetAnimationMatrix
directly.There is also some shortage for this fix, a 3*3 matrix is unable to handle 3d rotation and perspective. We will fail back to old implementation when those property is used.
Note this pr may have a conflict with #37606.
Changelog:
[ANDROID] [Fixed] - Implement of css
Transform
property.Test Plan:
RNTester App: Apis -> Animated -> Transform Styles.