-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(progress-bar/progress-spinner): prevent animations when in a noopanimations module context #10881
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
Conversation
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.
change title to fix(progress-bar/progress-spinner): ...
@@ -0,0 +1,9 @@ | |||
// If the mat-animation-noop class is present on the components root element, | |||
// prevent non css animations from running. | |||
@mixin noop-animation() { |
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.
mat-noopable-animation
?
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 would also prefix it with an underscore
353d9ef
to
4bedbef
Compare
// If the mat-animation-noop class is present on the components root element, | ||
// prevent non css animations from running. | ||
@mixin noop-animation() { | ||
@at-root .mat-animation-noop#{&} { |
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.
Shouldn't this one be wrapped by the at-root
?
@at-root {
.mat-animation-noop {
...
}
}
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.
If you do
@at-root {
.mat-animation-noop {
...
}
}
It ends up as
root-element-thing .mat-animation-noop
, but we want root-element-thing.mat-animation-noop
ViewEncapsulation | ||
} from '@angular/core'; | ||
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/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.
Wouldn't adding this import be considered a breaking change, in the case where somebody might not have the animations package? I think we had a discussion along the same lines with @mmalerba where we considered adding animations to a component, that didn't have any, a breaking change. That being said, most people should have platform-browser
already.
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 this is different because it doesn't require a module to be loaded; for animations, the breaking change is that you need to include BrowserAnimationsModule
at the root for it to work. For this, I don't think it actually breaks anything.
@@ -144,7 +146,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements | |||
|
|||
constructor(public _elementRef: ElementRef, | |||
platform: Platform, | |||
@Optional() @Inject(DOCUMENT) private _document: any) { | |||
@Optional() @Inject(DOCUMENT) private _document: any, | |||
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode: string) { |
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.
The _animationMode
param should also be marked as optional, in case anybody was extending the component.
src/demo-app/demo-app-module.ts
Outdated
@@ -20,7 +20,7 @@ import {AccessibilityDemoModule} from './a11y/a11y-module'; | |||
@NgModule({ | |||
imports: [ | |||
BrowserModule, | |||
BrowserAnimationsModule, | |||
NoopAnimationsModule, |
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.
We don't want to switch the demo-app completely to noop. It should only be for some specific section you want to test.
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.
Whoops.
@@ -0,0 +1,9 @@ | |||
// If the mat-animation-noop class is present on the components root element, | |||
// prevent non css animations from running. | |||
@mixin noop-animation() { |
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 would also prefix it with an underscore
ViewEncapsulation | ||
} from '@angular/core'; | ||
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/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 this is different because it doesn't require a module to be loaded; for animations, the breaking change is that you need to include BrowserAnimationsModule
at the root for it to work. For this, I don't think it actually breaks anything.
|
||
$mat-progress-bar-height: 5px !default; | ||
$mat-progress-bar-full-animation-duration: 2000ms !default; | ||
$mat-progress-bar-piece-animation-duration: 250ms !default; | ||
|
||
|
||
.mat-progress-bar { | ||
@include noop-animation(); |
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'm not a fan of the way the mixin is peppered throughout the file in so many places. Let's take a look next week to see what it would look like with the noop animations code in one place.
2aa3839
to
ee2ef0e
Compare
// If the mat-animation-noop class is present on the components root element, | ||
// prevent non css animations from running. | ||
@mixin _noop-animation() { | ||
@at-root .mat-animation-noop#{&} { |
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.
Add comment that explains why @at-root
is used here, perhaps with an example?
// prevent non css animations from running. | ||
@mixin _noop-animation() { | ||
@at-root .mat-animation-noop#{&} { | ||
transition-property: none; |
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.
You probably don't need transition-property
// prevent non css animations from running. | ||
// NOTE: Currently this mixin should only be used with components that do not | ||
// have any projected content. | ||
@mixin _noop-animation() { |
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.
_mat-noop-animation
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.
can we call it noopable
? it's not nooping the animation, it's just making it noopable in case you add the noop class
ee2ef0e
to
780c2b5
Compare
780c2b5
to
eb6c4b8
Compare
Hi there! It does not make sense to me to disable animations on a progress spinner, as this is a functional animation not just for visuals. |
Bennyboer is correct. Why would you want to disable the progress bars? A loading screen looks then broken. |
The main use case for this is something like e2e or screenshot tests where your results could be thrown off by the animation. |
You can force the animations of the progress spinner using the I created an issue as this is not the correct place to discuss that. |
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. |
For #10590