-
Notifications
You must be signed in to change notification settings - Fork 658
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
[css-grid] Grid Item Position Transitions #6736
Comments
In my mind this could perhaps be an extra property on the Grid Container to activate this behavior. Borrowing from .grid {
grid-item-reflow-behavior: smooth;
} (property name to be bikeshed) But I'm sure other folks / the WG has a better solution for this, should this be considered ;) |
On Twitter it was pointed out that this approach, just like Perhaps a new keyword to be used in conjunction with the already existing .grid-item {
transition: reflow 1s ease-in-out;
} |
I'm wary of special casing grid for this. It seems to me to be just as common to want to animate flex box etc. In general I think it would be great if browsers could interpolate between layouts since the browser already knows the before and after positions of the elements when updating layout. Doing it in JS requires recording the positions of each element before and after and generating appropriate (Not only that, if you get an update while the previous animations are still in play, you need to temporarily disable the animations so you can accurately get the un-animated end position--something which an API to get the un-animated computed style could help with.) See https://twitter.com/mhartington/status/1449031009052368896 for a recent example of this use case. I believe shared element transitions is the first step in that direction but it would be great to see what use cases are not well served by that and consider how we might address them in future. |
I was really hoping to use grid to avoid using javascript to animate this effect here. By changing the highlight's grid position which moves from one grid cell to another as the user clicks. I got it working except for the animation. So I had to use javascript instead to transition the translation and width. |
When changing a Grid Container's
grid-gap
,grid-template-columns
or when changing a Grid Item'sgrid-column
,grid-row
, Grid Layout will do its thing and reposition the Grid Items as space becomes available/unavailable.Adjusting things such as
grid-gap
can already be done via transition/animation, but a Grid Item switching Row/Column will happen instantaneously.See a demo such as https://codepen.io/bramus/pen/ad379eb0cb8c4e11e0eb17e3e751d58c?editors=1010 where you can alter these properties. Notice how the grid-gap gets transitions but the grid items (if too less space is available) jump from one row to the other.
The demo listed above is a fork from https://codepen.io/aholachek/pen/VXjOPB, which uses a JS-library named
animate-css-grid
to smoothly animate the Grid Items as the Grid changes.It would be nice if this kind of behavior could be achieved without any JS.
The text was updated successfully, but these errors were encountered: