Skip to content

fix(material/tooltip): decouple removal logic from change detection #19432

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

Merged
merged 2 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class MatTooltipHarness extends _MatTooltipHarnessBase {
protected _optionalPanel =
this.documentRootLocatorFactory().locatorForOptional('.mat-mdc-tooltip');
static hostSelector = '.mat-mdc-tooltip-trigger';
protected _hiddenClass = 'mat-mdc-tooltip-hide';
protected _showAnimationName = 'mat-mdc-tooltip-show';
protected _hideAnimationName = 'mat-mdc-tooltip-hide';

/**
* Gets a `HarnessPredicate` that can be used to search
Expand Down
7 changes: 3 additions & 4 deletions src/material-experimental/mdc-tooltip/tooltip.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div
#tooltip
class="mdc-tooltip mdc-tooltip--shown mat-mdc-tooltip"
[ngClass]="tooltipClass"
[class.mdc-tooltip--multiline]="_isMultiline"
[@state]="_visibility"
(@state.start)="_animationStart()"
(@state.done)="_animationDone($event)">
(animationend)="_handleAnimationEnd($event)"
[class.mdc-tooltip--multiline]="_isMultiline">
<div class="mdc-tooltip__surface mdc-tooltip__surface-animation">{{message}}</div>
</div>
40 changes: 40 additions & 0 deletions src/material-experimental/mdc-tooltip/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.mat-mdc-tooltip {
// We don't use MDC's positioning so this has to be relative.
position: relative;
transform: scale(0);

// Increases the area of the tooltip so the user's pointer can go from the trigger directly to it.
&::before {
Expand All @@ -18,8 +19,47 @@
z-index: -1;
position: absolute;
}

&._mat-animation-noopable {
animation: none;
transform: scale(1);
}
}

.mat-mdc-tooltip-panel-non-interactive {
pointer-events: none;
}

// TODO(crisbeto): we may be able to use MDC directly for these animations.

@keyframes mat-mdc-tooltip-show {
0% {
opacity: 0;
transform: scale(0.8);
}

100% {
opacity: 1;
transform: scale(1);
}
}

@keyframes mat-mdc-tooltip-hide {
0% {
opacity: 1;
transform: scale(1);
}

100% {
opacity: 0;
transform: scale(0.8);
}
}

.mat-mdc-tooltip-show {
animation: mat-mdc-tooltip-show 150ms cubic-bezier(0, 0, 0.2, 1) forwards;
}

.mat-mdc-tooltip-hide {
animation: mat-mdc-tooltip-hide 75ms cubic-bezier(0.4, 0, 1, 1) forwards;
}
Loading