Skip to content

Commit

Permalink
fix(material/dialog): scale animation not working (#28449)
Browse files Browse the repository at this point in the history
[A change in MDC](material-components/material-components-web@d153db6) moved the `transform` animation from the container to the surface which broke our implementation.

These changes also take the chance to fix that the animation was targeting all properties, rather than just `transform` and `opacity`. I've also fixed up the demo a bit to make it less jumpy.

Fixes #28447.

(cherry picked from commit 7f1562d)
  • Loading branch information
crisbeto committed Jan 18, 2024
1 parent 9e7fe24 commit 90456b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/dev-app/dialog/dialog-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,24 @@ export class JazzDialog {
`
img {
max-width: 100%;
height: 800px;
}
`,
],
template: `
<h2 mat-dialog-title>Neptune</h2>
<mat-dialog-content>
<img src="https://upload.wikimedia.org/wikipedia/commons/5/56/Neptune_Full.jpg"/>
<p>
Neptune is the eighth and farthest known planet from the Sun in the Solar System. In the
Solar System, it is the fourth-largest planet by diameter, the third-most-massive planet,
and the densest giant planet. Neptune is 17 times the mass of Earth and is slightly more
massive than its near-twin Uranus, which is 15 times the mass of Earth and slightly larger
than Neptune. Neptune orbits the Sun once every 164.8 years at an average distance of 30.1
astronomical units (4.50×109 km). It is named after the Roman god of the sea and has the
astronomical units (4.50x109 km). It is named after the Roman god of the sea and has the
astronomical symbol ♆, a stylised version of the god Neptune's trident.
</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/5/56/Neptune_Full.jpg"/>
</mat-dialog-content>
<mat-dialog-actions [align]="actionsAlignment">
Expand Down
13 changes: 10 additions & 3 deletions src/material/dialog/dialog.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '@material/dialog' as mdc-dialog;
@use '@material/animation/animation' as mdc-animation;
@use '@material/dialog/dialog-theme' as mdc-dialog-theme;
@use '../core/tokens/m2/mdc/dialog' as tokens-mdc-dialog;
@use '../core/mdc-helpers/mdc-helpers';
Expand Down Expand Up @@ -33,14 +34,20 @@ $mat-dialog-button-horizontal-margin: 8px !default;
outline: 0;

.mdc-dialog__container {
transition-duration: var(--mat-dialog-transition-duration, 0ms);
transition: opacity linear var(--mat-dialog-transition-duration, 0ms);
}

.mdc-dialog__surface {
transition: mdc-animation.enter(transform, var(--mat-dialog-transition-duration, 0ms));
}

// Angular Material supports disabling all animations when NoopAnimationsModule is imported.
// TODO(devversion): Look into using MDC's Sass queries to separate the animation styles and
// conditionally add them. Consider the size cost and churn when deciding whether to switch.
&._mat-animation-noopable .mdc-dialog__container {
transition: none;
&._mat-animation-noopable {
.mdc-dialog__container, .mdc-dialog__surface {
transition: none;
}
}
}
}
Expand Down

0 comments on commit 90456b0

Please sign in to comment.