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 ,
@@ -35,16 +34,18 @@ import {
35
34
CanDisableRipple ,
36
35
HasTabIndex ,
37
36
MAT_RIPPLE_GLOBAL_OPTIONS ,
38
- MatRipple ,
39
37
mixinColor ,
40
38
mixinDisabled ,
41
39
mixinDisableRipple ,
42
- mixinTabIndex ,
40
+ mixinTabIndex , RippleConfig ,
43
41
RippleGlobalOptions ,
42
+ RippleRenderer ,
43
+ RippleTarget ,
44
44
ThemePalette ,
45
45
} from '@angular/material/core' ;
46
46
import { merge } from 'rxjs/observable/merge' ;
47
47
import { of as observableOf } from 'rxjs/observable/of' ;
48
+ import { takeUntil } from 'rxjs/operators/takeUntil' ;
48
49
import { Subject } from 'rxjs/Subject' ;
49
50
import { MatInkBar } from '../ink-bar' ;
50
51
@@ -171,15 +172,16 @@ export class MatTabNav extends _MatTabNavMixinBase implements AfterContentInit,
171
172
172
173
// Boilerplate for applying mixins to MatTabLink.
173
174
export class MatTabLinkBase { }
174
- export const _MatTabLinkMixinBase = mixinTabIndex ( mixinDisabled ( MatTabLinkBase ) ) ;
175
+ export const _MatTabLinkMixinBase =
176
+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MatTabLinkBase ) ) ) ;
175
177
176
178
/**
177
179
* Link inside of a `mat-tab-nav-bar`.
178
180
*/
179
181
@Directive ( {
180
182
selector : '[mat-tab-link], [matTabLink]' ,
181
183
exportAs : 'matTabLink' ,
182
- inputs : [ 'disabled' , 'tabIndex' ] ,
184
+ inputs : [ 'disabled' , 'disableRipple' , ' tabIndex'] ,
183
185
host : {
184
186
'class' : 'mat-tab-link' ,
185
187
'[attr.aria-disabled]' : 'disabled.toString()' ,
@@ -189,16 +191,13 @@ export const _MatTabLinkMixinBase = mixinTabIndex(mixinDisabled(MatTabLinkBase))
189
191
}
190
192
} )
191
193
export class MatTabLink extends _MatTabLinkMixinBase
192
- implements OnDestroy , CanDisable , HasTabIndex {
194
+ implements OnDestroy , CanDisable , CanDisableRipple , HasTabIndex , RippleTarget {
193
195
194
196
/** Whether the tab link is active or not. */
195
197
private _isActive : boolean = false ;
196
198
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 ;
199
+ /** Reference to the RippleRenderer for the tab-link. */
200
+ private _tabLinkRipple : RippleRenderer ;
202
201
203
202
/** Whether the link is active. */
204
203
@Input ( )
@@ -210,11 +209,18 @@ export class MatTabLink extends _MatTabLinkMixinBase
210
209
}
211
210
}
212
211
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 ;
212
+ /**
213
+ * Ripple configuration for ripples that are launched on pointer down.
214
+ * @docs -private
215
+ */
216
+ rippleConfig : RippleConfig = { } ;
217
+
218
+ /**
219
+ * Whether ripples are disabled on interaction
220
+ * @docs -private
221
+ */
222
+ get rippleDisabled ( ) : boolean {
223
+ return this . disabled || this . disableRipple ;
218
224
}
219
225
220
226
constructor ( private _tabNavBar : MatTabNav ,
@@ -225,17 +231,17 @@ export class MatTabLink extends _MatTabLinkMixinBase
225
231
@Attribute ( 'tabindex' ) tabIndex : string ) {
226
232
super ( ) ;
227
233
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 ( ) ;
234
+ this . _tabLinkRipple = new RippleRenderer ( this , ngZone , _elementRef , platform ) ;
235
+ this . _tabLinkRipple . setupTriggerEvents ( _elementRef . nativeElement ) ;
232
236
233
237
this . tabIndex = parseInt ( tabIndex ) || 0 ;
238
+
239
+ if ( globalOptions ) {
240
+ this . rippleConfig = { speedFactor : globalOptions . baseSpeedFactor } ;
241
+ }
234
242
}
235
243
236
244
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 ( ) ;
245
+ this . _tabLinkRipple . _removeTriggerEvents ( ) ;
240
246
}
241
247
}
0 commit comments