From e3830b4fd6f1bb6ac1c90cfe13d5ecff9183bc99 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Thu, 17 Nov 2016 09:50:30 -0800 Subject: [PATCH] chore: fix closure compiler warning in ripple (#1904) --- src/lib/core/ripple/ripple-renderer.ts | 32 ++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/lib/core/ripple/ripple-renderer.ts b/src/lib/core/ripple/ripple-renderer.ts index f85b9d42095..8e379bb0a66 100644 --- a/src/lib/core/ripple/ripple-renderer.ts +++ b/src/lib/core/ripple/ripple-renderer.ts @@ -42,6 +42,7 @@ export class RippleRenderer { private _backgroundDiv: HTMLElement; private _rippleElement: HTMLElement; private _triggerElement: HTMLElement; + _opacity: string; constructor(_elementRef: ElementRef, private _eventHandlers: Map void>) { this._rippleElement = _elementRef.nativeElement; @@ -50,9 +51,7 @@ export class RippleRenderer { this._backgroundDiv = null; } - /** - * Creates the div for the ripple background, if it doesn't already exist. - */ + /** Creates the div for the ripple background, if it doesn't already exist. */ createBackgroundIfNeeded() { if (!this._backgroundDiv) { this._backgroundDiv = document.createElement('div'); @@ -81,16 +80,12 @@ export class RippleRenderer { } } - /** - * Installs event handlers on the host element of the md-ripple directive. - */ + /** Installs event handlers on the host element of the md-ripple directive. */ setTriggerElementToHost() { this.setTriggerElement(this._rippleElement); } - /** - * Removes event handlers from the current trigger element if needed. - */ + /** Removes event handlers from the current trigger element if needed. */ clearTriggerElement() { this.setTriggerElement(null); } @@ -137,7 +132,8 @@ export class RippleRenderer { rippleDiv.style.transitionDuration = `${fadeInSeconds}s`; // https://timtaubert.de/blog/2012/09/css-transitions-for-dynamically-created-dom-elements/ - window.getComputedStyle(rippleDiv).opacity; + // Store the opacity to prevent this line as being seen as a no-op by optimizers. + this._opacity = window.getComputedStyle(rippleDiv).opacity; rippleDiv.classList.add('md-ripple-fade-in'); // Clearing the transform property causes the ripple to animate to its full size. @@ -149,33 +145,25 @@ export class RippleRenderer { (event: TransitionEvent) => transitionEndCallback(ripple, event)); } - /** - * Fades out a foreground ripple after it has fully expanded and faded in. - */ + /** Fades out a foreground ripple after it has fully expanded and faded in. */ fadeOutForegroundRipple(ripple: Element) { ripple.classList.remove('md-ripple-fade-in'); ripple.classList.add('md-ripple-fade-out'); } - /** - * Removes a foreground ripple from the DOM after it has faded out. - */ + /** Removes a foreground ripple from the DOM after it has faded out. */ removeRippleFromDom(ripple: Element) { ripple.parentElement.removeChild(ripple); } - /** - * Fades in the ripple background. - */ + /** Fades in the ripple background. */ fadeInRippleBackground(color: string) { this._backgroundDiv.classList.add('md-ripple-active'); // If color is not set, this will default to the background color defined in CSS. this._backgroundDiv.style.backgroundColor = color; } - /** - * Fades out the ripple background. - */ + /** Fades out the ripple background. */ fadeOutRippleBackground() { if (this._backgroundDiv) { this._backgroundDiv.classList.remove('md-ripple-active');