-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Tabs] Add ability to disable animations #2706
Comments
Have you tried adding |
Yes but it works only partially. I have a nested |
Even if you put trackBy on both? |
Yes, even with two trackBys
I work with ngrx and the table gets rebuilt and sorted on every change, will have to rethink my data structure. In the meantime it would just be easier to disable the animation though. |
Ok my bad, I have been googling trackBy a little more and I implemented it incorrectly.
The tabs don't get rerendered anymore, thanks. |
Anyone knows how can I turn those animations off? I have "heavy" content inside tabs . It is fetched (and need to be fetched) from backend one every switch between tabs. Without animations it worked well but now it jam and freeze. I thought I could overrie CSS styles but it's defined inside Component decorator in tab-body. |
My workaround for this, for AngularJS: <md-tabs md-dynamic-height md-border-bottom md-selected="selectedIndex">
<md-tab label="one"></md-tab>
<md-tab label="two"></md-tab>
<md-tab label="three"></md-tab>
</md-tabs>
<section ng-if="selectedIndex === 0">ONE</section>
<section ng-if="selectedIndex === 1">TWO</section>
<section ng-if="selectedIndex === 2">THREE</section> |
@BrunnerLivio Awesome, I made some changes for the new version:
|
Yup, it's a bit bizarre that this option wasn't provided. It looks great the first time you see the animation, but soon drives you mad... |
@jelbourn |
+1. |
@mateuszwitkowski @jelbourn You can disable animation using @.disabled property which is introduced in angular 4.3.1. just add code to your component
or in your html
Here is working plnkr https://plnkr.co/edit/sVJM8H?p=preview |
Thanks @lokeshdaiya Because the tab buttons still have animations, but the tab content animation disabled as well! I wonder if there is any performance concern for using |
|
The tabs use the Angular animations framework for its animations. By using |
We should point out that certain components fail to work if you disable animation using the @.disabled property. E.g. the mat-sidenav component stops working: https://stackblitz.com/edit/angular-material2-sidenav-disable-animation-issue Issue: #7053 |
I'm facing issues with this approach. When I set [@.disabled]="true" for mat-tab-group and have a nested tab-group inside it disables animation for both, while I want only for the parent. Animation is also disabled for the expansion panel inside the second md-tab-group. |
[@.disabled]="true" works for components like tabs, but not works for Select component, any ideas? |
+1 works for me and now have a new thing to learn in [@.disabled]="true". Thanks |
cool |
lokeshdaiya had suggested a good solution. However, this feature should not be closed, because mat-tab-nav-bar + mat-tab-link does not have the sliding animation. It makes sense that matTab and matLink are consistent with or without sliding animation effect. Please reopen this feature request. |
Any new developer to the codebase will understand this attribute disables the tab component behavior, not the animations. Can we re-discuss implementing something like |
also as mentioned earlier that this breaks the sidenav component, |
@aldo-roman has a good solution. It'd be nice to have a global and/or component level setting to disable all of material's animations. +1 for this feature, or a way to do this easily. |
[@.disabled] is not a valid solution. Using [@.disabled] on mat-tab-group disabled all animations inside tabs. |
im unable to get [@.disabled]="true" working on mat-menu items. seems like this solution only works on certain elements... |
Any update on disabling animations in tabs? |
Another approach is a hackie with route navigation
This will be same as
And of corse you should use And also it'll be nice to restore current tab on page reload
And in html
|
I just find this astonishingly obtuse. The property Something so simple and obviously sought after shouldn't take a year and a half of discussion :-( |
If using the [@.disabled] workaround, is there a way to re-enable animations for components inside tabs? I've tried adding [@.disabled]="false" inside, but to no avail. |
I am going to second this as well. On large full page tabs, the animation is pretty poor. We should have the ability to turn them off explicitly or even better to assign animations and transitions to use with a noop animation to turn them off. |
Got sick of looking at those animations. Hopefully this is enough. |
Please add a toggle to disable animations, we deal with massive pages and having the entire page scroll either slows down the animation or makes it absolutely unusable. Using disabled = true doesn't work as it disables all animation inside the tab. Huge defect in my opinion. |
Still an open issue. Please re-open |
I tried to write a PR for this a couple months ago, honestly this issue isn't going to be resolved unless the mat-tab is rewritten from the ground up. It was designed only with the animations in mind, and unfortunately angular doesn't provide a way to disable animations for one component without it propagating down to other ones. |
@CodySchrank Thanks for the additional info. Helpful for some insight into the implementation, it's always easy for us on the outside to assume something is super easy when it isn't. With that said it's not that we want to DISABLE an animation using angular's funky [@.disabled] notation - it's that we just don't want the animation there in the first place. Surely that can't be so difficult. The tab isn't animating itself of its own free will - there's code there to do it! In fact - here I just fixed it in 30 seconds. This is all people are asking for :
I really don't want to duplicate the whole mat-tab control just to make this change. I have one tab control where people would routinely tab back and forth between two 'screens' and it's just a disaster for it to be animated. Still hoping for a change before I have to release it though. But what to say to my boss when he says 'make it not slide'. That's a days worth of work.... :-/ Really hope you can help make this happen :-) Thanks Oh and I don't think anyone is ever complaining about the other animations - like the way them tab headers move - that's very cool - it's just this one. |
@simeyla unfortunately your example doesn't work properly. Setting to null [@translateTab] property completely turns off animation and no more @translateTab.start and @translateTab.done events are fired. But it is bad as component code make some computation based on these events. |
Ugh we just duplicated the material tab and remove animations :(. |
What are valid values for animationDuration? I was trying to have no animation happen. I used and received error
I thought maybe I needed '0ms' but then I received |
facepalm. I was just missing using both quotes . This worked |
@leopardy, animationDuration is a string property, you should use what I had illustrated above, or Since you just want to disable animation, the first form with a string constant is simpler thus preferred. animationDuration was released with #13428, however, not documented in the changelog somehow, until v7.3 while I am using 7.2.1. |
This was done a while back |
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. |
Bug, feature request, or proposal:
Feature request
What is the expected behavior?
I would like to disable the slide-in animation
What is the current behavior?
The slide-in animation cannot be disabled.
What is the use-case or motivation for changing an existing behavior?
I have a couple of tabs, which are rendered using
*ngFor
.The data is retrieved from
ngrx/store
and upon any change of state, the tabs get rerendered and slide-in again, which sucks for UX.Which versions of Angular, Material, OS, browsers are affected?
@angular/material: 2.0.0-beta.1
The text was updated successfully, but these errors were encountered: