Skip to content

Commit f972123

Browse files
committed
Address feedback
1 parent af169a0 commit f972123

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/lib/core/ripple/ripple-renderer.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,12 @@ export class RippleRenderer {
9999

100100
// By default the browser does not recalculate the styles of dynamically created
101101
// 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);
105103

106104
ripple.style.transform = 'scale(1)';
107105

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.
110108
this.runTimeoutOutsideZone(() => {
111109
this._isMousedown ? this._activeRipples.push(ripple) : this.fadeOutRipple(ripple);
112110
}, duration * 1000);
@@ -167,4 +165,13 @@ export class RippleRenderer {
167165
this._ngZone.runOutsideAngular(() => setTimeout(fn, delay));
168166
}
169167

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+
170177
}

0 commit comments

Comments
 (0)