MCPcopy Create free account
hub / github.com/angular/components / MatDrawer

Class MatDrawer

src/material/sidenav/drawer.ts:192–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 imports: [CdkScrollable],
191})
192export class MatDrawer implements AfterViewInit, OnDestroy {
193 private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
194 private _focusTrapFactory = inject(FocusTrapFactory);
195 private _focusMonitor = inject(FocusMonitor);
196 private _platform = inject(Platform);
197 private _ngZone = inject(NgZone);
198 private _renderer = inject(Renderer2);
199 private readonly _interactivityChecker = inject(InteractivityChecker);
200 private _doc = inject(DOCUMENT);
201 _container? = inject<MatDrawerContainer>(MAT_DRAWER_CONTAINER, {optional: true});
202
203 private _focusTrap: FocusTrap | null = null;
204 private _elementFocusedBeforeDrawerWasOpened: HTMLElement | null = null;
205 private _eventCleanups!: (() => void)[];
206
207 /** Whether the view of the component has been attached. */
208 private _isAttached = false;
209
210 /** Anchor node used to restore the drawer to its initial position. */
211 private _anchor: Comment | null = null;
212
213 /** The side that the drawer is attached to. */
214 @Input()
215 get position(): 'start' | 'end' {
216 return this._position;
217 }
218 set position(value: 'start' | 'end') {
219 // Make sure we have a valid value.
220 value = value === 'end' ? 'end' : 'start';
221 if (value !== this._position) {
222 // Static inputs in Ivy are set before the element is in the DOM.
223 if (this._isAttached) {
224 this._updatePositionInParent(value);
225 }
226
227 this._position = value;
228 this.onPositionChanged.emit();
229 }
230 }
231 private _position: 'start' | 'end' = 'start';
232
233 /** Mode of the drawer; one of 'over', 'push' or 'side'. */
234 @Input()
235 get mode(): MatDrawerMode {
236 return this._mode;
237 }
238 set mode(value: MatDrawerMode) {
239 this._mode = value;
240 this._updateFocusTrapState();
241 this._modeChanged.next();
242 this._getContent()?._drawerModeChanged();
243 }
244 private _mode: MatDrawerMode = 'over';
245
246 /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
247 @Input()
248 get disableClose(): boolean {
249 return this._disableClose;

Callers

nothing calls this directly

Calls 3

_setIsAnimatingMethod · 0.95
signalFunction · 0.85
nextMethod · 0.45

Tested by

no test coverage detected