-
Notifications
You must be signed in to change notification settings - Fork 6.8k
bug(MatDrawer): Resizing drawer after 'mat-drawer-transition' class added causes animation lag #24119
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
Comments
I think that this is the problem. Since you're calling |
@crisbeto I don't know what you mean by compounding the animations. The I have tried all different ways to get this to work correctly and I am not convinced that the api for autosizing the drawer works correctly or at least doesn't work correctly when an animation is applied to the drawer width. I would appreciate a little guidance from the team on whether this api is meant to be used like this. |
|
Okay, I understand this now. I misunderstood how this would work. I still don't understand why the public api That being said there is still an issue with adding an animation to the width of the drawer but after search some more I realize that this is a long-standing issue as seen here #9837 (comment) As commented in that issue #9837 (comment) I am using the I am closing this as it is now a duplicate of another issue. |
For context, |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Is this a regression?
The previous version in which this bug was not present was
No response
Description
Currently the MatDrawer component is able to resize the content when the size of the drawer changes. This works great unless you add an animation to the drawer's width after the 'mat-drawer-transition' class has been added to the drawer container. After the class has been added the animation for the drawer content lags behind the animation for the drawer width.
Currently all of the hacks and work arounds I have seen for this behavior don't take into account resizing after the drawer has been toggled open and closed. Toggling the drawer adds a class called 'mat-drawer-transition' to the drawer container in the
_watchDrawerToggle
method of MatDrawerContainer. This class adds the css transitions for the drawer content and backdrop and these animations seem to cause the issue. Also setting theautosize
property on the drawer container does nothing in this instance.In the sample I provided I use an inner component in the drawer to do the resizing. This encapsulates the behavior and causes the drawer itself to resize. I also use a ResizeObserver (because it is almost 2022 and we don't support IE anymore) to update the content margins continually during the width animation. I have also not used the
autosize
property on the drawer container because it doesn't do anything to fix the issue and the content margins are being updated during the width animation.In my experiments removing the 'mat-drawer-transition' class after the drawer open/close animation completes fixes the issue.
Reproduction
Stackblitz of the issue is here: https://stackblitz.com/edit/angular-ivy-ftfajt?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce:
To see it working properly uncomment the code in the AppComponent openChanged method and run steps again.
Expected Behavior
The animation for the drawer should not lag behind the animation for the content.
Actual Behavior
The animation for the content lags behind the animation for the drawer when the 'mat-drawer-transition' class is present on the MatDrawerContainer.
Environment
The text was updated successfully, but these errors were encountered: