Skip to content

Commit 9b9833b

Browse files
committed
Address feedback
1 parent 941ecd0 commit 9b9833b

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@ import {RippleConfig, RippleRenderer} from './ripple-renderer';
66
export class RippleRef {
77

88
constructor(
9-
private renderer: RippleRenderer,
9+
private _renderer: RippleRenderer,
1010
public element: HTMLElement,
1111
public config: RippleConfig) {
1212
}
1313

1414
/** Fades out the ripple element. */
1515
fadeOut() {
16-
let rippleIndex = this.renderer.activeRipples.indexOf(this);
17-
18-
// Remove the ripple reference if added to the list of active ripples.
19-
if (rippleIndex !== -1) {
20-
this.renderer.activeRipples.splice(rippleIndex, 1);
21-
}
22-
23-
// Regardless of being added to the list, fade-out the ripple element.
24-
this.renderer.fadeOutRipple(this.element);
16+
this._renderer.fadeOutRipple(this);
2517
}
2618
}

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,22 @@ export class RippleRenderer {
114114
return rippleRef;
115115
}
116116

117-
/** Fades out a ripple element. */
118-
fadeOutRipple(ripple: HTMLElement) {
119-
ripple.style.transitionDuration = `${RIPPLE_FADE_OUT_DURATION}ms`;
120-
ripple.style.opacity = '0';
117+
/** Fades out a ripple reference. */
118+
fadeOutRipple(ripple: RippleRef) {
119+
let rippleEl = ripple.element;
120+
let rippleIndex = this.activeRipples.indexOf(ripple);
121+
122+
// Remove the ripple reference if added to the list of active ripples.
123+
if (rippleIndex !== -1) {
124+
this.activeRipples.splice(rippleIndex, 1);
125+
}
126+
127+
rippleEl.style.transitionDuration = `${RIPPLE_FADE_OUT_DURATION}ms`;
128+
rippleEl.style.opacity = '0';
121129

122130
// Once the ripple faded out, the ripple can be safely removed from the DOM.
123131
this.runTimeoutOutsideZone(() => {
124-
ripple.parentNode.removeChild(ripple);
132+
rippleEl.parentNode.removeChild(rippleEl);
125133
}, RIPPLE_FADE_OUT_DURATION);
126134
}
127135

0 commit comments

Comments
 (0)