-
Notifications
You must be signed in to change notification settings - Fork 26.3k
docs: add guide for using native CSS animations #60984
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
docs: add guide for using native CSS animations #60984
Conversation
Deployed adev-preview for 961cb6c to: https://ng-dev-previews-fw--pr-angular-angular-60984-adev-prev-c22fgdvu.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
7d06779
to
385bc59
Compare
Does this also allow transitions from and to auto height, between display hidden and flex/block/etc? Because that is currently the only reason I use the animations package, you can make it so that you do your transition and then close your animation by completely hide the element, or to show the element before doing the animation. And animating between auto-height depending on what is inside it, is also still a pain in the ass without a few new CSS features becoming mainstream. I feel that this is a bit too soon to completely dump the system before CSS has enough support for various items if that is not supported. And as far as I know with keyframes you don't have that yet? And with manually using transitionEnd eventlisteners is also not really all that clean. If Angular would replace this with directives around those transitions, it would make it a little cleaner since the adding/removing of eventlisteners is just tedious work that shouldn't be needed for this. And it also seems to me that if you want both enter and leave animations that are different, you also need more code than what makes sense. To me it seems that this animations module is better off being forked for those that still prefer doing it this way, over completely removing it. |
Hi, great job with the toturial!
|
...src/content/examples/animations/src/app/animations-package/increment-decrement.component.css
Outdated
Show resolved
Hide resolved
...src/content/examples/animations/src/app/animations-package/increment-decrement.component.css
Outdated
Show resolved
Hide resolved
adev/src/content/examples/animations/src/app/native-css/increment-decrement.component.ts
Outdated
Show resolved
Hide resolved
@kbrilla I chose not to make it fully 1:1, but close because some of the headings in the animation guide are either redundant or unnecessary in the case of pure CSS. I'll be adding a bit about animating to auto heights. On the view transitions front, I'd like to add more, but since scoped view transitions haven't landed yet, that'll be a future update. Per the hostbinding thing, I'll take a look. Thanks for the suggestion. |
@Martinspire Actually the CSS platform has already added support for animating the types of things you are mentioning. Take a look at |
Very cool. I didn't know support was already that far with those. I think we do need a few more examples then to highlight these features because I'm sure people will be forgetting it. Animating between 2 auto-height positions still seems like we need a better example for that too. There's also new CSS properties that can help with that, but I don't think we should be relying on CSS Grid to hack our way around it. Calc-size is coming but is still not there yet on Firefox and Safari, let alone older devices. Which is (to me) the moment where we can really drop this module. I just hope its not unsupported before that happens... |
6eab48b
to
a1b0dce
Compare
@Martinspire @kbrilla please take a look at this proof of concept regarding |
@waterplea Ok, more weird things after few more test runs. It appears that img 1 takes place every time new stackblitz is opened. Refreshing preview does not help. Only changing code make the img 2 take place. But refreshing preview breaks example again. |
@kbrilla regarding first weird thing — you just got there in between me testing two different ideas :) The warnings are probably due to old stackblitz preset that does not work well with hot replacement. The multiple overrides is an interesting thing, we need it to make sure to test against current element. Maybe after removing the element we can return it back to the previous value, this way it will only have as many overrides as we currently have children with potential leave animation 🤔 EDIT: Updated stackblitz, now it should only override it once per child and return it back to the previous state upon removal, also no more potential memory leak with addEventListener |
I like that it works as good as it does, ideally though, it should work without overriding anything in |
Yes, one other important thing is that it requires setting |
06c4655
to
90d7f6e
Compare
contentPath: 'guide/animations/css', | ||
}, | ||
{ | ||
label: 'Route transition animations', |
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 in a lot of people's minds "transition" and "animation" are synonymous. Maybe "Route change animations" or "Animating a route change"?
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.
Possibly though we've used this exact label for probably a year plus at this point, and changing it would possibly break links to it.
90d7f6e
to
bea3fce
Compare
Ok, clear, but shouldn't Angular still have the groundwork to easily add this to ones project without reinventing the wheel? Can't the animations module continue as a library for providing either barebone setup for adding animations or more detailed one that can perhaps be lazyloaded and cherry picked? But yeah, animating items that are shown/hidden based on @if flow and then still properly do animations on entry/leave is something I would expect the framework to help me with so I don't need to reinvent it, even though the code could be small. Because by providing it, there is a chance it will become a standard and thus another "opinionated and batteries included" feature added to angular... |
This adds a guide for how to switch from the angular animations package over to native CSS animations.
bea3fce
to
961cb6c
Compare
This PR was merged into the repository by commit f054c00. The changes were merged into the following branches: main, 20.0.x |
This adds a guide for how to switch from the angular animations package over to native CSS animations. PR Close #60984
css usage was introduced by angular#60984
This adds a guide for how to switch from the angular animations package over to native CSS animations. This is a first draft. Questions:
Here's a quick link to the guide in the adev preview: https://ng-dev-previews-fw--pr-angular-angular-60984-adev-prev-c22fgdvu.web.app/guide/animations/migration