@@ -37,8 +37,8 @@ export class RippleRenderer {
37
37
/** Events to be registered on the trigger element. */
38
38
private _triggerEvents = new Map < string , any > ( ) ;
39
39
40
- /** Currently active ripples . */
41
- activeRipples : RippleRef [ ] = [ ] ;
40
+ /** Currently active ripple references . */
41
+ private _activeRipples : RippleRef [ ] = [ ] ;
42
42
43
43
/** Ripple config for all ripples created by events. */
44
44
rippleConfig : RippleConfig = { } ;
@@ -105,7 +105,7 @@ export class RippleRenderer {
105
105
// Once it's faded in, the ripple can be hidden immediately if the mouse is released.
106
106
this . runTimeoutOutsideZone ( ( ) => {
107
107
if ( config . persistent || this . _isMousedown ) {
108
- this . activeRipples . push ( rippleRef ) ;
108
+ this . _activeRipples . push ( rippleRef ) ;
109
109
} else {
110
110
rippleRef . fadeOut ( ) ;
111
111
}
@@ -117,11 +117,11 @@ export class RippleRenderer {
117
117
/** Fades out a ripple reference. */
118
118
fadeOutRipple ( ripple : RippleRef ) {
119
119
let rippleEl = ripple . element ;
120
- let rippleIndex = this . activeRipples . indexOf ( ripple ) ;
120
+ let rippleIndex = this . _activeRipples . indexOf ( ripple ) ;
121
121
122
122
// Remove the ripple reference if added to the list of active ripples.
123
123
if ( rippleIndex !== - 1 ) {
124
- this . activeRipples . splice ( rippleIndex , 1 ) ;
124
+ this . _activeRipples . splice ( rippleIndex , 1 ) ;
125
125
}
126
126
127
127
rippleEl . style . transitionDuration = `${ RIPPLE_FADE_OUT_DURATION } ms` ;
@@ -133,6 +133,16 @@ export class RippleRenderer {
133
133
} , RIPPLE_FADE_OUT_DURATION ) ;
134
134
}
135
135
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
+
136
146
/** Sets the trigger element and registers the mouse events. */
137
147
setTriggerElement ( element : HTMLElement ) {
138
148
// Remove all previously register event listeners from the trigger element.
@@ -163,7 +173,7 @@ export class RippleRenderer {
163
173
this . _isMousedown = false ;
164
174
165
175
// On mouseup, fade-out all ripples that are active and not persistent.
166
- this . activeRipples
176
+ this . _activeRipples
167
177
. filter ( ripple => ! ripple . config . persistent )
168
178
. forEach ( ripple => ripple . fadeOut ( ) ) ;
169
179
}
0 commit comments