MCPcopy
hub / github.com/angular/components / _attachBackdrop

Method _attachBackdrop

src/cdk/overlay/overlay-ref.ts:455–488  ·  view source on GitHub ↗

Attaches a backdrop for this overlay.

()

Source from the content-addressed store, hash-verified

453
454 /** Attaches a backdrop for this overlay. */
455 private _attachBackdrop() {
456 const showingClass = 'cdk-overlay-backdrop-showing';
457
458 this._backdropRef?.dispose();
459 this._backdropRef = new BackdropRef(this._document, this._renderer, this._ngZone, event => {
460 this._backdropClick.next(event);
461 });
462
463 if (this._animationsDisabled) {
464 this._backdropRef.element.classList.add('cdk-overlay-backdrop-noop-animation');
465 }
466
467 if (this._config.backdropClass) {
468 this._toggleClasses(this._backdropRef.element, this._config.backdropClass, true);
469 }
470
471 if (this._config.usePopover) {
472 // When using popovers, the backdrop needs to be inside the popover.
473 this._host.prepend(this._backdropRef.element);
474 } else {
475 // Insert the backdrop before the pane in the DOM order,
476 // in order to handle stacked overlays properly.
477 this._host.parentElement!.insertBefore(this._backdropRef.element, this._host);
478 }
479
480 // Add class to fade-in the backdrop after one frame.
481 if (!this._animationsDisabled && typeof requestAnimationFrame !== 'undefined') {
482 this._ngZone.runOutsideAngular(() => {
483 requestAnimationFrame(() => this._backdropRef?.element.classList.add(showingClass));
484 });
485 } else {
486 this._backdropRef.element.classList.add(showingClass);
487 }
488 }
489
490 /**
491 * Updates the stacking order of the element, moving it to the top if necessary.

Callers 1

attachMethod · 0.95

Calls 4

_toggleClassesMethod · 0.95
disposeMethod · 0.65
nextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected