Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix closure compiler warning in ripple #1904

Merged
merged 1 commit into from
Nov 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions src/lib/core/ripple/ripple-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class RippleRenderer {
private _backgroundDiv: HTMLElement;
private _rippleElement: HTMLElement;
private _triggerElement: HTMLElement;
_opacity: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be made private?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it were private then it would be seen as assigned but never used. If it's public, an optimizer doesn't know if an outside class will refer to it.


constructor(_elementRef: ElementRef, private _eventHandlers: Map<string, (e: Event) => void>) {
this._rippleElement = _elementRef.nativeElement;
Expand All @@ -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');
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
Expand All @@ -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');
Expand Down