8
8
import { Directionality } from '@angular/cdk/bidi' ;
9
9
import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
10
10
import { Platform } from '@angular/cdk/platform' ;
11
- import { takeUntil } from 'rxjs/operators/takeUntil' ;
12
11
import { ViewportRuler } from '@angular/cdk/scrolling' ;
13
12
import {
14
13
AfterContentInit ,
@@ -39,12 +38,15 @@ import {
39
38
mixinColor ,
40
39
mixinDisabled ,
41
40
mixinDisableRipple ,
42
- mixinTabIndex ,
41
+ mixinTabIndex , RippleConfig ,
43
42
RippleGlobalOptions ,
43
+ RippleRenderer ,
44
+ RippleTarget ,
44
45
ThemePalette ,
45
46
} from '@angular/material/core' ;
46
47
import { merge } from 'rxjs/observable/merge' ;
47
48
import { of as observableOf } from 'rxjs/observable/of' ;
49
+ import { takeUntil } from 'rxjs/operators/takeUntil' ;
48
50
import { Subject } from 'rxjs/Subject' ;
49
51
import { MatInkBar } from '../ink-bar' ;
50
52
@@ -171,15 +173,16 @@ export class MatTabNav extends _MatTabNavMixinBase implements AfterContentInit,
171
173
172
174
// Boilerplate for applying mixins to MatTabLink.
173
175
export class MatTabLinkBase { }
174
- export const _MatTabLinkMixinBase = mixinTabIndex ( mixinDisabled ( MatTabLinkBase ) ) ;
176
+ export const _MatTabLinkMixinBase =
177
+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MatTabLinkBase ) ) ) ;
175
178
176
179
/**
177
180
* Link inside of a `mat-tab-nav-bar`.
178
181
*/
179
182
@Directive ( {
180
183
selector : '[mat-tab-link], [matTabLink]' ,
181
184
exportAs : 'matTabLink' ,
182
- inputs : [ 'disabled' , 'tabIndex' ] ,
185
+ inputs : [ 'disabled' , 'disableRipple' , ' tabIndex'] ,
183
186
host : {
184
187
'class' : 'mat-tab-link' ,
185
188
'[attr.aria-disabled]' : 'disabled.toString()' ,
@@ -189,16 +192,13 @@ export const _MatTabLinkMixinBase = mixinTabIndex(mixinDisabled(MatTabLinkBase))
189
192
}
190
193
} )
191
194
export class MatTabLink extends _MatTabLinkMixinBase
192
- implements OnDestroy , CanDisable , HasTabIndex {
195
+ implements OnDestroy , CanDisable , CanDisableRipple , HasTabIndex , RippleTarget {
193
196
194
197
/** Whether the tab link is active or not. */
195
198
private _isActive : boolean = false ;
196
199
197
- /** Whether the ripples for this tab should be disabled or not. */
198
- private _disableRipple : boolean = false ;
199
-
200
- /** Reference to the instance of the ripple for the tab link. */
201
- private _tabLinkRipple : MatRipple ;
200
+ /** Reference to the RippleRenderer for the tab-link. */
201
+ private _tabLinkRipple : RippleRenderer ;
202
202
203
203
/** Whether the link is active. */
204
204
@Input ( )
@@ -210,11 +210,18 @@ export class MatTabLink extends _MatTabLinkMixinBase
210
210
}
211
211
}
212
212
213
- /** Whether ripples should be disabled or not. */
214
- get disableRipple ( ) : boolean { return this . disabled || this . _disableRipple ; }
215
- set disableRipple ( value : boolean ) {
216
- this . _disableRipple = value ;
217
- this . _tabLinkRipple . disabled = this . disableRipple ;
213
+ /**
214
+ * Ripple configuration for ripples that are launched on pointer down.
215
+ * @docs -private
216
+ */
217
+ rippleConfig : RippleConfig = { } ;
218
+
219
+ /**
220
+ * Whether ripples are disabled on interaction
221
+ * @docs -private
222
+ */
223
+ get rippleDisabled ( ) : boolean {
224
+ return this . disabled || this . disableRipple ;
218
225
}
219
226
220
227
constructor ( private _tabNavBar : MatTabNav ,
@@ -225,17 +232,17 @@ export class MatTabLink extends _MatTabLinkMixinBase
225
232
@Attribute ( 'tabindex' ) tabIndex : string ) {
226
233
super ( ) ;
227
234
228
- // Manually create a ripple instance that uses the tab link element as trigger element.
229
- // Notice that the lifecycle hooks for the ripple config won't be called anymore.
230
- this . _tabLinkRipple = new MatRipple ( _elementRef , ngZone , platform , globalOptions ) ;
231
- this . _tabLinkRipple . ngOnInit ( ) ;
235
+ this . _tabLinkRipple = new RippleRenderer ( this , ngZone , _elementRef , platform ) ;
236
+ this . _tabLinkRipple . setupTriggerEvents ( _elementRef . nativeElement ) ;
232
237
233
238
this . tabIndex = parseInt ( tabIndex ) || 0 ;
239
+
240
+ if ( globalOptions ) {
241
+ this . rippleConfig = { speedFactor : globalOptions . baseSpeedFactor } ;
242
+ }
234
243
}
235
244
236
245
ngOnDestroy ( ) {
237
- // Manually call the ngOnDestroy lifecycle hook of the ripple instance because it won't be
238
- // called automatically since its instance is not created by Angular.
239
- this . _tabLinkRipple . ngOnDestroy ( ) ;
246
+ this . _tabLinkRipple . _removeTriggerEvents ( ) ;
240
247
}
241
248
}
0 commit comments