Skip to content

Commit 4cdb828

Browse files
committed
feat(sidenav): open all sidenavs from MdSidenavContainer
- added `open` and `close` functions that applies to both sidenavs in the container and resolves when both are finished fixes #2591
1 parent 3b6cab0 commit 4cdb828

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/lib/sidenav/sidenav.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,36 @@ export class MdSidenavContainer implements AfterContentInit {
367367
this._validateDrawers();
368368
}
369369

370+
/** Calls `open` of both start and end sidenavs */
371+
public open() {
372+
const promises: Promise<MdSidenavToggleResult>[] = [];
373+
374+
if (this._start) {
375+
promises.push(this._start.open());
376+
}
377+
378+
if (this._end) {
379+
promises.push(this._end.open());
380+
}
381+
382+
return Promise.all(promises);
383+
}
384+
385+
/** Calls `close` of both start and end sidenavs */
386+
public close() {
387+
const promises: Promise<MdSidenavToggleResult>[] = [];
388+
389+
if (this._start) {
390+
promises.push(this._start.close());
391+
}
392+
393+
if (this._end) {
394+
promises.push(this._end.close());
395+
}
396+
397+
return Promise.all(promises);
398+
}
399+
370400
/**
371401
* Subscribes to sidenav events in order to set a class on the main container element when the
372402
* sidenav is open and the backdrop is visible. This ensures any overflow on the container element

0 commit comments

Comments
 (0)