layoutTransition using height instead of transforms
See original GitHub issueComment moved from #268.
For the new layoutTransition was opted for a transform + useInvertedScale()
approach. There are several practical issues with this when trying to implement something like a auto growing container for items:
- It requires an extra child component just to be able to use
useInvertedScale()
- The inversion isn’t always exact, causing a wonky shifting effect (#274)
- There is often a subtle shift when the browser changes render mechanisms when the transition finishes and goes back to
transform: none
. Could be ‘fixed’ by doing something liketransform: rotate( .0001deg )
, but is a nasty workaround and not easy to do as the transform is applied inline. - Most importantly, the contents around the container do not follow the grow/shrink transition; they instantly snap into their new location, which looks odd (see https://codesandbox.io/s/framer-motion-sandbox-c7urd).
Describe the solution you’d like
An option to animate height
(+ overflow:hidden
) on the parent container instead of using transforms. Ideal would be if the overflow:hidden
would be applied automatically as well, and only while the animation is running.
Here is an example of the effect I like to achieve: https://codesandbox.io/s/example-growing-container-t3sq2 -> but of course, without setting fixed heights (it also animate when content changes).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:24
Top Results From Across the Web
Layout animations | Framer for Developers
Framer Motion can animate between any CSS layout by using performant transforms instead of the layout system. For example, this component is animated...
Read more >Android animate layout changed weight height - Stack Overflow
with equal weight. When I scroll down, I change weight of [layout 1] and [layout 2] . I want to know how is...
Read more >Animate layout changes using a transition - Android Developers
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending ......
Read more >Transition Property - Tailwind CSS
transition-transform, transition-property: transform; ... Use the transition-{properties} utilities to specify which properties should transition when they ...
Read more >How To Do CSS Transitions With Height: Auto - Carl Anderson
Instead of the smooth open and close you wanted, your element flashes to its new height. No smooth animation. As it turns out,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Rijk
We aren’t going to implement this because of the performance implications - I’d rather keep working on the transform approach.
The good news is you can cover a lot of layoutTransition use-cases simply by animating
height
viaanimate
. For instance in your use-case animatingheight: 20
andheight: 'auto'
.Also if you didn’t know, you know you can use
useInvertedScale
without a new component:Likewise there is an experimental API in the works for animating surrounding elements into their new positions. You can already use the
UnstableSyncLayout
component today:We will be trying to land on a better name ASAP.
Aah, sorry I should have seen that. Works like a charm man! https://codesandbox.io/s/example-growing-container-7xx10