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

Class MatDrawer

src/material/sidenav/drawer.ts:192–707  ·  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 private _isAnimating = false;
202 _container? = inject<MatDrawerContainer>(MAT_DRAWER_CONTAINER, {optional: true});
203
204 private _focusTrap: FocusTrap | null = null;
205 private _elementFocusedBeforeDrawerWasOpened: HTMLElement | null = null;
206 private _eventCleanups!: (() => void)[];
207
208 /** Whether the view of the component has been attached. */
209 private _isAttached = false;
210
211 /** Anchor node used to restore the drawer to its initial position. */
212 private _anchor: Comment | null = null;
213
214 /** The side that the drawer is attached to. */
215 @Input()
216 get position(): 'start' | 'end' {
217 return this._position;
218 }
219 set position(value: 'start' | 'end') {
220 // Make sure we have a valid value.
221 value = value === 'end' ? 'end' : 'start';
222 if (value !== this._position) {
223 // Static inputs in Ivy are set before the element is in the DOM.
224 if (this._isAttached) {
225 this._updatePositionInParent(value);
226 }
227
228 this._position = value;
229 this.onPositionChanged.emit();
230 }
231 }
232 private _position: 'start' | 'end' = 'start';
233
234 /** Mode of the drawer; one of 'over', 'push' or 'side'. */
235 @Input()
236 get mode(): MatDrawerMode {
237 return this._mode;
238 }
239 set mode(value: MatDrawerMode) {
240 this._mode = value;
241 this._updateFocusTrapState();
242 this._modeChanged.next();
243 this._getContent()?._drawerModeChanged();
244 }
245 private _mode: MatDrawerMode = 'over';
246
247 /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
248 @Input()
249 get disableClose(): boolean {

Callers

nothing calls this directly

Calls 3

_setIsAnimatingMethod · 0.95
signalFunction · 0.85
nextMethod · 0.45

Tested by

no test coverage detected