Attaches a backdrop for this overlay.
()
| 480 | |
| 481 | /** Attaches a backdrop for this overlay. */ |
| 482 | private _attachBackdrop() { |
| 483 | const showingClass = 'cdk-overlay-backdrop-showing'; |
| 484 | |
| 485 | this._backdropRef?.dispose(); |
| 486 | this._backdropRef = new BackdropRef(this._document, this._renderer, this._ngZone, event => { |
| 487 | this._backdropClick.next(event); |
| 488 | }); |
| 489 | |
| 490 | if (this._animationsDisabled) { |
| 491 | this._backdropRef.element.classList.add('cdk-overlay-backdrop-noop-animation'); |
| 492 | } |
| 493 | |
| 494 | if (this._config.backdropClass) { |
| 495 | this._toggleClasses(this._backdropRef.element, this._config.backdropClass, true); |
| 496 | } |
| 497 | |
| 498 | if (this._config.usePopover) { |
| 499 | // When using popovers, the backdrop needs to be inside the popover. |
| 500 | this._host.prepend(this._backdropRef.element); |
| 501 | } else { |
| 502 | // Insert the backdrop before the pane in the DOM order, |
| 503 | // in order to handle stacked overlays properly. |
| 504 | this._host.parentElement!.insertBefore(this._backdropRef.element, this._host); |
| 505 | } |
| 506 | |
| 507 | // Add class to fade-in the backdrop after one frame. |
| 508 | if (!this._animationsDisabled && typeof requestAnimationFrame !== 'undefined') { |
| 509 | this._ngZone.runOutsideAngular(() => { |
| 510 | requestAnimationFrame(() => this._backdropRef?.element.classList.add(showingClass)); |
| 511 | }); |
| 512 | } else { |
| 513 | this._backdropRef.element.classList.add(showingClass); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Updates the stacking order of the element, moving it to the top if necessary. |
no test coverage detected