-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(overlay): lazily create container (#894)
- Loading branch information
1 parent
3179fec
commit 1efbbb9
Showing
12 changed files
with
83 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
|
||
|
||
/** | ||
* Create the overlay container element, which is simply a div | ||
* with the 'md-overlay-container' class on the document body. | ||
* The OverlayContainer is the container in which all overlays will load. | ||
* It should be provided in the root component to ensure it is properly shared. | ||
*/ | ||
export function createOverlayContainer(): Element { | ||
let container = document.createElement('div'); | ||
container.classList.add('md-overlay-container'); | ||
document.body.appendChild(container); | ||
return container; | ||
export class OverlayContainer { | ||
private _containerElement: HTMLElement; | ||
|
||
/** | ||
* This method returns the overlay container element. It will lazily | ||
* create the element the first time it is called to facilitate using | ||
* the container in non-browser environments. | ||
* @returns {HTMLElement} the container element | ||
*/ | ||
getContainerElement(): HTMLElement { | ||
if (!this._containerElement) { this._createContainer(); } | ||
return this._containerElement; | ||
} | ||
|
||
/** | ||
* Create the overlay container element, which is simply a div | ||
* with the 'md-overlay-container' class on the document body. | ||
*/ | ||
private _createContainer(): void { | ||
let container = document.createElement('div'); | ||
container.classList.add('md-overlay-container'); | ||
document.body.appendChild(container); | ||
this._containerElement = container; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters