66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import { AfterContentInit , AfterViewInit , Component , ChangeDetectorRef , ContentChild , Directive , ElementRef , EventEmitter , Input , OnDestroy , Output } from '@angular/core' ;
9+ import { Platform } from '@angular/cdk/platform' ;
10+ import { AfterContentInit , AfterViewInit , Component , ChangeDetectorRef , ContentChild , Directive , ElementRef , EventEmitter , Input , NgZone , OnDestroy , Output , ViewChild } from '@angular/core' ;
11+ import { RippleRenderer , RippleTarget } from '@angular/material/core' ;
1012import { MDCChipAdapter , MDCChipFoundation } from '@material/chips' ;
1113import { Subject } from 'rxjs' ;
1214import { takeUntil } from 'rxjs/operators' ;
1315
1416let uid = 0 ;
1517
18+ const rippleTarget : RippleTarget = {
19+ rippleConfig : {
20+ animation : {
21+ // TODO(mmalerba): Use the MDC constants once they are exported separately from the
22+ // foundation. Grabbing them off the foundation prevents the foundation class from being
23+ // tree-shaken. There is an open PR for this:
24+ // https://github.com/material-components/material-components-web/pull/4593
25+ enterDuration : 225 /* MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS */ ,
26+ exitDuration : 150 /* MDCRippleFoundation.numbers.FG_DEACTIVATION_MS */ ,
27+ } ,
28+ } ,
29+ rippleDisabled : false
30+ } ;
31+
1632/**
1733 * Dummy directive to add CSS class to chip leading icon.
1834 * @docs -private
@@ -113,12 +129,16 @@ export class MatChipCell implements AfterContentInit, AfterViewInit, OnDestroy {
113129 /** Subject that emits when the component has been destroyed. */
114130 private _destroyed = new Subject < void > ( ) ;
115131
132+ /** The ripple renderer for this chip. */
133+ private _rippleRenderer : RippleRenderer ;
134+
116135 /** The chip's leading icon. */
117136 @ContentChild ( MatChipAvatar , { static : false } ) leadingIcon : MatChipAvatar ;
118137
119138 /** The chip's trailing icon. */
120139 @ContentChild ( MatChipTrailingIcon , { static : false } ) trailingIcon : MatChipTrailingIcon ;
121140
141+ @ViewChild ( 'wrapper' ) _wrapper ! : ElementRef ;
122142 /**
123143 * Implementation of the MDC chip adapter interface.
124144 * These methods are called by the chip foundation.
@@ -149,7 +169,9 @@ export class MatChipCell implements AfterContentInit, AfterViewInit, OnDestroy {
149169
150170 constructor (
151171 private _changeDetectorRef : ChangeDetectorRef ,
152- private _elementRef : ElementRef ) {
172+ readonly _elementRef : ElementRef ,
173+ private _platform : Platform ,
174+ private _ngZone : NgZone ) {
153175 this . _chipFoundation = new MDCChipFoundation ( this . _chipAdapter ) ;
154176 }
155177
@@ -162,6 +184,7 @@ export class MatChipCell implements AfterContentInit, AfterViewInit, OnDestroy {
162184 }
163185
164186 ngAfterViewInit ( ) {
187+ this . _initRipple ( ) ;
165188 this . _chipFoundation . init ( ) ;
166189 }
167190
@@ -185,5 +208,12 @@ export class MatChipCell implements AfterContentInit, AfterViewInit, OnDestroy {
185208 this . _classes [ cssClass ] = active ;
186209 this . _changeDetectorRef . markForCheck ( ) ;
187210 }
211+
212+ /** Initializes the ripple renderer. */
213+ private _initRipple ( ) {
214+ this . _rippleRenderer =
215+ new RippleRenderer ( rippleTarget , this . _ngZone , this . _wrapper , this . _platform ) ;
216+ this . _rippleRenderer . setupTriggerEvents ( this . _wrapper . nativeElement ) ;
217+ }
188218}
189219
0 commit comments