@@ -37,8 +37,8 @@ export class RippleRenderer {
3737 /** Events to be registered on the trigger element. */
3838 private _triggerEvents = new Map < string , any > ( ) ;
3939
40- /** Currently active ripples . */
41- activeRipples : RippleRef [ ] = [ ] ;
40+ /** Currently active ripple references . */
41+ private _activeRipples : RippleRef [ ] = [ ] ;
4242
4343 /** Ripple config for all ripples created by events. */
4444 rippleConfig : RippleConfig = { } ;
@@ -105,7 +105,7 @@ export class RippleRenderer {
105105 // Once it's faded in, the ripple can be hidden immediately if the mouse is released.
106106 this . runTimeoutOutsideZone ( ( ) => {
107107 if ( config . persistent || this . _isMousedown ) {
108- this . activeRipples . push ( rippleRef ) ;
108+ this . _activeRipples . push ( rippleRef ) ;
109109 } else {
110110 rippleRef . fadeOut ( ) ;
111111 }
@@ -117,11 +117,11 @@ export class RippleRenderer {
117117 /** Fades out a ripple reference. */
118118 fadeOutRipple ( ripple : RippleRef ) {
119119 let rippleEl = ripple . element ;
120- let rippleIndex = this . activeRipples . indexOf ( ripple ) ;
120+ let rippleIndex = this . _activeRipples . indexOf ( ripple ) ;
121121
122122 // Remove the ripple reference if added to the list of active ripples.
123123 if ( rippleIndex !== - 1 ) {
124- this . activeRipples . splice ( rippleIndex , 1 ) ;
124+ this . _activeRipples . splice ( rippleIndex , 1 ) ;
125125 }
126126
127127 rippleEl . style . transitionDuration = `${ RIPPLE_FADE_OUT_DURATION } ms` ;
@@ -133,6 +133,16 @@ export class RippleRenderer {
133133 } , RIPPLE_FADE_OUT_DURATION ) ;
134134 }
135135
136+ /** Fades out all currently active ripples. */
137+ fadeOutAll ( ) {
138+ // Iterate in reverse, to avoid issues with the `fadeOut` method that will immediately remove
139+ // items from the array.
140+ let i = this . _activeRipples . length ;
141+ while ( i -- ) {
142+ this . _activeRipples [ i ] . fadeOut ( ) ;
143+ }
144+ }
145+
136146 /** Sets the trigger element and registers the mouse events. */
137147 setTriggerElement ( element : HTMLElement ) {
138148 // Remove all previously register event listeners from the trigger element.
@@ -163,7 +173,7 @@ export class RippleRenderer {
163173 this . _isMousedown = false ;
164174
165175 // On mouseup, fade-out all ripples that are active and not persistent.
166- this . activeRipples
176+ this . _activeRipples
167177 . filter ( ripple => ! ripple . config . persistent )
168178 . forEach ( ripple => ripple . fadeOut ( ) ) ;
169179 }
0 commit comments