@@ -22,6 +22,9 @@ import {
22
22
QueryList ,
23
23
ViewChild ,
24
24
ViewEncapsulation ,
25
+ InjectionToken ,
26
+ Inject ,
27
+ Optional ,
25
28
} from '@angular/core' ;
26
29
import {
27
30
CanColor ,
@@ -51,6 +54,15 @@ export class MatTabChangeEvent {
51
54
/** Possible positions for the tab header. */
52
55
export type MatTabHeaderPosition = 'above' | 'below' ;
53
56
57
+ /** Object that can be used to configure the default options for the tabs module. */
58
+ export interface MatTabsConfig {
59
+ /** Duration for the tab animation. Must be a valid CSS value (e.g. 600ms). */
60
+ animationDuration ?: string ;
61
+ }
62
+
63
+ /** Injection token that can be used to provide the default options the tabs module. */
64
+ export const MAT_TABS_CONFIG = new InjectionToken ( 'MAT_TABS_CONFIG' ) ;
65
+
54
66
// Boilerplate for applying mixins to MatTabGroup.
55
67
/** @docs -private */
56
68
export class MatTabGroupBase {
@@ -117,6 +129,9 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
117
129
/** Position of the tab header. */
118
130
@Input ( ) headerPosition : MatTabHeaderPosition = 'above' ;
119
131
132
+ /** Duration for the tab animation. Must be a valid CSS value (e.g. 600ms). */
133
+ @Input ( ) animationDuration : string ;
134
+
120
135
/** Background color of the tab group. */
121
136
@Input ( )
122
137
get backgroundColor ( ) : ThemePalette { return this . _backgroundColor ; }
@@ -150,9 +165,12 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
150
165
private _groupId : number ;
151
166
152
167
constructor ( elementRef : ElementRef ,
153
- private _changeDetectorRef : ChangeDetectorRef ) {
168
+ private _changeDetectorRef : ChangeDetectorRef ,
169
+ @Inject ( MAT_TABS_CONFIG ) @Optional ( ) defaultConfig ?: MatTabsConfig ) {
154
170
super ( elementRef ) ;
155
171
this . _groupId = nextId ++ ;
172
+ this . animationDuration = defaultConfig && defaultConfig . animationDuration ?
173
+ defaultConfig . animationDuration : '500ms' ;
156
174
}
157
175
158
176
/**
0 commit comments