@@ -99,14 +99,12 @@ export class RippleRenderer {
99
99
100
100
// By default the browser does not recalculate the styles of dynamically created
101
101
// ripple elements. This is critical because then the `scale` would not animate properly.
102
- // Enforce a style recalculation by calling `getComputedStyle` and accessing any property.
103
- // See: https://gist.github.com/paulirish/5d52fb081b3570c81e3a
104
- window . getComputedStyle ( ripple ) . getPropertyValue ( 'opacity' ) ;
102
+ this . _enforceStyleRecalculation ( ripple ) ;
105
103
106
104
ripple . style . transform = 'scale(1)' ;
107
105
108
- // Wait for the ripple to be faded in. Once faded in the ripple can be hided if the mouse is
109
- // released.
106
+ // Wait for the ripple to be faded in. Once it's faded in, the ripple can be hidden immediately
107
+ // if the mouse is released.
110
108
this . runTimeoutOutsideZone ( ( ) => {
111
109
this . _isMousedown ? this . _activeRipples . push ( ripple ) : this . fadeOutRipple ( ripple ) ;
112
110
} , duration * 1000 ) ;
@@ -167,4 +165,13 @@ export class RippleRenderer {
167
165
this . _ngZone . runOutsideAngular ( ( ) => setTimeout ( fn , delay ) ) ;
168
166
}
169
167
168
+ /** Enforces a style recalculation of a DOM element by computing its styles. */
169
+ // TODO(devversion): Move into global utility function.
170
+ private _enforceStyleRecalculation ( element : HTMLElement ) {
171
+ // Enforce a style recalculation by calling `getComputedStyle` and accessing any property.
172
+ // Calling `getPropertyValue` is important to let optimizers know that this is not a noop.
173
+ // See: https://gist.github.com/paulirish/5d52fb081b3570c81e3a
174
+ window . getComputedStyle ( element ) . getPropertyValue ( 'opacity' ) ;
175
+ }
176
+
170
177
}
0 commit comments