Closed alexluong closed 6 years ago
@alexluong Let's see ...
There are dozens of ways. You can spring your elements individually or do something with the parent container: https://codesandbox.io/s/186yqz18n7 A transition and a simple flex layout (each item on flex:1) would probably be the best.
It depends on the use case. When css is enough use css. If it isn?t or if it gets increasingly hard, use RS. I ship two libs myself with a RS dependency: animated-tree and mauerwerk, i don't think i'd like to do this with css because it would be messy if not impossible in some cases. Also, users can use their own configurations and effects easily.
I'd always use native + animated.el when possible. Unless you animate text, numbers or other foreign components. Native is faster and doesn't re-render the component. Imagine someone uses your lib and wraps a huge tree of components inside. If react would attempt to render this 60fps, it would be very slow.
Hi @drcmda. I tweeted to you earlier about some questions I may have. Thanks a lot for taking the time to response and offer to help. I got a few different questions here. I would really appreciate it if you help me with those. So here goes:
Say I have 2 buttons next to each other, each 50% of the width. Whenever I click on one, I want it to animate to replace the other button and take the full width of the container. It seems like a common use case for me, but I'm not sure how to do it. Here's a codesandbox I set up for it: https://codesandbox.io/s/5k4pzymqon.
If I'm writing a UI library or a reusable React component (publish to npm), would you recommend using
react-spring
as the animation framework for it, or should I try to do everything withtransition
andanimation
CSS? I'm not entirely sure what would be best.If I'm abstracting the animation layer out of a UI component, would it still be a good idea to use
animated.element
to every elements in the UI component so I can make use ofnative rendering
? For example, I have anAnimatedModal
component that useModal
component. ShouldModal
be comprised ofanimated.div
so thatAnimatedModal
can usenative rendering
, although maybeDifferentModal
may not have any animation at all?Thank you very much for offering to help. I've been using
react-spring
for a while and absolutely love it. If there's any issue that may be a bit more user friendly, may be I can help out.