Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 9ef50a7

Browse files
devversionThomasBurleson
authored andcommitted
fix(toolbar): remove transition duration for $ngAnimate
* Other components, like `md-toolbar` use a custom transition on the background-color, color etc, but the related CSS selector has a high specificity. * So for example, when ng-hide is applied, then we set the transition to `none`. But that's not working sometimes, because the both selectors have the same specificity. To fix this, we can apply `!important` or increase the selector specificity by using a CSS hack. https://www.w3.org/TR/CSS2/cascade.html#specificity The toolbar selector has in our case a specificity of 20. * .md-button.ng-hide // 0,0,2,0 * .md-toolbar-tools .md-button // 0,0,2,0 ------ So this is actually a thing, which is caused by $ngAnimate, which is not able to solve this issue. We need to reset the transition duration, when $ngAnimate looks for it, manually. $ngAnimate Issue: angular/angular.js#8224 (comment) Fixes #7929 Closes #8190
1 parent 3e15998 commit 9ef50a7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/components/button/button.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ button.md-button::-moz-focus-inner {
7171
text-decoration: none;
7272
}
7373

74+
// By default $ngAnimate looks for transition durations on the element, when using ng-hide, ng-if, ng-show.
75+
// The .md-button has a transition duration applied, which means, that $ngAnimate delays the hide process.
76+
// To avoid this, we need to reset the transition, when $ngAnimate looks for the duration.
7477
&.ng-hide, &.ng-leave {
7578
transition: none;
7679
}

src/components/toolbar/toolbar.scss

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ md-toolbar {
3030
min-height: $baseline-grid * 8;
3131
width: 100%;
3232

33-
transition: $swift-ease-in-out;
33+
transition-duration: $swift-ease-in-out-duration;
34+
transition-timing-function: $swift-ease-in-out-timing-function;
3435
transition-property: background-color, fill, color;
3536

3637
&.md-whiteframe-z1-add, &.md-whiteframe-z1-remove {
@@ -47,6 +48,13 @@ md-toolbar {
4748
box-sizing: border-box;
4849
}
4950

51+
// By default $ngAnimate looks for transition durations on the element, when using ng-hide, ng-if, ng-show.
52+
// The toolbar has a transition duration applied, which means, that $ngAnimate delays the hide process.
53+
// To avoid this, we need to reset the transition, when $ngAnimate looks for the duration.
54+
&.ng-animate {
55+
transition: none;
56+
}
57+
5058
&.md-tall {
5159
height: $toolbar-tall-height;
5260
min-height: $toolbar-tall-height;
@@ -116,8 +124,16 @@ md-toolbar {
116124
margin-bottom: 0;
117125

118126
&, &.md-icon-button md-icon {
119-
transition: $swift-ease-in-out;
127+
transition-duration: $swift-ease-in-out-duration;
128+
transition-timing-function: $swift-ease-in-out-timing-function;
120129
transition-property: background-color, fill, color;
130+
131+
// Normally .md-button is already resetting the transition, when $ngAnimate looks for the duration,
132+
// but in this case, the selector has a higher specificity than the `reset selector`, which means, that
133+
// we need to reset the transition our self.
134+
&.ng-animate {
135+
transition: none;
136+
}
121137
}
122138
}
123139
&> .md-button:first-child {

0 commit comments

Comments
 (0)