-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: animated component style prop accepts transform functions #782
Conversation
looks great imo |
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! Just need to add more tests and get the current test to actually run (there's a transpiling issue with Jest). I got types working, and cleaned up a little. :)
a7b7db7
to
04be6b3
Compare
@aleclarson I think I've fixed the transpiling issue, now animated.test.tsx properly runs through tests... but fails. |
Ok, now at least in my case, all tests but the one that concerns this PR pass properly. |
More tests needed:
|
Will do this tonight. I already feel there’s an issue with |
Does |
I don't think there's any unit that would be added to |
Yeah, add a test please. There's no special case like you added for Also, I don't think 286d21e and de22f80 are necessary. What made you think they were? The |
Sure I can add a test, but
Hm
|
The public API never exposes |
I'm not a TS expert, I'm not exactly sure what I should do Alec, sorry... Are you saying I should replace |
Shortcut props include: - x/y/z - translate/translateX/translateY/translate3d - rotate/rotateX/rotateY/rotate3d - scale/scaleX/scaleY/scale3d - skew/skewX/skewY - matrix/matrix3d These props and the "transform" prop are combined (in order of appearance) into a single "transform" string. This feature is for "@react-spring/web" only. Co-Authored-By: Alec Larson <[email protected]> Co-Authored-By: Paul Henschel <[email protected]>
Co-Authored-By: David Bismut <[email protected]>
e749ad3
to
5ce760c
Compare
Great work, @dbismut! 🎉 |
A lot was done by @drcmda but I’m happy to take credit for him 😅 |
Hello guys, It seems that this feature does not work with the property It creates a regression as it does not work also with the old syntax. |
@drcmda hopefully #796 should fix this. Good catch @VincentCtr! |
Description
This pull requests allows passing transform functions to the
style
prop of a webanimated
component.Before
Currently, most web-based animations deal with the
transform
style attribute. Becausetransform
is a string composed of transform functions, it was necessary to interpolateAnimatedValue
as in:Or even more cumbersome:
After
The
style
prop would accept all transform functions (with the exception ofperspective
that would conflict with the native style attribute of the same name), plusx, y, z
as shortcuts fortranslate3d(x,y,z)
. Moreover, defaultpx
anddeg
units would be added to unit-less values.Just like other
style
attributes, transform functions can accept numbers, string, arrays,AnimatedValue
orAnimatedArray
.Moreover, if the overall transform is the identity the animated component will actually get a
transform: none
, which is necessary for fixed children to behave correctly.What remains to be done
Write test files!