@@ -14,6 +14,7 @@ import {
14
14
ElementRef ,
15
15
ViewEncapsulation ,
16
16
Optional ,
17
+ InjectionToken ,
17
18
} from '@angular/core' ;
18
19
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
19
20
import { CanColor , mixinColor } from '@angular/material/core' ;
@@ -43,6 +44,24 @@ export class MatProgressSpinnerBase {
43
44
}
44
45
export const _MatProgressSpinnerMixinBase = mixinColor ( MatProgressSpinnerBase , 'primary' ) ;
45
46
47
+ /** Default `mat-progress-spinner` options that can be overridden. */
48
+ export interface MatProgressSpinnerDefaultOptions {
49
+ /** Diameter of the spinner. */
50
+ diameter ?: number ;
51
+ }
52
+
53
+ /** Injection token to be used to override the default options for `mat-progress-spinner`. */
54
+ export const MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS =
55
+ new InjectionToken < MatProgressSpinnerDefaultOptions > ( 'mat-progress-spinner-default-options' , {
56
+ providedIn : 'root' ,
57
+ factory : MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY ,
58
+ } ) ;
59
+
60
+ /** @docs -private */
61
+ export function MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY ( ) : MatProgressSpinnerDefaultOptions {
62
+ return { diameter : BASE_SIZE } ;
63
+ }
64
+
46
65
// .0001 percentage difference is necessary in order to avoid unwanted animation frames
47
66
// for example because the animation duration is 4 seconds, .1% accounts to 4ms
48
67
// which are enough to see the flicker described in
@@ -120,7 +139,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
120
139
this . _attachStyleNode ( ) ;
121
140
}
122
141
}
123
- private _diameter = BASE_SIZE ;
142
+ private _diameter = this . _defaults && this . _defaults . diameter ?
143
+ this . _defaults . diameter : BASE_SIZE ;
124
144
125
145
/** Stroke width of the progress spinner. */
126
146
@Input ( )
@@ -131,7 +151,6 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
131
151
this . _strokeWidth = coerceNumberProperty ( value ) ;
132
152
}
133
153
134
-
135
154
/** Mode of the progress circle */
136
155
@Input ( ) mode : ProgressSpinnerMode = 'determinate' ;
137
156
@@ -147,7 +166,10 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
147
166
constructor ( public _elementRef : ElementRef ,
148
167
platform : Platform ,
149
168
@Optional ( ) @Inject ( DOCUMENT ) private _document : any ,
150
- @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
169
+ // @deletion -target 7.0.0 _animationMode and _defaults parameters to be made required.
170
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ,
171
+ @Inject ( MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS )
172
+ private _defaults ?: MatProgressSpinnerDefaultOptions ) {
151
173
152
174
super ( _elementRef ) ;
153
175
this . _fallbackAnimation = platform . EDGE || platform . TRIDENT ;
@@ -249,8 +271,11 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
249
271
export class MatSpinner extends MatProgressSpinner {
250
272
constructor ( elementRef : ElementRef , platform : Platform ,
251
273
@Optional ( ) @Inject ( DOCUMENT ) document : any ,
252
- @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) _animationMode ?: string ) {
253
- super ( elementRef , platform , document , _animationMode ) ;
274
+ // @deletion -targets 7.0.0 animationMode and defaults parameters to be made required.
275
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ,
276
+ @Inject ( MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS )
277
+ defaults ?: MatProgressSpinnerDefaultOptions ) {
278
+ super ( elementRef , platform , document , animationMode , defaults ) ;
254
279
this . mode = 'indeterminate' ;
255
280
}
256
281
}
0 commit comments