components icon indicating copy to clipboard operation
components copied to clipboard

bug(material/tabs): ink bar animation not disabling when animationDuration set to 0

Open midgleyc opened this issue 2 years ago • 4 comments

Feature Description

I can set the animation duration for the tabs themselves using animationDuration on the mat-tab-group. If I set this to 0, the tabs switch instantly, but the ink bar moves across taking 500ms, which makes the tab switching look slower than it actually is.

I can implement this myself using ng-deep:

::ng-deep .mat-ink-bar {                                                                             
  transition: none !important;                                                                       
}

but ng-deep is deprecated, so there's always the risk this will stop working in the future.

Use Case

Tab switching looks faster if tab switch animation duration is less than 500ms.

midgleyc avatar Jun 13 '22 13:06 midgleyc

Is this really a bug ? animationDuration is used to set the body animation speed, not the mat-ink-bar one.

So if you give it the value 0 or 0ms, the body will appear with no animation, but the mat-ink-bar will still have one.

To me, it looks like two very different things. I don't think the mat-ink-bar animation is supposed to follow the body one.

Also, removing the animation can be done by adding the _mat-animation-noop css property to the mat-ink-bar.

synopss avatar Jun 25 '22 10:06 synopss

Yes this is great and you can now check some information about it here on modern christening cakes where they have used it in a different shape.

yndue736 avatar Jun 27 '22 11:06 yndue736

I would be eager to attempt to solve this issue!

markusingvarsson avatar Aug 21 '22 11:08 markusingvarsson

@markusingvarsson did you manage to get a PR up for this? I'd be happy to take a look

mmalerba avatar Sep 09 '22 19:09 mmalerba

Hey!! Is this issue still open. I would like to work on this.

Gua00va avatar Feb 15 '23 19:02 Gua00va

Hi @Gua00va , Yes. You are welcome to work on this. Community PRs are encouraged.

-Zach

zarend avatar Feb 16 '23 15:02 zarend

import { MatTabGroup } from '@angular/material/tabs';

@Component({ // component metadata }) export class MyComponent { @ViewChild(MatTabGroup) tabGroup: MatTabGroup;

handleAnimationChange(event: AnimationEvent) { if (event.toState === 'center') { this.tabGroup._inkBar.animationDuration = '500ms'; // set ink bar animation duration to 500ms } else { this.tabGroup._inkBar.animationDuration = '0ms'; // set ink bar animation duration to 0ms } } }

piyushsrvastava avatar Mar 18 '23 06:03 piyushsrvastava

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.