-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
fix(ripple): Always remove ripple after a certain period #1915
Conversation
@@ -143,6 +143,8 @@ export class RippleRenderer { | |||
|
|||
rippleDiv.addEventListener('transitionend', | |||
(event: TransitionEvent) => transitionEndCallback(ripple, event)); | |||
// Remove the ripple after transitions (fade-in, transform, fade-out) | |||
setTimeout(() => this.removeRippleFromDom(ripple.rippleElement), fadeInSeconds * 3 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require all related tests to be async, right? @jelbourn Should we run this outside angular zone?
@@ -143,6 +143,8 @@ export class RippleRenderer { | |||
|
|||
rippleDiv.addEventListener('transitionend', | |||
(event: TransitionEvent) => transitionEndCallback(ripple, event)); | |||
// Remove the ripple after transitions (fade-in, transform, fade-out) | |||
setTimeout(() => this.removeRippleFromDom(ripple.rippleElement), fadeInSeconds * 3 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it solve the problem to remove the ripple element in ngOnDestroy
instead of using a timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes the element is only hidden
, or display: none
. In this case ngOnDestroy
is never called.
If we use *ngIf
to remove the element, the ripple will be removed when it's removed from the DOM tree.
@@ -143,6 +143,8 @@ export class RippleRenderer { | |||
|
|||
rippleDiv.addEventListener('transitionend', | |||
(event: TransitionEvent) => transitionEndCallback(ripple, event)); | |||
// Remove the ripple after transitions (fade-in, transform, fade-out) | |||
setTimeout(() => this.removeRippleFromDom(ripple.rippleElement), fadeInSeconds * 3 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Ensure that ripples are always removed, even when transitionend doesn't fire.
// Run this outside the Angular zone because there's nothing that Angular cares about.
// If it were to run inside the Angular zone, every test that used ripples would have to be
// either async or fakeAsync.
this._ngZone.runOutsideAngular(() => {
// The ripple lasts a time equal to the sum of fade-in, transform, and fade-out (3 * fade-in time).
let rippleDuration = fadeInSeconds * 3 * 1000;
setTimeout(() => this.removeRippleFromDom(ripple.rippleElement), rippleDuration);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. PTAL.
Thanks for review!
908862e
to
559fdb6
Compare
559fdb6
to
ab78c14
Compare
ab78c14
to
a0c30cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from one last comment. You can add the merge_ready
label when it's ready.
rippleElement.click(); | ||
expect(rippleElement.querySelectorAll('.md-ripple-foreground').length).toBe(1); | ||
|
||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment like
// Use a real timeout because the ripple's timeout runs outside of the angular zone.
Still seems to be failing on IE11... I'll try to take a look today. |
Fixed IE11 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The ripple foreground is not removed if transition is interrupt (e.g. change parent visibility, hidden).
Fixes #1818
R: @kara @jelbourn