Skip to content

Commit 49a56a0

Browse files
committed
refactor(sidenav): switch to the angular animations API
Switches the sidenav to use the `@angular/animations` API. This saves us a lot of code that was involved in orchestrating the various animations, in addition to making it easier to follow. It also makes it possible for the consumer to disable the animations by using the `NoopAnimationsModule`.
1 parent 536add3 commit 49a56a0

File tree

4 files changed

+113
-403
lines changed

4 files changed

+113
-403
lines changed

src/lib/sidenav/sidenav-transitions.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
@import '../core/style/variables';
33

44
.mat-sidenav-transition {
5-
.mat-sidenav {
6-
transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;
7-
}
8-
95
.mat-sidenav-content {
106
transition: {
117
duration: $swift-ease-out-duration;

src/lib/sidenav/sidenav.scss

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,6 @@
33
@import '../core/style/layout-common';
44
@import '../core/a11y/a11y';
55

6-
7-
// Mixin to help with defining LTR/RTL 'transform: translate3d()' values.
8-
// @param $open The translation value when the sidenav is opened.
9-
// @param $close The translation value when the sidenav is closed.
10-
@mixin mat-sidenav-transition($open, $close) {
11-
transform: translate3d($close, 0, 0);
12-
13-
&.mat-sidenav-closed {
14-
// We use 'visibility: hidden | visible' because 'display: none' will not animate any
15-
// transitions, while visibility will interpolate transitions properly.
16-
// see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility, the Interpolation
17-
// section.
18-
visibility: hidden;
19-
}
20-
21-
&.mat-sidenav-opening, &.mat-sidenav-opened {
22-
transform: translate3d($open, 0, 0);
23-
}
24-
}
25-
266
// Mixin that creates a new stacking context.
277
// see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
288
@mixin mat-sidenav-stacking-context() {
@@ -103,27 +83,25 @@
10383
box-sizing: border-box;
10484
height: 100%;
10585
overflow-y: auto; // TODO(kara): revisit scrolling behavior for sidenavs
106-
107-
@include mat-sidenav-transition(0, -100%);
86+
transform: translate3d(-100%, 0, 0);
87+
visibility: hidden;
10888

10989
&.mat-sidenav-side {
11090
z-index: 1;
11191
}
11292

11393
&.mat-sidenav-end {
11494
right: 0;
115-
116-
@include mat-sidenav-transition(0, 100%);
95+
transform: translate3d(100%, 0, 0);
11796
}
11897

11998
[dir='rtl'] & {
120-
@include mat-sidenav-transition(0, 100%);
99+
transform: translate3d(100%, 0, 0);
121100

122101
&.mat-sidenav-end {
123102
left: 0;
124103
right: auto;
125-
126-
@include mat-sidenav-transition(0, -100%);
104+
transform: translate3d(-100%, 0, 0);
127105
}
128106
}
129107

0 commit comments

Comments
 (0)