Skip to content

Commit 69302f9

Browse files
committed
refactor(drawer): expose CdkScrollable instance
Exposes the `CdkScrollable` instance that wraps around the drawer's content. This makes it easier for consumers to react to scrolling inside the container. Fixes #9136.
1 parent c3d7cd9 commit 69302f9

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/lib/sidenav/drawer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
QueryList,
3232
ViewEncapsulation,
3333
InjectionToken,
34+
ViewChild,
3435
} from '@angular/core';
3536
import {DOCUMENT} from '@angular/common';
3637
import {merge} from 'rxjs/observable/merge';
@@ -42,6 +43,7 @@ import {debounceTime} from 'rxjs/operators/debounceTime';
4243
import {map} from 'rxjs/operators/map';
4344
import {Subject} from 'rxjs/Subject';
4445
import {Observable} from 'rxjs/Observable';
46+
import {CdkScrollable} from '@angular/cdk/scrolling';
4547

4648

4749
/** Throws an exception when two MatDrawer are matching the same position. */
@@ -482,6 +484,9 @@ export class MatDrawerContainer implements AfterContentInit, OnDestroy {
482484

483485
_contentMargins = new Subject<{left: number|null, right: number|null}>();
484486

487+
/** Reference to the CdkScrollable instance that wraps the scrollable content. */
488+
@ViewChild(CdkScrollable) scrollable: CdkScrollable|undefined;
489+
485490
constructor(@Optional() private _dir: Directionality,
486491
private _element: ElementRef,
487492
private _ngZone: NgZone,

src/lib/sidenav/sidenav.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
*/
88

99
import {
10-
ChangeDetectionStrategy, ChangeDetectorRef,
11-
Component, ContentChild,
12-
ContentChildren, forwardRef, Inject, Input,
13-
ViewEncapsulation
10+
ChangeDetectionStrategy,
11+
ChangeDetectorRef,
12+
Component,
13+
ContentChild,
14+
ContentChildren,
15+
forwardRef,
16+
Inject,
17+
Input,
18+
ViewEncapsulation,
19+
QueryList,
1420
} from '@angular/core';
1521
import {MatDrawer, MatDrawerContainer, MatDrawerContent} from './drawer';
1622
import {animate, state, style, transition, trigger} from '@angular/animations';
@@ -120,7 +126,6 @@ export class MatSidenav extends MatDrawer {
120126
preserveWhitespaces: false,
121127
})
122128
export class MatSidenavContainer extends MatDrawerContainer {
123-
@ContentChildren(MatSidenav) _drawers;
124-
125-
@ContentChild(MatSidenavContent) _content;
129+
@ContentChildren(MatSidenav) _drawers: QueryList<MatSidenav>;
130+
@ContentChild(MatSidenavContent) _content: MatSidenavContent;
126131
}

0 commit comments

Comments
 (0)