Skip to content
Merged
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
17 changes: 15 additions & 2 deletions src/lib/sidenav/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Directionality} from '@angular/cdk/bidi';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {ESCAPE} from '@angular/cdk/keycodes';
import {Platform} from '@angular/cdk/platform';
import {CdkScrollable, ScrollDispatcher} from '@angular/cdk/scrolling';
import {CdkScrollable, ScrollDispatcher, ViewportRuler} from '@angular/cdk/scrolling';
import {DOCUMENT} from '@angular/common';
import {
AfterContentChecked,
Expand Down Expand Up @@ -502,7 +502,12 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
private _ngZone: NgZone,
private _changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DRAWER_DEFAULT_AUTOSIZE) defaultAutosize = false,
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string) {
@Optional() @Inject(ANIMATION_MODULE_TYPE) private _animationMode?: string,
/**
* @deprecated viewportRuler to become a required parameter.
* @breaking-change 8.0.0
*/
@Optional() viewportRuler?: ViewportRuler) {

// If a `Dir` directive exists up the tree, listen direction changes
// and update the left/right properties to point to the proper start/end.
Expand All @@ -513,6 +518,14 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy
});
}

// Since the minimum width of the sidenav depends on the viewport width,
// we need to recompute the margins if the viewport changes.
if (viewportRuler) {
viewportRuler.change()
.pipe(takeUntil(this._destroyed))
.subscribe(() => this._updateContentMargins());
}

this._autosize = defaultAutosize;
}

Expand Down